Commit f2b5aac6 authored by Ido Schimmel's avatar Ido Schimmel Committed by Jakub Kicinski

bridge: mcast: Use MDB configuration structure where possible

The MDB configuration structure (i.e., struct br_mdb_config) now
includes all the necessary information from the parsed RTM_{NEW,DEL}MDB
netlink messages, so use it.

This will later allow us to delete the calls to br_mdb_parse() from
br_mdb_add() and br_mdb_del().

No functional changes intended.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Acked-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 38661168
...@@ -1094,7 +1094,6 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1094,7 +1094,6 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net_bridge_vlan *v; struct net_bridge_vlan *v;
struct br_mdb_config cfg; struct br_mdb_config cfg;
struct net_device *dev; struct net_device *dev;
struct net_bridge *br;
int err; int err;
err = br_mdb_config_init(net, nlh, &cfg, extack); err = br_mdb_config_init(net, nlh, &cfg, extack);
...@@ -1105,30 +1104,30 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1105,30 +1104,30 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0) if (err < 0)
return err; return err;
br = netdev_priv(dev); if (cfg.p) {
if (cfg.p->state == BR_STATE_DISABLED && cfg.entry->state != MDB_PERMANENT) {
if (entry->ifindex != br->dev->ifindex) {
if (cfg.p->state == BR_STATE_DISABLED && entry->state != MDB_PERMANENT) {
NL_SET_ERR_MSG_MOD(extack, "Port is in disabled state and entry is not permanent"); NL_SET_ERR_MSG_MOD(extack, "Port is in disabled state and entry is not permanent");
return -EINVAL; return -EINVAL;
} }
vg = nbp_vlan_group(cfg.p); vg = nbp_vlan_group(cfg.p);
} else { } else {
vg = br_vlan_group(br); vg = br_vlan_group(cfg.br);
} }
/* If vlan filtering is enabled and VLAN is not specified /* If vlan filtering is enabled and VLAN is not specified
* install mdb entry on all vlans configured on the port. * install mdb entry on all vlans configured on the port.
*/ */
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) { if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) { list_for_each_entry(v, &vg->vlan_list, vlist) {
entry->vid = v->vid; cfg.entry->vid = v->vid;
err = __br_mdb_add(net, br, cfg.p, entry, mdb_attrs, extack); err = __br_mdb_add(net, cfg.br, cfg.p, cfg.entry,
mdb_attrs, extack);
if (err) if (err)
break; break;
} }
} else { } else {
err = __br_mdb_add(net, br, cfg.p, entry, mdb_attrs, extack); err = __br_mdb_add(net, cfg.br, cfg.p, cfg.entry, mdb_attrs,
extack);
} }
return err; return err;
...@@ -1186,7 +1185,6 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1186,7 +1185,6 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
struct net_bridge_vlan *v; struct net_bridge_vlan *v;
struct br_mdb_config cfg; struct br_mdb_config cfg;
struct net_device *dev; struct net_device *dev;
struct net_bridge *br;
int err; int err;
err = br_mdb_config_init(net, nlh, &cfg, extack); err = br_mdb_config_init(net, nlh, &cfg, extack);
...@@ -1197,23 +1195,21 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -1197,23 +1195,21 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0) if (err < 0)
return err; return err;
br = netdev_priv(dev); if (cfg.p)
if (entry->ifindex != br->dev->ifindex)
vg = nbp_vlan_group(cfg.p); vg = nbp_vlan_group(cfg.p);
else else
vg = br_vlan_group(br); vg = br_vlan_group(cfg.br);
/* If vlan filtering is enabled and VLAN is not specified /* If vlan filtering is enabled and VLAN is not specified
* delete mdb entry on all vlans configured on the port. * delete mdb entry on all vlans configured on the port.
*/ */
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) { if (br_vlan_enabled(cfg.br->dev) && vg && cfg.entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) { list_for_each_entry(v, &vg->vlan_list, vlist) {
entry->vid = v->vid; cfg.entry->vid = v->vid;
err = __br_mdb_del(br, entry, mdb_attrs); err = __br_mdb_del(cfg.br, cfg.entry, mdb_attrs);
} }
} else { } else {
err = __br_mdb_del(br, entry, mdb_attrs); err = __br_mdb_del(cfg.br, cfg.entry, mdb_attrs);
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment