net: bridge: multicast: make tracked EHT hosts limit configurable
authorNikolay Aleksandrov <nikolay@nvidia.com>
Tue, 26 Jan 2021 09:35:33 +0000 (11:35 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 28 Jan 2021 01:40:35 +0000 (17:40 -0800)
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

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/uapi/linux/if_link.h
net/bridge/br_multicast_eht.c
net/bridge/br_netlink.c
net/bridge/br_private_mcast_eht.h
net/bridge/br_sysfs_if.c
net/core/rtnetlink.c

index 2bd0d8bbcdb2595b1fea675280dfe04ce221f816..eb8018c3a737223cb856882bc3f77fb80e2c88ae 100644 (file)
@@ -525,6 +525,8 @@ enum {
        IFLA_BRPORT_BACKUP_PORT,
        IFLA_BRPORT_MRP_RING_OPEN,
        IFLA_BRPORT_MRP_IN_OPEN,
+       IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
+       IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
        __IFLA_BRPORT_MAX
 };
 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
index 445768c8495f1d0f83bc273d73c6112b62440466..fea38b9a72688212e3ee94f35b8c17d1cd199e9c 100644 (file)
@@ -861,3 +861,18 @@ bool br_multicast_eht_handle(struct net_bridge_port_group *pg,
 out:
        return changed;
 }
+
+int br_multicast_eht_set_hosts_limit(struct net_bridge_port *p,
+                                    u32 eht_hosts_limit)
+{
+       struct net_bridge *br = p->br;
+
+       if (!eht_hosts_limit)
+               return -EINVAL;
+
+       spin_lock_bh(&br->multicast_lock);
+       p->multicast_eht_hosts_limit = eht_hosts_limit;
+       spin_unlock_bh(&br->multicast_lock);
+
+       return 0;
+}
index 762f273802cdab4ab4705391e6878de6e055abda..bd3962da345a3fac3be4cb886e297f64033a11b9 100644 (file)
@@ -18,6 +18,7 @@
 #include "br_private_stp.h"
 #include "br_private_cfm.h"
 #include "br_private_tunnel.h"
+#include "br_private_mcast_eht.h"
 
 static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg,
                                u32 filter_mask)
@@ -199,6 +200,8 @@ static inline size_t br_port_info_size(void)
                + nla_total_size(sizeof(u16))   /* IFLA_BRPORT_GROUP_FWD_MASK */
                + nla_total_size(sizeof(u8))    /* IFLA_BRPORT_MRP_RING_OPEN */
                + nla_total_size(sizeof(u8))    /* IFLA_BRPORT_MRP_IN_OPEN */
+               + nla_total_size(sizeof(u32))   /* IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT */
+               + nla_total_size(sizeof(u32))   /* IFLA_BRPORT_MCAST_EHT_HOSTS_CNT */
                + 0;
 }
 
@@ -283,7 +286,11 @@ static int br_port_fill_attrs(struct sk_buff *skb,
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
        if (nla_put_u8(skb, IFLA_BRPORT_MULTICAST_ROUTER,
-                      p->multicast_router))
+                      p->multicast_router) ||
+           nla_put_u32(skb, IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
+                       p->multicast_eht_hosts_limit) ||
+           nla_put_u32(skb, IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
+                       p->multicast_eht_hosts_cnt))
                return -EMSGSIZE;
 #endif
 
@@ -820,6 +827,7 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = {
        [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NLA_U8 },
        [IFLA_BRPORT_ISOLATED]  = { .type = NLA_U8 },
        [IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 },
+       [IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT] = { .type = NLA_U32 },
 };
 
 /* 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[])
                if (err)
                        return err;
        }
+
+       if (tb[IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT]) {
+               u32 hlimit;
+
+               hlimit = nla_get_u32(tb[IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT]);
+               err = br_multicast_eht_set_hosts_limit(p, hlimit);
+               if (err)
+                       return err;
+       }
 #endif
 
        if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) {
index b2c8d988721f7285fe046b8f0ea3df82d67c8c7f..f89049f4892c936f44f88fc2886239fb157b53a6 100644 (file)
@@ -57,6 +57,8 @@ bool br_multicast_eht_handle(struct net_bridge_port_group *pg,
                             u32 nsrcs,
                             size_t addr_size,
                             int grec_type);
+int br_multicast_eht_set_hosts_limit(struct net_bridge_port *p,
+                                    u32 eht_hosts_limit);
 
 static inline bool
 br_multicast_eht_should_del_pg(const struct net_bridge_port_group *pg)
index 7a59cdddd3ce3b64a9a6899e6d0d14f0fd79e91c..b66305fae26b083d5be60190cab2dc8aafdc4c4b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sched/signal.h>
 
 #include "br_private.h"
+#include "br_private_mcast_eht.h"
 
 struct brport_attribute {
        struct attribute        attr;
@@ -245,6 +246,29 @@ static int store_multicast_router(struct net_bridge_port *p,
 static BRPORT_ATTR(multicast_router, 0644, show_multicast_router,
                   store_multicast_router);
 
+static ssize_t show_multicast_eht_hosts_limit(struct net_bridge_port *p,
+                                             char *buf)
+{
+       return sprintf(buf, "%u\n", p->multicast_eht_hosts_limit);
+}
+
+static int store_multicast_eht_hosts_limit(struct net_bridge_port *p,
+                                          unsigned long v)
+{
+       return br_multicast_eht_set_hosts_limit(p, v);
+}
+static BRPORT_ATTR(multicast_eht_hosts_limit, 0644,
+                  show_multicast_eht_hosts_limit,
+                  store_multicast_eht_hosts_limit);
+
+static ssize_t show_multicast_eht_hosts_cnt(struct net_bridge_port *p,
+                                           char *buf)
+{
+       return sprintf(buf, "%u\n", p->multicast_eht_hosts_cnt);
+}
+static BRPORT_ATTR(multicast_eht_hosts_cnt, 0444, show_multicast_eht_hosts_cnt,
+                  NULL);
+
 BRPORT_ATTR_FLAG(multicast_fast_leave, BR_MULTICAST_FAST_LEAVE);
 BRPORT_ATTR_FLAG(multicast_to_unicast, BR_MULTICAST_TO_UNICAST);
 #endif
@@ -274,6 +298,8 @@ static const struct brport_attribute *brport_attrs[] = {
        &brport_attr_multicast_router,
        &brport_attr_multicast_fast_leave,
        &brport_attr_multicast_to_unicast,
+       &brport_attr_multicast_eht_hosts_limit,
+       &brport_attr_multicast_eht_hosts_cnt,
 #endif
        &brport_attr_proxyarp,
        &brport_attr_proxyarp_wifi,
index 3d6ab194d0f58c909ada67d6bd6dd6f28576c932..c313aaf2bce1b5b1157bdcbee79eff1c066581da 100644 (file)
@@ -55,7 +55,7 @@
 #include <net/net_namespace.h>
 
 #define RTNL_MAX_TYPE          50
-#define RTNL_SLAVE_MAX_TYPE    36
+#define RTNL_SLAVE_MAX_TYPE    40
 
 struct rtnl_link {
        rtnl_doit_func          doit;