Commit 5225d5f5 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-bridge-multicast-add-initial-eht-support'

Nikolay Aleksandrov says:

====================
net: bridge: multicast: add initial EHT support

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.

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. :)
====================

Link: https://lore.kernel.org/r/20210120145203.1109140-1-razor@blackwall.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents b9046e88 d5a10222
...@@ -18,7 +18,7 @@ br_netfilter-y := br_netfilter_hooks.o ...@@ -18,7 +18,7 @@ br_netfilter-y := br_netfilter_hooks.o
br_netfilter-$(subst m,y,$(CONFIG_IPV6)) += br_netfilter_ipv6.o br_netfilter-$(subst m,y,$(CONFIG_IPV6)) += br_netfilter_ipv6.o
obj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.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 bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o
......
This diff is collapsed.
This diff is collapsed.
...@@ -252,6 +252,8 @@ struct net_bridge_port_group { ...@@ -252,6 +252,8 @@ struct net_bridge_port_group {
struct timer_list timer; struct timer_list timer;
struct timer_list rexmit_timer; struct timer_list rexmit_timer;
struct hlist_node mglist; struct hlist_node mglist;
struct rb_root eht_set_tree;
struct rb_root eht_host_tree;
struct rhash_head rhnode; struct rhash_head rhnode;
struct net_bridge_mcast_gc mcast_gc; struct net_bridge_mcast_gc mcast_gc;
...@@ -846,6 +848,10 @@ void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg, ...@@ -846,6 +848,10 @@ void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg,
u8 filter_mode); u8 filter_mode);
void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp, void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp,
struct net_bridge_port_group *sg); 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,
bool fastleave);
static inline bool br_group_is_l2(const struct br_ip *group) static inline bool br_group_is_l2(const struct br_ip *group)
{ {
......
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (c) 2020, Nikolay Aleksandrov <nikolay@nvidia.com>
*/
#ifndef _BR_PRIVATE_MCAST_EHT_H_
#define _BR_PRIVATE_MCAST_EHT_H_
union net_bridge_eht_addr {
__be32 ip4;
#if IS_ENABLED(CONFIG_IPV6)
struct in6_addr ip6;
#endif
};
/* single host's list of set entries and filter_mode */
struct net_bridge_group_eht_host {
struct rb_node rb_node;
union net_bridge_eht_addr h_addr;
struct hlist_head set_entries;
unsigned int num_entries;
unsigned char filter_mode;
struct net_bridge_port_group *pg;
};
/* (host, src entry) added to a per-src set and host's list */
struct net_bridge_group_eht_set_entry {
struct rb_node rb_node;
struct hlist_node host_list;
union net_bridge_eht_addr h_addr;
struct timer_list timer;
struct net_bridge *br;
struct net_bridge_group_eht_set *eht_set;
struct net_bridge_group_eht_host *h_parent;
struct net_bridge_mcast_gc mcast_gc;
};
/* per-src set */
struct net_bridge_group_eht_set {
struct rb_node rb_node;
union net_bridge_eht_addr src_addr;
struct rb_root entry_tree;
struct timer_list timer;
struct net_bridge_port_group *pg;
struct net_bridge *br;
struct net_bridge_mcast_gc mcast_gc;
};
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);
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_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment