Commit 6af52ae2 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-bridge-mcast-initial-IGMPv3-MLDv2-support-part-1'

Nikolay Aleksandrov says:

====================
net: bridge: mcast: initial IGMPv3/MLDv2 support (part 1)

This patch-set implements the control plane for initial IGMPv3/MLDv2
support which takes care of include/exclude sets and state transitions
based on the different report types.
Patch 01 arranges the structure better by moving the frequently used
fields together, patch 02 factors out the port group deletion code which is
used in a few places. Patches 03 and 04 add support for source lists and
group modes per port group which are dumped. Patch 05 adds support for
group-and-source specific queries required for IGMPv3/MLDv2. Then patch 06
adds support for group and group-and-source query retransmissions via a new
rexmit timer. Patches 07 and 08 make use of the already present mdb fill
functions when sending notifications so we can have the full mdb entries'
state filled in (with sources, mode etc). Patch 09 takes care of port group
expiration, it switches the group mode to include and deletes it if there
are no sources with active timers. Patches 10-13 are the core changes which
add support for IGMPv3/MLDv2 reports and handle the source list set
operations as per RFCs 3376 and 3810, all IGMPv3/MLDv2 report types with
their transitions should be supported after these patches. I've used RFCs
3376, 3810 and FRR as a reference implementation. The source lists are
capped at 32 entries, we can remove that limitation at a later point which
would require a better data structure to hold them. IGMPv3 processing is
hidden behind the bridge's multicast_igmp_version option which must be set
to 3 in order to enable it. MLDv2 processing is hidden behind the bridge's
multicast_mld_version which must be set to 2 in order to enable it.
Patch 14 improves other querier processing a bit (more about this below).
And finally patch 15 transforms the src gc so it can be used with all mcast
objects since now we have multiple timers that can be running and we
need to make sure they have all finished before freeing the objects.
This is part 1, it only adds control plane support and doesn't change
the fast path. A following patch-set will take care of that.

Here're the sets that will come next (in order):
 - Fast path patch-set which adds support for (S, G) mdb entries needed
   for IGMPv3/MLDv2 forwarding, entry add source (kernel, user-space etc)
   needed for IGMPv3/MLDv2 entry management, entry block mode needed for
   IGMPv3/MLDv2 exclude mode. This set will also add iproute2 support for
   manipulating and showing all the new state.
 - Selftests patches which will verify all state transitions and forwarding
 - Explicit host tracking patch-set, needed for proper fast leave and
   with it fast leave will be enabled for IGMPv3/MLDv2

Not implemented yet:
 - Host IGMPv3/MLDv2 filter support (currently we handle only join/leave
   as before)
 - Proper other querier source timer and value updates
 - IGMPv3/v2 MLDv2/v1 compat (I have a few rough patches for this one)

v4: move old patch 05 to 02 (group del patch), before src lists
    patch 02: set pg's fast leave flag when deleting due to fast leave
    patch 03: now can use the new port del function
              add igmpv2/mldv1 bool which are set when the entry is
              added in those modes (later will be passed as update_timer)
    patch 10: rename update_timer to igmpv2_mldv1 and use the passed
              value from br_multicast_add_group's callers
v3: add IPv6/MLDv2 support, most patches are changed
v2:
 patches 03-04: make src lists RCU friendly so they can be traversed
                when dumping, reduce limit to a more conservative 32
                src group entries for a start
 patches 11-13: remove helper and directly do bitops
 patch      15: force mcast gc on bridge port del to make sure port
                group timers have finished before freeing the port
====================
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents bb1416ad e12cec65
...@@ -455,10 +455,31 @@ enum { ...@@ -455,10 +455,31 @@ enum {
enum { enum {
MDBA_MDB_EATTR_UNSPEC, MDBA_MDB_EATTR_UNSPEC,
MDBA_MDB_EATTR_TIMER, MDBA_MDB_EATTR_TIMER,
MDBA_MDB_EATTR_SRC_LIST,
MDBA_MDB_EATTR_GROUP_MODE,
__MDBA_MDB_EATTR_MAX __MDBA_MDB_EATTR_MAX
}; };
#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1) #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
/* per mdb entry source */
enum {
MDBA_MDB_SRCLIST_UNSPEC,
MDBA_MDB_SRCLIST_ENTRY,
__MDBA_MDB_SRCLIST_MAX
};
#define MDBA_MDB_SRCLIST_MAX (__MDBA_MDB_SRCLIST_MAX - 1)
/* per mdb entry per source attributes
* these are embedded in MDBA_MDB_SRCLIST_ENTRY
*/
enum {
MDBA_MDB_SRCATTR_UNSPEC,
MDBA_MDB_SRCATTR_ADDRESS,
MDBA_MDB_SRCATTR_TIMER,
__MDBA_MDB_SRCATTR_MAX
};
#define MDBA_MDB_SRCATTR_MAX (__MDBA_MDB_SRCATTR_MAX - 1)
/* multicast router types */ /* multicast router types */
enum { enum {
MDB_RTR_TYPE_DISABLED, MDB_RTR_TYPE_DISABLED,
......
This diff is collapsed.
This diff is collapsed.
...@@ -214,26 +214,61 @@ struct net_bridge_fdb_entry { ...@@ -214,26 +214,61 @@ struct net_bridge_fdb_entry {
#define MDB_PG_FLAGS_OFFLOAD BIT(1) #define MDB_PG_FLAGS_OFFLOAD BIT(1)
#define MDB_PG_FLAGS_FAST_LEAVE BIT(2) #define MDB_PG_FLAGS_FAST_LEAVE BIT(2)
#define PG_SRC_ENT_LIMIT 32
#define BR_SGRP_F_DELETE BIT(0)
#define BR_SGRP_F_SEND BIT(1)
struct net_bridge_mcast_gc {
struct hlist_node gc_node;
void (*destroy)(struct net_bridge_mcast_gc *gc);
};
struct net_bridge_group_src {
struct hlist_node node;
struct br_ip addr;
struct net_bridge_port_group *pg;
u8 flags;
u8 src_query_rexmit_cnt;
struct timer_list timer;
struct net_bridge *br;
struct net_bridge_mcast_gc mcast_gc;
struct rcu_head rcu;
};
struct net_bridge_port_group { struct net_bridge_port_group {
struct net_bridge_port *port; struct net_bridge_port *port;
struct net_bridge_port_group __rcu *next; struct net_bridge_port_group __rcu *next;
struct hlist_node mglist;
struct rcu_head rcu;
struct timer_list timer;
struct br_ip addr; struct br_ip addr;
unsigned char eth_addr[ETH_ALEN] __aligned(2); unsigned char eth_addr[ETH_ALEN] __aligned(2);
unsigned char flags; unsigned char flags;
unsigned char filter_mode;
unsigned char grp_query_rexmit_cnt;
struct hlist_head src_list;
unsigned int src_ents;
struct timer_list timer;
struct timer_list rexmit_timer;
struct hlist_node mglist;
struct net_bridge_mcast_gc mcast_gc;
struct rcu_head rcu;
}; };
struct net_bridge_mdb_entry { struct net_bridge_mdb_entry {
struct rhash_head rhnode; struct rhash_head rhnode;
struct net_bridge *br; struct net_bridge *br;
struct net_bridge_port_group __rcu *ports; struct net_bridge_port_group __rcu *ports;
struct rcu_head rcu;
struct timer_list timer;
struct br_ip addr; struct br_ip addr;
bool host_joined; bool host_joined;
struct timer_list timer;
struct hlist_node mdb_node; struct hlist_node mdb_node;
struct net_bridge_mcast_gc mcast_gc;
struct rcu_head rcu;
}; };
struct net_bridge_port { struct net_bridge_port {
...@@ -406,6 +441,7 @@ struct net_bridge { ...@@ -406,6 +441,7 @@ struct net_bridge {
struct rhashtable mdb_hash_tbl; struct rhashtable mdb_hash_tbl;
struct hlist_head mcast_gc_list;
struct hlist_head mdb_list; struct hlist_head mdb_list;
struct hlist_head router_list; struct hlist_head router_list;
...@@ -419,6 +455,7 @@ struct net_bridge { ...@@ -419,6 +455,7 @@ struct net_bridge {
struct bridge_mcast_own_query ip6_own_query; struct bridge_mcast_own_query ip6_own_query;
struct bridge_mcast_querier ip6_querier; struct bridge_mcast_querier ip6_querier;
#endif /* IS_ENABLED(CONFIG_IPV6) */ #endif /* IS_ENABLED(CONFIG_IPV6) */
struct work_struct mcast_gc_work;
#endif #endif
struct timer_list hello_timer; struct timer_list hello_timer;
...@@ -766,13 +803,17 @@ br_multicast_new_group(struct net_bridge *br, struct br_ip *group); ...@@ -766,13 +803,17 @@ br_multicast_new_group(struct net_bridge *br, struct br_ip *group);
struct net_bridge_port_group * struct net_bridge_port_group *
br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group, br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group,
struct net_bridge_port_group __rcu *next, struct net_bridge_port_group __rcu *next,
unsigned char flags, const unsigned char *src); unsigned char flags, const unsigned char *src,
u8 filter_mode);
int br_mdb_hash_init(struct net_bridge *br); int br_mdb_hash_init(struct net_bridge *br);
void br_mdb_hash_fini(struct net_bridge *br); void br_mdb_hash_fini(struct net_bridge *br);
void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port, void br_mdb_notify(struct net_device *dev, struct net_bridge_mdb_entry *mp,
struct br_ip *group, int type, u8 flags); struct net_bridge_port_group *pg, int type);
void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port, void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
int type); int type);
void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
struct net_bridge_port_group *pg,
struct net_bridge_port_group __rcu **pp);
void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p, void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p,
const struct sk_buff *skb, u8 type, u8 dir); const struct sk_buff *skb, u8 type, u8 dir);
int br_multicast_init_stats(struct net_bridge *br); int br_multicast_init_stats(struct net_bridge *br);
...@@ -836,6 +877,19 @@ static inline int br_multicast_igmp_type(const struct sk_buff *skb) ...@@ -836,6 +877,19 @@ static inline int br_multicast_igmp_type(const struct sk_buff *skb)
{ {
return BR_INPUT_SKB_CB(skb)->igmp; return BR_INPUT_SKB_CB(skb)->igmp;
} }
static inline unsigned long br_multicast_lmqt(const struct net_bridge *br)
{
return br->multicast_last_member_interval *
br->multicast_last_member_count;
}
static inline unsigned long br_multicast_gmi(const struct net_bridge *br)
{
/* use the RFC default of 2 for QRV */
return 2 * br->multicast_query_interval +
br->multicast_query_response_interval;
}
#else #else
static inline int br_multicast_rcv(struct net_bridge *br, static inline int br_multicast_rcv(struct net_bridge *br,
struct net_bridge_port *port, struct net_bridge_port *port,
......
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