Commit 9e8430f8 authored by Elad Raz's avatar Elad Raz Committed by David S. Miller

bridge: mdb: Passing the port-group pointer to br_mdb module

Passing the port-group to br_mdb in order to allow direct access to the
structure. br_mdb will later use the structure to reflect HW reflection
status via "state" variable.
Signed-off-by: default avatarElad Raz <eladr@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d06b6d8
...@@ -217,7 +217,7 @@ static inline size_t rtnl_mdb_nlmsg_size(void) ...@@ -217,7 +217,7 @@ static inline size_t rtnl_mdb_nlmsg_size(void)
} }
static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry, static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry,
int type) int type, struct net_bridge_port_group *pg)
{ {
struct switchdev_obj_port_mdb mdb = { struct switchdev_obj_port_mdb mdb = {
.obj = { .obj = {
...@@ -240,10 +240,13 @@ static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry, ...@@ -240,10 +240,13 @@ static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry,
#endif #endif
mdb.obj.orig_dev = port_dev; mdb.obj.orig_dev = port_dev;
if (port_dev && type == RTM_NEWMDB) if (port_dev && type == RTM_NEWMDB) {
switchdev_port_obj_add(port_dev, &mdb.obj); err = switchdev_port_obj_add(port_dev, &mdb.obj);
else if (port_dev && type == RTM_DELMDB) if (!err && pg)
pg->flags |= MDB_PG_FLAGS_OFFLOAD;
} else if (port_dev && type == RTM_DELMDB) {
switchdev_port_obj_del(port_dev, &mdb.obj); switchdev_port_obj_del(port_dev, &mdb.obj);
}
skb = nlmsg_new(rtnl_mdb_nlmsg_size(), GFP_ATOMIC); skb = nlmsg_new(rtnl_mdb_nlmsg_size(), GFP_ATOMIC);
if (!skb) if (!skb)
...@@ -261,21 +264,21 @@ static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry, ...@@ -261,21 +264,21 @@ static void __br_mdb_notify(struct net_device *dev, struct br_mdb_entry *entry,
rtnl_set_sk_err(net, RTNLGRP_MDB, err); rtnl_set_sk_err(net, RTNLGRP_MDB, err);
} }
void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port, void br_mdb_notify(struct net_device *dev, struct net_bridge_port_group *pg,
struct br_ip *group, int type, u8 flags) int type)
{ {
struct br_mdb_entry entry; struct br_mdb_entry entry;
memset(&entry, 0, sizeof(entry)); memset(&entry, 0, sizeof(entry));
entry.ifindex = port->dev->ifindex; entry.ifindex = pg->port->dev->ifindex;
entry.addr.proto = group->proto; entry.addr.proto = pg->addr.proto;
entry.addr.u.ip4 = group->u.ip4; entry.addr.u.ip4 = pg->addr.u.ip4;
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
entry.addr.u.ip6 = group->u.ip6; entry.addr.u.ip6 = pg->addr.u.ip6;
#endif #endif
entry.vid = group->vid; entry.vid = pg->addr.vid;
__mdb_entry_fill_flags(&entry, flags); __mdb_entry_fill_flags(&entry, pg->flags);
__br_mdb_notify(dev, &entry, type); __br_mdb_notify(dev, &entry, type, pg);
} }
static int nlmsg_populate_rtr_fill(struct sk_buff *skb, static int nlmsg_populate_rtr_fill(struct sk_buff *skb,
...@@ -420,7 +423,8 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -420,7 +423,8 @@ 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, unsigned char state,
struct net_bridge_port_group **pg)
{ {
struct net_bridge_mdb_entry *mp; struct net_bridge_mdb_entry *mp;
struct net_bridge_port_group *p; struct net_bridge_port_group *p;
...@@ -451,6 +455,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -451,6 +455,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
if (unlikely(!p)) if (unlikely(!p))
return -ENOMEM; return -ENOMEM;
rcu_assign_pointer(*pp, p); rcu_assign_pointer(*pp, p);
*pg = p;
if (state == MDB_TEMPORARY) if (state == MDB_TEMPORARY)
mod_timer(&p->timer, now + br->multicast_membership_interval); mod_timer(&p->timer, now + br->multicast_membership_interval);
...@@ -458,7 +463,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -458,7 +463,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
} }
static int __br_mdb_add(struct net *net, struct net_bridge *br, static int __br_mdb_add(struct net *net, struct net_bridge *br,
struct br_mdb_entry *entry) struct br_mdb_entry *entry,
struct net_bridge_port_group **pg)
{ {
struct br_ip ip; struct br_ip ip;
struct net_device *dev; struct net_device *dev;
...@@ -487,7 +493,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br, ...@@ -487,7 +493,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
#endif #endif
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->state, pg);
spin_unlock_bh(&br->multicast_lock); spin_unlock_bh(&br->multicast_lock);
return ret; return ret;
} }
...@@ -495,6 +501,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br, ...@@ -495,6 +501,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh) static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct net_bridge_port_group *pg;
struct net_bridge_vlan_group *vg; struct net_bridge_vlan_group *vg;
struct net_device *dev, *pdev; struct net_device *dev, *pdev;
struct br_mdb_entry *entry; struct br_mdb_entry *entry;
...@@ -524,15 +531,15 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -524,15 +531,15 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh)
if (br_vlan_enabled(br) && vg && entry->vid == 0) { if (br_vlan_enabled(br) && vg && 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; entry->vid = v->vid;
err = __br_mdb_add(net, br, entry); err = __br_mdb_add(net, br, entry, &pg);
if (err) if (err)
break; break;
__br_mdb_notify(dev, entry, RTM_NEWMDB); __br_mdb_notify(dev, entry, RTM_NEWMDB, pg);
} }
} else { } else {
err = __br_mdb_add(net, br, entry); err = __br_mdb_add(net, br, entry, &pg);
if (!err) if (!err)
__br_mdb_notify(dev, entry, RTM_NEWMDB); __br_mdb_notify(dev, entry, RTM_NEWMDB, pg);
} }
return err; return err;
...@@ -628,12 +635,12 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -628,12 +635,12 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh)
entry->vid = v->vid; entry->vid = v->vid;
err = __br_mdb_del(br, entry); err = __br_mdb_del(br, entry);
if (!err) if (!err)
__br_mdb_notify(dev, entry, RTM_DELMDB); __br_mdb_notify(dev, entry, RTM_DELMDB, NULL);
} }
} else { } else {
err = __br_mdb_del(br, entry); err = __br_mdb_del(br, entry);
if (!err) if (!err)
__br_mdb_notify(dev, entry, RTM_DELMDB); __br_mdb_notify(dev, entry, RTM_DELMDB, NULL);
} }
return err; return err;
......
...@@ -283,8 +283,7 @@ static void br_multicast_del_pg(struct net_bridge *br, ...@@ -283,8 +283,7 @@ static void br_multicast_del_pg(struct net_bridge *br,
rcu_assign_pointer(*pp, p->next); rcu_assign_pointer(*pp, p->next);
hlist_del_init(&p->mglist); hlist_del_init(&p->mglist);
del_timer(&p->timer); del_timer(&p->timer);
br_mdb_notify(br->dev, p->port, &pg->addr, RTM_DELMDB, br_mdb_notify(br->dev, p, RTM_DELMDB);
p->flags);
call_rcu_bh(&p->rcu, br_multicast_free_pg); call_rcu_bh(&p->rcu, br_multicast_free_pg);
if (!mp->ports && !mp->mglist && if (!mp->ports && !mp->mglist &&
...@@ -706,7 +705,7 @@ static int br_multicast_add_group(struct net_bridge *br, ...@@ -706,7 +705,7 @@ static int br_multicast_add_group(struct net_bridge *br,
if (unlikely(!p)) if (unlikely(!p))
goto err; goto err;
rcu_assign_pointer(*pp, p); rcu_assign_pointer(*pp, p);
br_mdb_notify(br->dev, port, group, RTM_NEWMDB, 0); br_mdb_notify(br->dev, p, RTM_NEWMDB);
found: found:
mod_timer(&p->timer, now + br->multicast_membership_interval); mod_timer(&p->timer, now + br->multicast_membership_interval);
...@@ -1453,8 +1452,7 @@ br_multicast_leave_group(struct net_bridge *br, ...@@ -1453,8 +1452,7 @@ br_multicast_leave_group(struct net_bridge *br,
hlist_del_init(&p->mglist); hlist_del_init(&p->mglist);
del_timer(&p->timer); del_timer(&p->timer);
call_rcu_bh(&p->rcu, br_multicast_free_pg); call_rcu_bh(&p->rcu, br_multicast_free_pg);
br_mdb_notify(br->dev, port, group, RTM_DELMDB, br_mdb_notify(br->dev, p, RTM_DELMDB);
p->flags);
if (!mp->ports && !mp->mglist && if (!mp->ports && !mp->mglist &&
netif_running(br->dev)) netif_running(br->dev))
......
...@@ -560,8 +560,8 @@ br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group, ...@@ -560,8 +560,8 @@ br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group,
unsigned char flags); unsigned char flags);
void br_mdb_init(void); void br_mdb_init(void);
void br_mdb_uninit(void); void br_mdb_uninit(void);
void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port, void br_mdb_notify(struct net_device *dev, struct net_bridge_port_group *pg,
struct br_ip *group, int type, u8 flags); int type);
void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port, void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
int type); int type);
......
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