Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2030107pxj; Sun, 9 May 2021 12:48:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxKEuuWh/42QmKvBNyQ7xwweIV8S9yy4AUt8WlokAD7CU29V0EaDzPOUiAdeABnxnzHwu8 X-Received: by 2002:a50:fb02:: with SMTP id d2mr14114388edq.34.1620589703118; Sun, 09 May 2021 12:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620589703; cv=none; d=google.com; s=arc-20160816; b=GN7zMGwJ4lBAtKO0kXAVHhn+v2zz+KzEQJ4IE/68V22i9z1h73HOqthf2CXvtUVKVf NceD/a9Ph4LyMk19HQkwwxUeBGAVRe3o7ZHTYrS3r0V5UinuYxuEWowHAB6KN30o77Oy jY1Qlzvd/Q+1eo2DMnSWbz279xXXGRD6gAvveK7S5sj8/tYMQI3wP7Vbw1oeBIDPb1ya glANgHk5fp9S94Z612InleWz2zcZ3KMmPjcqDxjJO7aN09gTHIVCT44aYTKjixLlGbG0 iVMAiUQL2xxxM4SmxANEoIl4qh32/oTqbcXAyG7aKBHiUBqIorn1jeuG1wvmEHUZr3bU DYHg== 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=zG+pM+lEypNeNNK/88iv2rifa+FNEKyXybJkuPngPyI=; b=YjYx/aeqqVcWfTMJ+V8q6ZuhlCKIHctJAiK69J+P0aMa+fe3izi1aRDNT4A6LRBagZ 5lfArCR8BqV9L78VUXnVTilmYR6ZopAVDIgQyPnrGitNt7UfmU637HDNA0zYC2Qz1cy5 ytPtW4Uay8Hu4epTS+pf0AI/jY3PEhTJkbHQs26DX+bo9EpqNiDH8EJ+oSVWsAhi4QOs zQmmArTLyD9UvF8Y2f1onHB+zIqAjBhckkPg+8pL4cscGK8mTWp3ficU2QEDb3Vntn4b ZzQTTFywz4yz3jjrLFvXUp/Xda+5EAW42lZlrmTcDXLUD4UgQpzlkeAZtGMccbedr8L3 waDA== 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 u20si5796104edv.439.2021.05.09.12.48.00; Sun, 09 May 2021 12:48:23 -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 S230205AbhEITqz (ORCPT + 99 others); Sun, 9 May 2021 15:46:55 -0400 Received: from mail.aperture-lab.de ([116.203.183.178]:56020 "EHLO mail.aperture-lab.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbhEITqe (ORCPT ); Sun, 9 May 2021 15:46:34 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1ED773ED8B; Sun, 9 May 2021 21:45:28 +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 07/11] net: bridge: mcast: prepare add-router function for mcast router split Date: Sun, 9 May 2021 21:45:05 +0200 Message-Id: <20210509194509.10849-8-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 move the protocol specific router list access to an ip4 wrapper function. Signed-off-by: Linus Lüssing --- net/bridge/br_multicast.c | 59 +++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 6c844b2..839d21b 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -51,8 +51,8 @@ static const struct rhashtable_params br_sg_port_rht_params = { static void br_multicast_start_querier(struct net_bridge *br, struct bridge_mcast_own_query *query); -static void br_multicast_add_router(struct net_bridge *br, - struct net_bridge_port *port); +static void br_ip4_multicast_add_router(struct net_bridge *br, + struct net_bridge_port *port); static void br_ip4_multicast_leave_group(struct net_bridge *br, struct net_bridge_port *port, __be32 group, @@ -1689,7 +1689,7 @@ static void __br_multicast_enable_port(struct net_bridge_port *port) #endif if (port->multicast_router == MDB_RTR_TYPE_PERM && hlist_unhashed(&port->ip4_rlist)) - br_multicast_add_router(br, port); + br_ip4_multicast_add_router(br, port); } void br_multicast_enable_port(struct net_bridge_port *port) @@ -2659,28 +2659,51 @@ static void br_port_mc_router_state_change(struct net_bridge_port *p, * and locked by br->multicast_lock and RCU */ static void br_multicast_add_router(struct net_bridge *br, - struct net_bridge_port *port) + struct net_bridge_port *port, + struct hlist_node *slot, + struct hlist_node *rlist, + struct hlist_head *mc_router_list) { - struct net_bridge_port *p; - struct hlist_node *slot = NULL; - - if (!hlist_unhashed(&port->ip4_rlist)) + if (!hlist_unhashed(rlist)) return; - hlist_for_each_entry(p, &br->ip4_mc_router_list, ip4_rlist) { - if ((unsigned long) port >= (unsigned long) p) - break; - slot = &p->ip4_rlist; - } - if (slot) - hlist_add_behind_rcu(&port->ip4_rlist, slot); + hlist_add_behind_rcu(rlist, slot); else - hlist_add_head_rcu(&port->ip4_rlist, &br->ip4_mc_router_list); + hlist_add_head_rcu(rlist, mc_router_list); + br_rtr_notify(br->dev, port, RTM_NEWMDB); br_port_mc_router_state_change(port, true); } +struct hlist_node * +br_ip4_multicast_get_rport_slot(struct net_bridge *br, struct net_bridge_port *port) +{ + struct hlist_node *slot = NULL; + struct net_bridge_port *p; + + hlist_for_each_entry(p, &br->ip4_mc_router_list, ip4_rlist) { + if ((unsigned long)port >= (unsigned long)p) + break; + slot = &p->ip4_rlist; + } + + return slot; +} + +/* Add port to router_list + * list is maintained ordered by pointer value + * and locked by br->multicast_lock and RCU + */ +static void br_ip4_multicast_add_router(struct net_bridge *br, + struct net_bridge_port *port) +{ + struct hlist_node *slot = br_ip4_multicast_get_rport_slot(br, port); + + br_multicast_add_router(br, port, slot, &port->ip4_rlist, + &br->ip4_mc_router_list); +} + static void br_multicast_mark_router(struct net_bridge *br, struct net_bridge_port *port) { @@ -2700,7 +2723,7 @@ static void br_multicast_mark_router(struct net_bridge *br, port->multicast_router == MDB_RTR_TYPE_PERM) return; - br_multicast_add_router(br, port); + br_ip4_multicast_add_router(br, port); mod_timer(&port->ip4_mc_router_timer, now + br->multicast_querier_interval); @@ -3526,7 +3549,7 @@ int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val) case MDB_RTR_TYPE_PERM: p->multicast_router = MDB_RTR_TYPE_PERM; del_timer(&p->ip4_mc_router_timer); - br_multicast_add_router(br, p); + br_ip4_multicast_add_router(br, p); break; case MDB_RTR_TYPE_TEMP: p->multicast_router = MDB_RTR_TYPE_TEMP; -- 2.31.0