forked from mirrors/linux
		
	net: bridge: vlan: convert mcast router global option to per-vlan entry
The per-vlan router option controls the port/vlan and host vlan entries' mcast router config. The global option controlled only the host vlan config, but that is unnecessary and incosistent as it's not really a global vlan option, but rather bridge option to control host router config, so convert BRIDGE_VLANDB_GOPTS_MCAST_ROUTER to BRIDGE_VLANDB_ENTRY_MCAST_ROUTER which can be used to control both host vlan and port vlan mcast router config. Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									a53581d555
								
							
						
					
					
						commit
						2796d846d7
					
				
					 5 changed files with 63 additions and 19 deletions
				
			
		| 
						 | 
					@ -506,6 +506,7 @@ enum {
 | 
				
			||||||
	BRIDGE_VLANDB_ENTRY_STATE,
 | 
						BRIDGE_VLANDB_ENTRY_STATE,
 | 
				
			||||||
	BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
 | 
						BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
 | 
				
			||||||
	BRIDGE_VLANDB_ENTRY_STATS,
 | 
						BRIDGE_VLANDB_ENTRY_STATS,
 | 
				
			||||||
 | 
						BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
 | 
				
			||||||
	__BRIDGE_VLANDB_ENTRY_MAX,
 | 
						__BRIDGE_VLANDB_ENTRY_MAX,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
 | 
					#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
 | 
				
			||||||
| 
						 | 
					@ -561,7 +562,6 @@ enum {
 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL,
 | 
						BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL,
 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL,
 | 
						BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL,
 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
 | 
						BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_ROUTER,
 | 
					 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS,
 | 
						BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS,
 | 
				
			||||||
	BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE,
 | 
						BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE,
 | 
				
			||||||
	__BRIDGE_VLANDB_GOPTS_MAX
 | 
						__BRIDGE_VLANDB_GOPTS_MAX
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4310,6 +4310,19 @@ int br_multicast_set_port_router(struct net_bridge_mcast_port *pmctx,
 | 
				
			||||||
	return err;
 | 
						return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int br_multicast_set_vlan_router(struct net_bridge_vlan *v, u8 mcast_router)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (br_vlan_is_master(v))
 | 
				
			||||||
 | 
							err = br_multicast_set_router(&v->br_mcast_ctx, mcast_router);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							err = br_multicast_set_port_router(&v->port_mcast_ctx,
 | 
				
			||||||
 | 
											   mcast_router);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return err;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void br_multicast_start_querier(struct net_bridge_mcast *brmctx,
 | 
					static void br_multicast_start_querier(struct net_bridge_mcast *brmctx,
 | 
				
			||||||
				       struct bridge_mcast_own_query *query)
 | 
									       struct bridge_mcast_own_query *query)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -676,6 +676,20 @@ static inline bool br_vlan_valid_range(const struct bridge_vlan_info *cur,
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline u8 br_vlan_multicast_router(const struct net_bridge_vlan *v)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						u8 mcast_router = MDB_RTR_TYPE_DISABLED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 | 
				
			||||||
 | 
						if (!br_vlan_is_master(v))
 | 
				
			||||||
 | 
							mcast_router = v->port_mcast_ctx.multicast_router;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							mcast_router = v->br_mcast_ctx.multicast_router;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return mcast_router;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline int br_afspec_cmd_to_rtm(int cmd)
 | 
					static inline int br_afspec_cmd_to_rtm(int cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	switch (cmd) {
 | 
						switch (cmd) {
 | 
				
			||||||
| 
						 | 
					@ -881,6 +895,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, struct sk_buff *skb,
 | 
				
			||||||
int br_multicast_set_router(struct net_bridge_mcast *brmctx, unsigned long val);
 | 
					int br_multicast_set_router(struct net_bridge_mcast *brmctx, unsigned long val);
 | 
				
			||||||
int br_multicast_set_port_router(struct net_bridge_mcast_port *pmctx,
 | 
					int br_multicast_set_port_router(struct net_bridge_mcast_port *pmctx,
 | 
				
			||||||
				 unsigned long val);
 | 
									 unsigned long val);
 | 
				
			||||||
 | 
					int br_multicast_set_vlan_router(struct net_bridge_vlan *v, u8 mcast_router);
 | 
				
			||||||
int br_multicast_toggle(struct net_bridge *br, unsigned long val,
 | 
					int br_multicast_toggle(struct net_bridge *br, unsigned long val,
 | 
				
			||||||
			struct netlink_ext_ack *extack);
 | 
								struct netlink_ext_ack *extack);
 | 
				
			||||||
int br_multicast_set_querier(struct net_bridge_mcast *brmctx, unsigned long val);
 | 
					int br_multicast_set_querier(struct net_bridge_mcast *brmctx, unsigned long val);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2136,6 +2136,7 @@ static const struct nla_policy br_vlan_db_policy[BRIDGE_VLANDB_ENTRY_MAX + 1] =
 | 
				
			||||||
	[BRIDGE_VLANDB_ENTRY_RANGE]	= { .type = NLA_U16 },
 | 
						[BRIDGE_VLANDB_ENTRY_RANGE]	= { .type = NLA_U16 },
 | 
				
			||||||
	[BRIDGE_VLANDB_ENTRY_STATE]	= { .type = NLA_U8 },
 | 
						[BRIDGE_VLANDB_ENTRY_STATE]	= { .type = NLA_U8 },
 | 
				
			||||||
	[BRIDGE_VLANDB_ENTRY_TUNNEL_INFO] = { .type = NLA_NESTED },
 | 
						[BRIDGE_VLANDB_ENTRY_TUNNEL_INFO] = { .type = NLA_NESTED },
 | 
				
			||||||
 | 
						[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]	= { .type = NLA_U8 },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int br_vlan_rtm_process_one(struct net_device *dev,
 | 
					static int br_vlan_rtm_process_one(struct net_device *dev,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,22 +40,38 @@ static bool __vlan_tun_can_enter_range(const struct net_bridge_vlan *v_curr,
 | 
				
			||||||
bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,
 | 
					bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,
 | 
				
			||||||
			   const struct net_bridge_vlan *range_end)
 | 
								   const struct net_bridge_vlan *range_end)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						u8 range_mc_rtr = br_vlan_multicast_router(range_end);
 | 
				
			||||||
 | 
						u8 curr_mc_rtr = br_vlan_multicast_router(v_curr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return v_curr->state == range_end->state &&
 | 
						return v_curr->state == range_end->state &&
 | 
				
			||||||
	       __vlan_tun_can_enter_range(v_curr, range_end);
 | 
						       __vlan_tun_can_enter_range(v_curr, range_end) &&
 | 
				
			||||||
 | 
						       curr_mc_rtr == range_mc_rtr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v)
 | 
					bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return !nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE,
 | 
						if (nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE, br_vlan_get_state(v)) ||
 | 
				
			||||||
			   br_vlan_get_state(v)) &&
 | 
						    !__vlan_tun_put(skb, v))
 | 
				
			||||||
	       __vlan_tun_put(skb, v);
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 | 
				
			||||||
 | 
						if (nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
 | 
				
			||||||
 | 
							       br_vlan_multicast_router(v)))
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t br_vlan_opts_nl_size(void)
 | 
					size_t br_vlan_opts_nl_size(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_STATE */
 | 
						return nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_STATE */
 | 
				
			||||||
	       + nla_total_size(0) /* BRIDGE_VLANDB_ENTRY_TUNNEL_INFO */
 | 
						       + nla_total_size(0) /* BRIDGE_VLANDB_ENTRY_TUNNEL_INFO */
 | 
				
			||||||
	       + nla_total_size(sizeof(u32)); /* BRIDGE_VLANDB_TINFO_ID */
 | 
						       + nla_total_size(sizeof(u32)) /* BRIDGE_VLANDB_TINFO_ID */
 | 
				
			||||||
 | 
					#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 | 
				
			||||||
 | 
						       + nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_MCAST_ROUTER */
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						       + 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,
 | 
					static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,
 | 
				
			||||||
| 
						 | 
					@ -181,6 +197,18 @@ static int br_vlan_process_one_opts(const struct net_bridge *br,
 | 
				
			||||||
			return err;
 | 
								return err;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 | 
				
			||||||
 | 
						if (tb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]) {
 | 
				
			||||||
 | 
							u8 val;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							val = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]);
 | 
				
			||||||
 | 
							err = br_multicast_set_vlan_router(v, val);
 | 
				
			||||||
 | 
							if (err)
 | 
				
			||||||
 | 
								return err;
 | 
				
			||||||
 | 
							*changed = true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -298,8 +326,6 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range,
 | 
				
			||||||
			v_opts->br_mcast_ctx.multicast_startup_query_count) ||
 | 
								v_opts->br_mcast_ctx.multicast_startup_query_count) ||
 | 
				
			||||||
	    nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
 | 
						    nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
 | 
				
			||||||
		       v_opts->br_mcast_ctx.multicast_querier) ||
 | 
							       v_opts->br_mcast_ctx.multicast_querier) ||
 | 
				
			||||||
	    nla_put_u8(skb, BRIDGE_VLANDB_GOPTS_MCAST_ROUTER,
 | 
					 | 
				
			||||||
		       v_opts->br_mcast_ctx.multicast_router) ||
 | 
					 | 
				
			||||||
	    br_multicast_dump_querier_state(skb, &v_opts->br_mcast_ctx,
 | 
						    br_multicast_dump_querier_state(skb, &v_opts->br_mcast_ctx,
 | 
				
			||||||
					    BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE))
 | 
										    BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE))
 | 
				
			||||||
		goto out_err;
 | 
							goto out_err;
 | 
				
			||||||
| 
						 | 
					@ -380,7 +406,6 @@ static size_t rtnl_vlan_global_opts_nlmsg_size(const struct net_bridge_vlan *v)
 | 
				
			||||||
		+ nla_total_size(sizeof(u64)) /* BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL */
 | 
							+ nla_total_size(sizeof(u64)) /* BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL */
 | 
				
			||||||
		+ nla_total_size(sizeof(u64)) /* BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL */
 | 
							+ nla_total_size(sizeof(u64)) /* BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL */
 | 
				
			||||||
		+ nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER */
 | 
							+ nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER */
 | 
				
			||||||
		+ nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER */
 | 
					 | 
				
			||||||
		+ br_multicast_querier_state_size() /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE */
 | 
							+ br_multicast_querier_state_size() /* BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE */
 | 
				
			||||||
		+ nla_total_size(0) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */
 | 
							+ nla_total_size(0) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */
 | 
				
			||||||
		+ br_rports_size(&v->br_mcast_ctx) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */
 | 
							+ br_rports_size(&v->br_mcast_ctx) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */
 | 
				
			||||||
| 
						 | 
					@ -522,15 +547,6 @@ static int br_vlan_process_global_one_opts(const struct net_bridge *br,
 | 
				
			||||||
			return err;
 | 
								return err;
 | 
				
			||||||
		*changed = true;
 | 
							*changed = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (tb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER]) {
 | 
					 | 
				
			||||||
		u8 val;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		val = nla_get_u8(tb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER]);
 | 
					 | 
				
			||||||
		err = br_multicast_set_router(&v->br_mcast_ctx, val);
 | 
					 | 
				
			||||||
		if (err)
 | 
					 | 
				
			||||||
			return err;
 | 
					 | 
				
			||||||
		*changed = true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#if IS_ENABLED(CONFIG_IPV6)
 | 
					#if IS_ENABLED(CONFIG_IPV6)
 | 
				
			||||||
	if (tb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]) {
 | 
						if (tb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]) {
 | 
				
			||||||
		u8 ver;
 | 
							u8 ver;
 | 
				
			||||||
| 
						 | 
					@ -554,7 +570,6 @@ static const struct nla_policy br_vlan_db_gpol[BRIDGE_VLANDB_GOPTS_MAX + 1] = {
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]	= { .type = NLA_U8 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]	= { .type = NLA_U8 },
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL]	= { .type = NLA_U64 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL]	= { .type = NLA_U64 },
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER]	= { .type = NLA_U8 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER]	= { .type = NLA_U8 },
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER]	= { .type = NLA_U8 },
 | 
					 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION]	= { .type = NLA_U8 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION]	= { .type = NLA_U8 },
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT]	= { .type = NLA_U32 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT]	= { .type = NLA_U32 },
 | 
				
			||||||
	[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT]	= { .type = NLA_U32 },
 | 
						[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT]	= { .type = NLA_U32 },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue