Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1460796rdb; Wed, 20 Sep 2023 09:39:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsY8eMeKJg/Yp0QEtPakX58kD9VEiQQqsfY/BSoytVIbWo6Z9yOhEmkAha148t+H0SpbN1 X-Received: by 2002:a17:903:25cd:b0:1bb:b855:db3c with SMTP id jc13-20020a17090325cd00b001bbb855db3cmr2394871plb.41.1695227997826; Wed, 20 Sep 2023 09:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695227997; cv=none; d=google.com; s=arc-20160816; b=H/oLlhctUiGc3BDSDUkwZJd23P3hvnNs5w3YW/AIz+MbhRW469Ve8aUoGf4tBWOFBy oAjxXjAgKfcDEPMyEp782tyFoGbgTVzHx/A6eWAvxXXLW279BwwNUBq1JWe8dZogkyHu ZCg4i6Tl9hetMYyWISaInxNqINTj/ImDAtXWDn0a+ou8qus2RtfMKj8qbLAn6bwQz+ol c0Z39e6va3ZMLhkWeHF6XPmMyxJ0nN30gIxQ7kIxXI0RdehvWx8WBImq1Pjm/u8E9L3d 0xpxd0alldXMavJ2wDurdtsVlKqFblWlCDcvLtCNP1NOp1/TRxCV6NZAd0JKgFrR9h6D SH0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=WdySEJI2yS6LDSRHQg7SGzxRhw3iuitdUpfv1l3JcAY=; fh=r8zpVSSoSO6PfqQy7ooLS7GpPkua5AzwTepuYCrhBPo=; b=UEmWYz1YPmUT62pzKjH4xpvuIOJZkEw5genBm1bmvihYqe7+y/4pGORpO36cpmxDcF 7ccNoe78L/Z00mPtphMLaCkJde4IMpUUoTm9WwmDvcNZEkJgQoRu07+hDGvB/EcYzH24 HujLToWxPzSw2RaTRX8wh86X6vHndH4j1UThgKId8SoFDN3ZA9bvpuoVVd91yo5oYLNw 9ryCSHhEKH3w3VnW68pTlzJL5RwX73bR/eKpbjZT9On96yxrB5JFzEdDltWbxMP/qD+4 Oy/n5cQLdRaQMgq8fxKSjw3WWMviMmKlNjzEuwQNrugSO8LFKcvLAXs4xLbgsME3mGqn uRHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackwall-org.20230601.gappssmtp.com header.s=20230601 header.b=DC7g9gSc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l8-20020a170902f68800b001bc079974dbsi12928275plg.355.2023.09.20.09.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 09:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@blackwall-org.20230601.gappssmtp.com header.s=20230601 header.b=DC7g9gSc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 11E00802547C; Wed, 20 Sep 2023 03:50:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjITKun (ORCPT + 99 others); Wed, 20 Sep 2023 06:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232192AbjITKul (ORCPT ); Wed, 20 Sep 2023 06:50:41 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C3C997 for ; Wed, 20 Sep 2023 03:50:35 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9adb9fa7200so171706666b.0 for ; Wed, 20 Sep 2023 03:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20230601.gappssmtp.com; s=20230601; t=1695207034; x=1695811834; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=WdySEJI2yS6LDSRHQg7SGzxRhw3iuitdUpfv1l3JcAY=; b=DC7g9gScHH264+gpbJTEP+wT94XTBYYMmkqrHx6/WPA/3wViLI964kc6pFLJVReF6X sqOkuA5mzJjh5URLylNuwDWtyXHgerd+zlyc8TyI+0YvRYu4Een2PZ0skGMhzujL625C +ePY9wXpbS2285crO4xBhkADxBYnSJdkZYrho8ec9xqZ3xVkXlW8SBIl4plqgAuRTJnO jlaQllxo5tx+uPQQu9o0NplYTIhpLWeAUzCxUvi7xDhcnXx/dJ6dlWXT2bMBemI35G4R olz/dRMlpE23nyYlqfiig86BA8uVVnL0U2iTyauTRuleNHWCUVPTMi9FwWl1/v+miL2t 3fbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695207034; x=1695811834; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WdySEJI2yS6LDSRHQg7SGzxRhw3iuitdUpfv1l3JcAY=; b=SZjyKeeaZ5/Ol4D9mVZzPF6BBVtA9YG5dGaUtJw8376IyuzSpO/XdNhwJPAogA8AkH I2+V6dUZGFlmvPMW6x46HBIXUA8W3a3JKSFZ9QFIa5ksUPh1v8m4WWZ4+E1EAAqmNP+v 8drTDM5KIkx3bjyd05svYs2EKHsJ00zCE/jzDonox5m6DOgtPqhMjrd+FY9cZzA2qD7L GocMpY2tNsKzmvuyN2VMCYb4S8I8nieJMULtzMVrJ8gJL5N/mnti72i/UgGlqlz/eNEz jzaO5fLeMWd9ruGPIKiBKoFJfLSAmYigcTOjbjxWNzUCOet0v29N3gytSnPsrA5WBPL2 bxYA== X-Gm-Message-State: AOJu0Ywb2bKHUbTMQavOviGRTNnjz0EcQ/DuLvle9BoBs7bh1I6P+HxA PGipalM1KT3Qw9QV1l0JUFnkBQ== X-Received: by 2002:a17:907:3e15:b0:9ad:e3fd:d46c with SMTP id hp21-20020a1709073e1500b009ade3fdd46cmr7182594ejc.10.1695207033924; Wed, 20 Sep 2023 03:50:33 -0700 (PDT) Received: from [192.168.0.105] (haunt.prize.volia.net. [93.72.109.136]) by smtp.gmail.com with ESMTPSA id c6-20020a17090620c600b009888aa1da11sm9182888ejc.188.2023.09.20.03.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Sep 2023 03:50:33 -0700 (PDT) Message-ID: Date: Wed, 20 Sep 2023 13:50:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH net-next v4 4/6] net: bridge: Add netlink knobs for number / max learned FDB entries Content-Language: en-US To: Johannes Nixdorf , "David S. Miller" , Andrew Lunn , David Ahern , Eric Dumazet , Florian Fainelli , Ido Schimmel , Jakub Kicinski , 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 References: <20230919-fdb_limit-v4-0-39f0293807b8@avm.de> <20230919-fdb_limit-v4-4-39f0293807b8@avm.de> From: Nikolay Aleksandrov In-Reply-To: <20230919-fdb_limit-v4-4-39f0293807b8@avm.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 20 Sep 2023 03:50:44 -0700 (PDT) On 9/19/23 11:12, Johannes Nixdorf wrote: > 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 }, hmm? I thought this one was RO. > + [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 >