From patchwork Tue May 9 03:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13235327 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3C4D17F8 for ; Tue, 9 May 2023 03:12:27 +0000 (UTC) Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1C6A251 for ; Mon, 8 May 2023 20:12:10 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ab14cb3aaeso37459595ad.2 for ; Mon, 08 May 2023 20:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683601930; x=1686193930; 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=Xz8EbTp6cnKXRSu16PeJ7H/2zeR4wrxo2ZYzQZzLLts=; b=eiu8S3T2yblblJ8f5KE7BCO+Y1rDYimfXHozUtWim/2SIocjk3HiOtGQJH3B9TFNTl 13RW6FZAKF+Z+yXf+ixyoTZDDD1w543GxyiFPxesPny8324xYIGVy7o3dGNhhJVQhSZK qnydAaxVdJem8/x7PzFTM1TPTf8dspcKu3AoXYQuiXiH23jW9PIPmgGaY7gYrDY3SILe SFfuiF8tVbRXfO9B6Mr1JVTu7JGCfGlO4oN7v8w4gUoH9pPO88/W7SO0D6QjhI6sqpMG VUUyUwcLeoSkRAjWELnVuXedXRBCXYb/dee+cXuSoMAPFKq88XoNweNOsqbH6VSCuvuK 7kng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683601930; x=1686193930; 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=Xz8EbTp6cnKXRSu16PeJ7H/2zeR4wrxo2ZYzQZzLLts=; b=CrRHiHWXtLa5/H2I6cfG+KrwUA6QtMwyJZaIGucvQ2C1EonqbKLaQ0tO7cPZre0koR CdWlbMehojvfsw+fBuFAqV03tgL53L4n8ZaQn8wFg997b6oqPh0H7E3pAKUMP+qLtTKG OqVLyYyzWqPIDBPgW3wPhOmZEdSu1URbobwIesZs7+nMnOWiOqP28aDE20Dk93fHZwlq x6jl8s42lhRfdadrtkhk+MnZExRwboSWP+ySkwDPU5Qj/cMNljN4RKEt3ei0sda4XVvP aohQl3OJ8Xg2zLibxvQYF8atjEmJcraEldziEknGsYKyDc9Zz5L4bOezKCLkBw2VJLW0 uwsA== X-Gm-Message-State: AC+VfDwAzDOt+17m00yA0x997HqAXX1WxDCEnJS5DbpPnOX3qMKHDHdp okJByqEgq8LFHXDlrGjZKCseOS/38c0FoqUS X-Google-Smtp-Source: ACHHUZ6+3oCJOeMvV+OoH3c+8ZLeirXGotMjj2Ojt4lHmKQN0XGvVoV1E0JqH7myZy3+xJjRzWzEug== X-Received: by 2002:a17:902:ea0a:b0:1a9:3447:71ef with SMTP id s10-20020a170902ea0a00b001a9344771efmr16235322plg.54.1683601929781; Mon, 08 May 2023 20:12:09 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm250768plx.38.2023.05.08.20.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:12:09 -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 , Simon Horman , Hangbin Liu Subject: [PATCHv3 net 1/4] bonding: fix send_peer_notif overflow Date: Tue, 9 May 2023 11:11:57 +0800 Message-Id: <20230509031200.2152236-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230509031200.2152236-1-liuhangbin@gmail.com> References: <20230509031200.2152236-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. Reported-by: Liang Li Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2090053 Fixes: 07a4ddec3ce9 ("bonding: add an option to specify a delay between peer notifications") Signed-off-by: Hangbin Liu --- v3: use NLA_POLICY_FULL_RANGE to limit the max value. The NLA_POLICY_MAX only support s16 max limit. v2: define send_peer_notif as u32 and limit the peer_notif_delay to 300s --- drivers/net/bonding/bond_netlink.c | 7 ++++++- drivers/net/bonding/bond_options.c | 8 +++++++- include/net/bonding.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index c2d080fc4fc4..27cbe148f0db 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c @@ -84,6 +84,11 @@ static int bond_fill_slave_info(struct sk_buff *skb, return -EMSGSIZE; } +/* Limit the max delay range to 300s */ +static struct netlink_range_validation delay_range = { + .max = 300000, +}; + static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_MODE] = { .type = NLA_U8 }, [IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 }, @@ -114,7 +119,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY, .len = ETH_ALEN }, [IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NLA_U8 }, - [IFLA_BOND_PEER_NOTIF_DELAY] = { .type = NLA_U32 }, + [IFLA_BOND_PEER_NOTIF_DELAY] = NLA_POLICY_FULL_RANGE(NLA_U32, &delay_range), [IFLA_BOND_MISSED_MAX] = { .type = NLA_U8 }, [IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED }, }; diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 0498fc6731f8..f3f27f0bd2a6 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 a60a24923b55..0efef2a952b7 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 Tue May 9 03:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13235328 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C19120F7 for ; Tue, 9 May 2023 03:12:28 +0000 (UTC) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC5183E7 for ; Mon, 8 May 2023 20:12:14 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1aaed87d8bdso37472985ad.3 for ; Mon, 08 May 2023 20:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683601933; x=1686193933; 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=bgmAIX2R0setgTaRXMJc5M9uinv3GbYBn1yWtinkYOlDmrmwBSTfYVUlaabMlcXrSm 575pJTIXIsWTelr52iN6Pxd+OPdQ6Q6+OebD7ou0NE9nO6j0RgecbC3QE5Gcf9tH3bdE heFGNJjZLUL5dRS/c/uMFLdC1FShXK+vjJs3I+oQfY//Lc6R1e1F0+nWca5S8pThizRH Pmph2+QtQs9aoieotVJ8VqIXtmEVzlsOkfw+V+76z2IzXixnVneeOKwvg6WTmK1RAxBu lu5EkDpMSzQGxYEHlukg0sCaGL+jvKbPZm1YRGUIIGDODPj7ilACAc3vMISmChg9olL9 G/dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683601933; x=1686193933; 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=VpZ3wr95Ch9ie7Usu1sLJX9BJUKgwitGCEOGt2eWY9tMZJeB6kCljskB+lI/opbvW/ alIail1UzgGxh4QobD5aTwQ386w6a2SmctFoJeSUHVSeFeYyfgYwqztEaFApQ+DVH3lu VVYTVyceOvTYOMqFadHTj3m6WERYuZaIGpueyv8LWFIeyNhDHeTdlL7NopWcImwq4naB ozdc9t3gLqf18OvfZvOHWgFjrzn3aJ5FMUEYwRjhIjtcYUbT/EN0po7aDlQPGma1rfll RAeKqNa9tVXVjDKXgXh8tehudtrV9hHL0P06JjkfRJg5BvGAbl7P47L99uS3uKuap8hN STuA== X-Gm-Message-State: AC+VfDz9qQQ3wZ9WMsRNdS+fNM5+r86qS0a5Wi2xSA684vrBg1vii98h qrvA1HKqCuAlysSHywizXNH121Fxzvx3602J X-Google-Smtp-Source: ACHHUZ6BBQ7gpP05KGPWcWQERKXguepKiuIBxIhE4PaH6FrW/H3BT21ziIokT9tsMYwGPKNyXJlAWw== X-Received: by 2002:a17:902:e846:b0:1ac:85e9:3cab with SMTP id t6-20020a170902e84600b001ac85e93cabmr4229557plg.56.1683601933003; Mon, 08 May 2023 20:12:13 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm250768plx.38.2023.05.08.20.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:12:12 -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 , Simon Horman , Hangbin Liu Subject: [PATCHv3 net 2/4] Documentation: bonding: fix the doc of peer_notif_delay Date: Tue, 9 May 2023 11:11:58 +0800 Message-Id: <20230509031200.2152236-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230509031200.2152236-1-liuhangbin@gmail.com> References: <20230509031200.2152236-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 Tue May 9 03:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13235329 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DA620F2 for ; Tue, 9 May 2023 03:12:28 +0000 (UTC) Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 331C9659F for ; Mon, 8 May 2023 20:12:17 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ab1ce53ca6so38323365ad.0 for ; Mon, 08 May 2023 20:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683601936; x=1686193936; 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=N2Gjn/Xn7/rXFOIsbTHIvULH0U+fm/sURSyKXcEl/zg=; b=S9s4gTPwngiuYYvTAxFSFmMburvz76tB/1uJbeQxBQg8TW1sdueiQrExSafvNv1xOu ZMlyW7v3fZSPE/OAnclfglKjKNxhBihDYoOZH0w77ogWwpDKKfsCw6m3e0mUFDAFrzLa 5cFiD+rY6gU/igMyS5yYhLKmOG9XfZzYo42bD7YJBbLyBlV1Oy4PP1F8CfEBsC9eR4jQ +ftsYHSUhtBqkNYzOk+99knrUKmLq4uzpswpsEfhGfuoF2iyHAXvdgO4UP4nLVh6qt9e 1C4g6aCD0sRAwxV1kYAOcuEZZR6J3Z2iwL/yMUd73sOcAB2g9jRYoCvo8LhPqIlCnGv2 HmSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683601936; x=1686193936; 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=N2Gjn/Xn7/rXFOIsbTHIvULH0U+fm/sURSyKXcEl/zg=; b=BPSn9cMiv80SQ3nizbmyTVd6BbaCurCAjPON1zFYI6DkqOqA1eS0ngw4EGYBAMFk26 J5scwwFg7lqlUIlhcm/Sh43WvyNT+54qWGfNt3Fd7uyoHXlPsRLfOGVNojmwvmucnq68 PNTHB2IwkhFP6YGXIQ/0L+t4EdyiJgyuIrVP8kJbe4CRyjr0Mc4ZRRCxaoz3UsOS5t7b v+o9Y49poWjpYLXRsJVB+gM2UJMclCPw3cg8rom5AVTV5J6S6yLvHy6Qs45j4UBrhmoX Gh/GMOlpBzEZPXXH7v/NfED5THfsR4cnZ9NZ5x1zN9G7vK1Q9ZSJAB96dtalP/Uz2uyr 52Gw== X-Gm-Message-State: AC+VfDyOG+z+ty99JppRPuJATv2gzg8E4m4t0HMMrm9Yelqtme2rPm2m v/8L1lZDGz1MH+50NdnCY1Q9TktRV6PkIt+U X-Google-Smtp-Source: ACHHUZ6MfVYEWu/MM9sOe2+s9cJzunJ2ex6Raaxdp0ExbfPDjEZu8c/w35nHvFvnJ9Wms2dWRa5Aaw== X-Received: by 2002:a17:902:d4c6:b0:1ac:8ad0:1707 with SMTP id o6-20020a170902d4c600b001ac8ad01707mr3952107plg.1.1683601936107; Mon, 08 May 2023 20:12:16 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm250768plx.38.2023.05.08.20.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:12:15 -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 , Simon Horman , Hangbin Liu Subject: [PATCHv3 net 3/4] selftests: forwarding: lib: add netns support for tc rule handle stats get Date: Tue, 9 May 2023 11:11:59 +0800 Message-Id: <20230509031200.2152236-4-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230509031200.2152236-1-liuhangbin@gmail.com> References: <20230509031200.2152236-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org When run the test in netns, it's not easy to get the tc stats via tc_rule_handle_stats_get(). With the new netns parameter, we can get stats from specific netns like num=$(tc_rule_handle_stats_get "dev eth0 ingress" 101 ".packets" "-n ns") 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 057c3d0ad620..9ddb68dd6a08 100755 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -791,8 +791,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 Tue May 9 03:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13235330 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A4095256 for ; Tue, 9 May 2023 03:12:29 +0000 (UTC) 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 C72D87ED2 for ; Mon, 8 May 2023 20:12:20 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6436e075166so3974133b3a.0 for ; Mon, 08 May 2023 20:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683601939; x=1686193939; 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=kOeeKsuQ00vEMLgss4RT6cm83FEuwEX/53MbDqidwMAq29v5DUa96D2mTIN2V1yI8G pjVESI2qNRVoPvlO5wneSRFywMUN9eij5D/7RYY3sY1SSElui35p7gumpbgOH3l/exr0 hg7XGzv2c4vsGQ65UJ9uUFrxjh1sPCg10eOnfbKGB/UNIQZIDRJRKPf+q3FzHBaPSTCb dLub6x82p00bqwaRZ9GrTxbbSYvm62ydWdTfXFNnaLrt4TolWcGSPoF834Ms6pUlst7H cY8l4YL20yms84sGTw1hAT7CoMZY5qAuExSnyo9IvwuRLGlEZMfwfb6ExYuaY4kqbwwT P8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683601939; x=1686193939; 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=OJyleHqjWk0bLmpw4H+M+irisUxQyeaNC7quye0namaZahSrPqwNjKcHhxtYiAue+U XlkeuMCySA1mHexhDST17hd3L06RROn4jXY7eVtRRTbhOHErWywDMXeT+QJK5fkFKRgK O7yLYT1HniHpOVcnxQT8pfwzHd5gWNBLpJoersxn/iTI19qpoHcV5LjZXhZ1sf/kv1w8 k+yLIYphXMZqMXMm/oBZTt5ok6yQvEzG8Cu3cO0Rh7a/qxrQQeqzbxl+QiPXux3KUI/O TdD71DdeBBDfbXvSKMMkjsM2PtNJWxU0lkhKFhKVhRandpqiL7A/Idxb7+lThbz88XcQ YEVA== X-Gm-Message-State: AC+VfDzllUkG/nZT2YAKdEmgV3Yoe0Ab1F82FeX5Dx2MYyI84ZUANSNX rJNyLackPa312O7sk0NhWYM4ejNUqoIDoM2S X-Google-Smtp-Source: ACHHUZ5Kg+RkPU/vABzty7mo2Rlulk7V7yNE/ttkhFFCpdd4TR0gEHFdnGvIAhOo4dnME+Pcw48k6A== X-Received: by 2002:a05:6a20:7348:b0:db:b7:fe3f with SMTP id v8-20020a056a20734800b000db00b7fe3fmr16066348pzc.10.1683601939369; Mon, 08 May 2023 20:12:19 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm250768plx.38.2023.05.08.20.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 20:12:18 -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 , Simon Horman , Hangbin Liu Subject: [PATCHv3 net 4/4] kselftest: bonding: add num_grat_arp test Date: Tue, 9 May 2023 11:12:00 +0800 Message-Id: <20230509031200.2152236-5-liuhangbin@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230509031200.2152236-1-liuhangbin@gmail.com> References: <20230509031200.2152236-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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