Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp347448pxj; Thu, 13 May 2021 06:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq43ljLPHM2/P0um0fSGD7lOePeTIB7umXp/qkX94q4FpkrgsGh73SHupzJuDtxf6NHswR X-Received: by 2002:a05:6402:34c5:: with SMTP id w5mr51264680edc.237.1620912332539; Thu, 13 May 2021 06:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620912332; cv=none; d=google.com; s=arc-20160816; b=MtwF6uqixpL5S11Fe/IRaLRRf8ZBrQpAwP5qHXIpgDGukV9yLalGlVlkRcXNnR6Xqx YY1HUrgQQm1ELbt9Svz0iaAMIbDxEyYx1HTcCr6zHvnJ5N2ukgNPb/pKv9LDtsxqjpVn ZgIdh2KdXXfIWzZ5N/VJYpjjDjHfdpKWVJUZoJHqEBhSpg2rGo4a5j2Psbne9pH2ViGT hL1JrfVSfnn0PltAG4IAxSf+NZw3cDsUdq4uIYsHqnqJ2E/j2zn4Eqdcmf8mYYBvY+8s upA3Zbw7b03swbXSCJ3KODOBowLLPjIH8r0CETICLBxIR1J8IQruKI+JWVs06t2L54xi jQtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4pUpE7Ok19opMY7QCqNQi4MZvl8VDSUjcLHW3nfqir4=; b=UkRzM/MFyfv7dsN1PokXxdKnj6/vmm0VDsGOER3GutDNY0sW3AYc4tD28GMxa4LWVg VzkPC/kGdNI50WYXZyg8VH6nt80pS7k76Gjl5BKDz/N/O7/sjjBmcBNmm0SJptJlG/QT n6syNfR37/3gvgS27LEElyyrFyvbT21K0tICPkZtEzpFy3cyE27zuH6dOE4UkcrCojl3 pEKZhKh6YUzoPKLlx+4laTUxZ8WWxud4Z3Hs2b3foFtEFyjCRN6EVhC5s3GOjCMPjvep kOaVHEE3PRQhooFpI2wfCLKuVio/IBfHxfZUilcE1M9/QpKmMAWEHf2dc7Ox/0NY3d8l NEgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt8si3204894ejb.153.2021.05.13.06.25.04; Thu, 13 May 2021 06:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbhEMNX0 (ORCPT + 99 others); Thu, 13 May 2021 09:23:26 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:52932 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233998AbhEMNWb (ORCPT ); Thu, 13 May 2021 09:22:31 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 43A983ED8D; Thu, 13 May 2021 15:21:06 +0200 (CEST) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: netdev@vger.kernel.org Cc: Roopa Prabhu , Nikolay Aleksandrov , Jakub Kicinski , "David S . Miller" , bridge@lists.linux-foundation.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [net-next v4 08/11] net: bridge: mcast: split router port del+notify for mcast router split Date: Thu, 13 May 2021 15:20:50 +0200 Message-Id: <20210513132053.23445-9-linus.luessing@c0d3.blue> In-Reply-To: <20210513132053.23445-1-linus.luessing@c0d3.blue> References: <20210513132053.23445-1-linus.luessing@c0d3.blue> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for the upcoming split of multicast router state into their IPv4 and IPv6 variants split router port deletion and notification into two functions. When we disable a port for instance later we want to only send one notification to switchdev and netlink for compatibility and want to avoid sending one for IPv4 and one for IPv6. For that the split is needed. Signed-off-by: Linus Lüssing --- net/bridge/br_multicast.c | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index dc95464..30144f9 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -60,7 +60,8 @@ static void br_ip4_multicast_leave_group(struct net_bridge *br, const unsigned char *src); static void br_multicast_port_group_rexmit(struct timer_list *t); -static void __del_port_router(struct net_bridge_port *p); +static void +br_multicast_rport_del_notify(struct net_bridge_port *p, bool deleted); #if IS_ENABLED(CONFIG_IPV6) static void br_ip6_multicast_leave_group(struct net_bridge *br, struct net_bridge_port *port, @@ -1354,11 +1355,26 @@ static int br_ip6_multicast_add_group(struct net_bridge *br, } #endif +static bool br_multicast_rport_del(struct hlist_node *rlist) +{ + if (hlist_unhashed(rlist)) + return false; + + hlist_del_init_rcu(rlist); + return true; +} + +static bool br_ip4_multicast_rport_del(struct net_bridge_port *p) +{ + return br_multicast_rport_del(&p->ip4_rlist); +} + static void br_multicast_router_expired(struct net_bridge_port *port, struct timer_list *t, struct hlist_node *rlist) { struct net_bridge *br = port->br; + bool del; spin_lock(&br->multicast_lock); if (port->multicast_router == MDB_RTR_TYPE_DISABLED || @@ -1366,7 +1382,8 @@ static void br_multicast_router_expired(struct net_bridge_port *port, timer_pending(t)) goto out; - __del_port_router(port); + del = br_multicast_rport_del(rlist); + br_multicast_rport_del_notify(port, del); out: spin_unlock(&br->multicast_lock); } @@ -1705,19 +1722,20 @@ void br_multicast_disable_port(struct net_bridge_port *port) struct net_bridge *br = port->br; struct net_bridge_port_group *pg; struct hlist_node *n; + bool del = false; spin_lock(&br->multicast_lock); hlist_for_each_entry_safe(pg, n, &port->mglist, mglist) if (!(pg->flags & MDB_PG_FLAGS_PERMANENT)) br_multicast_find_del_pg(br, pg); - __del_port_router(port); - + del |= br_ip4_multicast_rport_del(port); del_timer(&port->ip4_mc_router_timer); del_timer(&port->ip4_own_query.timer); #if IS_ENABLED(CONFIG_IPV6) del_timer(&port->ip6_own_query.timer); #endif + br_multicast_rport_del_notify(port, del); spin_unlock(&br->multicast_lock); } @@ -3538,11 +3556,12 @@ int br_multicast_set_router(struct net_bridge *br, unsigned long val) return err; } -static void __del_port_router(struct net_bridge_port *p) +static void +br_multicast_rport_del_notify(struct net_bridge_port *p, bool deleted) { - if (hlist_unhashed(&p->ip4_rlist)) + if (!deleted) return; - hlist_del_init_rcu(&p->ip4_rlist); + br_rtr_notify(p->br->dev, p, RTM_DELMDB); br_port_mc_router_state_change(p, false); @@ -3556,6 +3575,7 @@ int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val) struct net_bridge *br = p->br; unsigned long now = jiffies; int err = -EINVAL; + bool del = false; spin_lock(&br->multicast_lock); if (p->multicast_router == val) { @@ -3569,12 +3589,14 @@ int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val) switch (val) { case MDB_RTR_TYPE_DISABLED: p->multicast_router = MDB_RTR_TYPE_DISABLED; - __del_port_router(p); + del |= br_ip4_multicast_rport_del(p); del_timer(&p->ip4_mc_router_timer); + br_multicast_rport_del_notify(p, del); break; case MDB_RTR_TYPE_TEMP_QUERY: p->multicast_router = MDB_RTR_TYPE_TEMP_QUERY; - __del_port_router(p); + del |= br_ip4_multicast_rport_del(p); + br_multicast_rport_del_notify(p, del); break; case MDB_RTR_TYPE_PERM: p->multicast_router = MDB_RTR_TYPE_PERM; -- 2.31.0