From patchwork Wed Jul 19 13:57:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 704492 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 926F8EB64DA for ; Wed, 19 Jul 2023 13:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231420AbjGSN5o (ORCPT ); Wed, 19 Jul 2023 09:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbjGSN5n (ORCPT ); Wed, 19 Jul 2023 09:57:43 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E68A1FFB; Wed, 19 Jul 2023 06:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LCVrFmt5NKhRTsGhnlgU6ohT9/+6HK9tEwzn4JDeIz805o+ky1WjX4zXEQTKlz2ZPp+J4ComvIq++VggrUUZbVotQktsIHG9PWKbrdqVTbp/30Esx0emdb/LvEZ0iGSl/IrwSM4z+NC1NwLk2oPWoskFlg0MOF2whsDljg8wAo1TXjy9H6R21bpxJWFB1AklDkciYPt/MGq/YIIBhX3MU2mx6FR5vp9gXq8tc2VB3fZmld7oP4Kk4ErAHD0CBbeh5Rbx1+Y1f9n+7JTF4bVbSJh4/CN6Blbg4C2FgaDcePOk4S5EjnbJWD2sZwD58AANX2m6pqI+DCEfYWdSMWtt1w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mHreOrxHmeQscue0UYzAUvLaEA5x2VQ2tDaoVTf6vR0=; b=Y6J7dLe3Bv6QXEFDj2Dv8aqd6p2Q3vWX2094cjd9tdaeMX6vHcq0M/xmdqHRS0gCa8NRgCxb4vzk76n1uiRGLMM23Oc9+dxYsAtxazwqKphKxlWlHIeJmE+u2E30TvDc72k0UrTxkaAor+Nf+H9tQzzxWGGzvpbxnWWdFkah/9+5DRipGs2S7fv023fxSmuMZtzfc45mpM9LvvN+ehc8Bp3n5Ue0kFlBDutcQSyesMvvhyDPWRu5BrmotvPEbMSpf/qcpc1fnngxFR7kFjfaNxbB2ACm+GrcOqqNq+XDIei5ESPsjNqBAEPSS0IIe2Cthvn/lPM+3nABOrkf00VJfQ== 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=mHreOrxHmeQscue0UYzAUvLaEA5x2VQ2tDaoVTf6vR0=; b=Pk0fRJ5l0cwtD8YsmKLHbSOJOYWr/ClDW1npDFvUJyo//FBFSEGnvPi+UXz65p56S5KgRjviXRwUCdV//QwQAN7d3004baNUnl+uIe5V/7SLOL3DTHa5A8EMPLRWcuhjn1JH0OXyqE3JRZV2ZP98yrETbwwIJLCQV1Kv3LZFdMrpBipCGUs1kszEJAr4Al5rz7UYKBB7lX3yEBXFWbq+HVRBb+/9O8IqOSX6muNlPn0JSe19K/muhbfUsTiUS4hf27bEH7Q+FwkECbQ5JOVPvLAgsTRFOB5HEAFKzbd4vduPVZgpC+vBdR5no/X40lWYrCOpmx76AvXoQMEy1PqDLQ== Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SJ0PR12MB6687.namprd12.prod.outlook.com (2603:10b6:a03:47a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Wed, 19 Jul 2023 13:57:27 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::982f:232b:f4af:29ec]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::982f:232b:f4af:29ec%5]) with mapi id 15.20.6609.022; Wed, 19 Jul 2023 13:57:27 +0000 From: Benjamin Poirier To: David Ahern , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" Subject: [PATCH net-next v2 4/4] selftests: net: Add test cases for nexthop groups with invalid neighbors Thread-Topic: [PATCH net-next v2 4/4] selftests: net: Add test cases for nexthop groups with invalid neighbors Thread-Index: Adm6SPOwIKYdSXmxeUyme8WchlbtrA== Date: Wed, 19 Jul 2023 13:57:27 +0000 Message-ID: <20230719-nh_select-v2-4-04383e89f868@nvidia.com> References: <20230719-nh_select-v2-0-04383e89f868@nvidia.com> In-Reply-To: <20230719-nh_select-v2-0-04383e89f868@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: YQBPR01CA0033.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01::41) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) x-mailer: b4 0.12.2 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB4373:EE_|SJ0PR12MB6687:EE_ x-ms-office365-filtering-correlation-id: b927cd76-6496-43f2-22e8-08db8860162e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YbBlhdjsajkkNGTzG6GYm6OJG5xLZ2wfMUzLsoEohLFkyPJiUHtDdsPdk6Jc929t8qD6j3wzR5scFAlbSpota3L322NKlArs3GNXcuIkbCRzGpqbhTsTtI0yRjjHJAAySRVfrl+6AiA3S+FNZW76hRhQUPZOnnouz0FE1JrZK81sxwlhotYZTrx9yYxoafWZJk/9bl+l58EviyyWfWvoZpDdYNf+jdwh9bN6CsmUY3uUZjB42kxMYKSIBOSgf90tSw7DtLedsbrO/pfvvnjVSBKY9CShFhXoyPpTt97OQ4SCvIVG/NEND/lSbElGSw2EiO7sochBgtQ0/hZYcg5yVhtxbnF3+KZbA03LE5+8Am2Y92EIdFYjL8quw/TzpYzpYd2399VcuEJYuUk6CwD0bpkAUSRMtOKe5RhkaUnvlw6eE0j3obXbJvdG0Cvbq1bPUtwuL1dXcv/mG+HvDPen8xWbOFuuiQy3XEjfLKeoEqvj01v7q1GDCEQLchk2aAfkLUQMiqJUoEC6qw6Rr6WuLK0hZaeqc5/1vbmrBh1T8Odp9Sv3CP5AYUTrFKK7d8wo x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB4373.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(366004)(136003)(346002)(39860400002)(396003)(451199021)(71200400001)(38100700002)(122000001)(2906002)(6512007)(6486002)(2616005)(83380400001)(36756003)(186003)(6506007)(26005)(86362001)(64756008)(478600001)(4326008)(66446008)(41300700001)(8936002)(8676002)(54906003)(110136005)(66556008)(66476007)(316002)(66946007)(5660300002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?6Hzk4atqK4krWnV1DWwJ+M3npQZL?= =?utf-8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xffFBYs4PYcC6CluyQc9uwknGyuZ+L7PND9Jmqdao2hOWbsz8M?= =?utf-8?q?zVrlPFTiwSfpPhyAIoeEi//g+ZQzBZ09w1Wg9dGD7uhWruXBF0w2Wuklu1Dg1WqAN?= =?utf-8?q?cyffm0v2SGHYhlvl77NR63mcd5rlwRMRu2hU9ckhhqFovCEKT3OZaRT1P7EurWXBA?= =?utf-8?q?YZtVbr/GLQMO2BzoT7TbTlK/U0BIPR0+2hn+dP750nuopusY5R/EHcLUgXgRO8kLy?= =?utf-8?q?IUjcW7kgawTDF+2QwhnQfvi3o2CxnHDAQ5F8A7KEhHMfcegoEfYB43iMsz++n9JcO?= =?utf-8?q?VF8GP9ab8z1aYEHKQNr6ohxx2BkD5lYnl5DzmgXwXYDlXQ3dHqj3xujbHUKuUqDp8?= =?utf-8?q?Mm+IeUGEsXLo+xL4hfYiN0UkEuD7xY2LmcPC3yD8a6L/WxBRiMg8QiuS7rSp4vix2?= =?utf-8?q?4fOcRBMZsvcDJr7ENHBtxeh1hFX+l87TGIgymhVbKPnTrEdQBhrR4fc81fsBZWtnL?= =?utf-8?q?Y3sAhm3VWn6F6R0LvsFcWWvmbaKex6XcXcCxtaoanGn3r3S6tzlbC1cR5FgDvdJsQ?= =?utf-8?q?Y596ykyhV1/XaL66sK+h9PwLMGWR6wwcmkigrvN+AzgK0F3apX0e2+I2DGTC8RLfe?= =?utf-8?q?8vdI6PrDc/+w?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b927cd76-6496-43f2-22e8-08db8860162e X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2023 13:57:27.3386 (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: opR0o+KslADtf3gXgBq+ILajGfBVh4AlIMKsae1jbjrcMtSFeWIXQkNbpXUoZAMX9sfpoZSbej1/0uawRbRptA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6687 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add test cases for hash threshold (multipath) nexthop groups with invalid neighbors. Check that a nexthop with invalid neighbor is not selected when there is another nexthop with a valid neighbor. Check that there is no crash when there is no nexthop with a valid neighbor. The first test fails before the previous commit in this series. Signed-off-by: Benjamin Poirier Reviewed-by: David Ahern --- tools/testing/selftests/net/fib_nexthops.sh | 129 ++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh index 0f5e88c8f4ff..54ec2b7b7b8c 100755 --- a/tools/testing/selftests/net/fib_nexthops.sh +++ b/tools/testing/selftests/net/fib_nexthops.sh @@ -29,6 +29,7 @@ IPV4_TESTS=" ipv4_large_res_grp ipv4_compat_mode ipv4_fdb_grp_fcnal + ipv4_mpath_select ipv4_torture ipv4_res_torture " @@ -42,6 +43,7 @@ IPV6_TESTS=" ipv6_large_res_grp ipv6_compat_mode ipv6_fdb_grp_fcnal + ipv6_mpath_select ipv6_torture ipv6_res_torture " @@ -370,6 +372,27 @@ check_large_res_grp() log_test $? 0 "Dump large (x$buckets) nexthop buckets" } +get_route_dev() +{ + local pfx="$1" + local out + + if out=$($IP -j route get "$pfx" | jq -re ".[0].dev"); then + echo "$out" + fi +} + +check_route_dev() +{ + local pfx="$1" + local expected="$2" + local out + + out=$(get_route_dev "$pfx") + + check_output "$out" "$expected" +} + start_ip_monitor() { local mtype=$1 @@ -575,6 +598,112 @@ ipv4_fdb_grp_fcnal() $IP link del dev vx10 } +ipv4_mpath_select() +{ + local rc dev match h addr + + echo + echo "IPv4 multipath selection" + echo "------------------------" + if [ ! -x "$(command -v jq)" ]; then + echo "SKIP: Could not run test; need jq tool" + return $ksft_skip + fi + + # Use status of existing neighbor entry when determining nexthop for + # multipath routes. + local -A gws + gws=([veth1]=172.16.1.2 [veth3]=172.16.2.2) + local -A other_dev + other_dev=([veth1]=veth3 [veth3]=veth1) + + run_cmd "$IP nexthop add id 1 via ${gws["veth1"]} dev veth1" + run_cmd "$IP nexthop add id 2 via ${gws["veth3"]} dev veth3" + run_cmd "$IP nexthop add id 1001 group 1/2" + run_cmd "$IP ro add 172.16.101.0/24 nhid 1001" + rc=0 + for dev in veth1 veth3; do + match=0 + for h in {1..254}; do + addr="172.16.101.$h" + if [ "$(get_route_dev "$addr")" = "$dev" ]; then + match=1 + break + fi + done + if (( match == 0 )); then + echo "SKIP: Did not find a route using device $dev" + return $ksft_skip + fi + run_cmd "$IP neigh add ${gws[$dev]} dev $dev nud failed" + if ! check_route_dev "$addr" "${other_dev[$dev]}"; then + rc=1 + break + fi + run_cmd "$IP neigh del ${gws[$dev]} dev $dev" + done + log_test $rc 0 "Use valid neighbor during multipath selection" + + run_cmd "$IP neigh add 172.16.1.2 dev veth1 nud incomplete" + run_cmd "$IP neigh add 172.16.2.2 dev veth3 nud incomplete" + run_cmd "$IP route get 172.16.101.1" + # if we did not crash, success + log_test $rc 0 "Multipath selection with no valid neighbor" +} + +ipv6_mpath_select() +{ + local rc dev match h addr + + echo + echo "IPv6 multipath selection" + echo "------------------------" + if [ ! -x "$(command -v jq)" ]; then + echo "SKIP: Could not run test; need jq tool" + return $ksft_skip + fi + + # Use status of existing neighbor entry when determining nexthop for + # multipath routes. + local -A gws + gws=([veth1]=2001:db8:91::2 [veth3]=2001:db8:92::2) + local -A other_dev + other_dev=([veth1]=veth3 [veth3]=veth1) + + run_cmd "$IP nexthop add id 1 via ${gws["veth1"]} dev veth1" + run_cmd "$IP nexthop add id 2 via ${gws["veth3"]} dev veth3" + run_cmd "$IP nexthop add id 1001 group 1/2" + run_cmd "$IP ro add 2001:db8:101::/64 nhid 1001" + rc=0 + for dev in veth1 veth3; do + match=0 + for h in {1..65535}; do + addr=$(printf "2001:db8:101::%x" $h) + if [ "$(get_route_dev "$addr")" = "$dev" ]; then + match=1 + break + fi + done + if (( match == 0 )); then + echo "SKIP: Did not find a route using device $dev" + return $ksft_skip + fi + run_cmd "$IP neigh add ${gws[$dev]} dev $dev nud failed" + if ! check_route_dev "$addr" "${other_dev[$dev]}"; then + rc=1 + break + fi + run_cmd "$IP neigh del ${gws[$dev]} dev $dev" + done + log_test $rc 0 "Use valid neighbor during multipath selection" + + run_cmd "$IP neigh add 2001:db8:91::2 dev veth1 nud incomplete" + run_cmd "$IP neigh add 2001:db8:92::2 dev veth3 nud incomplete" + run_cmd "$IP route get 2001:db8:101::1" + # if we did not crash, success + log_test $rc 0 "Multipath selection with no valid neighbor" +} + ################################################################################ # basic operations (add, delete, replace) on nexthops and nexthop groups #