Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3349969pxj; Tue, 11 May 2021 02:25:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztw9QEwI2T8kf00XNJ6gDMY1C9jVz22QVR6FaDCM1GKd7nCHiKENcdhuD2NHqMJoBJz7Pi X-Received: by 2002:a05:6402:416:: with SMTP id q22mr35098271edv.204.1620725109451; Tue, 11 May 2021 02:25:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620725109; cv=pass; d=google.com; s=arc-20160816; b=009wAQ+ArZH9oU0HQkZShSBvIVir4vvDVV+XquJ+6pn4J8b5TCM2Q41vJ7T4Y5oe81 4cldVN2UtlKbEh2K3YUSthXTPywNYqu4vricxR5wgyd+6gRiYveoUqIS0g6P74kQEY+7 GG4jJmPzfGMuICZJgmjbBgK7j0HhnKEkqA9b1IaqHA8wQJNl3MPhYLvRyzIf5/8OT6wE x116xNb4CDugd8CXkO7/0oHsTChVNCzofqN+pgQaoodS1WZa/B/C8uoEKri/Q6Sq0kLO 7JbBFmOjrLkE6fUTCU0LpHT0LgncgQb5KTtM7LvUQAp9sxoLL3sWxlh00uLg6RfsfwlR KtXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=QslpgAfoPSMyQTcwVuRxE/Clc9H3kQJwpSw0ATzzLfM=; b=AcPGm6lpxFAKDzlO3t4iZE9lKKk5J63XXGz11CAheBf0H/1dfh+S+WHh7ydcNGwvVz 9cXhtZz4ivhm6cjlbfLMO8UKf6O/4dVk0zW/9s3bPt2kVpz1CjfJipkNzkcY4vZjQYif 6f8xyUG27mZ/jsBLnOxiInh8zAucvuEsbZFQvIhI2Ot345JYv4Un/oeCSQP0ramRZVuK BwSN3MtjwH7kisTNDj5T0NiV56f9+zttomSe5VL7amfGDyTBpeDzUhYBt/Yx3a2hxYWw dKKuP7wIqct/IvnUzLplja9y9FLcvt4OTsJSYTVIj5VJ3504lU7WztgwoXrYCDK4c73D V/Qg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=A4WJgu5U; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo12si1678942ejb.317.2021.05.11.02.24.45; Tue, 11 May 2021 02:25:09 -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; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=A4WJgu5U; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhEKJYl (ORCPT + 99 others); Tue, 11 May 2021 05:24:41 -0400 Received: from mail-bn7nam10on2042.outbound.protection.outlook.com ([40.107.92.42]:48608 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230126AbhEKJYj (ORCPT ); Tue, 11 May 2021 05:24:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FU1YFM8k0Z9MgpTovtrLHcTWPRO287KT8iaY0PtQ5H0BFbVmmr3wLKFtR1gIV4BYppLtfaEZM+r/GFg2iTvtfJZutMF5iFS4jEnFEtNttQdj4acHQMqjwLCHAtzvcOLX/L8GuKoA92WNNa4DpHZlqTz6VEI010EB5g8UTR0kC58ddYhZ8kCNjkURPrNlzFa/ncpgr/EDka04ldDfgqo7poc3hQzCjEaVjZJDSI/jYLi9cMp6j+C6T/1VbvYFBV9An6J4nWwOlGJIjdzf7zbacSl2NyBdCOOqcZhpcSfL0shngB5ElKRLEHoICLeFFSjh/2VWi3OQf5bYKDHEu5KqSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QslpgAfoPSMyQTcwVuRxE/Clc9H3kQJwpSw0ATzzLfM=; b=HjMb6EndRzhKJ1VlJGbDzcllHUnQQ5QsjKoGuyoZLvxooTAAUmAAGdludkw5KrOaeYZlmsTnignbH4a058yf9RuUHu7kTQBS3dqCgGPe4sbbdE4TcCrTorqE7l3wjif5m37vGAjmZorpTsaUwMmKn2W9fq/+GOekbzlFf6tSqDegVgV9jFh6U347BgvJV4Wo0NrN730iKL1BtMXQy2IfMrUPYu+1oAly6+DH/b4hKxTFZawUdAuQZ5XKRDXdwfMJZ0qujeaxXbBy0RV7OjAgXw98beCtykv2J3qz3X9SCWbZty89SNWHLQ4YNTse9lAZwiM3ZmmlIdGl0N+Iovxspg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QslpgAfoPSMyQTcwVuRxE/Clc9H3kQJwpSw0ATzzLfM=; b=A4WJgu5U1MfknRodQBGk03f9hDOevSNbW1whKJ8i/FJPs+k97L8+DNHp40FEaAc/plSBqKPPe+Mt/m5tPA+rCmHzwi3s9b5p5nPvMIcwgSA9Pu7a+tuYaJ1YwKcGM+er7MyNflDZn+wswSKbiv8//hy7qvzsrPe3XT3EXqOx+KnzOAqJFSkbZMA3qmxnn76d5qyp3ay1BBarD/5EXBpcZFEn0hXsb8+FdWblckMfzso9JADsDi6waJWjHrK5fQh5ZgruPOLG3yUYDPJ4DS15ct67dRSqDpDCP9TYDTvpEVIfxp+a+2W9KJWn/UuASqgylc/gB7I5ux0I9Y69Regulg== Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=nvidia.com; Received: from DM4PR12MB5278.namprd12.prod.outlook.com (2603:10b6:5:39e::17) by DM4PR12MB5326.namprd12.prod.outlook.com (2603:10b6:5:39f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 11 May 2021 09:23:32 +0000 Received: from DM4PR12MB5278.namprd12.prod.outlook.com ([fe80::d556:5155:7243:5f0f]) by DM4PR12MB5278.namprd12.prod.outlook.com ([fe80::d556:5155:7243:5f0f%6]) with mapi id 15.20.4108.031; Tue, 11 May 2021 09:23:32 +0000 Subject: Re: [net-next v2 11/11] net: bridge: mcast: export multicast router presence adjacent to a port To: =?UTF-8?Q?Linus_L=c3=bcssing?= , netdev@vger.kernel.org Cc: Roopa Prabhu , 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 References: <20210509194509.10849-1-linus.luessing@c0d3.blue> <20210509194509.10849-12-linus.luessing@c0d3.blue> From: Nikolay Aleksandrov Message-ID: <7279c94e-a4ff-2fbb-290e-bdaf5844148c@nvidia.com> Date: Tue, 11 May 2021 12:23:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 In-Reply-To: <20210509194509.10849-12-linus.luessing@c0d3.blue> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [213.179.129.39] X-ClientProxiedBy: ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) To DM4PR12MB5278.namprd12.prod.outlook.com (2603:10b6:5:39e::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.21.241.170] (213.179.129.39) by ZR0P278CA0057.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 11 May 2021 09:23:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 267782ce-ef72-44fe-ffb2-08d9145e71ef X-MS-TrafficTypeDiagnostic: DM4PR12MB5326: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5RHwPtdbfN8J9iyoFBwB8xuApdMIWGn3Jn6230HIoX+AXOtv6St0qlCIuYAb3R/a6h29OV/XxRzySpdOuQsrg7nhfzSPdmBUVEFsTSc3J/3NonnlLW1DquqQzw7IEinhMNfXkJ9HHzN0roiZZnRjoUF+7y7UHTrO6fJalfNRQbKT28/JRk9htxuoZbpGvRHL8/E4jNlLwE+cz73Q+NzvQb9foOxkSAfrZ/NiOOFKGKh04DadS8PBd4Qjl2ZuGvMZu12r6xfcdwU4kgi3iWCKFGQih987TVIYQub3JxOzw5XQ+VjPvXcPCFUZ1ESKyVM+oAkIOodN14RRckFKVPgzz3Gzl/4EQwXy2uS2nQgHgyI2fUhLWEB5FMEQPLmbKNFCOiSDcVApMwk1za4u4Qo+4sO6XmsN/yKShaz/dscnbRkI4NX4cXNF8VQh7NqCa4nsWg/KChrXiUCSfKJtBDiSL7Qyi90v4VVRe05k7ITvPKLZe+G3EXZ8L+yoDOLOYy/DVNzgwtEGr+uUnvIxoPYuU8WAQgqjuHyYdiO13hlu6txYf/fk2U7A8tDtPZhXBDSLVB2QQ1OMp6Ju6b0oV9h/dPjR1nraFKcp40tY50xTRS3Q74kS+++WlUbK8LjO3uVAJe5U7/fbx/YsAYx5fTCJb7ljcV/xKWupIQOutPWccFSKW5jvshj1/GiVwiyXFGtL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5278.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(136003)(376002)(39860400002)(366004)(396003)(6486002)(8676002)(54906003)(478600001)(316002)(16576012)(16526019)(186003)(956004)(2616005)(2906002)(4326008)(5660300002)(31686004)(53546011)(26005)(8936002)(38100700002)(66574015)(36756003)(31696002)(86362001)(6666004)(66556008)(66946007)(66476007)(83380400001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?eTR6SGYwSmJkRjNkM1hNdlVlS0lyMERlSXZyWjlTSDZZUUtMV2wzU1pHMjRl?= =?utf-8?B?OXZCRTFOd2VDZmJ6UXVNVWNTZm1RZlNoU0hqMWdUWjBqUmxpZm5BZmh5Zng1?= =?utf-8?B?KzJhUWhIVTY5VTNqazcvUmNRZFJ2OUJCcm1MckQ5dnBSSzl0bHArZEpXc0xY?= =?utf-8?B?SjcwMW8vczlCU3hPUWw1MUI2bmswOExhYjBSZTAxRlFnM2ZoMGo0eG5FUEp0?= =?utf-8?B?SGV0cXhWaFQ3MFFXL3JGaE04dks1eit5MFZXZEVxd0FMczNUS0ljNFg4Mlhx?= =?utf-8?B?eXVjTFJINHBxSVlVSnpvc2Q3bEI3QVNtNFRUdDFrVjdC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o3ZzBuZEdlWWZlZUEzeW56Y1ZlSWJUYWZp?= =?utf-8?B?aXJXcFQ2QlhpaXNMcTR4QUZ2cFFQUGhpWFZxbHAxeXhwY05qZnFqWDZrRXQ1?= =?utf-8?B?U2w3SCtqNnJjM2dCMEQ0eG1MajJiRzdGSzBZam9ma25EdWdOaGlwUURBaGNT?= =?utf-8?B?OEVUaUE0cFgrd0s4M1N4aU1nK3drRnljb25JNFNiY2VGdXRZZzB2dXB1cTBX?= =?utf-8?B?VlpzNm5Ta3BCRnQ0dThLOG11RTUySGI5a0hNMlpwSUduZUZlczVtYTc5UFZo?= =?utf-8?B?ajVGZ1JPTXdKNjFSdG9ESGhINmVsdVQ5dTh0bGdURmtVdXdjN3htWk5aRXFS?= =?utf-8?B?SVhidU8zSUNZaTVKNThtdWViUEtqYnRjejRIOGJ4VkM5Z1NVcEhvK1UyNTVF?= =?utf-8?B?QUNKSkRPZDFyRzZpc3NhWUlXU0JKdHhrSDcrbExvaHh6UGw4dy9oVDVhNzc2?= =?utf-8?B?V3N0ZSsyWUhDb3l5OGRVYjREdHpSUHEzTTJ1VEVOakZpdVcyUElSWUUzZitG?= =?utf-8?Q?j+ZFIKUgWwVBPDe0O2uYxzEjN1IfP1dvh7zvY1+?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 267782ce-ef72-44fe-ffb2-08d9145e71ef X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5278.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2021 09:23:32.2134 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6VieaMAypGIxUSTXcotuaV/u/C+MvtepqBXnnEN6hgDao/h8NdtrbH1StbIoFK4qjQfSHfXNVachr6lJVJ+oqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5326 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/2021 22:45, Linus Lüssing wrote: > To properly support routable multicast addresses in batman-adv in a > group-aware way, a batman-adv node needs to know if it serves multicast > routers. > > This adds a function to the bridge to export this so that batman-adv > can then make full use of the Multicast Router Discovery capability of > the bridge. > > Signed-off-by: Linus Lüssing > --- > net/bridge/br_multicast.c | 58 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c > index b625fd6..e963de5 100644 > --- a/net/bridge/br_multicast.c > +++ b/net/bridge/br_multicast.c > @@ -4061,6 +4061,64 @@ unlock: > } > EXPORT_SYMBOL_GPL(br_multicast_has_querier_adjacent); > > +/** > + * br_multicast_has_router_adjacent - Checks for a router behind a bridge port > + * @dev: The bridge port adjacent to which to check for a multicast router > + * @proto: The protocol family to check for: IGMP -> ETH_P_IP, MLD -> ETH_P_IPV6 > + * > + * Checks whether the given interface has a bridge on top and if so returns > + * true if a multicast router is behind one of the other ports of this > + * bridge. Otherwise returns false. > + */ > +bool br_multicast_has_router_adjacent(struct net_device *dev, int proto) > +{ > + struct net_bridge_port *port, *p; > + bool ret = false; > + > + rcu_read_lock(); > + if (!netif_is_bridge_port(dev)) > + goto unlock; > + > + port = br_port_get_rcu(dev); You can combine both of netif_is_bridge_port and br_port_get_rcu() checks and use br_port_get_check_rcu(). Then you can also drop the port->br check. > + if (!port || !port->br) > + goto unlock; > + > + switch (proto) { > + case ETH_P_IP: > + hlist_for_each_entry_rcu(p, &port->br->ip4_mc_router_list, > + ip4_rlist) { > + if (p == port) > + continue; > + > + ret = true; > + goto unlock; > + } > + break; > +#if IS_ENABLED(CONFIG_IPV6) > + case ETH_P_IPV6: > + hlist_for_each_entry_rcu(p, &port->br->ip6_mc_router_list, > + ip6_rlist) { > + if (p == port) > + continue; > + > + ret = true; > + goto unlock; > + } > + break; > +#endif > + default: > + /* when compiled without IPv6 support, be conservative and > + * always assume presence of an IPv6 multicast router > + */ > + ret = true; > + } > + > +unlock: > + rcu_read_unlock(); > + return ret; > +} > +EXPORT_SYMBOL_GPL(br_multicast_has_router_adjacent); > + > static void br_mcast_stats_add(struct bridge_mcast_stats __percpu *stats, > const struct sk_buff *skb, u8 type, u8 dir) > { >