Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp846240rdb; Tue, 19 Sep 2023 11:55:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+FGpjd6vhiGgwdjPJOia1UGveK+iF4/FxzJ7nooIyWgIsm5JV/N1MzO+AQBtT/IsHQi5j X-Received: by 2002:a17:90a:f694:b0:268:1d1e:baaf with SMTP id cl20-20020a17090af69400b002681d1ebaafmr621635pjb.17.1695149710332; Tue, 19 Sep 2023 11:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695149710; cv=none; d=google.com; s=arc-20160816; b=gyHZm2KaF3ZnwNeu4w8y/7p/g7iQet5p9UhjOxPYICD8VJQCCw+pBEhjkDIbXjQJ0c Q8bfrhRd3ajsJbczb8EppVwyNXlgRrqghJgltUgtnDJoF9/BWNsoAXRGMQA9cf3K89ej vzb/EN3HVuFdv8xdpFdIOdDlzEVJuHbn3aF1OD/REZ7GC5jb9ECv+qfCgrwI8Kw6c4DC xMDaUsIEjZx2K884XZ+pZp7QG4kOVkXi0BgVlaYdz+RtBxdOjl86a158jUN0UTlJhhXl o9knRt3Qox5sk8Doan8FwJ9Wnv27Lh0vz5zd7ZbeQ1gXZTH3bwGxiMtS7qQ/vwh5KrmG IORA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=FFAVIDThynaUuw3KjodCdWkK5N5+YBkUoLl7NOLpIso=; fh=vdy8fLmkzgLosg2v5sVYMftPpjJTf1v+KansN80xFQ8=; b=oUoVYUn6zwljyfiRqMVBm8Hra9Nz+46zuL6iKscUjBq/MnXLXn6Iuo//VlnBIRGg0i aHkmDMgqaERvvz+kKA22Fq+yvG8cSNeNtsBrgfpIU1VlFqZpvla0sZDH+wbRoBQ2rlol Ot7Nu62BXQF0Hf+WZ484X/Os2ZqcxX1OYUaSqi6dHVrX2XbTivDG1tlpDJgrn6vxRHwN TliTeBTbP6z0l/sEX7pRLjzJ4oOPsatpU1HgFeEm/SiWH9jRUpWFJ5pN8+TZTnM4fzqE Mkpw+PzPnYbzYsDrsGP2B1UBRFWPUP4vbi3ATLUCiWuUraEg8vsGbY4C9aFvRb0JRaZ3 5OTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@avm.de header.s=mail header.b=acSKyeYx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=avm.de Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id q102-20020a17090a17ef00b0025c238650d1si10093751pja.174.2023.09.19.11.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:55:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@avm.de header.s=mail header.b=acSKyeYx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=avm.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id D9E9780DCC86; Tue, 19 Sep 2023 05:18:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbjISMSC (ORCPT + 99 others); Tue, 19 Sep 2023 08:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbjISMR1 (ORCPT ); Tue, 19 Sep 2023 08:17:27 -0400 Received: from mail.avm.de (mail.avm.de [IPv6:2001:bf0:244:244::120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78553E41; Tue, 19 Sep 2023 05:16:37 -0700 (PDT) Received: from mail-auth.avm.de (unknown [IPv6:2001:bf0:244:244::71]) by mail.avm.de (Postfix) with ESMTPS; Tue, 19 Sep 2023 14:16:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=avm.de; s=mail; t=1695125794; bh=98I6K9g8d9UN6Mj6dcFBDTX8Omeq6aFBdEfYnJIQo8g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=acSKyeYx4V18C3VvK0tRaOEch2dY1e4YLmb8HLY5/y3LSwTeQd6fBMjgF6l2V3+mQ bxvZj1Ss0fZVsL8Hczg9YwKkWJpxxRjBFsObXvJ4mVAwdbLKL+H2MOqeqEBlz26ISp ePwmT2TkGyC/bu7i1aUqj1BpP2z8ndAr6ZnrS3cU= Received: from localhost (unknown [172.17.88.63]) by mail-auth.avm.de (Postfix) with ESMTPSA id 8953782000; Tue, 19 Sep 2023 14:16:34 +0200 (CEST) From: Johannes Nixdorf Date: Tue, 19 Sep 2023 10:12:51 +0200 Subject: [PATCH net-next v4 4/6] net: bridge: Add netlink knobs for number / max learned FDB entries MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230919-fdb_limit-v4-4-39f0293807b8@avm.de> References: <20230919-fdb_limit-v4-0-39f0293807b8@avm.de> In-Reply-To: <20230919-fdb_limit-v4-0-39f0293807b8@avm.de> To: "David S. Miller" , Andrew Lunn , David Ahern , Eric Dumazet , Florian Fainelli , Ido Schimmel , Jakub Kicinski , Nikolay Aleksandrov , Oleksij Rempel , Paolo Abeni , Roopa Prabhu , Shuah Khan , Vladimir Oltean Cc: bridge@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Johannes Nixdorf X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695111167; l=3675; i=jnixdorf-oss@avm.de; s=20230906; h=from:subject:message-id; bh=98I6K9g8d9UN6Mj6dcFBDTX8Omeq6aFBdEfYnJIQo8g=; b=+O/vG30P80aYeRD2NeTJD51vvX0AL1hjsD1wwhht5rPqD1HX/7YgV5QWmeQ4nEGjXQ53fo9cT 5NxEoDKzjB5CFOMrx4+/m0WyzKvecxDhMpxlQ+AYMUjjBYg9Iaej1Fi X-Developer-Key: i=jnixdorf-oss@avm.de; a=ed25519; pk=KMraV4q7ANHRrwjf9EVhvU346JsqGGNSbPKeNILOQfo= X-purgate-ID: 149429::1695125793-80FD1D8B-195B29DA/0/0 X-purgate-type: clean X-purgate-size: 3677 X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-Spam-Status: No, score=0.2 required=5.0 tests=DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 05:18:11 -0700 (PDT) The previous patch added accounting and a limit for the number of dynamically learned FDB entries per bridge. However it did not provide means to actually configure those bounds or read back the count. This patch does that. Two new netlink attributes are added for the accounting and limit of dynamically learned FDB entries: - IFLA_BR_FDB_N_LEARNED (RO) for the number of entries accounted for a single bridge. - IFLA_BR_FDB_MAX_LEARNED (RW) for the configured limit of entries for the bridge. The new attributes are used like this: # ip link add name br up type bridge fdb_max_learned 256 # ip link add name v1 up master br type veth peer v2 # ip link set up dev v2 # mausezahn -a rand -c 1024 v2 0.01 seconds (90877 packets per second # bridge fdb | grep -v permanent | wc -l 256 # ip -d link show dev br 13: br: mtu 1500 [...] [...] fdb_n_learned 256 fdb_max_learned 256 Signed-off-by: Johannes Nixdorf --- include/uapi/linux/if_link.h | 2 ++ net/bridge/br_netlink.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index ce3117df9cec..0486f314c176 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -510,6 +510,8 @@ enum { IFLA_BR_VLAN_STATS_PER_PORT, IFLA_BR_MULTI_BOOLOPT, IFLA_BR_MCAST_QUERIER_STATE, + IFLA_BR_FDB_N_LEARNED, + IFLA_BR_FDB_MAX_LEARNED, __IFLA_BR_MAX, }; diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 505683ef9a26..f5d49a05e61b 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1267,6 +1267,8 @@ static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = { [IFLA_BR_VLAN_STATS_PER_PORT] = { .type = NLA_U8 }, [IFLA_BR_MULTI_BOOLOPT] = NLA_POLICY_EXACT_LEN(sizeof(struct br_boolopt_multi)), + [IFLA_BR_FDB_N_LEARNED] = { .type = NLA_U32 }, + [IFLA_BR_FDB_MAX_LEARNED] = { .type = NLA_U32 }, }; static int br_changelink(struct net_device *brdev, struct nlattr *tb[], @@ -1541,6 +1543,12 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[], return err; } + if (data[IFLA_BR_FDB_MAX_LEARNED]) { + u32 val = nla_get_u32(data[IFLA_BR_FDB_MAX_LEARNED]); + + WRITE_ONCE(br->fdb_max_learned, val); + } + return 0; } @@ -1595,6 +1603,8 @@ static size_t br_get_size(const struct net_device *brdev) nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_TOPOLOGY_CHANGE_TIMER */ nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_GC_TIMER */ nla_total_size(ETH_ALEN) + /* IFLA_BR_GROUP_ADDR */ + nla_total_size(sizeof(u32)) + /* IFLA_BR_FDB_N_LEARNED */ + nla_total_size(sizeof(u32)) + /* IFLA_BR_FDB_MAX_LEARNED */ #ifdef CONFIG_BRIDGE_IGMP_SNOOPING nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_ROUTER */ nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_SNOOPING */ @@ -1670,7 +1680,10 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev) nla_put_u8(skb, IFLA_BR_TOPOLOGY_CHANGE_DETECTED, br->topology_change_detected) || nla_put(skb, IFLA_BR_GROUP_ADDR, ETH_ALEN, br->group_addr) || - nla_put(skb, IFLA_BR_MULTI_BOOLOPT, sizeof(bm), &bm)) + nla_put(skb, IFLA_BR_MULTI_BOOLOPT, sizeof(bm), &bm) || + nla_put_u32(skb, IFLA_BR_FDB_N_LEARNED, + atomic_read(&br->fdb_n_learned)) || + nla_put_u32(skb, IFLA_BR_FDB_MAX_LEARNED, br->fdb_max_learned)) return -EMSGSIZE; #ifdef CONFIG_BRIDGE_VLAN_FILTERING -- 2.42.0