Skip to content

Commit dc00287

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
net: bridge: vlan: use br_rports_fill_info() to export mcast router ports
Embed the standard multicast router port export by br_rports_fill_info() into a new global vlan attribute BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS. In order to have the same format for the global bridge mcast context and the per-vlan mcast context we need a double-nesting: - BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS - MDBA_ROUTER Currently we don't compare router lists, if any router port exists in the bridge mcast contexts we consider their option sets as different and export them separately. In addition we export the router port vlan id when dumping similar to the router port notification format. Signed-off-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e04d377 commit dc00287

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

include/uapi/linux/if_bridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ enum {
562562
BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL,
563563
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
564564
BRIDGE_VLANDB_GOPTS_MCAST_ROUTER,
565+
BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS,
565566
__BRIDGE_VLANDB_GOPTS_MAX
566567
};
567568
#define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1)

net/bridge/br_mdb.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616

1717
#include "br_private.h"
1818

19-
static bool br_rports_have_mc_router(const struct net_bridge_mcast *brmctx)
20-
{
21-
#if IS_ENABLED(CONFIG_IPV6)
22-
return !hlist_empty(&brmctx->ip4_mc_router_list) ||
23-
!hlist_empty(&brmctx->ip6_mc_router_list);
24-
#else
25-
return !hlist_empty(&brmctx->ip4_mc_router_list);
26-
#endif
27-
}
28-
2919
static bool
3020
br_ip4_rports_get_timer(struct net_bridge_mcast_port *pmctx,
3121
unsigned long *timer)
@@ -47,8 +37,8 @@ br_ip6_rports_get_timer(struct net_bridge_mcast_port *pmctx,
4737
#endif
4838
}
4939

50-
static int br_rports_fill_info(struct sk_buff *skb,
51-
const struct net_bridge_mcast *brmctx)
40+
int br_rports_fill_info(struct sk_buff *skb,
41+
const struct net_bridge_mcast *brmctx)
5242
{
5343
u16 vid = brmctx->vlan ? brmctx->vlan->vid : 0;
5444
bool have_ip4_mc_rtr, have_ip6_mc_rtr;
@@ -97,7 +87,8 @@ static int br_rports_fill_info(struct sk_buff *skb,
9787
ip4_timer)) ||
9888
(have_ip6_mc_rtr &&
9989
nla_put_u32(skb, MDBA_ROUTER_PATTR_INET6_TIMER,
100-
ip6_timer))) {
90+
ip6_timer)) ||
91+
(vid && nla_put_u16(skb, MDBA_ROUTER_PATTR_VID, vid))) {
10192
nla_nest_cancel(skb, port_nest);
10293
goto fail;
10394
}

net/bridge/br_private.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,8 @@ bool br_multicast_toggle_global_vlan(struct net_bridge_vlan *vlan, bool on);
945945
int br_mdb_replay(struct net_device *br_dev, struct net_device *dev,
946946
const void *ctx, bool adding, struct notifier_block *nb,
947947
struct netlink_ext_ack *extack);
948+
int br_rports_fill_info(struct sk_buff *skb,
949+
const struct net_bridge_mcast *brmctx);
948950

949951
static inline bool br_group_is_l2(const struct br_ip *group)
950952
{
@@ -1168,6 +1170,17 @@ br_multicast_port_ctx_state_stopped(const struct net_bridge_mcast_port *pmctx)
11681170
pmctx->vlan->state == BR_STATE_BLOCKING);
11691171
}
11701172

1173+
static inline bool
1174+
br_rports_have_mc_router(const struct net_bridge_mcast *brmctx)
1175+
{
1176+
#if IS_ENABLED(CONFIG_IPV6)
1177+
return !hlist_empty(&brmctx->ip4_mc_router_list) ||
1178+
!hlist_empty(&brmctx->ip6_mc_router_list);
1179+
#else
1180+
return !hlist_empty(&brmctx->ip4_mc_router_list);
1181+
#endif
1182+
}
1183+
11711184
static inline bool
11721185
br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
11731186
const struct net_bridge_mcast *brmctx2)
@@ -1192,6 +1205,8 @@ br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
11921205
brmctx2->multicast_startup_query_interval &&
11931206
brmctx1->multicast_querier == brmctx2->multicast_querier &&
11941207
brmctx1->multicast_router == brmctx2->multicast_router &&
1208+
!br_rports_have_mc_router(brmctx1) &&
1209+
!br_rports_have_mc_router(brmctx2) &&
11951210
#if IS_ENABLED(CONFIG_IPV6)
11961211
brmctx1->multicast_mld_version ==
11971212
brmctx2->multicast_mld_version &&

net/bridge/br_vlan_options.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_curr,
272272
bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range,
273273
const struct net_bridge_vlan *v_opts)
274274
{
275+
struct nlattr *nest2 __maybe_unused;
275276
u64 clockval __maybe_unused;
276277
struct nlattr *nest;
277278

@@ -326,6 +327,23 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range,
326327
clockval, BRIDGE_VLANDB_GOPTS_PAD))
327328
goto out_err;
328329

330+
if (br_rports_have_mc_router(&v_opts->br_mcast_ctx)) {
331+
nest2 = nla_nest_start(skb,
332+
BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS);
333+
if (!nest2)
334+
goto out_err;
335+
336+
rcu_read_lock();
337+
if (br_rports_fill_info(skb, &v_opts->br_mcast_ctx)) {
338+
rcu_read_unlock();
339+
nla_nest_cancel(skb, nest2);
340+
goto out_err;
341+
}
342+
rcu_read_unlock();
343+
344+
nla_nest_end(skb, nest2);
345+
}
346+
329347
#if IS_ENABLED(CONFIG_IPV6)
330348
if (nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION,
331349
v_opts->br_mcast_ctx.multicast_mld_version))

0 commit comments

Comments
 (0)