From patchwork Thu Apr 27 03:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13225147 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88098C77B61 for ; Thu, 27 Apr 2023 03:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242825AbjD0DjY (ORCPT ); Wed, 26 Apr 2023 23:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbjD0DjV (ORCPT ); Wed, 26 Apr 2023 23:39:21 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC349212D for ; Wed, 26 Apr 2023 20:39:20 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-63b620188aeso9307060b3a.0 for ; Wed, 26 Apr 2023 20:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682566760; x=1685158760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c6SMA9y8JQBDxsApK2oZlZlBs4sUItW2ct+DINr1dnM=; b=kmVASjCIpjCVMietVi+rU5OzjE2uEYXEi0tthSnXy9buMgDYn5L+42/ZQbB9bYRLnX m5U0+oBfZpA3n5KlFoLAgkzYlMlBpuW1cLLXwXhJpFJsbigRp1F7cvSHocNqOapBjkzC YcoNVfk2Riy110vD2CACF9qtOHTt6mTlu6iVNSZM9urvjn81OVTNoY5BX3B7z6bNWdT0 tcRqRNeD/l1j0Wwzng2atytWmYbMruvS/kGlE4F7EK5OKRXOs/K0XlBUIb9gpYh1reL3 XGWf5ENba/zHYRzfEHiqfwJ6UYQ8+pwotbBflXUBLIfzmV9llfq91LFi05GXoYr0VFJ0 BWGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682566760; x=1685158760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c6SMA9y8JQBDxsApK2oZlZlBs4sUItW2ct+DINr1dnM=; b=ZWn3/QTTNZKLC2aPUyrwMbitdJD0FvmAQxxBUixf+Pdbw2nVvBQaTatXaKle4vtBZL YNuIoJnoRAt2xLih0J2R9Ch38mjeEKXb71lzKvooE2lyGqe354k+pRwY7fuG78Y+t4Ex DZQ3nRlZ/Ww9K2iUwoONbU4vzVxZCt/PKCevfl5+LufXpqnHCTspxsjd+2c8OyWIMXyv oFb+5kKsoDXJ/uqd9/LNhj6VS4zSkydMFBGnZFYFBe7jDYiYn1RO2nKJcbT4u6bNF+FZ iG9fBHn7neKeQGsttdiLBRWkFOe6XXfiTyopbIZE1vBSVlErSByXd2QqRUnGVpkPdkBV Nifg== X-Gm-Message-State: AC+VfDzaGFO7VGdBb+rqMxk/1PjwquuQTSm7FdxUcJUR3RCZ3tBzovo1 Wa/zShZ/BNi4CeyWpywSXoSbMBDIXuGYPj2f X-Google-Smtp-Source: ACHHUZ5P0vnupIqkAHLSmqFl1epO01YXXGDAinjx+tYCwacDIOPzVUgrkSXljvJDIm9vEdyUxMoJKQ== X-Received: by 2002:a05:6a00:190d:b0:636:e52f:631e with SMTP id y13-20020a056a00190d00b00636e52f631emr520961pfi.1.1682566759629; Wed, 26 Apr 2023 20:39:19 -0700 (PDT) Received: from Laptop-X1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h17-20020a056a001a5100b005abc30d9445sm12017743pfv.180.2023.04.26.20.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 20:39:19 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Vincent Bernat , Hangbin Liu Subject: [PATCHv2 net 1/4] bonding: fix send_peer_notif overflow Date: Thu, 27 Apr 2023 11:39:06 +0800 Message-Id: <20230427033909.4109569-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230427033909.4109569-1-liuhangbin@gmail.com> References: <20230427033909.4109569-1-liuhangbin@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Bonding send_peer_notif was defined as u8. Since commit 07a4ddec3ce9 ("bonding: add an option to specify a delay between peer notifications"). the bond->send_peer_notif will be num_peer_notif multiplied by peer_notif_delay, which is u8 * u32. This would cause the send_peer_notif overflow easily. e.g. ip link add bond0 type bond mode 1 miimon 100 num_grat_arp 30 peer_notify_delay 1000 To fix the overflow, let's set the send_peer_notif to u32 and limit peer_notif_delay to 300s. Fixes: 07a4ddec3ce9 ("bonding: add an option to specify a delay between peer notifications") Reported-by: Liang Li Signed-off-by: Hangbin Liu --- v2: define send_peer_notif as u32 and limit the peer_notif_delay to 300s --- drivers/net/bonding/bond_netlink.c | 6 ++++++ drivers/net/bonding/bond_options.c | 8 +++++++- include/net/bonding.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index c2d080fc4fc4..09a501cdea0c 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -244,6 +244,12 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[], if (data[IFLA_BOND_PEER_NOTIF_DELAY]) { int delay = nla_get_u32(data[IFLA_BOND_PEER_NOTIF_DELAY]); + if (delay > 300000) { + NL_SET_ERR_MSG_ATTR(extack, data[IFLA_BOND_PEER_NOTIF_DELAY], + "peer_notif_delay should be less than 300s"); + return -EINVAL; + } + bond_opt_initval(&newval, delay); err = __bond_opt_set(bond, BOND_OPT_PEER_NOTIF_DELAY, &newval, data[IFLA_BOND_PEER_NOTIF_DELAY], extack); diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index f71d5517f829..5310cb488f11 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -169,6 +169,12 @@ static const struct bond_opt_value bond_num_peer_notif_tbl[] = { { NULL, -1, 0} }; +static const struct bond_opt_value bond_peer_notif_delay_tbl[] = { + { "off", 0, 0}, + { "maxval", 300000, BOND_VALFLAG_MAX}, + { NULL, -1, 0} +}; + static const struct bond_opt_value bond_primary_reselect_tbl[] = { { "always", BOND_PRI_RESELECT_ALWAYS, BOND_VALFLAG_DEFAULT}, { "better", BOND_PRI_RESELECT_BETTER, 0}, @@ -488,7 +494,7 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .id = BOND_OPT_PEER_NOTIF_DELAY, .name = "peer_notif_delay", .desc = "Delay between each peer notification on failover event, in milliseconds", - .values = bond_intmax_tbl, + .values = bond_peer_notif_delay_tbl, .set = bond_option_peer_notif_delay_set } }; diff --git a/include/net/bonding.h b/include/net/bonding.h index c3843239517d..2d034e07b796 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -233,7 +233,7 @@ struct bonding { */ spinlock_t mode_lock; spinlock_t stats_lock; - u8 send_peer_notif; + u32 send_peer_notif; u8 igmp_retrans; #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry; From patchwork Thu Apr 27 03:39:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13225148 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B162BC77B61 for ; Thu, 27 Apr 2023 03:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242898AbjD0Djd (ORCPT ); Wed, 26 Apr 2023 23:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242863AbjD0Dj0 (ORCPT ); Wed, 26 Apr 2023 23:39:26 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861F6212D for ; Wed, 26 Apr 2023 20:39:24 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-63b5c4c76aaso5678188b3a.2 for ; Wed, 26 Apr 2023 20:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682566763; x=1685158763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u4GgPuMvOtgtHE50nx3nV3rRoZO6RT1RIo2g9Oqwf7Q=; b=ady0oyrs5B1+86YKVMRQtdrbLukvRVeIJrRDjI7jS1xy9tg2Jw8pLIKjGN8+mBinQJ iBQzP26wGR9xY/DCNbpckHpwALMZmo5YUdAWu2yUv18q91g6I7+g9BSp+/qGHW4leICh 5usfZ4NzwlS8t+sSCIzmzzqwAMT/LF6aeOxWDVb7eVPEi2ex/DSfFZLaJ+oNg0HyGCq2 S0yynzAhHvHG5zVANkqOBPFVlQ6tuRpoen9IdK4ZFu2eQ7uHVsvZm49zlJs9w6NKm2Ul Y8RvJlB9J1BmNyA7lwdH70d3Vh4I3ZNzvDCqwt7Xn5KwBP4YwE2cgHZEYkUM5zGFgwFK DKZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682566763; x=1685158763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u4GgPuMvOtgtHE50nx3nV3rRoZO6RT1RIo2g9Oqwf7Q=; b=LyfrTY2lONn3QncidVvMbCe6EILZCyR6T9tSsnL+mm+pN/MUC5TPFY2cs2LOLt4nmd i1k7ypGnl31Jilu4OMJkqfclE/ynqT9Q5+EfnB+SXXmnInOBklhygFPAL/E4LE8RiPol Nm3yUGqx/+3t9bfQHbzwnJ7wtwRtVoeGszJWumb9rt94BORm6gTxC3wyssCji43hKDuX O7leNPvHGNlr6vZxKYzoGWH5UoddOikw1NKOKQxmss0ftwNDiM9i+aIfO0DeimgjYFwj oSsJghgqs1Syh0gO6Q4zbUrAIKJ4tvUmojtwSiu1BPUFsOnZX/3/QABcf6bG19xesiNY BnSg== X-Gm-Message-State: AC+VfDwWj6XvxZBpiRgG/vGKlevvFa92tiS3iJzE9PbcSLgxA4gbC61A s+3qTDjntvT6zbOEkxXEl6F04aywyrk8OjzS X-Google-Smtp-Source: ACHHUZ4dzwOvmchzAnphNDDmz4nHHsMa+J0XNAm685xX6ghRvxQI3xYjhACL01Ud0tK+mOB+27dGNw== X-Received: by 2002:a05:6a00:2344:b0:63d:311a:a16b with SMTP id j4-20020a056a00234400b0063d311aa16bmr333309pfj.23.1682566763458; Wed, 26 Apr 2023 20:39:23 -0700 (PDT) Received: from Laptop-X1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h17-20020a056a001a5100b005abc30d9445sm12017743pfv.180.2023.04.26.20.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 20:39:22 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Vincent Bernat , Hangbin Liu Subject: [PATCHv2 net 2/4] Documentation: bonding: fix the doc of peer_notif_delay Date: Thu, 27 Apr 2023 11:39:07 +0800 Message-Id: <20230427033909.4109569-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230427033909.4109569-1-liuhangbin@gmail.com> References: <20230427033909.4109569-1-liuhangbin@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Bonding only supports setting peer_notif_delay with miimon set. Fixes: 0307d589c4d6 ("bonding: add documentation for peer_notif_delay") Signed-off-by: Hangbin Liu --- Documentation/networking/bonding.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/bonding.rst b/Documentation/networking/bonding.rst index adc4bf4f3c50..28925e19622d 100644 --- a/Documentation/networking/bonding.rst +++ b/Documentation/networking/bonding.rst @@ -776,10 +776,11 @@ peer_notif_delay Specify the delay, in milliseconds, between each peer notification (gratuitous ARP and unsolicited IPv6 Neighbor Advertisement) when they are issued after a failover event. - This delay should be a multiple of the link monitor interval - (arp_interval or miimon, whichever is active). The default - value is 0 which means to match the value of the link monitor - interval. + This delay should be a multiple of the MII link monitor interval + (miimon). + + The valid range is 0 - 300000. The default value is 0, which means + to match the value of the MII link monitor interval. prio Slave priority. A higher number means higher priority. From patchwork Thu Apr 27 03:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13225149 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8FFBC77B61 for ; Thu, 27 Apr 2023 03:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242875AbjD0Dji (ORCPT ); Wed, 26 Apr 2023 23:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242874AbjD0Dja (ORCPT ); Wed, 26 Apr 2023 23:39:30 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A223C3F for ; Wed, 26 Apr 2023 20:39:28 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b60365f53so9654610b3a.0 for ; Wed, 26 Apr 2023 20:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682566767; x=1685158767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=485fSWTzxfO4MaaYixxcOQ+EgmPdfYoR20+Ca5UsZVM=; b=dIrrH3IwkElvUoeIorcmymSLJ+4vaxcoTUhLWSQkA5t4Rd7+Tv2HHPMtKou7/M8Gaj II4m/XOm0jDh1c7fC4n9/6YX8oZ1gpUehmNCrUkEv6fLjsq47oYLyyUMEFHFT8mT9l9f nXU1GGUQVhdt65QQwJI5KZTBsDike6EjCrE/LeZtINZPlBs/ih7OUvj6f8f2bvCdLw0C tobufRF7PkpL7YDjSom6Vzg+dmX2pWK81JvGsLrlr33ayhVowLnyVGxffGkKreLe3uzi Mw88VGF6U/Y3skA2fg7JOhmJYRBNwkW6fvo8G7dkXsCl9u2u9y+Ttk/Ae3S34ukxiCVi fHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682566767; x=1685158767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=485fSWTzxfO4MaaYixxcOQ+EgmPdfYoR20+Ca5UsZVM=; b=Z9cPB4l441oOX3Dk9crOZzgWsAPT5x0XwW+L2u/x1fi3JBDETIlEs5B1T1m50csRKj fB7NqJM3KPAicHfIYuSDWu14Xetq7VDWFg/TwO2yGOhXzyE78ILxF1cvMjCXDVOej56A 8KeaiqR1DY6p4AV5iblNaQ1Vb+MN1HYxsiQmk+z+rVX8T4ya7OX2C58oxf3hHuFGal8N SJ0nJ+NSMbSgRbghekGSevbQTbJ/OyYL3NhTaMlpzDs1xh0WQHK4QHB5U9DrkYq5PgxO 5K/ObnWTofG/gVPZAYmICk8DJI7aL9+j4flQtcxwXZ6pTsxS4CUVShN0OIoApn/kQTog TBiw== X-Gm-Message-State: AC+VfDxo7Dh1wWttANw/QOF0ejenaKuGFzyDjDuUqbMKmwiW6Nf1ePoq fuhdBzm426Ufl6uPtxIFWLXoEMEzARN9pEtl X-Google-Smtp-Source: ACHHUZ6F2pTSLl+BGQIFDZ/vuR4lh+NyXbbBcqna6OiEOdITBL9BY7BOXSzpF8/0HjWKPpO9UYNTMQ== X-Received: by 2002:a05:6a00:2d84:b0:63b:e4:554 with SMTP id fb4-20020a056a002d8400b0063b00e40554mr548530pfb.4.1682566767326; Wed, 26 Apr 2023 20:39:27 -0700 (PDT) Received: from Laptop-X1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h17-20020a056a001a5100b005abc30d9445sm12017743pfv.180.2023.04.26.20.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 20:39:26 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Vincent Bernat , Hangbin Liu Subject: [PATCHv2 net 3/4] selftests: forwarding: lib: add netns support for tc rule handle stats get Date: Thu, 27 Apr 2023 11:39:08 +0800 Message-Id: <20230427033909.4109569-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230427033909.4109569-1-liuhangbin@gmail.com> References: <20230427033909.4109569-1-liuhangbin@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Signed-off-by: Hangbin Liu --- tools/testing/selftests/net/forwarding/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d47499ba81c7..426bab05fe0a 100755 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -773,8 +773,9 @@ tc_rule_handle_stats_get() local id=$1; shift local handle=$1; shift local selector=${1:-.packets}; shift + local netns=${1:-""}; shift - tc -j -s filter show $id \ + tc $netns -j -s filter show $id \ | jq ".[] | select(.options.handle == $handle) | \ .options.actions[0].stats$selector" } From patchwork Thu Apr 27 03:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13225150 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E5BC77B61 for ; Thu, 27 Apr 2023 03:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242924AbjD0Djo (ORCPT ); Wed, 26 Apr 2023 23:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242907AbjD0Djd (ORCPT ); Wed, 26 Apr 2023 23:39:33 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E63212D for ; Wed, 26 Apr 2023 20:39:32 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b50a02bffso6506406b3a.2 for ; Wed, 26 Apr 2023 20:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682566772; x=1685158772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YeQDXm9CMBUR8AZx0MS+ObA2072iRcqiixIQ1S3eJEE=; b=i7OmKyDE6tnYR2ACl3ePynhT8RBKJNfahShx4vwm+3sC6PnsUR5SJqewoJ8u+CDXuH 57pANs3xxyAgz2WOqhrefmvv4RMylEfj1x3MtEQJLbDJKcBrcE5nLjggKmgCpJK6w4NO upind+RIzGeycafQGdkZeod+crBUJUgX78rDLQiMfB2WnEnDGZEl1hCQoalRjYnIo9gn ZU96JDk/L6YdTXp11IDimdag8Nmket2RHuNJVLVdEBIr3xLorP9/26FIdPmisRDP1liQ /ndtUw36nwwCbg2hIaxdbkcFZuIy6PvffuBGijNjMQsmyUUKdgs9jU1lNQAd3Yu7fi74 mDNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682566772; x=1685158772; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YeQDXm9CMBUR8AZx0MS+ObA2072iRcqiixIQ1S3eJEE=; b=IN15TepIRQqDHqjYXUlaCAyqzLSoJQc1tS2aZeAG2SJSRBBVMe6P9n/7p+h3R6HKqT gHyGF6A6vaTy5/taa+KnRHbU9FKxcWiwLD367ikBWWZDHFKtsZaoAAmQlpNlJ4DkoFsY X52P2hNw3q8CnF7M6Djt7a4GACHb6gKiKnaJUn8CEAIVAIgR63popqflf+QT5Xufx536 R9W7ikKK6gCdl8yhexet0JEqH2hIQ6HOF0/s1G6g+MZ4bJNbY1zSw95TNzo+5HzMppZL tB7uXth0FN9tJ8wI5DAszNggk6H36Yyr2nO1WgrKj8JEnBD9D/fqZlZSaGYCU6TyVvEw N6Pw== X-Gm-Message-State: AC+VfDwGsUdWObnqiIozdk6RFseEjISMLjY7/oy9XOn+FSphrx5By1a8 um9knLQfl7cFv+jvH/zkbbFrJEIuQGIYiHOS X-Google-Smtp-Source: ACHHUZ7wT9Tf5llVbur+R3hv6WRWrPmXmxbMT4a68MdmTzSv6XqF/1f8NqInw7ZileMIej8nHpOpJA== X-Received: by 2002:a05:6a00:218e:b0:638:7e00:3737 with SMTP id h14-20020a056a00218e00b006387e003737mr361256pfi.23.1682566771688; Wed, 26 Apr 2023 20:39:31 -0700 (PDT) Received: from Laptop-X1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id h17-20020a056a001a5100b005abc30d9445sm12017743pfv.180.2023.04.26.20.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 20:39:31 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Liang Li , Vincent Bernat , Hangbin Liu Subject: [PATCHv2 net 4/4] kselftest: bonding: add num_grat_arp test Date: Thu, 27 Apr 2023 11:39:09 +0800 Message-Id: <20230427033909.4109569-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230427033909.4109569-1-liuhangbin@gmail.com> References: <20230427033909.4109569-1-liuhangbin@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org TEST: num_grat_arp (active-backup miimon num_grat_arp 10) [ OK ] TEST: num_grat_arp (active-backup miimon num_grat_arp 20) [ OK ] TEST: num_grat_arp (active-backup miimon num_grat_arp 30) [ OK ] TEST: num_grat_arp (active-backup miimon num_grat_arp 50) [ OK ] Signed-off-by: Hangbin Liu --- .../drivers/net/bonding/bond_options.sh | 50 +++++++++++++++++++ .../drivers/net/bonding/bond_topo_3d1c.sh | 2 + 2 files changed, 52 insertions(+) diff --git a/tools/testing/selftests/drivers/net/bonding/bond_options.sh b/tools/testing/selftests/drivers/net/bonding/bond_options.sh index db29a3146a86..607ba5c38977 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond_options.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_options.sh @@ -6,6 +6,7 @@ ALL_TESTS=" prio arp_validate + num_grat_arp " REQUIRE_MZ=no @@ -255,6 +256,55 @@ arp_validate() arp_validate_ns "active-backup" } +garp_test() +{ + local param="$1" + local active_slave exp_num real_num i + RET=0 + + # create bond + bond_reset "${param}" + + bond_check_connection + [ $RET -ne 0 ] && log_test "num_grat_arp" "$retmsg" + + + # Add tc rules to count GARP number + for i in $(seq 0 2); do + tc -n ${g_ns} filter add dev s$i ingress protocol arp pref 1 handle 101 \ + flower skip_hw arp_op request arp_sip ${s_ip4} arp_tip ${s_ip4} action pass + done + + # Do failover + active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") + ip -n ${s_ns} link set ${active_slave} down + + exp_num=$(echo "${param}" | cut -f6 -d ' ') + sleep $((exp_num + 2)) + + active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") + + # check result + real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}") + if [ "${real_num}" -ne "${exp_num}" ]; then + echo "$real_num garp packets sent on active slave ${active_slave}" + RET=1 + fi + + for i in $(seq 0 2); do + tc -n ${g_ns} filter del dev s$i ingress + done +} + +num_grat_arp() +{ + local val + for val in 10 20 30 50; do + garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000" + log_test "num_grat_arp" "active-backup miimon num_grat_arp $val" + done +} + trap cleanup EXIT setup_prepare diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh index 4045ca97fb22..69ab99a56043 100644 --- a/tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh @@ -61,6 +61,8 @@ server_create() ip -n ${g_ns} link set s${i} up ip -n ${g_ns} link set s${i} master br0 ip -n ${s_ns} link set eth${i} master bond0 + + tc -n ${g_ns} qdisc add dev s${i} clsact done ip -n ${s_ns} link set bond0 up