Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp347009pxj; Thu, 13 May 2021 06:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9FmrvMOqGBnXFIpUQIjQrkpziDFwT80VJuovAC7B3W+sTxTT7Y8f8LCz24qFdkjJjIQsm X-Received: by 2002:a17:906:4f1a:: with SMTP id t26mr993690eju.280.1620912304977; Thu, 13 May 2021 06:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620912304; cv=none; d=google.com; s=arc-20160816; b=HjwSwCqifEnKbT0NSlWZTBuvSAS3Nf2wZhzZyyL6FLeU3VEKLai/y3YUBlL+JFz3Xk /M97Mp1O+zDC8ddA646SPion0Bte6koBpLI38Fi6PjtptgdnPeH9COn6zdvg3Zv/ABOp 1B4sqj06kYN9BzFNxKYFR876pCnl4SJ9xT1rLorNTG0SDrpB0S+SZLz5yTW2BVCE9MKe /KjidXrEIlovyDfXXkKO6m0qO5RTovk4/OnBa6v6PTfn0mA4Tk/VD0vddTzNdnOXRPa+ VtyUhL+n4Mwr1VmYU2RIsCxhkAJE91x6/eZfGudHodKIR7hjID2iZ0k1B2U21vZHbSh4 eRaw== 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=xxbfcOfPnona16xpZfuFzGMKOg/F1GlYPuFVK2bGtME=; b=AwWS9qX5E2BA1GkScrO4q4bbrl3lcoiwoPNMKMZvkJBOaEOmT/svppaZdmIKfzW3hm XgLzcyzhJ9p9OtgiOf8ITqRM2IdufKIvp46AU0qJ5GGxp5Aywhz3jzKlKsOgDuwFqeCJ +AFxHxKTc+J0pcuB25BmC1lULG7tAhEuGYoIhjwXSusAFMO3U5kSIYi6WGjrbuggHGEZ cCLd9qn7V9jguUEizSBSKElti/5O1rA+In16I2Uh3t8kTiNnj/ZaBIpkv8an94Ap/Dq0 tPkjhz/lUnzyRLq4eQ4GUma1H+gz3iQOHG4VCU70MJhmN6AKr8qJZ6ERsyBcq7NsqZhz nxNA== 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 ss21si3038347ejb.390.2021.05.13.06.24.38; Thu, 13 May 2021 06:25:04 -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 S234190AbhEMNXU (ORCPT + 99 others); Thu, 13 May 2021 09:23:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233997AbhEMNW3 (ORCPT ); Thu, 13 May 2021 09:22:29 -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 F00C9C06174A; Thu, 13 May 2021 06:21:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2D3F441007; Thu, 13 May 2021 15:21:00 +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 02/11] net: bridge: mcast: add wrappers for router node retrieval Date: Thu, 13 May 2021 15:20:44 +0200 Message-Id: <20210513132053.23445-3-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 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..0785636 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_skb(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..d970ef7 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_skb(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