net: bridge: multicast: add initial EHT support
Subsystems (3)
Nikolay Aleksandrov
maintainercover net: bridge: multicast: add initial EHT support
From: Nikolay Aleksandrov <[email protected]>
Hi,
This set adds explicit host tracking support for IGMPv3/MLDv2. The already present per-port fast leave flag is used to enable it since that is the primary goal of EHT, to track a group and its S,Gs usage per-host and when left without any interested hosts delete them before the standard timers. The EHT code is pretty self-contained and not enabled by default. There is no new uAPI added, all of the functionality is currently hidden behind the fast leave flag. In the future that will change (more below). The host tracking uses two new sets per port group: one having an entry for each host which contains that host's view of the group (source list and filter mode), and one set which contains an entry for each source having an internal set which contains an entry for each host that has reported an interest for that source. RB trees are used for all sets so they're compact when not used and fast when we need to do lookups.
To illustrate it:
[ bridge port group ]
` [ host set (rb) ]
` [ host entry with a list of sources and filter mode ]
` [ source set (rb) ]
` [ source entry ]
` [ source host set (rb) ]
` [ source host entry with a timer ]
The number of tracked sources per host is limited to the maximum total number of S,G entries per port group - PG_SRC_ENT_LIMIT (currently 32). The number of hosts is unlimited, I think the argument that a local attacker can exhaust the memory/cause high CPU usage can be applied to fdb entries as well which are unlimited. In the future if needed we can add an option to limit these, but I don't think it's necessary for a start. All of the new sets are protected by the bridge's multicast lock. I'm pretty sure we'll be changing the cases and improving the convergence time in the future, but this seems like a good start.
I'll post self-tests as a separate patch-set.
Patch breakdown:
patch 1 - 4: minor cleanups and preparations for EHT
patch 5: adds the new structures which will be used in the
following patches
patch 6: adds support to create, destroy and lookup host entries
patch 7: adds support to create, delete and lokup source set entries
patch 8: adds a host "delete" function which is just a host's
source list flush since that would automatically delete
the host
patch 9 - 10: add support for handling all IGMPv3/MLDv2 report types
more information can be found in the individual patches
patch 11: optmizes a specific TO_INCLUDE use-case with host timeouts
patch 12: handles per-host filter mode changing (include <-> exclude)
patch 13: pulls out block group deletion since now it can be deleted in both filter modes
patch 14: marks deletions done due to fast leave
Future plans:
- export host information
- add an option to reduce queries
- add an option to limit the number of host entries
- tune more fast leave cases for quicker convergence
By the way I think this is the first open-source EHT implementation, I couldn't find any while researching it. :)
Thanks,
Nik
Nikolay Aleksandrov (14):
net: bridge: multicast: rename src_size to addr_size
net: bridge: multicast: pass host src address to IGMPv3/MLDv2
functions
net: bridge: multicast: __grp_src_block_incl can modify pg
net: bridge: multicast: calculate idx position without changing ptr
net: bridge: multicast: add EHT structures and definitions
net: bridge: multicast: add EHT host handling functions
net: bridge: multicast: add EHT source set handling functions
net: bridge: multicast: add EHT host delete function
net: bridge: multicast: add EHT allow/block handling
net: bridge: multicast: add EHT include and exclude handling
net: bridge: multicast: optimize TO_INCLUDE EHT timeouts
net: bridge: multicast: add EHT host filter_mode handling
net: bridge: multicast: handle block pg delete for all cases
net: bridge: multicast: mark IGMPv3/MLDv2 fast-leave deletes
net/bridge/Makefile | 2 +- net/bridge/br_multicast.c | 254 +++++---- net/bridge/br_multicast_eht.c | 856 ++++++++++++++++++++++++++++++ net/bridge/br_private.h | 6 + net/bridge/br_private_mcast_eht.h | 65 +++ 5 files changed, 1093 insertions(+), 90 deletions(-) create mode 100644 net/bridge/br_multicast_eht.c create mode 100644 net/bridge/br_private_mcast_eht.h
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 1/14 net: bridge: multicast: rename src_size to addr_size
From: Nikolay Aleksandrov <[email protected]>
Rename src_size argument to addr_size in preparation for passing host address as an argument to IGMPv3/MLDv2 functions.
No functional change.
--- net/bridge/br_multicast.c | 78 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-)
net/bridge/br_multicast.c +39 -39
@@ -1800,7 +1800,7 @@ static void __grp_send_query_and_rexmit(struct net_bridge_port_group *pg)* EXCLUDE (X,Y) ALLOW (A) EXCLUDE (X+A,Y-A) (A)=GMI */ static bool br_multicast_isinc_allow (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;struct net_bridge_group_src *ent;
@@ -1812,7 +1812,7 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (!ent) { ent =br_multicast_new_group_src (pg, &src_ip);
@@ -1822,7 +1822,7 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg,if (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += src_size; + srcs += addr_size; }return changed;
@@ -1834,7 +1834,7 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg,* Group Timer=GMI */ static void __grp_src_isexc_incl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;struct br_ip src_ip;
@@ -1846,7 +1846,7 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -1854,7 +1854,7 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg, ent =br_multicast_new_group_src (pg, &src_ip);if (ent)br_multicast_fwd_src_handle (ent); - srcs += src_size; + srcs += addr_size; }__grp_src_delete_marked (pg);
@@ -1867,7 +1867,7 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg,* Group Timer=GMI */ static bool __grp_src_isexc_excl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;struct net_bridge_group_src *ent;
@@ -1882,7 +1882,7 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -1894,7 +1894,7 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, changed = true; } } - srcs += src_size; + srcs += addr_size; }if (__grp_src_delete_marked (pg))
@@ -1904,19 +1904,19 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, }static bool br_multicast_isexc (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_isexc_incl (pg, srcs, nsrcs, src_size); +__grp_src_isexc_incl (pg, srcs, nsrcs, addr_size);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_isexc_excl (pg, srcs, nsrcs, src_size); + changed =__grp_src_isexc_excl (pg, srcs, nsrcs, addr_size);break ; }
@@ -1931,7 +1931,7 @@ static bool br_multicast_isexc(struct net_bridge_port_group *pg,* Send Q(G,A-B) */ static bool __grp_src_toin_incl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;u32 src_idx, to_send = pg->src_ents;
@@ -1946,7 +1946,7 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_SEND ;
@@ -1958,7 +1958,7 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg, }if (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += src_size; + srcs += addr_size; }if (to_send)
@@ -1973,7 +1973,7 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg,* Send Q(G) */ static bool __grp_src_toin_excl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;u32 src_idx, to_send = pg->src_ents;
@@ -1989,7 +1989,7 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) {if (timer_pending (&ent->timer)) {
@@ -2003,7 +2003,7 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, }if (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += src_size; + srcs += addr_size; }if (to_send)
@@ -2015,16 +2015,16 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, }static bool br_multicast_toin (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : - changed =__grp_src_toin_incl (pg, srcs, nsrcs, src_size); + changed =__grp_src_toin_incl (pg, srcs, nsrcs, addr_size);break ;case MCAST_EXCLUDE : - changed =__grp_src_toin_excl (pg, srcs, nsrcs, src_size); + changed =__grp_src_toin_excl (pg, srcs, nsrcs, addr_size);break ; }
@@ -2038,7 +2038,7 @@ static bool br_multicast_toin(struct net_bridge_port_group *pg,* Group Timer=GMI */ static void __grp_src_toex_incl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2050,7 +2050,7 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags = (ent->flags & ~BR_SGRP_F_DELETE) |
@@ -2061,7 +2061,7 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg, }if (ent)br_multicast_fwd_src_handle (ent); - srcs += src_size; + srcs += addr_size; }__grp_src_delete_marked (pg);
@@ -2077,7 +2077,7 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg,* Group Timer=GMI */ static bool __grp_src_toex_excl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2090,7 +2090,7 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -2105,7 +2105,7 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += src_size; + srcs += addr_size; }if (__grp_src_delete_marked (pg))
@@ -2117,19 +2117,19 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, }static bool br_multicast_toex (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_toex_incl (pg, srcs, nsrcs, src_size); +__grp_src_toex_incl (pg, srcs, nsrcs, addr_size);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_toex_excl (pg, srcs, nsrcs, src_size); + changed =__grp_src_toex_excl (pg, srcs, nsrcs, addr_size);break ; }
@@ -2143,7 +2143,7 @@ static bool br_multicast_toex(struct net_bridge_port_group *pg,* INCLUDE (A) BLOCK (B) INCLUDE (A) Send Q(G,A*B) */ static void __grp_src_block_incl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2155,13 +2155,13 @@ static void __grp_src_block_incl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += src_size; + srcs += addr_size; }if (to_send)
@@ -2176,7 +2176,7 @@ static void __grp_src_block_incl(struct net_bridge_port_group *pg,* Send Q(G,A-Y) */ static bool __grp_src_block_excl (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2189,7 +2189,7 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, src_size); +memcpy (&src_ip.src, srcs, addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (!ent) { ent =br_multicast_new_group_src (pg, &src_ip);
@@ -2202,7 +2202,7 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += src_size; + srcs += addr_size; }if (to_send)
@@ -2212,16 +2212,16 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, }static bool br_multicast_block (struct net_bridge_port_group *pg, -void *srcs,u32 nsrcs,size_t src_size) +void *srcs,u32 nsrcs,size_t addr_size) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_block_incl (pg, srcs, nsrcs, src_size); +__grp_src_block_incl (pg, srcs, nsrcs, addr_size);break ;case MCAST_EXCLUDE : - changed =__grp_src_block_excl (pg, srcs, nsrcs, src_size); + changed =__grp_src_block_excl (pg, srcs, nsrcs, addr_size);break ; }
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 2/14 net: bridge: multicast: pass host src address to IGMPv3/MLDv2 functions
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
We need to pass the host address so later it can be used for explicit host tracking. No functional change.
--- net/bridge/br_multicast.c | 90 +++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 41 deletions(-)
net/bridge/br_multicast.c +49 -41
@@ -1799,7 +1799,7 @@ static void __grp_send_query_and_rexmit(struct net_bridge_port_group *pg)* INCLUDE (A) ALLOW (B) INCLUDE (A+B) (B)=GMI * EXCLUDE (X,Y) ALLOW (A) EXCLUDE (X+A,Y-A) (A)=GMI */ -static bool br_multicast_isinc_allow (struct net_bridge_port_group *pg, +static bool br_multicast_isinc_allow (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -1833,7 +1833,7 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg,* Delete (A-B) * Group Timer=GMI */ -static void __grp_src_isexc_incl (struct net_bridge_port_group *pg, +static void __grp_src_isexc_incl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;
@@ -1866,7 +1866,7 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg,* Delete (Y-A) * Group Timer=GMI */ -static bool __grp_src_isexc_excl (struct net_bridge_port_group *pg, +static bool __grp_src_isexc_excl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -1903,7 +1903,7 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg,return changed; } -static bool br_multicast_isexc (struct net_bridge_port_group *pg, +static bool br_multicast_isexc (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -1911,12 +1911,12 @@ static bool br_multicast_isexc(struct net_bridge_port_group *pg,switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_isexc_incl (pg, srcs, nsrcs, addr_size); +__grp_src_isexc_incl (pg, h_addr, srcs, nsrcs, addr_size);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_isexc_excl (pg, srcs, nsrcs, addr_size); + changed =__grp_src_isexc_excl (pg, h_addr, srcs, nsrcs, addr_size);break ; }
@@ -1930,7 +1930,7 @@ static bool br_multicast_isexc(struct net_bridge_port_group *pg,* INCLUDE (A) TO_IN (B) INCLUDE (A+B) (B)=GMI * Send Q(G,A-B) */ -static bool __grp_src_toin_incl (struct net_bridge_port_group *pg, +static bool __grp_src_toin_incl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -1972,7 +1972,7 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg,* Send Q(G,X-A) * Send Q(G) */ -static bool __grp_src_toin_excl (struct net_bridge_port_group *pg, +static bool __grp_src_toin_excl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -2014,17 +2014,17 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg,return changed; } -static bool br_multicast_toin (struct net_bridge_port_group *pg, +static bool br_multicast_toin (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : - changed =__grp_src_toin_incl (pg, srcs, nsrcs, addr_size); + changed =__grp_src_toin_incl (pg, h_addr, srcs, nsrcs, addr_size);break ;case MCAST_EXCLUDE : - changed =__grp_src_toin_excl (pg, srcs, nsrcs, addr_size); + changed =__grp_src_toin_excl (pg, h_addr, srcs, nsrcs, addr_size);break ; }
@@ -2037,7 +2037,7 @@ static bool br_multicast_toin(struct net_bridge_port_group *pg,* Send Q(G,A*B) * Group Timer=GMI */ -static void __grp_src_toex_incl (struct net_bridge_port_group *pg, +static void __grp_src_toex_incl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;
@@ -2076,7 +2076,7 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg,* Send Q(G,A-Y) * Group Timer=GMI */ -static bool __grp_src_toex_excl (struct net_bridge_port_group *pg, +static bool __grp_src_toex_excl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;
@@ -2116,7 +2116,7 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg,return changed; } -static bool br_multicast_toex (struct net_bridge_port_group *pg, +static bool br_multicast_toex (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge *br = pg->key.port->br;
@@ -2124,12 +2124,12 @@ static bool br_multicast_toex(struct net_bridge_port_group *pg,switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_toex_incl (pg, srcs, nsrcs, addr_size); +__grp_src_toex_incl (pg, h_addr, srcs, nsrcs, addr_size);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_toex_excl (pg, srcs, nsrcs, addr_size); + changed =__grp_src_toex_excl (pg, h_addr, srcs, nsrcs, addr_size);break ; }
@@ -2142,7 +2142,7 @@ static bool br_multicast_toex(struct net_bridge_port_group *pg,/* State Msg type New state Actions * INCLUDE (A) BLOCK (B) INCLUDE (A) Send Q(G,A*B) */ -static void __grp_src_block_incl (struct net_bridge_port_group *pg, +static void __grp_src_block_incl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;
@@ -2175,7 +2175,7 @@ static void __grp_src_block_incl(struct net_bridge_port_group *pg,* EXCLUDE (X,Y) BLOCK (A) EXCLUDE (X+(A-Y),Y) (A-X-Y)=Group Timer * Send Q(G,A-Y) */ -static bool __grp_src_block_excl (struct net_bridge_port_group *pg, +static bool __grp_src_block_excl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;
@@ -2211,17 +2211,17 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg,return changed; } -static bool br_multicast_block (struct net_bridge_port_group *pg, +static bool br_multicast_block (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_block_incl (pg, srcs, nsrcs, addr_size); +__grp_src_block_incl (pg, h_addr, srcs, nsrcs, addr_size);break ;case MCAST_EXCLUDE : - changed =__grp_src_block_excl (pg, srcs, nsrcs, addr_size); + changed =__grp_src_block_excl (pg, h_addr, srcs, nsrcs, addr_size);break ; }
@@ -2257,8 +2257,8 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,struct igmpv3_report *ih;struct igmpv3_grec *grec;int i, len, num, type; +__be32 group, *h_addr;bool changed = false; -__be32 group;int err =0 ;u16 nsrcs;
@@ -2318,32 +2318,33 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br, pg =br_multicast_find_port (mdst, port, src);if (!pg || (pg->flags &MDB_PG_FLAGS_PERMANENT )) goto unlock_continue; -/* reload grec */ +/* reload grec and host addr */ grec = (void *)(skb->data + len -sizeof (*grec) - (nsrcs *4 )); + h_addr = &ip_hdr (skb)->saddr;switch (type) {case IGMPV3_ALLOW_NEW_SOURCES : - changed =br_multicast_isinc_allow (pg, grec->grec_src, + changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, nsrcs,sizeof (__be32));break ;case IGMPV3_MODE_IS_INCLUDE : - changed =br_multicast_isinc_allow (pg, grec->grec_src, nsrcs, -sizeof (__be32)); + changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, + nsrcs,sizeof (__be32));break ;case IGMPV3_MODE_IS_EXCLUDE : - changed =br_multicast_isexc (pg, grec->grec_src, nsrcs, -sizeof (__be32)); + changed =br_multicast_isexc (pg, h_addr, grec->grec_src, + nsrcs,sizeof (__be32));break ;case IGMPV3_CHANGE_TO_INCLUDE : - changed =br_multicast_toin (pg, grec->grec_src, nsrcs, -sizeof (__be32)); + changed =br_multicast_toin (pg, h_addr, grec->grec_src, + nsrcs,sizeof (__be32));break ;case IGMPV3_CHANGE_TO_EXCLUDE : - changed =br_multicast_toex (pg, grec->grec_src, nsrcs, -sizeof (__be32)); + changed =br_multicast_toex (pg, h_addr, grec->grec_src, + nsrcs,sizeof (__be32));break ;case IGMPV3_BLOCK_OLD_SOURCES : - changed =br_multicast_block (pg, grec->grec_src, nsrcs, -sizeof (__be32)); + changed =br_multicast_block (pg, h_addr, grec->grec_src, + nsrcs,sizeof (__be32));break ; }if (changed)
@@ -2367,6 +2368,7 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,unsigned int nsrcs_offset;const unsigned char *src;struct icmp6hdr *icmp6h; +struct in6_addr *h_addr;struct mld2_grec *grec;unsigned int grec_len;bool changed = false;
@@ -2445,30 +2447,36 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br, pg =br_multicast_find_port (mdst, port, src);if (!pg || (pg->flags &MDB_PG_FLAGS_PERMANENT )) goto unlock_continue; + h_addr = &ipv6_hdr (skb)->saddr;switch (grec->grec_type) {case MLD2_ALLOW_NEW_SOURCES : - changed =br_multicast_isinc_allow (pg, grec->grec_src, - nsrcs, + changed =br_multicast_isinc_allow (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ;case MLD2_MODE_IS_INCLUDE : - changed =br_multicast_isinc_allow (pg, grec->grec_src, nsrcs, + changed =br_multicast_isinc_allow (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ;case MLD2_MODE_IS_EXCLUDE : - changed =br_multicast_isexc (pg, grec->grec_src, nsrcs, + changed =br_multicast_isexc (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ;case MLD2_CHANGE_TO_INCLUDE : - changed =br_multicast_toin (pg, grec->grec_src, nsrcs, + changed =br_multicast_toin (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ;case MLD2_CHANGE_TO_EXCLUDE : - changed =br_multicast_toex (pg, grec->grec_src, nsrcs, + changed =br_multicast_toex (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ;case MLD2_BLOCK_OLD_SOURCES : - changed =br_multicast_block (pg, grec->grec_src, nsrcs, + changed =br_multicast_block (pg, h_addr, + grec->grec_src, nsrcs,sizeof (struct in6_addr ));break ; }
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 3/14 net: bridge: multicast: __grp_src_block_incl can modify pg
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Prepare __grp_src_block_incl() for being able to cause a notification due to changes. Currently it cannot happen, but EHT would change that since we'll be deleting sources immediately. Make sure that if the pg is deleted we don't return true as that would cause the caller to access freed pg. This patch shouldn't cause any functional change.
--- net/bridge/br_multicast.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
net/bridge/br_multicast.c +11 -3
@@ -2142,11 +2142,12 @@ static bool br_multicast_toex(struct net_bridge_port_group *pg, void *h_addr,/* State Msg type New state Actions * INCLUDE (A) BLOCK (B) INCLUDE (A) Send Q(G,A*B) */ -static void __grp_src_block_incl (struct net_bridge_port_group *pg,void *h_addr, +static bool __grp_src_block_incl (struct net_bridge_port_group *pg,void *h_addr,void *srcs,u32 nsrcs,size_t addr_size) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ; +bool changed = false;struct br_ip src_ip;hlist_for_each_entry (ent, &pg->src_list, node)
@@ -2167,8 +2168,15 @@ static void __grp_src_block_incl(struct net_bridge_port_group *pg, void *h_addr,if (to_send)__grp_src_query_marked_and_rexmit (pg); -if (pg->filter_mode ==MCAST_INCLUDE &&hlist_empty (&pg->src_list)) +if (pg->filter_mode ==MCAST_INCLUDE &&hlist_empty (&pg->src_list)) {br_multicast_find_del_pg (pg->key.port->br, pg); +/* a notification has already been sent and we shouldn't access +* pg after the delete thus we have to return false +*/ + changed = false; + } + +return changed; }/* State Msg type New state Actions
@@ -2218,7 +2226,7 @@ static bool br_multicast_block(struct net_bridge_port_group *pg, void *h_addr,switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_block_incl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_block_incl (pg, h_addr, srcs, nsrcs, addr_size);break ;case MCAST_EXCLUDE : changed =__grp_src_block_excl (pg, h_addr, srcs, nsrcs, addr_size);
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 4/14 net: bridge: multicast: calculate idx position without changing ptr
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
We need to preserve the srcs pointer since we'll be passing it for EHT handling later.
--- net/bridge/br_multicast.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
net/bridge/br_multicast.c +9 -18
@@ -1812,7 +1812,7 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg, void *h_amemset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (!ent) { ent =br_multicast_new_group_src (pg, &src_ip);
@@ -1822,7 +1822,6 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg, void *h_aif (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += addr_size; }return changed;
@@ -1846,7 +1845,7 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -1854,7 +1853,6 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg, void *h_addr, ent =br_multicast_new_group_src (pg, &src_ip);if (ent)br_multicast_fwd_src_handle (ent); - srcs += addr_size; }__grp_src_delete_marked (pg);
@@ -1882,7 +1880,7 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -1894,7 +1892,6 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, void *h_addr, changed = true; } } - srcs += addr_size; }if (__grp_src_delete_marked (pg))
@@ -1946,7 +1943,7 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_SEND ;
@@ -1958,7 +1955,6 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg, void *h_addr, }if (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += addr_size; }if (to_send)
@@ -1989,7 +1985,7 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) {if (timer_pending (&ent->timer)) {
@@ -2003,7 +1999,6 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, void *h_addr, }if (ent)__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); - srcs += addr_size; }if (to_send)
@@ -2050,7 +2045,7 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags = (ent->flags & ~BR_SGRP_F_DELETE) |
@@ -2061,7 +2056,6 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg, void *h_addr, }if (ent)br_multicast_fwd_src_handle (ent); - srcs += addr_size; }__grp_src_delete_marked (pg);
@@ -2090,7 +2084,7 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags &= ~BR_SGRP_F_DELETE ;
@@ -2105,7 +2099,6 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, void *h_addr, ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += addr_size; }if (__grp_src_delete_marked (pg))
@@ -2156,13 +2149,12 @@ static bool __grp_src_block_incl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (ent) { ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += addr_size; }if (to_send)
@@ -2197,7 +2189,7 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, void *h_addr,memset (&src_ip,0 ,sizeof (src_ip)); src_ip.proto = pg->key.addr.proto;for (src_idx =0 ; src_idx < nsrcs; src_idx++) { -memcpy (&src_ip.src, srcs, addr_size); +memcpy (&src_ip.src, srcs + (src_idx * addr_size), addr_size); ent =br_multicast_find_group_src (pg, &src_ip);if (!ent) { ent =br_multicast_new_group_src (pg, &src_ip);
@@ -2210,7 +2202,6 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, void *h_addr, ent->flags |=BR_SGRP_F_SEND ; to_send++; } - srcs += addr_size; }if (to_send)
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 5/14 net: bridge: multicast: add EHT structures and definitions
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add EHT structures for tracking hosts and sources per group. We keep one set for each host which has all of the host's S,G entries, and one set for each multicast source which has all hosts that have joined that S,G. For each host, source entry we record the filter_mode and we keep an expiry timer. There is also one global expiry timer per source set, it is updated with each set entry update, it will be later used to lower the set's timer instead of lowering each entry's timer separately.
--- net/bridge/br_multicast.c | 1 + net/bridge/br_private.h | 2 ++ net/bridge/br_private_mcast_eht.h | 50 +++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 net/bridge/br_private_mcast_eht.h
net/bridge/br_multicast.c +1 -0
@@ -33,6 +33,7 @@#endif #include "br_private.h" +#include "br_private_mcast_eht.h" static const struct rhashtable_params br_mdb_rht_params = { .head_offset = offsetof(struct net_bridge_mdb_entry , rhnode),
net/bridge/br_private.h +2 -0
@@ -252,6 +252,8 @@ struct net_bridge_port_group {struct timer_list timer;struct timer_list rexmit_timer;struct hlist_node mglist; +struct rb_root eht_set_tree; +struct rb_root eht_host_tree;struct rhash_head rhnode;struct net_bridge_mcast_gc mcast_gc;
net/bridge/br_private_mcast_eht.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 6/14 net: bridge: multicast: add EHT host handling functions
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add functions to create, destroy and lookup an EHT host. These are per-host entries contained in the eht_host_tree in net_bridge_port_group which are used to store a list of all sources (S,G) entries joined for that group by each host, the host's current filter mode and total number of joined entries.
No functional changes yet, these would be used in later patches.
--- net/bridge/Makefile | 2 +- net/bridge/br_multicast.c | 1 + net/bridge/br_multicast_eht.c | 115 ++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 net/bridge/br_multicast_eht.c
net/bridge/Makefile +1 -1
@@ -18,7 +18,7 @@ br_netfilter-y := br_netfilter_hooks.o br_netfilter-$(subst m,y,$(CONFIG_IPV6)) += br_netfilter_ipv6.o obj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o -bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o +bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o br_multicast_eht.o bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o
net/bridge/br_multicast.c +1 -0
@@ -1173,6 +1173,7 @@ struct net_bridge_port_group *br_multicast_new_port_group( p->flags = flags; p->filter_mode = filter_mode; p->rt_protocol = rt_protocol; + p->eht_host_tree =RB_ROOT ; p->mcast_gc.destroy = br_multicast_destroy_port_group;INIT_HLIST_HEAD (&p->src_list);
net/bridge/br_multicast_eht.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 7/14 net: bridge: multicast: add EHT source set handling functions
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add EHT source set and set-entry create, delete and lookup functions. These allow to manipulate source sets which contain their own host sets with entries which joined that S,G. We're limiting the maximum number of tracked S,G entries per host to PG_SRC_ENT_LIMIT (currently 32) which is the current maximum of S,G entries for a group. There's a per-set timer which will be used to destroy the whole set later.
--- net/bridge/br_multicast.c | 2 + net/bridge/br_multicast_eht.c | 321 ++++++++++++++++++++++++++++++ net/bridge/br_private_mcast_eht.h | 2 + 3 files changed, 325 insertions(+)
net/bridge/br_multicast.c +2 -0
@@ -594,6 +594,7 @@ void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,rcu_assign_pointer (*pp, pg->next);hlist_del_init (&pg->mglist); +br_multicast_eht_clean_sets (pg);hlist_for_each_entry_safe (ent, tmp, &pg->src_list, node)br_multicast_del_group_src (ent);br_mdb_notify (br->dev, mp, pg,RTM_DELMDB );
@@ -1174,6 +1175,7 @@ struct net_bridge_port_group *br_multicast_new_port_group( p->filter_mode = filter_mode; p->rt_protocol = rt_protocol; p->eht_host_tree =RB_ROOT ; + p->eht_set_tree =RB_ROOT ; p->mcast_gc.destroy = br_multicast_destroy_port_group;INIT_HLIST_HEAD (&p->src_list);
net/bridge/br_multicast_eht.c +321 -0
342 lines not on this page · raw message
net/bridge/br_private_mcast_eht.h +2 -0
@@ -47,4 +47,6 @@ struct net_bridge_group_eht_set { struct net_bridge_mcast_gc mcast_gc; }; +void br_multicast_eht_clean_sets (struct net_bridge_port_group *pg); +#endif /* _BR_PRIVATE_MCAST_EHT_H_ */
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 8/14 net: bridge: multicast: add EHT host delete function
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Now that we can delete set entries, we can use that to remove EHT hosts. Since the group's host set entries exist only when there are related source set entries we just have to flush all source set entries joined by the host set entry and it will be automatically removed.
--- net/bridge/br_multicast_eht.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
net/bridge/br_multicast_eht.c +17 -0
@@ -434,3 +434,20 @@ static bool br_multicast_del_eht_set_entry(struct net_bridge_port_group *pg, out:return set_deleted; } + +static void br_multicast_del_eht_host (struct net_bridge_port_group *pg, +union net_bridge_eht_addr *h_addr) +{ +struct net_bridge_group_eht_set_entry *set_h; +struct net_bridge_group_eht_host *eht_host; +struct hlist_node *tmp; + + eht_host =br_multicast_eht_host_lookup (pg, h_addr); +if (!eht_host) +return ; + +hlist_for_each_entry_safe (set_h, tmp, &eht_host->set_entries, host_list) +br_multicast_del_eht_set_entry (set_h->eht_set->pg, + &set_h->eht_set->src_addr, + &set_h->h_addr); +}
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 9/14 net: bridge: multicast: add EHT allow/block handling
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add support for IGMPv3/MLDv2 allow/block EHT handling. Similar to how the reports are processed we have 2 cases when the group is in include or exclude mode, these are processed as follows:
- group include
- allow: create missing entries
- block: remove existing matching entries and remove the corresponding S,G entries if there are no more set host entries, then possibly delete the whole group if there are no more S,G entries
- group exclude
- allow
- host include: create missing entries
- host exclude: remove existing matching entries and remove the corresponding S,G entries if there are no more set host entries
- block
- host include: remove existing matching entries and remove the corresponding S,G entries if there are no more set host entries, then possibly delete the whole group if there are no more S,G entries
- host exclude: create missing entries
--- net/bridge/br_multicast.c | 43 +++-- net/bridge/br_multicast_eht.c | 252 ++++++++++++++++++++++++++++++ net/bridge/br_private.h | 3 + net/bridge/br_private_mcast_eht.h | 6 + 4 files changed, 290 insertions(+), 14 deletions(-)
net/bridge/br_multicast.c +29 -14
@@ -560,7 +560,7 @@ static void br_multicast_destroy_group_src(struct net_bridge_mcast_gc *gc)kfree_rcu (src, rcu); } -static void br_multicast_del_group_src (struct net_bridge_group_src *src) +void br_multicast_del_group_src (struct net_bridge_group_src *src) {struct net_bridge *br = src->pg->key.port->br;
@@ -1092,7 +1092,7 @@ static void br_multicast_group_src_expired(struct timer_list *t)spin_unlock (&br->multicast_lock); } -static struct net_bridge_group_src * +struct net_bridge_group_src *br_multicast_find_group_src (struct net_bridge_port_group *pg,struct br_ip *ip) {struct net_bridge_group_src *ent;
@@ -1804,7 +1804,8 @@ static void __grp_send_query_and_rexmit(struct net_bridge_port_group *pg)* EXCLUDE (X,Y) ALLOW (A) EXCLUDE (X+A,Y-A) (A)=GMI */ static bool br_multicast_isinc_allow (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;struct net_bridge_group_src *ent;
@@ -1828,6 +1829,9 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg, void *h_a__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +return changed; }
@@ -2140,7 +2144,7 @@ static bool br_multicast_toex(struct net_bridge_port_group *pg, void *h_addr,* INCLUDE (A) BLOCK (B) INCLUDE (A) Send Q(G,A*B) */ static bool __grp_src_block_incl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size,int grec_type) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2161,6 +2165,9 @@ static bool __grp_src_block_incl(struct net_bridge_port_group *pg, void *h_addr, } } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (to_send)__grp_src_query_marked_and_rexmit (pg);
@@ -2180,7 +2187,7 @@ static bool __grp_src_block_incl(struct net_bridge_port_group *pg, void *h_addr,* Send Q(G,A-Y) */ static bool __grp_src_block_excl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size,int grec_type) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2208,6 +2215,9 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, void *h_addr, } } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (to_send)__grp_src_query_marked_and_rexmit (pg);
@@ -2215,16 +2225,18 @@ static bool __grp_src_block_excl(struct net_bridge_port_group *pg, void *h_addr, }static bool br_multicast_block (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size,int grec_type) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : - changed =__grp_src_block_incl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_block_incl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ;case MCAST_EXCLUDE : - changed =__grp_src_block_excl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_block_excl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ; }
@@ -2327,11 +2339,11 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,switch (type) {case IGMPV3_ALLOW_NEW_SOURCES : changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ;case IGMPV3_MODE_IS_INCLUDE : changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ;case IGMPV3_MODE_IS_EXCLUDE : changed = br_multicast_isexc(pg, h_addr, grec->grec_src,
@@ -2347,7 +2359,7 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,break ;case IGMPV3_BLOCK_OLD_SOURCES : changed =br_multicast_block (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ; }if (changed)
@@ -2455,12 +2467,14 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,case MLD2_ALLOW_NEW_SOURCES : changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ;case MLD2_MODE_IS_INCLUDE : changed =br_multicast_isinc_allow (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ;case MLD2_MODE_IS_EXCLUDE : changed = br_multicast_isexc(pg, h_addr,
@@ -2480,7 +2494,8 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,case MLD2_BLOCK_OLD_SOURCES : changed =br_multicast_block (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ; }if (changed)
net/bridge/br_multicast_eht.c +252 -0
261 lines not on this page · raw message
net/bridge/br_private.h +3 -0
@@ -848,6 +848,9 @@ void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg, u8 filter_mode);void br_multicast_sg_add_exclude_ports (struct net_bridge_mdb_entry *star_mp,struct net_bridge_port_group *sg); +struct net_bridge_group_src * +br_multicast_find_group_src (struct net_bridge_port_group *pg,struct br_ip *ip); +void br_multicast_del_group_src (struct net_bridge_group_src *src);static inline bool br_group_is_l2 (const struct br_ip *group) {
net/bridge/br_private_mcast_eht.h +6 -0
@@ -48,5 +48,11 @@ struct net_bridge_group_eht_set { };void br_multicast_eht_clean_sets (struct net_bridge_port_group *pg); +bool br_multicast_eht_handle (struct net_bridge_port_group *pg, +void *h_addr, +void *srcs, +u32 nsrcs, +size_t addr_size, +int grec_type);#endif /* _BR_PRIVATE_MCAST_EHT_H_ */
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 10/14 net: bridge: multicast: add EHT include and exclude handling
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Add support for IGMPv3/MLDv2 include and exclude EHT handling. Similar to how the reports are processed we have 2 cases when the group is in include or exclude mode, these are processed as follows:
- group include
- is_include: create missing entries
- to_include: flush existing entries and create a new set from the report, obviously if the src set is empty then we delete the group
- group exclude
- is_exclude: create missing entries
- to_exclude: flush existing entries and create a new set from the report, any empty source set entries are removed
If the group is in a different mode then we just flush all entries reported by the host and we create a new set with the new mode entries created from the report. If the report is include type, the source list is empty and the group has empty sources' set then we remove it. Any source set entries which are empty are removed as well. If the group is in exclude mode it can exist without any S,G entries (allowing for all traffic to pass).
--- net/bridge/br_multicast.c | 84 ++++++++++++++++++------- net/bridge/br_multicast_eht.c | 100 +++++++++++++++++++++++++++++- net/bridge/br_private_mcast_eht.h | 7 +++ 3 files changed, 168 insertions(+), 23 deletions(-)
net/bridge/br_multicast.c +63 -21
@@ -1841,7 +1841,8 @@ static bool br_multicast_isinc_allow(struct net_bridge_port_group *pg, void *h_a* Group Timer=GMI */ static void __grp_src_isexc_incl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge_group_src *ent;struct br_ip src_ip;
@@ -1863,6 +1864,8 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg, void *h_addr,br_multicast_fwd_src_handle (ent); } +br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type); +__grp_src_delete_marked (pg); }
@@ -1873,7 +1876,8 @@ static void __grp_src_isexc_incl(struct net_bridge_port_group *pg, void *h_addr,* Group Timer=GMI */ static bool __grp_src_isexc_excl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;struct net_bridge_group_src *ent;
@@ -1902,6 +1906,9 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, void *h_addr, } } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (__grp_src_delete_marked (pg)) changed = true;
@@ -1909,19 +1916,22 @@ static bool __grp_src_isexc_excl(struct net_bridge_port_group *pg, void *h_addr, }static bool br_multicast_isexc (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_isexc_incl (pg, h_addr, srcs, nsrcs, addr_size); +__grp_src_isexc_incl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_isexc_excl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_isexc_excl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ; }
@@ -1936,7 +1946,8 @@ static bool br_multicast_isexc(struct net_bridge_port_group *pg, void *h_addr,* Send Q(G,A-B) */ static bool __grp_src_toin_incl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;u32 src_idx, to_send = pg->src_ents;
@@ -1965,6 +1976,9 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg, void *h_addr,__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (to_send)__grp_src_query_marked_and_rexmit (pg);
@@ -1977,7 +1991,8 @@ static bool __grp_src_toin_incl(struct net_bridge_port_group *pg, void *h_addr,* Send Q(G) */ static bool __grp_src_toin_excl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;u32 src_idx, to_send = pg->src_ents;
@@ -2009,6 +2024,9 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, void *h_addr,__grp_src_mod_timer (ent, now +br_multicast_gmi (br)); } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (to_send)__grp_src_query_marked_and_rexmit (pg);
@@ -2018,19 +2036,30 @@ static bool __grp_src_toin_excl(struct net_bridge_port_group *pg, void *h_addr, }static bool br_multicast_toin (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : - changed =__grp_src_toin_incl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_toin_incl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ;case MCAST_EXCLUDE : - changed =__grp_src_toin_excl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_toin_excl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ; } +if (br_multicast_eht_should_del_pg (pg)) { +br_multicast_find_del_pg (pg->key.port->br, pg); +/* a notification has already been sent and we shouldn't +* access pg after the delete so we have to return false +*/ + changed = false; + } +return changed; }
@@ -2041,7 +2070,8 @@ static bool br_multicast_toin(struct net_bridge_port_group *pg, void *h_addr,* Group Timer=GMI */ static void __grp_src_toex_incl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2066,6 +2096,8 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg, void *h_addr,br_multicast_fwd_src_handle (ent); } +br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type); +__grp_src_delete_marked (pg);if (to_send)__grp_src_query_marked_and_rexmit (pg);
@@ -2079,7 +2111,8 @@ static void __grp_src_toex_incl(struct net_bridge_port_group *pg, void *h_addr,* Group Timer=GMI */ static bool __grp_src_toex_excl (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge_group_src *ent;u32 src_idx, to_send =0 ;
@@ -2109,6 +2142,9 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, void *h_addr, } } +if (br_multicast_eht_handle (pg, h_addr, srcs, nsrcs, addr_size, grec_type)) + changed = true; +if (__grp_src_delete_marked (pg)) changed = true;if (to_send)
@@ -2118,19 +2154,22 @@ static bool __grp_src_toex_excl(struct net_bridge_port_group *pg, void *h_addr, }static bool br_multicast_toex (struct net_bridge_port_group *pg,void *h_addr, -void *srcs,u32 nsrcs,size_t addr_size) +void *srcs,u32 nsrcs,size_t addr_size, +int grec_type) {struct net_bridge *br = pg->key.port->br;bool changed = false;switch (pg->filter_mode) {case MCAST_INCLUDE : -__grp_src_toex_incl (pg, h_addr, srcs, nsrcs, addr_size); +__grp_src_toex_incl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);br_multicast_star_g_handle_mode (pg,MCAST_EXCLUDE ); changed = true;break ;case MCAST_EXCLUDE : - changed =__grp_src_toex_excl (pg, h_addr, srcs, nsrcs, addr_size); + changed =__grp_src_toex_excl (pg, h_addr, srcs, nsrcs, addr_size, + grec_type);break ; }
@@ -2347,15 +2386,15 @@ static int br_ip4_multicast_igmp3_report(struct net_bridge *br,break ;case IGMPV3_MODE_IS_EXCLUDE : changed =br_multicast_isexc (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ;case IGMPV3_CHANGE_TO_INCLUDE : changed =br_multicast_toin (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ;case IGMPV3_CHANGE_TO_EXCLUDE : changed =br_multicast_toex (pg, h_addr, grec->grec_src, - nsrcs,sizeof (__be32)); + nsrcs,sizeof (__be32), type);break ;case IGMPV3_BLOCK_OLD_SOURCES : changed = br_multicast_block(pg, h_addr, grec->grec_src,
@@ -2479,17 +2518,20 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,case MLD2_MODE_IS_EXCLUDE : changed =br_multicast_isexc (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ;case MLD2_CHANGE_TO_INCLUDE : changed =br_multicast_toin (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ;case MLD2_CHANGE_TO_EXCLUDE : changed =br_multicast_toex (pg, h_addr, grec->grec_src, nsrcs, -sizeof (struct in6_addr )); +sizeof (struct in6_addr ), + grec->grec_type);break ;case MLD2_BLOCK_OLD_SOURCES : changed = br_multicast_block(pg, h_addr,
net/bridge/br_multicast_eht.c +98 -2
130 lines not on this page · raw message
net/bridge/br_private_mcast_eht.h +7 -0
@@ -55,4 +55,11 @@ bool br_multicast_eht_handle(struct net_bridge_port_group *pg,size_t addr_size, int grec_type); +static inline bool +br_multicast_eht_should_del_pg (const struct net_bridge_port_group *pg) +{ +return !!((pg->key.port->flags &BR_MULTICAST_FAST_LEAVE ) && +RB_EMPTY_ROOT (&pg->eht_host_tree)); +} +#endif /* _BR_PRIVATE_MCAST_EHT_H_ */
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 11/14 net: bridge: multicast: optimize TO_INCLUDE EHT timeouts
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
This is an optimization specifically for TO_INCLUDE which sends queries for the older entries and thus lowers the S,G timers to LMQT. If we have the following situation for a group in either include or exclude mode:
- host A was interested in srcs X and Y, but is timing out
- host B sends TO_INCLUDE src Z, the bridge lowers X and Y's timeouts to LMQT
- host B sends BLOCK src Z after LMQT time has passed
=> since host B is the last host we can delete the group, but if we
still have host A's EHT entries for X and Y (i.e. if they weren't lowered to LMQT previously) then we'll have to wait another LMQT time before deleting the group, with this optimization we can directly remove it regardless of the group mode as there are no more interested hosts
--- net/bridge/br_multicast_eht.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
net/bridge/br_multicast_eht.c +21 -0
@@ -656,6 +656,8 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg, }/* we can be missing sets only if we've deleted some entries */ if (flush_entries) { +struct net_bridge *br = pg->key.port->br; +struct net_bridge_group_eht_set *eht_set;struct net_bridge_group_src *src_ent;struct hlist_node *tmp;
@@ -667,6 +669,25 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg, changed = true;continue ; } +/* this is an optimization for TO_INCLUDE where we lower +* the set's timeout to LMQT to catch timeout hosts: +* - host A (timing out): set entries X, Y +* - host B: set entry Z (new from current TO_INCLUDE) +* sends BLOCK Z after LMQT but host A's EHT +* entries still exist (unless lowered to LMQT +* so they can timeout with the S,Gs) +* => we wait another LMQT, when we can just delete the +* group immediately +*/ +if (!(src_ent->flags &BR_SGRP_F_SEND ) || + filter_mode !=MCAST_INCLUDE || + !to_report) +continue ; + eht_set =br_multicast_eht_set_lookup (pg, + &eht_src_addr); +if (!eht_set) +continue ; +mod_timer (&eht_set->timer, jiffies +br_multicast_lmqt (br)); } }
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 12/14 net: bridge: multicast: add EHT host filter_mode handling
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
We should be able to handle host filter mode changing. For exclude mode we must create a zero-src entry so the group will be kept even without any S,G entries (non-zero source sets). That entry doesn't count to the entry limit and can always be created, its timer is refreshed on new exclude reports and if we change the host filter mode to include then it gets removed and we rely only on the non-zero source sets.
--- net/bridge/br_multicast_eht.c | 42 +++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-)
net/bridge/br_multicast_eht.c +38 -4
@@ -381,6 +381,30 @@ static void br_multicast_ip_src_to_eht_addr(const struct br_ip *src, } } +static void br_eht_convert_host_filter_mode (struct net_bridge_port_group *pg, +union net_bridge_eht_addr *h_addr, +int filter_mode) +{ +struct net_bridge_group_eht_host *eht_host; +union net_bridge_eht_addr zero_addr; + + eht_host =br_multicast_eht_host_lookup (pg, h_addr); +if (eht_host) + eht_host->filter_mode = filter_mode; + +memset (&zero_addr,0 ,sizeof (zero_addr)); +switch (filter_mode) { +case MCAST_INCLUDE : +br_multicast_del_eht_set_entry (pg, &zero_addr, h_addr); +break ; +case MCAST_EXCLUDE : +br_multicast_create_eht_set_entry (pg, &zero_addr, h_addr, +MCAST_EXCLUDE , + true); +break ; + } +} + static void br_multicast_create_eht_set_entry(struct net_bridge_port_group *pg, union net_bridge_eht_addr *src_addr, union net_bridge_eht_addr *h_addr,
@@ -701,8 +725,13 @@ static bool br_multicast_eht_inc(struct net_bridge_port_group *pg,size_t addr_size, bool to_report) { - return __eht_inc_exc(pg, h_addr, srcs, nsrcs, addr_size, MCAST_INCLUDE, -to_report ); + bool changed; + + changed =__eht_inc_exc (pg, h_addr, srcs, nsrcs, addr_size, +MCAST_INCLUDE , to_report); +br_eht_convert_host_filter_mode (pg, h_addr,MCAST_INCLUDE ); + +return changed; } static bool br_multicast_eht_exc(struct net_bridge_port_group *pg,
@@ -712,8 +741,13 @@ static bool br_multicast_eht_exc(struct net_bridge_port_group *pg,size_t addr_size, bool to_report) { - return __eht_inc_exc(pg, h_addr, srcs, nsrcs, addr_size, MCAST_EXCLUDE, -to_report ); + bool changed; + + changed =__eht_inc_exc (pg, h_addr, srcs, nsrcs, addr_size, +MCAST_EXCLUDE , to_report); +br_eht_convert_host_filter_mode (pg, h_addr,MCAST_EXCLUDE ); + +return changed; } static bool __eht_ip4_handle(struct net_bridge_port_group *pg,
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 13/14 net: bridge: multicast: handle block pg delete for all cases
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
A block report can result in empty source and host sets for both include and exclude groups so if there are no hosts left we can safely remove the group. Pull the block group handling so it can cover both cases and add a check if EHT requires the delete.
--- net/bridge/br_multicast.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/bridge/br_multicast.c +9 -8
@@ -2210,14 +2210,6 @@ static bool __grp_src_block_incl(struct net_bridge_port_group *pg, void *h_addr,if (to_send)__grp_src_query_marked_and_rexmit (pg); -if (pg->filter_mode ==MCAST_INCLUDE &&hlist_empty (&pg->src_list)) { -br_multicast_find_del_pg (pg->key.port->br, pg); -/* a notification has already been sent and we shouldn't access -* pg after the delete thus we have to return false -*/ - changed = false; - } -return changed; }
@@ -2279,6 +2271,15 @@ static bool br_multicast_block(struct net_bridge_port_group *pg, void *h_addr,break ; } +if ((pg->filter_mode ==MCAST_INCLUDE &&hlist_empty (&pg->src_list)) || +br_multicast_eht_should_del_pg (pg)) { +br_multicast_find_del_pg (pg->key.port->br, pg); +/* a notification has already been sent and we shouldn't +* access pg after the delete so we have to return false +*/ + changed = false; + } +return changed; }
Signature · 1 line
2.29.2
Nikolay Aleksandrov
maintainerPATCH 14/14 net: bridge: multicast: mark IGMPv3/MLDv2 fast-leave deletes
In reply to Nikolay AleksandrovFrom: Nikolay Aleksandrov <[email protected]>
Mark groups which were deleted due to fast leave/EHT.
--- net/bridge/br_multicast.c | 21 ++++++++++++++------- net/bridge/br_multicast_eht.c | 8 ++++---- net/bridge/br_private.h | 3 ++- 3 files changed, 20 insertions(+), 12 deletions(-)
net/bridge/br_multicast.c +14 -7
@@ -442,7 +442,8 @@ static void br_multicast_fwd_src_add(struct net_bridge_group_src *src)br_multicast_sg_add_exclude_ports (star_mp, sg); } -static void br_multicast_fwd_src_remove (struct net_bridge_group_src *src) +static void br_multicast_fwd_src_remove (struct net_bridge_group_src *src, +bool fastleave) {struct net_bridge_port_group *p, *pg = src->pg;struct net_bridge_port_group __rcu **pp;
@@ -467,6 +468,8 @@ static void br_multicast_fwd_src_remove(struct net_bridge_group_src *src) (p->flags & MDB_PG_FLAGS_PERMANENT))break ; +if (fastleave) + p->flags |=MDB_PG_FLAGS_FAST_LEAVE ;br_multicast_del_pg (mp, p, pp);break ; }
@@ -560,11 +563,12 @@ static void br_multicast_destroy_group_src(struct net_bridge_mcast_gc *gc)kfree_rcu (src, rcu); } -void br_multicast_del_group_src (struct net_bridge_group_src *src) +void br_multicast_del_group_src (struct net_bridge_group_src *src, +bool fastleave) {struct net_bridge *br = src->pg->key.port->br; -br_multicast_fwd_src_remove (src); +br_multicast_fwd_src_remove (src, fastleave);hlist_del_init_rcu (&src->node); src->pg->src_ents--;hlist_add_head (&src->mcast_gc.gc_node, &br->mcast_gc_list);
@@ -596,7 +600,7 @@ void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,hlist_del_init (&pg->mglist);br_multicast_eht_clean_sets (pg);hlist_for_each_entry_safe (ent, tmp, &pg->src_list, node) -br_multicast_del_group_src (ent); +br_multicast_del_group_src (ent, false);br_mdb_notify (br->dev, mp, pg,RTM_DELMDB );if (!br_multicast_is_star_g (&mp->addr)) { rhashtable_remove_fast(&br->sg_port_tbl, &pg->rhnode,
@@ -653,7 +657,7 @@ static void br_multicast_port_group_expired(struct timer_list *t) pg->filter_mode =MCAST_INCLUDE ;hlist_for_each_entry_safe (src_ent, tmp, &pg->src_list, node) {if (!timer_pending (&src_ent->timer)) { -br_multicast_del_group_src (src_ent); +br_multicast_del_group_src (src_ent, false); changed = true; } }
@@ -1080,7 +1084,7 @@ static void br_multicast_group_src_expired(struct timer_list *t) pg = src->pg;if (pg->filter_mode ==MCAST_INCLUDE ) { -br_multicast_del_group_src (src); +br_multicast_del_group_src (src, false);if (!hlist_empty (&pg->src_list)) goto out;br_multicast_find_del_pg (br, pg);
@@ -1704,7 +1708,7 @@ static int __grp_src_delete_marked(struct net_bridge_port_group *pg)hlist_for_each_entry_safe (ent, tmp, &pg->src_list, node)if (ent->flags &BR_SGRP_F_DELETE ) { -br_multicast_del_group_src (ent); +br_multicast_del_group_src (ent, false); deleted++; }
@@ -2053,6 +2057,7 @@ static bool br_multicast_toin(struct net_bridge_port_group *pg, void *h_addr, }if (br_multicast_eht_should_del_pg (pg)) { + pg->flags |=MDB_PG_FLAGS_FAST_LEAVE ;br_multicast_find_del_pg (pg->key.port->br, pg);/* a notification has already been sent and we shouldn't * access pg after the delete so we have to return false
@@ -2273,6 +2278,8 @@ static bool br_multicast_block(struct net_bridge_port_group *pg, void *h_addr,if ((pg->filter_mode ==MCAST_INCLUDE &&hlist_empty (&pg->src_list)) ||br_multicast_eht_should_del_pg (pg)) { +if (br_multicast_eht_should_del_pg (pg)) + pg->flags |=MDB_PG_FLAGS_FAST_LEAVE ;br_multicast_find_del_pg (pg->key.port->br, pg);/* a notification has already been sent and we shouldn't * access pg after the delete so we have to return false
net/bridge/br_multicast_eht.c +4 -4
@@ -537,7 +537,7 @@ static bool __eht_allow_excl(struct net_bridge_port_group *pg, src_ent =br_multicast_find_group_src (pg, &src_ip);if (!src_ent)continue ; -br_multicast_del_group_src (src_ent); +br_multicast_del_group_src (src_ent, true); changed = true; } }
@@ -588,7 +588,7 @@ static bool __eht_block_incl(struct net_bridge_port_group *pg, src_ent =br_multicast_find_group_src (pg, &src_ip);if (!src_ent)continue ; -br_multicast_del_group_src (src_ent); +br_multicast_del_group_src (src_ent, true); changed = true; }
@@ -625,7 +625,7 @@ static bool __eht_block_excl(struct net_bridge_port_group *pg, src_ent =br_multicast_find_group_src (pg, &src_ip);if (!src_ent)continue ; -br_multicast_del_group_src (src_ent); +br_multicast_del_group_src (src_ent, true); changed = true; } }
@@ -689,7 +689,7 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg,br_multicast_ip_src_to_eht_addr (&src_ent->addr, &eht_src_addr);if (!br_multicast_eht_set_lookup (pg, &eht_src_addr)) { -br_multicast_del_group_src (src_ent); +br_multicast_del_group_src (src_ent, true); changed = true;continue ; }
net/bridge/br_private.h +2 -1
@@ -850,7 +850,8 @@ void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp, struct net_bridge_port_group *sg);struct net_bridge_group_src *br_multicast_find_group_src (struct net_bridge_port_group *pg,struct br_ip *ip); -void br_multicast_del_group_src (struct net_bridge_group_src *src); +void br_multicast_del_group_src (struct net_bridge_group_src *src, +bool fastleave);static inline bool br_group_is_l2 (const struct br_ip *group) {
Signature · 1 line
2.29.2
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 25 lines · On Wed, 20 Jan 2021 16:51:49 +0200 you wrote:
From: Nikolay Aleksandrov <[email protected]>
Hi,
This set adds explicit host tracking support for IGMPv3/MLDv2. The already present per-port fast leave flag is used to enable it since that is the primary goal of EHT, to track a group and its S,Gs usage per-host and when left without any interested hosts delete them before the standard timers. The EHT code is pretty self-contained and not enabled by default. There is no new uAPI added, all of the functionality is currently hidden behind the fast leave flag. In the future that will change (more below). The host tracking uses two new sets per port group: one having an entry for each host which contains that host's view of the group (source list and filter mode), and one set which contains an entry for each source having an internal set which contains an entry for each host that has reported an interest for that source. RB trees are used for all sets so they're compact when not used and fast when we need to do lookups.
To illustrate it:
[ bridge port group ]
` [ host set (rb) ]
` [ host entry with a list of sources and filter mode ]
` [ source set (rb) ]
` [ source entry ]
` [ source host set (rb) ]
` [ source host entry with a timer ]
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,01/14] net: bridge: multicast: rename src_size to addr_size
https://git.kernel.org/netdev/net-next/c/9e10b9e65699 - [net-next,02/14] net: bridge: multicast: pass host src address to IGMPv3/MLDv2 functions https://git.kernel.org/netdev/net-next/c/54bea7219641 - [net-next,03/14] net: bridge: multicast: __grp_src_block_incl can modify pg https://git.kernel.org/netdev/net-next/c/0ad57c99e857 - [net-next,04/14] net: bridge: multicast: calculate idx position without changing ptr https://git.kernel.org/netdev/net-next/c/e7cfcf2c18c5 - [net-next,05/14] net: bridge: multicast: add EHT structures and definitions https://git.kernel.org/netdev/net-next/c/8f07b831197e - [net-next,06/14] net: bridge: multicast: add EHT host handling functions https://git.kernel.org/netdev/net-next/c/5b1632887930 - [net-next,07/14] net: bridge: multicast: add EHT source set handling functions https://git.kernel.org/netdev/net-next/c/baa74d39ca39 - [net-next,08/14] net: bridge: multicast: add EHT host delete function https://git.kernel.org/netdev/net-next/c/dba6b0a5ca21 - [net-next,09/14] net: bridge: multicast: add EHT allow/block handling https://git.kernel.org/netdev/net-next/c/474ddb37fa3a - [net-next,10/14] net: bridge: multicast: add EHT include and exclude handling https://git.kernel.org/netdev/net-next/c/ddc255d993d8 - [net-next,11/14] net: bridge: multicast: optimize TO_INCLUDE EHT timeouts https://git.kernel.org/netdev/net-next/c/b66bf55bbc1c - [net-next,12/14] net: bridge: multicast: add EHT host filter_mode handling https://git.kernel.org/netdev/net-next/c/c9739016a032 - [net-next,13/14] net: bridge: multicast: handle block pg delete for all cases https://git.kernel.org/netdev/net-next/c/e87e4b5caa5d - [net-next,14/14] net: bridge: multicast: mark IGMPv3/MLDv2 fast-leave deletes https://git.kernel.org/netdev/net-next/c/d5a1022283c3
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html