On 02/02/2023 19:59, Petr Machata wrote: > The previous patch added accounting for number of MDB entries per port and > per port-VLAN, and the logic to verify that these values stay within > configured bounds. However it didn't provide means to actually configure > those bounds or read the occupancy. This patch does that. > > Two new netlink attributes are added for the MDB occupancy: > IFLA_BRPORT_MCAST_N_GROUPS for the per-port occupancy and > BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS for the per-port-VLAN occupancy. > And another two for the maximum number of MDB entries: > IFLA_BRPORT_MCAST_MAX_GROUPS for the per-port maximum, and > BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS for the per-port-VLAN one. > > Note that the two new IFLA_BRPORT_ attributes prompt bumping of > RTNL_SLAVE_MAX_TYPE to size the slave attribute tables large enough. > > The new attributes are used like this: > > # ip link add name br up type bridge vlan_filtering 1 mcast_snooping 1 \ > mcast_vlan_snooping 1 mcast_querier 1 > # ip link set dev v1 master br > # bridge vlan add dev v1 vid 2 > > # bridge vlan set dev v1 vid 1 mcast_max_groups 1 > # bridge mdb add dev br port v1 grp 230.1.2.3 temp vid 1 > # bridge mdb add dev br port v1 grp 230.1.2.4 temp vid 1 > Error: bridge: Port-VLAN is already in 1 groups, and mcast_max_groups=1. > > # bridge link set dev v1 mcast_max_groups 1 > # bridge mdb add dev br port v1 grp 230.1.2.3 temp vid 2 > Error: bridge: Port is already in 1 groups, and mcast_max_groups=1. > > # bridge -d link show > 5: v1@v2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br [...] > [...] mcast_n_groups 1 mcast_max_groups 1 > > # bridge -d vlan show > port vlan-id > br 1 PVID Egress Untagged > state forwarding mcast_router 1 > v1 1 PVID Egress Untagged > [...] mcast_n_groups 1 mcast_max_groups 1 > 2 > [...] mcast_n_groups 0 mcast_max_groups 0 > > Signed-off-by: Petr Machata <petrm@xxxxxxxxxx> > --- > > Notes: > v3: > - Move the br_multicast_port_ctx_vlan_disabled() check > out to the _vlan_ helpers callers. Thus these helpers > cannot fail, which makes them very similar to the > _port_ helpers. Have them take the MC context directly > and unify them. > > v2: > - Drop locks around accesses in > br_multicast_{port,vlan}_ngroups_{get,set_max}(), > - Drop bounces due to max<n in > br_multicast_{port,vlan}_ngroups_set_max(). > > include/uapi/linux/if_bridge.h | 2 ++ > include/uapi/linux/if_link.h | 2 ++ > net/bridge/br_multicast.c | 15 +++++++++++++++ > net/bridge/br_netlink.c | 17 ++++++++++++++++- > net/bridge/br_private.h | 6 +++++- > net/bridge/br_vlan.c | 11 +++++++---- > net/bridge/br_vlan_options.c | 27 ++++++++++++++++++++++++++- > net/core/rtnetlink.c | 2 +- > 8 files changed, 74 insertions(+), 8 deletions(-) > Acked-by: Nikolay Aleksandrov <razor@xxxxxxxxxxxxx>