Skip to content

Commit 59f78f9

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a55d824 commit 59f78f9

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

include/uapi/linux/if_bridge.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ struct bridge_vlan_info {
144144
* }
145145
* }
146146
* [MDBA_ROUTER] = {
147-
* [MDBA_ROUTER_PORT]
147+
* [MDBA_ROUTER_PORT] = {
148+
* u32 ifindex
149+
* [MDBA_ROUTER_PATTR attributes]
150+
* }
148151
* }
149152
*/
150153
enum {
@@ -192,6 +195,15 @@ enum {
192195
};
193196
#define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1)
194197

198+
/* router port attributes */
199+
enum {
200+
MDBA_ROUTER_PATTR_UNSPEC,
201+
MDBA_ROUTER_PATTR_TIMER,
202+
MDBA_ROUTER_PATTR_TYPE,
203+
__MDBA_ROUTER_PATTR_MAX
204+
};
205+
#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
206+
195207
struct br_port_msg {
196208
__u8 family;
197209
__u32 ifindex;

net/bridge/br_mdb.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static int br_rports_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
2020
{
2121
struct net_bridge *br = netdev_priv(dev);
2222
struct net_bridge_port *p;
23-
struct nlattr *nest;
23+
struct nlattr *nest, *port_nest;
2424

2525
if (!br->multicast_router || hlist_empty(&br->router_list))
2626
return 0;
@@ -30,8 +30,20 @@ static int br_rports_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
3030
return -EMSGSIZE;
3131

3232
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)
3437
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);
3547
}
3648

3749
nla_nest_end(skb, nest);

0 commit comments

Comments
 (0)