Skip to content

Commit e04d377

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
net: bridge: mcast: use the proper multicast context when dumping router ports
When we are dumping the router ports of a vlan mcast context we need to use the bridge/vlan and port/vlan's multicast contexts to check if IPv4/IPv6 router port is present and later to dump the vlan id. Signed-off-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a97df08 commit e04d377

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

net/bridge/br_mdb.c

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "br_private.h"
1818

19-
static bool br_rports_have_mc_router(struct net_bridge_mcast *brmctx)
19+
static bool br_rports_have_mc_router(const struct net_bridge_mcast *brmctx)
2020
{
2121
#if IS_ENABLED(CONFIG_IPV6)
2222
return !hlist_empty(&brmctx->ip4_mc_router_list) ||
@@ -27,46 +27,58 @@ static bool br_rports_have_mc_router(struct net_bridge_mcast *brmctx)
2727
}
2828

2929
static bool
30-
br_ip4_rports_get_timer(struct net_bridge_port *port, unsigned long *timer)
30+
br_ip4_rports_get_timer(struct net_bridge_mcast_port *pmctx,
31+
unsigned long *timer)
3132
{
32-
*timer = br_timer_value(&port->multicast_ctx.ip4_mc_router_timer);
33-
return !hlist_unhashed(&port->multicast_ctx.ip4_rlist);
33+
*timer = br_timer_value(&pmctx->ip4_mc_router_timer);
34+
return !hlist_unhashed(&pmctx->ip4_rlist);
3435
}
3536

3637
static bool
37-
br_ip6_rports_get_timer(struct net_bridge_port *port, unsigned long *timer)
38+
br_ip6_rports_get_timer(struct net_bridge_mcast_port *pmctx,
39+
unsigned long *timer)
3840
{
3941
#if IS_ENABLED(CONFIG_IPV6)
40-
*timer = br_timer_value(&port->multicast_ctx.ip6_mc_router_timer);
41-
return !hlist_unhashed(&port->multicast_ctx.ip6_rlist);
42+
*timer = br_timer_value(&pmctx->ip6_mc_router_timer);
43+
return !hlist_unhashed(&pmctx->ip6_rlist);
4244
#else
4345
*timer = 0;
4446
return false;
4547
#endif
4648
}
4749

48-
static int br_rports_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
49-
struct net_device *dev)
50+
static int br_rports_fill_info(struct sk_buff *skb,
51+
const struct net_bridge_mcast *brmctx)
5052
{
51-
struct net_bridge *br = netdev_priv(dev);
53+
u16 vid = brmctx->vlan ? brmctx->vlan->vid : 0;
5254
bool have_ip4_mc_rtr, have_ip6_mc_rtr;
5355
unsigned long ip4_timer, ip6_timer;
5456
struct nlattr *nest, *port_nest;
5557
struct net_bridge_port *p;
5658

57-
if (!br->multicast_ctx.multicast_router)
58-
return 0;
59-
60-
if (!br_rports_have_mc_router(&br->multicast_ctx))
59+
if (!brmctx->multicast_router || !br_rports_have_mc_router(brmctx))
6160
return 0;
6261

6362
nest = nla_nest_start_noflag(skb, MDBA_ROUTER);
6463
if (nest == NULL)
6564
return -EMSGSIZE;
6665

67-
list_for_each_entry_rcu(p, &br->port_list, list) {
68-
have_ip4_mc_rtr = br_ip4_rports_get_timer(p, &ip4_timer);
69-
have_ip6_mc_rtr = br_ip6_rports_get_timer(p, &ip6_timer);
66+
list_for_each_entry_rcu(p, &brmctx->br->port_list, list) {
67+
struct net_bridge_mcast_port *pmctx;
68+
69+
if (vid) {
70+
struct net_bridge_vlan *v;
71+
72+
v = br_vlan_find(nbp_vlan_group(p), vid);
73+
if (!v)
74+
continue;
75+
pmctx = &v->port_mcast_ctx;
76+
} else {
77+
pmctx = &p->multicast_ctx;
78+
}
79+
80+
have_ip4_mc_rtr = br_ip4_rports_get_timer(pmctx, &ip4_timer);
81+
have_ip6_mc_rtr = br_ip6_rports_get_timer(pmctx, &ip6_timer);
7082

7183
if (!have_ip4_mc_rtr && !have_ip6_mc_rtr)
7284
continue;
@@ -390,6 +402,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
390402

391403
for_each_netdev_rcu(net, dev) {
392404
if (dev->priv_flags & IFF_EBRIDGE) {
405+
struct net_bridge *br = netdev_priv(dev);
393406
struct br_port_msg *bpm;
394407

395408
if (idx < s_idx)
@@ -406,7 +419,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
406419
bpm->ifindex = dev->ifindex;
407420
if (br_mdb_fill_info(skb, cb, dev) < 0)
408421
goto out;
409-
if (br_rports_fill_info(skb, cb, dev) < 0)
422+
if (br_rports_fill_info(skb, &br->multicast_ctx) < 0)
410423
goto out;
411424

412425
cb->args[1] = 0;

0 commit comments

Comments
 (0)