Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2029380pxj; Sun, 9 May 2021 12:46:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUA5AmStWpKZskXgHwIMyydc8IPVr+IXJMnRgWyYzo9pk8fjTxzm/KijfZCAuCvTsscTVu X-Received: by 2002:aa7:cd0c:: with SMTP id b12mr25168804edw.236.1620589602810; Sun, 09 May 2021 12:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620589602; cv=none; d=google.com; s=arc-20160816; b=mAjUvSfk90JkY04nlIdYQMBHOanJ0hSJPvxpH1HSiVOWhZu1uaTuxVHlYuwUbDpbum Gv0ccv5BxIJKhf5iXTBhxESsXQiAvTdDCgGLSnDPiiZBcBo7js34AE4fFy9BAloy56NK 2xlE80/z3xi3dUU4rh9QS3ZClhzZ0cgSIq5L0odIQ8IAP6wh7ijvoXB6UgEKMiJz0+tl LOpKADlLAFcU+rYChPx6YKRYcQZZEP1UTu7ZWIjY3E4HZfi6yuHwryXnerbr+Oq6QyzS IYhKnMJTkODsbEHQJrer7A5t7mzxlZpAqSYUP4UJQNzR5IziwRFKxQNn7NPO1qZK1nlU fl+g== 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=AckrL2PnSpJlD3bsEHsGMAYBg+XljUTSiEnqpiUEZ88=; b=ucKu3Y8Zjy/BN29NWVeXdaqhQlOp9sZ6KrPU4ibES+4s9UcJ1Vmy2sMtcbsxF//zEJ g9JHELTZ+lbPL3U0IyhC6Z1YIF3QeORjCxxZYRrzqZuKY3mE5dsEbZDA87uYjDlFcCqU L+PlrrnCDZApz9OloMiPO5sSYGAVGdOnSs8YZ1c0rI8KYdUn4hOAGnQaG+Kvr/6rnbdI K+IrDhrn96QC86kV4DZoBOuhG9l2KkgIaot0fx+raZg2uFWX1GQIujNyr8354bWbzsjq tEiKRTHEPl0aBKepxmU82EeLfmXsT/gYw+3FHrRJH2ppdjIneOoj0fBHdVk3IYdrN3ow dbUA== 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 gg8si11694724ejb.649.2021.05.09.12.46.18; Sun, 09 May 2021 12:46:42 -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 S229933AbhEITq3 (ORCPT + 99 others); Sun, 9 May 2021 15:46:29 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:55828 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbhEITq2 (ORCPT ); Sun, 9 May 2021 15:46:28 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 39DBC3EDDD; Sun, 9 May 2021 21:45:23 +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 02/11] net: bridge: mcast: add wrappers for router node retrieval Date: Sun, 9 May 2021 21:45:00 +0200 Message-Id: <20210509194509.10849-3-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 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 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 3b67184..b5ec4f9 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -264,6 +264,16 @@ static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb, __br_forward(p, skb, local_orig); } +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); +} + /* called with rcu_read_lock */ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, struct sk_buff *skb, @@ -276,7 +286,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->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 +301,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; -- 2.31.0