Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2030773pxj; Sun, 9 May 2021 12:50:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6ReZSJZgQjrNP/xqvt2w2RQapBTZFdQx0GEyjT/EoCxcY8xHJQ5Wd8/fl2DzbpjXPHIXZ X-Received: by 2002:aa7:d41a:: with SMTP id z26mr26422444edq.54.1620589806657; Sun, 09 May 2021 12:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620589806; cv=none; d=google.com; s=arc-20160816; b=eICy8ipbEYqMJB9MJMRPuTOBZlVj3MwWTAtavtCayPt4D3oKPQ5tJH32cRsstc5+yJ l1v6Vm8eex1zo2oIZrTUwMmvygIdeTcrB/Qj08qhDgMXktq9ZMcruRLwjzMIy2ITsk1X ECsCkLDgN/h4066rmwbBhDkKfojpwMfCQUadlsV3khyU1uqBQv/q+3fbdnPJhaLZXGaH 0TP/hpy/ELjWTiqiS2VrBFBeNT+YQIVoCXnJMA9Pbn5s7d1rajfTblbRW1mq+JPV54qR DY2gmrbpc5IhBO+rYGQrKyznuWwj0AX1RNp4mnTZ4VK1kngsru040oUSZLz9qGFZxY3B 8vvw== 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=wz1aEZsQhu/WQkAyoJkhzen0dDkS7IBsiueVz2i/Lw4=; b=NkvMfRXrglYOHTmkC4bxrCJwbr5xvF2mL4M5P2EG4PTKqrQjMQoiZ86UUOIe7AkNsl o+T7xBIfHNGnS0AL8P6/mubdnVPM4sqSlxbLR3J7uZwlk7aFiczC9vT5W/YAmQU6eQtt yJL+dqUUYnkAIizE2MT7fg7uozcoeVyNa7buWMjT6dUw5WzUttWrYJPEJfenuufrwLYy pI+G8WOsVFj8bJnvSomf/gb4I2jeMLTZPBbOJo+aj+oAwAuuBMS4+I4/ggNTGSxqfq0s 0umtcA3O2h3JFjINRvRFj2VFBEZkolvtTWc35Bn0qbFGmh4j10/KhFMZnlqutIivlR2n LaeQ== 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 au16si10002650ejc.178.2021.05.09.12.49.43; Sun, 09 May 2021 12:50:06 -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 S230254AbhEITq6 (ORCPT + 99 others); Sun, 9 May 2021 15:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhEITqf (ORCPT ); Sun, 9 May 2021 15:46:35 -0400 Received: from mail.aperture-lab.de (mail.aperture-lab.de [IPv6:2a01:4f8:c2c:665b::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3127DC061763; Sun, 9 May 2021 12:45:31 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 698273ED8E; Sun, 9 May 2021 21:45:29 +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, b.a.t.m.a.n@lists.open-mesh.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [net-next v2 08/11] net: bridge: mcast: split router port del+notify for mcast router split Date: Sun, 9 May 2021 21:45:06 +0200 Message-Id: <20210509194509.10849-9-linus.luessing@c0d3.blue> In-Reply-To: <20210509194509.10849-1-linus.luessing@c0d3.blue> References: <20210509194509.10849-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 839d21b..39854d5 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 inline 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); } @@ -1706,19 +1723,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); } @@ -3508,11 +3526,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); @@ -3526,6 +3545,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) { @@ -3539,12 +3559,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