Skip to content

Possible bug in brstate.c -> br_set_state() #1

@mplum

Description

@mplum

In br_set_state() the port state is passed in as a u8 and the attribute is added to the netlink message with the following line:

addattr32(&req.n, sizeof(req.buf), IFLA_PROTINFO, state);

In the kernel: net/bridge/br_netlink.c -> br_rtm_setlink()
The port state is grabbed using:
new_state = nla_get_u8(protinfo);
if (new_state > BR_STATE_BLOCKING)
return -EINVAL;

I was seeing the port state always being returned as zero.

In br_set_state() I changed to:
addattr_l(&req.n, sizeof(req.buf), IFLA_PROTINFO, &state, 1);
To only add the port state as one byte to the netlink message which corrected the problem and the kernel correctly received change of port states.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions