History

net: bridge: multicast: make tracked EHT hosts limit configurable

Add two new port attributes which make EHT hosts limit configurable and export the current number of tracked EHT hosts: - IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT: configure/retrieve current limit - IFLA_BRPORT_MCAST_EHT_HOSTS_CNT: current number of tracked hosts Setting IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT to 0 is currently not allowed. Note that we have to increase RTNL_SLAVE_MAX_TYPE to 38 minimum, I've increased it to 40 to have space for two more future entries. v2: move br_multicast_eht_set_hosts_limit() to br_multicast_eht.c, no functional change

Nikolay Aleksandrov committed 5 years ago

Commit 2dba4071 parent 89268b06 files · +64 −2Browse files

Unified · Split

6 files
  1. include/uapi/linux/if_link.h +2 −0
  2. net/bridge/br_multicast_eht.c +15 −0
  3. net/bridge/br_netlink.c +18 −1
  4. net/bridge/br_private_mcast_eht.h +2 −0
  5. net/bridge/br_sysfs_if.c +26 −0
  6. net/core/rtnetlink.c +1 −1
include/uapi/linux/if_link.h+2−0
@@ -525,6 +525,8 @@ enum { · 524 unmodified lines
525 IFLA_BRPORT_BACKUP_PORT,525 IFLA_BRPORT_BACKUP_PORT,
526 IFLA_BRPORT_MRP_RING_OPEN,526 IFLA_BRPORT_MRP_RING_OPEN,
527 IFLA_BRPORT_MRP_IN_OPEN,527 IFLA_BRPORT_MRP_IN_OPEN,
528 IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
529 IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
528 __IFLA_BRPORT_MAX530 __IFLA_BRPORT_MAX
529};531};
530#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)532#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
net/bridge/br_multicast_eht.c+15−0
@@ -861,3 +861,18 @@ bool br_multicast_eht_handle(struct net_bridge_port_group *pg, · 860 unmodified lines
861out:861out:
862 return changed;862 return changed;
863}863}
864
865int br_multicast_eht_set_hosts_limit(struct net_bridge_port *p,
866 u32 eht_hosts_limit)
867{
868 struct net_bridge *br = p->br;
869
870 if (!eht_hosts_limit)
871 return -EINVAL;
872
873 spin_lock_bh(&br->multicast_lock);
874 p->multicast_eht_hosts_limit = eht_hosts_limit;
875 spin_unlock_bh(&br->multicast_lock);
876
877 return 0;
878}
net/bridge/br_netlink.c+18−1
@@ -18,6 +18,7 @@ · 17 unmodified lines
18#include "br_private_stp.h"18#include "br_private_stp.h"
19#include "br_private_cfm.h"19#include "br_private_cfm.h"
20#include "br_private_tunnel.h"20#include "br_private_tunnel.h"
21#include "br_private_mcast_eht.h"
21 22
22static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg,23static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg,
23 u32 filter_mask)24 u32 filter_mask)
@@ -199,6 +200,8 @@ static inline size_t br_port_info_size(void) · 175 unmodified lines
199 + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_GROUP_FWD_MASK */200 + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_GROUP_FWD_MASK */
200 + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_RING_OPEN */201 + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_RING_OPEN */
201 + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_IN_OPEN */202 + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_IN_OPEN */
203 + nla_total_size(sizeof(u32)) /* IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT */
204 + nla_total_size(sizeof(u32)) /* IFLA_BRPORT_MCAST_EHT_HOSTS_CNT */
202 + 0;205 + 0;
203}206}
204 207
@@ -283,7 +286,11 @@ static int br_port_fill_attrs(struct sk_buff *skb, · 78 unmodified lines
283 286
284#ifdef CONFIG_BRIDGE_IGMP_SNOOPING287#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
285 if (nla_put_u8(skb, IFLA_BRPORT_MULTICAST_ROUTER,288 if (nla_put_u8(skb, IFLA_BRPORT_MULTICAST_ROUTER,
286 p->multicast_router))289 p->multicast_router) ||
290 nla_put_u32(skb, IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
291 p->multicast_eht_hosts_limit) ||
292 nla_put_u32(skb, IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
293 p->multicast_eht_hosts_cnt))
287 return -EMSGSIZE;294 return -EMSGSIZE;
288#endif295#endif
289 296
@@ -820,6 +827,7 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = { · 530 unmodified lines
820 [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NLA_U8 },827 [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NLA_U8 },
821 [IFLA_BRPORT_ISOLATED] = { .type = NLA_U8 },828 [IFLA_BRPORT_ISOLATED] = { .type = NLA_U8 },
822 [IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 },829 [IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 },
830 [IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT] = { .type = NLA_U32 },
823};831};
824 832
825/* Change the state of the port and notify spanning tree */833/* Change the state of the port and notify spanning tree */
@@ -955,6 +963,15 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[]) · 129 unmodified lines
955 if (err)963 if (err)
956 return err;964 return err;
957 }965 }
966
967 if (tb[IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT]) {
968 u32 hlimit;
969
970 hlimit = nla_get_u32(tb[IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT]);
971 err = br_multicast_eht_set_hosts_limit(p, hlimit);
972 if (err)
973 return err;
974 }
958#endif975#endif
959 976
960 if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) {977 if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) {
net/bridge/br_private_mcast_eht.h+2−0
@@ -57,6 +57,8 @@ bool br_multicast_eht_handle(struct net_bridge_port_group *pg, · 56 unmodified lines
57 u32 nsrcs,57 u32 nsrcs,
58 size_t addr_size,58 size_t addr_size,
59 int grec_type);59 int grec_type);
60int br_multicast_eht_set_hosts_limit(struct net_bridge_port *p,
61 u32 eht_hosts_limit);
60 62
61static inline bool63static inline bool
62br_multicast_eht_should_del_pg(const struct net_bridge_port_group *pg)64br_multicast_eht_should_del_pg(const struct net_bridge_port_group *pg)
net/bridge/br_sysfs_if.c+26−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
16#include <linux/sched/signal.h>16#include <linux/sched/signal.h>
17 17
18#include "br_private.h"18#include "br_private.h"
19#include "br_private_mcast_eht.h"
19 20
20struct brport_attribute {21struct brport_attribute {
21 struct attribute attr;22 struct attribute attr;
@@ -245,6 +246,29 @@ static int store_multicast_router(struct net_bridge_port *p, · 223 unmodified lines
245static BRPORT_ATTR(multicast_router, 0644, show_multicast_router,246static BRPORT_ATTR(multicast_router, 0644, show_multicast_router,
246 store_multicast_router);247 store_multicast_router);
247 248
249static ssize_t show_multicast_eht_hosts_limit(struct net_bridge_port *p,
250 char *buf)
251{
252 return sprintf(buf, "%u\n", p->multicast_eht_hosts_limit);
253}
254
255static int store_multicast_eht_hosts_limit(struct net_bridge_port *p,
256 unsigned long v)
257{
258 return br_multicast_eht_set_hosts_limit(p, v);
259}
260static BRPORT_ATTR(multicast_eht_hosts_limit, 0644,
261 show_multicast_eht_hosts_limit,
262 store_multicast_eht_hosts_limit);
263
264static ssize_t show_multicast_eht_hosts_cnt(struct net_bridge_port *p,
265 char *buf)
266{
267 return sprintf(buf, "%u\n", p->multicast_eht_hosts_cnt);
268}
269static BRPORT_ATTR(multicast_eht_hosts_cnt, 0444, show_multicast_eht_hosts_cnt,
270 NULL);
271
248BRPORT_ATTR_FLAG(multicast_fast_leave, BR_MULTICAST_FAST_LEAVE);272BRPORT_ATTR_FLAG(multicast_fast_leave, BR_MULTICAST_FAST_LEAVE);
249BRPORT_ATTR_FLAG(multicast_to_unicast, BR_MULTICAST_TO_UNICAST);273BRPORT_ATTR_FLAG(multicast_to_unicast, BR_MULTICAST_TO_UNICAST);
250#endif274#endif
@@ -274,6 +298,8 @@ static const struct brport_attribute *brport_attrs[] = { · 23 unmodified lines
274 &brport_attr_multicast_router,298 &brport_attr_multicast_router,
275 &brport_attr_multicast_fast_leave,299 &brport_attr_multicast_fast_leave,
276 &brport_attr_multicast_to_unicast,300 &brport_attr_multicast_to_unicast,
301 &brport_attr_multicast_eht_hosts_limit,
302 &brport_attr_multicast_eht_hosts_cnt,
277#endif303#endif
278 &brport_attr_proxyarp,304 &brport_attr_proxyarp,
279 &brport_attr_proxyarp_wifi,305 &brport_attr_proxyarp_wifi,
net/core/rtnetlink.c+1−1
@@ -55,7 +55,7 @@ · 54 unmodified lines
55#include <net/net_namespace.h>55#include <net/net_namespace.h>
56 56
57#define RTNL_MAX_TYPE 5057#define RTNL_MAX_TYPE 50
58#define RTNL_SLAVE_MAX_TYPE 3658#define RTNL_SLAVE_MAX_TYPE 40
59 59
60struct rtnl_link {60struct rtnl_link {
61 rtnl_doit_func doit;61 rtnl_doit_func doit;