Skip to content

Commit

Permalink
switchdev: cut over to new switchdev_port_bridge_setlink
Browse files Browse the repository at this point in the history
Rocker, bonding, and team can now use the switchdev bridge setlink to parse
raw netlink; no need to duplicate this code in each driver.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Scott Feldman authored and David S. Miller committed May 12, 2015
1 parent 47f8328 commit fc8f40d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4039,7 +4039,7 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_add_slave = bond_enslave,
.ndo_del_slave = bond_release,
.ndo_fix_features = bond_fix_features,
.ndo_bridge_setlink = ndo_dflt_switchdev_port_bridge_setlink,
.ndo_bridge_setlink = switchdev_port_bridge_setlink,
.ndo_bridge_dellink = ndo_dflt_switchdev_port_bridge_dellink,
.ndo_features_check = passthru_features_check,
};
Expand Down
42 changes: 1 addition & 41 deletions drivers/net/ethernet/rocker/rocker.c
Original file line number Diff line number Diff line change
Expand Up @@ -4295,46 +4295,6 @@ static int rocker_port_fdb_dump(struct sk_buff *skb,
return idx;
}

static int rocker_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags)
{
struct rocker_port *rocker_port = netdev_priv(dev);
struct nlattr *protinfo;
struct nlattr *attr;
int err;

protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg),
IFLA_PROTINFO);
if (protinfo) {
attr = nla_find_nested(protinfo, IFLA_BRPORT_LEARNING);
if (attr) {
if (nla_len(attr) < sizeof(u8))
return -EINVAL;

if (nla_get_u8(attr))
rocker_port->brport_flags |= BR_LEARNING;
else
rocker_port->brport_flags &= ~BR_LEARNING;
err = rocker_port_set_learning(rocker_port,
SWITCHDEV_TRANS_NONE);
if (err)
return err;
}
attr = nla_find_nested(protinfo, IFLA_BRPORT_LEARNING_SYNC);
if (attr) {
if (nla_len(attr) < sizeof(u8))
return -EINVAL;

if (nla_get_u8(attr))
rocker_port->brport_flags |= BR_LEARNING_SYNC;
else
rocker_port->brport_flags &= ~BR_LEARNING_SYNC;
}
}

return 0;
}

static int rocker_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
struct net_device *dev,
u32 filter_mask, int nlflags)
Expand Down Expand Up @@ -4374,7 +4334,7 @@ static const struct net_device_ops rocker_port_netdev_ops = {
.ndo_fdb_add = rocker_port_fdb_add,
.ndo_fdb_del = rocker_port_fdb_del,
.ndo_fdb_dump = rocker_port_fdb_dump,
.ndo_bridge_setlink = rocker_port_bridge_setlink,
.ndo_bridge_setlink = switchdev_port_bridge_setlink,
.ndo_bridge_getlink = rocker_port_bridge_getlink,
.ndo_get_phys_port_name = rocker_port_get_phys_port_name,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ static const struct net_device_ops team_netdev_ops = {
.ndo_del_slave = team_del_slave,
.ndo_fix_features = team_fix_features,
.ndo_change_carrier = team_change_carrier,
.ndo_bridge_setlink = ndo_dflt_switchdev_port_bridge_setlink,
.ndo_bridge_setlink = switchdev_port_bridge_setlink,
.ndo_bridge_dellink = ndo_dflt_switchdev_port_bridge_dellink,
.ndo_features_check = passthru_features_check,
};
Expand Down

0 comments on commit fc8f40d

Please sign in to comment.