Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4925034pxj; Wed, 12 May 2021 16:44:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfCcaDwCBFG2rPUHdhutNoIPLyxKlIWZBPO+1YUJMsEl2EgzD/HNmR8al1tzhG4QordWAI X-Received: by 2002:a9d:491:: with SMTP id 17mr32891657otm.184.1620863067859; Wed, 12 May 2021 16:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620863067; cv=none; d=google.com; s=arc-20160816; b=DwzIkY5r5i4MAVAOY3V7tZy5f6CeTqS1F2/edHRCjpVfGgPsi7l1pJz37UbRZZAlnU e0VhtzCdaB0WSahG5r/ZECu7+9AmiBj5J9Mg6DDoqfa2SuZywnQq7BaKtFpnGnTgb78j xH1mdLui5XmD7f9V0fQTtv4rhEXcCZ6iFsTRRFK82NfD+IlxX/zx4YNhfnnj13uffvtn wR9MBb5WKhClATa8XwyaDldRibWcQGlY8EaO5NihxHpa6/9Nwr/GZ+yFNwdCJRWMCbks hmlwWx7pcYu3a0t4Zv2wbr2eQJ7SoN0ZpAPAdGVIv/sXyCfPGT0Qgq2Ui4/WFDaSBcO3 fdiA== 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=TcEnCuLEd7Z9ojHqTmVzwYqLtKdVbHA203DmM+qNYLM=; b=ZPlUIcPEM/RLKD+uVh2qOntOqN6VUyDiFTmdd3uEiW0SphGl0Q5bWTk852fyvdmx18 f/V61q2fuSq+Q5IX4NosV+7EXck7FbAJn5hYJXg2sjPP+7mASw53atOgG0R/7FgL2zyp CUY+r2gBO3u6gEkZG2ozcnyK52lhKA9cRFKeBgVH7IRk8/aBabgRCXj4TMDD/ONJaeql lCERcbBb9SxCHhWPgCi7hbDZmAwkARd35cWN+bbWYCjgxYdZcRHfvz6F4X+Cl+7p1Mru gPL0YrNYgGVJOqHzlBTMWGRdoxYdXE22uztaVLCK2gz5Cre6mEyVxiisD4eoageDdm/r 2mFw== 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 q8si1575922otg.199.2021.05.12.16.44.13; Wed, 12 May 2021 16:44:27 -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 S233283AbhELXie (ORCPT + 99 others); Wed, 12 May 2021 19:38:34 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:50648 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233940AbhELXVA (ORCPT ); Wed, 12 May 2021 19:21:00 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EB30D41007; Thu, 13 May 2021 01:19:48 +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 v3 02/11] net: bridge: mcast: add wrappers for router node retrieval Date: Thu, 13 May 2021 01:19:32 +0200 Message-Id: <20210512231941.19211-3-linus.luessing@c0d3.blue> In-Reply-To: <20210512231941.19211-1-linus.luessing@c0d3.blue> References: <20210512231941.19211-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 and to avoid IPv6 #ifdef clutter later add two wrapper functions for router node retrieval in the payload forwarding code. Signed-off-by: Linus Lüssing --- net/bridge/br_forward.c | 5 +++-- net/bridge/br_private.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index eb9847a..4e591b1 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -276,7 +276,8 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, bool allow_mode_include = true; struct hlist_node *rp; - rp = rcu_dereference(hlist_first_rcu(&br->ip4_mc_router_list)); + rp = br_multicast_get_first_rport_node(br, skb); + if (mdst) { p = rcu_dereference(mdst->ports); if (br_multicast_should_handle_mode(br, mdst->addr.proto) && @@ -290,7 +291,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, struct net_bridge_port *port, *lport, *rport; lport = p ? p->key.port : NULL; - rport = hlist_entry_safe(rp, struct net_bridge_port, ip4_rlist); + rport = br_multicast_rport_from_node(rp, skb); if ((unsigned long)lport > (unsigned long)rport) { port = lport; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 26e91d2..5b9a6b2 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -864,6 +864,16 @@ static inline bool br_group_is_l2(const struct br_ip *group) #define mlock_dereference(X, br) \ rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock)) +static inline struct hlist_node * +br_multicast_get_first_rport_node(struct net_bridge *b, struct sk_buff *skb) { + return rcu_dereference(hlist_first_rcu(&b->ip4_mc_router_list)); +} + +static inline struct net_bridge_port * +br_multicast_rport_from_node(struct hlist_node *rp, struct sk_buff *skb) { + return hlist_entry_safe(rp, struct net_bridge_port, ip4_rlist); +} + static inline bool br_multicast_is_router(struct net_bridge *br) { return br->multicast_router == 2 || -- 2.31.0