Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bridge: mcast: add support for more router port information dumping

Allow for more multicast router port information to be dumped such as
timer and type attributes. For that that purpose we need to extend the
MDBA_ROUTER_PORT attribute similar to how it was done for the mdb entries
recently. The new format is thus:
[MDBA_ROUTER_PORT] = { <- nested attribute
u32 ifindex <- router port ifindex for user-space compatibility
[MDBA_ROUTER_PATTR attributes]
}
This way it remains compatible with older users (they'll simply retrieve
the u32 in the beginning) and new users can parse the remaining
attributes. It would also allow to add future extensions to the router
port without breaking compatibility.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Nikolay Aleksandrov and committed by
David S. Miller
59f78f9f a55d8246

+27 -3
+13 -1
include/uapi/linux/if_bridge.h
··· 144 144 * } 145 145 * } 146 146 * [MDBA_ROUTER] = { 147 - * [MDBA_ROUTER_PORT] 147 + * [MDBA_ROUTER_PORT] = { 148 + * u32 ifindex 149 + * [MDBA_ROUTER_PATTR attributes] 150 + * } 148 151 * } 149 152 */ 150 153 enum { ··· 194 191 __MDBA_ROUTER_MAX, 195 192 }; 196 193 #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1) 194 + 195 + /* router port attributes */ 196 + enum { 197 + MDBA_ROUTER_PATTR_UNSPEC, 198 + MDBA_ROUTER_PATTR_TIMER, 199 + MDBA_ROUTER_PATTR_TYPE, 200 + __MDBA_ROUTER_PATTR_MAX 201 + }; 202 + #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1) 197 203 198 204 struct br_port_msg { 199 205 __u8 family;
+14 -2
net/bridge/br_mdb.c
··· 20 20 { 21 21 struct net_bridge *br = netdev_priv(dev); 22 22 struct net_bridge_port *p; 23 - struct nlattr *nest; 23 + struct nlattr *nest, *port_nest; 24 24 25 25 if (!br->multicast_router || hlist_empty(&br->router_list)) 26 26 return 0; ··· 30 30 return -EMSGSIZE; 31 31 32 32 hlist_for_each_entry_rcu(p, &br->router_list, rlist) { 33 - if (p && nla_put_u32(skb, MDBA_ROUTER_PORT, p->dev->ifindex)) 33 + if (!p) 34 + continue; 35 + port_nest = nla_nest_start(skb, MDBA_ROUTER_PORT); 36 + if (!port_nest) 34 37 goto fail; 38 + if (nla_put_nohdr(skb, sizeof(u32), &p->dev->ifindex) || 39 + nla_put_u32(skb, MDBA_ROUTER_PATTR_TIMER, 40 + br_timer_value(&p->multicast_router_timer)) || 41 + nla_put_u8(skb, MDBA_ROUTER_PATTR_TYPE, 42 + p->multicast_router)) { 43 + nla_nest_cancel(skb, port_nest); 44 + goto fail; 45 + } 46 + nla_nest_end(skb, port_nest); 35 47 } 36 48 37 49 nla_nest_end(skb, nest);