16
16
17
17
#include "br_private.h"
18
18
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 )
20
20
{
21
21
#if IS_ENABLED (CONFIG_IPV6 )
22
22
return !hlist_empty (& brmctx -> ip4_mc_router_list ) ||
@@ -27,46 +27,58 @@ static bool br_rports_have_mc_router(struct net_bridge_mcast *brmctx)
27
27
}
28
28
29
29
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 )
31
32
{
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 );
34
35
}
35
36
36
37
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 )
38
40
{
39
41
#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 );
42
44
#else
43
45
* timer = 0 ;
44
46
return false;
45
47
#endif
46
48
}
47
49
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 )
50
52
{
51
- struct net_bridge * br = netdev_priv ( dev ) ;
53
+ u16 vid = brmctx -> vlan ? brmctx -> vlan -> vid : 0 ;
52
54
bool have_ip4_mc_rtr , have_ip6_mc_rtr ;
53
55
unsigned long ip4_timer , ip6_timer ;
54
56
struct nlattr * nest , * port_nest ;
55
57
struct net_bridge_port * p ;
56
58
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 ))
61
60
return 0 ;
62
61
63
62
nest = nla_nest_start_noflag (skb , MDBA_ROUTER );
64
63
if (nest == NULL )
65
64
return - EMSGSIZE ;
66
65
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 );
70
82
71
83
if (!have_ip4_mc_rtr && !have_ip6_mc_rtr )
72
84
continue ;
@@ -390,6 +402,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
390
402
391
403
for_each_netdev_rcu (net , dev ) {
392
404
if (dev -> priv_flags & IFF_EBRIDGE ) {
405
+ struct net_bridge * br = netdev_priv (dev );
393
406
struct br_port_msg * bpm ;
394
407
395
408
if (idx < s_idx )
@@ -406,7 +419,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
406
419
bpm -> ifindex = dev -> ifindex ;
407
420
if (br_mdb_fill_info (skb , cb , dev ) < 0 )
408
421
goto out ;
409
- if (br_rports_fill_info (skb , cb , dev ) < 0 )
422
+ if (br_rports_fill_info (skb , & br -> multicast_ctx ) < 0 )
410
423
goto out ;
411
424
412
425
cb -> args [1 ] = 0 ;
0 commit comments