Commit 79abc875 authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by Jakub Kicinski

net: bridge: mdb: push notifications in __br_mdb_add/del

This change is in preparation for using the mdb port group entries when
sending a notification, so their full state and additional attributes can
be filled in.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 42c11ccf
...@@ -681,7 +681,7 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -681,7 +681,7 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh,
} }
static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
struct br_ip *group, unsigned char state) struct br_ip *group, struct br_mdb_entry *entry)
{ {
struct net_bridge_mdb_entry *mp; struct net_bridge_mdb_entry *mp;
struct net_bridge_port_group *p; struct net_bridge_port_group *p;
...@@ -700,12 +700,13 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -700,12 +700,13 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
/* host join */ /* host join */
if (!port) { if (!port) {
/* don't allow any flags for host-joined groups */ /* don't allow any flags for host-joined groups */
if (state) if (entry->state)
return -EINVAL; return -EINVAL;
if (mp->host_joined) if (mp->host_joined)
return -EEXIST; return -EEXIST;
br_multicast_host_join(mp, false); br_multicast_host_join(mp, false);
__br_mdb_notify(br->dev, NULL, entry, RTM_NEWMDB);
return 0; return 0;
} }
...@@ -719,13 +720,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -719,13 +720,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
break; break;
} }
p = br_multicast_new_port_group(port, group, *pp, state, NULL, p = br_multicast_new_port_group(port, group, *pp, entry->state, NULL,
MCAST_EXCLUDE); MCAST_EXCLUDE);
if (unlikely(!p)) if (unlikely(!p))
return -ENOMEM; return -ENOMEM;
rcu_assign_pointer(*pp, p); rcu_assign_pointer(*pp, p);
if (state == MDB_TEMPORARY) if (entry->state == MDB_TEMPORARY)
mod_timer(&p->timer, now + br->multicast_membership_interval); mod_timer(&p->timer, now + br->multicast_membership_interval);
__br_mdb_notify(br->dev, port, entry, RTM_NEWMDB);
return 0; return 0;
} }
...@@ -754,7 +756,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br, ...@@ -754,7 +756,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
__mdb_entry_to_br_ip(entry, &ip); __mdb_entry_to_br_ip(entry, &ip);
spin_lock_bh(&br->multicast_lock); spin_lock_bh(&br->multicast_lock);
ret = br_mdb_add_group(br, p, &ip, entry->state); ret = br_mdb_add_group(br, p, &ip, entry);
spin_unlock_bh(&br->multicast_lock); spin_unlock_bh(&br->multicast_lock);
return ret; return ret;
} }
...@@ -799,12 +801,9 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -799,12 +801,9 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
err = __br_mdb_add(net, br, entry); err = __br_mdb_add(net, br, entry);
if (err) if (err)
break; break;
__br_mdb_notify(dev, p, entry, RTM_NEWMDB);
} }
} else { } else {
err = __br_mdb_add(net, br, entry); err = __br_mdb_add(net, br, entry);
if (!err)
__br_mdb_notify(dev, p, entry, RTM_NEWMDB);
} }
return err; return err;
...@@ -832,6 +831,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry) ...@@ -832,6 +831,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
if (entry->ifindex == mp->br->dev->ifindex && mp->host_joined) { if (entry->ifindex == mp->br->dev->ifindex && mp->host_joined) {
br_multicast_host_leave(mp, false); br_multicast_host_leave(mp, false);
err = 0; err = 0;
__br_mdb_notify(br->dev, NULL, entry, RTM_DELMDB);
if (!mp->ports && netif_running(br->dev)) if (!mp->ports && netif_running(br->dev))
mod_timer(&mp->timer, jiffies); mod_timer(&mp->timer, jiffies);
goto unlock; goto unlock;
...@@ -894,13 +894,9 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -894,13 +894,9 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
list_for_each_entry(v, &vg->vlan_list, vlist) { list_for_each_entry(v, &vg->vlan_list, vlist) {
entry->vid = v->vid; entry->vid = v->vid;
err = __br_mdb_del(br, entry); err = __br_mdb_del(br, entry);
if (!err)
__br_mdb_notify(dev, p, entry, RTM_DELMDB);
} }
} else { } else {
err = __br_mdb_del(br, entry); err = __br_mdb_del(br, entry);
if (!err)
__br_mdb_notify(dev, p, entry, RTM_DELMDB);
} }
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