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
525525 IFLA_BRPORT_BACKUP_PORT,
526526 IFLA_BRPORT_MRP_RING_OPEN,
527527 IFLA_BRPORT_MRP_IN_OPEN,
528+ IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
529+ IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
528530 __IFLA_BRPORT_MAX
529531 };
530532 #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
861861 out:
862862 return changed;
863863 }
864+
865+int 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
1818 #include "br_private_stp.h"
1919 #include "br_private_cfm.h"
2020 #include "br_private_tunnel.h"
21+#include "br_private_mcast_eht.h"
2122
2223 static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg,
2324 u32 filter_mask)
@@ -199,6 +200,8 @@ static inline size_t br_port_info_size(void) · 175 unmodified lines
199200 + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_GROUP_FWD_MASK */
200201 + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_RING_OPEN */
201202 + 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 */
202205 + 0;
203206 }
204207
@@ -283,7 +286,11 @@ static int br_port_fill_attrs(struct sk_buff *skb, · 78 unmodified lines
283286
284287 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
285288 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))
287294 return -EMSGSIZE;
288295 #endif
289296
@@ -820,6 +827,7 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = { · 530 unmodified lines
820827 [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NLA_U8 },
821828 [IFLA_BRPORT_ISOLATED] = { .type = NLA_U8 },
822829 [IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 },
830+ [IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT] = { .type = NLA_U32 },
823831 };
824832
825833 /* 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
955963 if (err)
956964 return err;
957965 }
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+ }
958975 #endif
959976
960977 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
5757 u32 nsrcs,
5858 size_t addr_size,
5959 int grec_type);
60+int br_multicast_eht_set_hosts_limit(struct net_bridge_port *p,
61+ u32 eht_hosts_limit);
6062
6163 static inline bool
6264 br_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
1616 #include <linux/sched/signal.h>
1717
1818 #include "br_private.h"
19+#include "br_private_mcast_eht.h"
1920
2021 struct brport_attribute {
2122 struct attribute attr;
@@ -245,6 +246,29 @@ static int store_multicast_router(struct net_bridge_port *p, · 223 unmodified lines
245246 static BRPORT_ATTR(multicast_router, 0644, show_multicast_router,
246247 store_multicast_router);
247248
249+static 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+
255+static 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+}
260+static BRPORT_ATTR(multicast_eht_hosts_limit, 0644,
261+ show_multicast_eht_hosts_limit,
262+ store_multicast_eht_hosts_limit);
263+
264+static 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+}
269+static BRPORT_ATTR(multicast_eht_hosts_cnt, 0444, show_multicast_eht_hosts_cnt,
270+ NULL);
271+
248272 BRPORT_ATTR_FLAG(multicast_fast_leave, BR_MULTICAST_FAST_LEAVE);
249273 BRPORT_ATTR_FLAG(multicast_to_unicast, BR_MULTICAST_TO_UNICAST);
250274 #endif
@@ -274,6 +298,8 @@ static const struct brport_attribute *brport_attrs[] = { · 23 unmodified lines
274298 &brport_attr_multicast_router,
275299 &brport_attr_multicast_fast_leave,
276300 &brport_attr_multicast_to_unicast,
301+ &brport_attr_multicast_eht_hosts_limit,
302+ &brport_attr_multicast_eht_hosts_cnt,
277303 #endif
278304 &brport_attr_proxyarp,
279305 &brport_attr_proxyarp_wifi,
net/core/rtnetlink.c+1−1
@@ -55,7 +55,7 @@ · 54 unmodified lines
5555 #include <net/net_namespace.h>
5656
5757 #define RTNL_MAX_TYPE 50
58−#define RTNL_SLAVE_MAX_TYPE 36
58+#define RTNL_SLAVE_MAX_TYPE 40
5959
6060 struct rtnl_link {
6161 rtnl_doit_func doit;