From patchwork Fri Aug 18 16:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13357984 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 E5F074430 for ; Fri, 18 Aug 2023 16:36:16 +0000 (UTC) Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C695C3AAE for ; Fri, 18 Aug 2023 09:36:15 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-56d455462c2so719424eaf.2 for ; Fri, 18 Aug 2023 09:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1692376575; x=1692981375; 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=/0vTjezjoSM1DOz+TAXl0KH6KmFNNk+EeAzo4+1prqo=; b=uLol21rTJ8zlthRUBaFgSevYbtXZX4yet/tpiqR3VujKxBl1NPoRivqii8lOuyvFy7 wheddWRh9mx2STYA6H2Uu42z6JUJHR8rsE8Jxy/VaFuYAp6mxBpKrpSjP9BweyXuimxv dQ8ARVDDTv4PFgVMGngMJ/PSFfQrZS+iW7mOOo3005yjZZji9TO6t0+KR8UugLONCmQi zx244mnRU84sMrD+ZEI+iBsTwbQNIvvaSslb692K263k5z3jfA/grnffV3JAxSG27b9p iTDZE9gCcY1nDxQGEZ7PontKn26ByXsN1GUgRd2GDUSXtfvNuYZ5N4Q1u5QUccu+cc6A J6/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692376575; x=1692981375; 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=/0vTjezjoSM1DOz+TAXl0KH6KmFNNk+EeAzo4+1prqo=; b=ihiExUR79FhnTYcaBvLJqfuUM/nhSQl457+LxpFshvdDBeJ6u1i1AQtAUwD4Qs/xRa 1QSr+fdr53Jpffm4hMWbgUXI0jKDg9+b2gGuhtVl7X0NPJFXjZDOY0VE4bXT2TChcERG zKFmrnVoj/6P/HC6LM35ivCvUV8HIEI8kHdgYnxrr8e/szkxiXA7Qiy9SetRmTDRskk2 F/f86jiwLPC/r16HOD1PF0ciIGHJRL/mt/aPcDCbZ0qoL4Q1pj/I1HPARe1inspaXffn +LxVhgCs9Agqt1Lnez/kUQMO27YVT9RFQL+fnJpfeS7JeQYa/AfgI7FQiaSF4Fm/S0nV XngQ== X-Gm-Message-State: AOJu0Yxum+NLIXYsxoRLrURc1BDKvrUPiibqX7S/uiYL8TGrkZq1LKGW V1p2p93y/5oHhqbB5aUQDwMOy7I0f4iQZMcLm98= X-Google-Smtp-Source: AGHT+IE7ZCRfbZQMn/peHeIwd+plzLAAyHhIZfAw1u0RDArOS+F7IgnuDa3uloNfabrFWwzlQhIh4A== X-Received: by 2002:a4a:6f56:0:b0:56c:7428:4a35 with SMTP id i22-20020a4a6f56000000b0056c74284a35mr3403976oof.7.1692376574986; Fri, 18 Aug 2023 09:36:14 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:bdfa:b54a:9d12:de38]) by smtp.gmail.com with ESMTPSA id f200-20020a4a58d1000000b005634e8c4bbdsm561531oob.11.2023.08.18.09.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 09:36:14 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next 1/5] selftests/tc-testing: cls_fw: add tests for classid Date: Fri, 18 Aug 2023 13:35:40 -0300 Message-Id: <20230818163544.351104-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818163544.351104-1-pctammela@mojatatu.com> References: <20230818163544.351104-1-pctammela@mojatatu.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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 As discussed in '76e42ae83199', cls_fw was handling the use of classid incorrectly. Add a few tests to check if it's conforming to the correct behaviour. Signed-off-by: Pedro Tammela --- .../tc-testing/tc-tests/filters/fw.json | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/fw.json b/tools/testing/selftests/tc-testing/tc-tests/filters/fw.json index 742ebc34e15c..a9b071e1354b 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/fw.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/fw.json @@ -1343,5 +1343,54 @@ "teardown": [ "$TC qdisc del dev $DEV1 ingress" ] + }, + { + "id": "e470", + "name": "Try to delete class referenced by fw after a replace", + "category": [ + "filter", + "fw" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DEV1 parent root handle 10: drr", + "$TC class add dev $DEV1 parent root classid 1 drr", + "$TC filter add dev $DEV1 parent 10: handle 1 prio 1 fw classid 10:1 action ok", + "$TC filter replace dev $DEV1 parent 10: handle 1 prio 1 fw classid 10:1 action drop" + ], + "cmdUnderTest": "$TC class delete dev $DEV1 parent 10: classid 10:1", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DEV1", + "matchPattern": "class drr 10:1", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 parent root drr" + ] + }, + { + "id": "ec1a", + "name": "Replace fw classid with nil", + "category": [ + "filter", + "fw" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DEV1 parent root handle 10: drr", + "$TC class add dev $DEV1 parent root classid 1 drr", + "$TC filter add dev $DEV1 parent 10: handle 1 prio 1 fw classid 10:1 action ok" + ], + "cmdUnderTest": "$TC filter replace dev $DEV1 parent 10: handle 1 prio 1 fw action drop", + "expExitCode": "0", + "verifyCmd": "$TC filter show dev $DEV1 parent 10:", + "matchPattern": "fw chain 0 handle 0x1", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 parent root drr" + ] } ] From patchwork Fri Aug 18 16:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13357985 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 9F99B469E for ; Fri, 18 Aug 2023 16:36:20 +0000 (UTC) Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E003AAE for ; Fri, 18 Aug 2023 09:36:19 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6b9c9944da8so895836a34.3 for ; Fri, 18 Aug 2023 09:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1692376578; x=1692981378; 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=GKt5SyjNVCauUVIET/enhIq+pinooJIPlCEWGPfyFGw=; b=ZVu+zbrwKsw/YHroybkX903AH5dct+W7VAusKKiTUVH3PzLzuFSIpdLnhz338lfMLu fIGFuLbxMsmlGxeji5auTcMpzptFcFs8Luzoh3MB/iG3NXz/AfDPlYazKocRPTKewFRX +EDY7REQvAGe358XbhK9Hr4NJBxSJlVfs9G27cUGYzrDS10wqHhcCnFnzafIseqqH63E FyF8xmHABw9Y3ZzxmUJOv2rdh3rT3OZKh5sjU0XkqzpfAYUJmglCZQ8jtXcIHMWQ45Wo FMu+7k5Y03xuHwDlitlannuRdwKy9yq3jo3jG1TGYHgrShzoJx7bh7///xPcvVxDjhSt NfPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692376578; x=1692981378; 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=GKt5SyjNVCauUVIET/enhIq+pinooJIPlCEWGPfyFGw=; b=ZVoWe6FHVKfDjTjoIfWeQYDsLynBjvlKkwu2skJlXgdb0u0vXzfbBaVyGfSaGtO0M2 Yfe6t4TObKmHdZaEVnSuPHwvRHwdMhUr+PGykU6pFXmQYOELRHRCoN4XdBbISfIIqfVk vw78Pg0DdpKEM8jQkIH3arm1UQx1ubpwJ/J+v0M+1XsVf2UACXtMop6SgYYKSmdpmOVJ wsITjnrT4koMhjznice2CiBomCPwkCIalASvKWujSKBHHGrkXzeoZO/wA3v20FJTGn0b 9p0n+BfgRZD4xxjlIyInYwUSHFhmwTR+ozGc23An2xgxFJF0LroOY41vZqTEWdL3vn0S ozWA== X-Gm-Message-State: AOJu0Yxk0z2a8nWoFF9F8ixDLcB7yWK3duPrCoKj6yOt3gu9dqn1tuBF ff5dgNkJBLJGGz5su+CJ0FTvSgJFtsV1IgNTVgI= X-Google-Smtp-Source: AGHT+IHZavZahAJuvVys5ESgkgyYVznTsYafEOFiWVDLwnpDertN86Kq7tjSHQ+Ik/eqO4o1lyMSeg== X-Received: by 2002:a05:6870:14d4:b0:1bf:8c9a:9a2c with SMTP id l20-20020a05687014d400b001bf8c9a9a2cmr3693560oab.15.1692376578646; Fri, 18 Aug 2023 09:36:18 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:bdfa:b54a:9d12:de38]) by smtp.gmail.com with ESMTPSA id f200-20020a4a58d1000000b005634e8c4bbdsm561531oob.11.2023.08.18.09.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 09:36:18 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next 2/5] selftest/tc-testing: cls_route: add tests for classid Date: Fri, 18 Aug 2023 13:35:41 -0300 Message-Id: <20230818163544.351104-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818163544.351104-1-pctammela@mojatatu.com> References: <20230818163544.351104-1-pctammela@mojatatu.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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 As discussed in 'b80b829e9e2c', cls_route was handling the use of classid incorrectly. Add a test to check if it's conforming to the correct behaviour. Signed-off-by: Pedro Tammela --- .../tc-testing/tc-tests/filters/route.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/route.json b/tools/testing/selftests/tc-testing/tc-tests/filters/route.json index 1f6f19f02997..8d8de8f65aef 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/route.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/route.json @@ -177,5 +177,30 @@ "teardown": [ "$TC qdisc del dev $DEV1 ingress" ] + }, + { + "id": "b042", + "name": "Try to delete class referenced by route after a replace", + "category": [ + "filter", + "route" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DEV1 parent root handle 10: drr", + "$TC class add dev $DEV1 parent root classid 1 drr", + "$TC filter add dev $DEV1 parent 10: prio 1 route from 10 classid 10:1 action ok", + "$TC filter replace dev $DEV1 parent 10: prio 1 route from 5 classid 10:1 action drop" + ], + "cmdUnderTest": "$TC class delete dev $DEV1 parent 10: classid 10:1", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DEV1", + "matchPattern": "class drr 10:1", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 parent root drr" + ] } ] From patchwork Fri Aug 18 16:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13357986 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 E8787A38 for ; Fri, 18 Aug 2023 16:36:24 +0000 (UTC) Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 475B93C0A for ; Fri, 18 Aug 2023 09:36:23 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-56e99f97f0fso365411eaf.0 for ; Fri, 18 Aug 2023 09:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1692376582; x=1692981382; 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=hSDSdR8lYA3CyRQ61SRbC2eytywvaKi5Vn+nvHm9A2c=; b=ZKE09onA+xh5BBzDDYx6s2/RJu7RLre5B4pAKK3VbWcV+UT0Bs0PQLNlruQ03Nat3g Qzshd4G1AtNk711JCl5CeY6hbuHK2StjR9/5s0MTTcXYJMukw/wYOANnX4zGJ2nrJTNy qbBq70JW74SRMtOVTXA0wIKXxIdc4O+EFgcj7ZZkxoQNaBkFJ3fLwCL/bpdTxPwtiw3b mE+oZCYniRt8fnlRrkF7bKqwHiqw5ODfMFkxfcv5H4EERDmGRWjmkVlasDXcwBRm1AEK 8ih3o34ChwawQf2wO5ojE38LvqCBau3cara+00zakZV2ITRkgQHa6DBulpPuk/zwbRyN +eDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692376582; x=1692981382; 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=hSDSdR8lYA3CyRQ61SRbC2eytywvaKi5Vn+nvHm9A2c=; b=BRMsdp8dSiBwmc4wt6syZSn7BySIIxnmwXTRDxzbmyunEx00+up5i9Qbk7RbX7hlM1 gV1IhzX+vlsTA/FgHjuLwWcfw2iKckywjg4PskY9XzSgIaHpVGwOqui44O4du0/+pyQS 9oQWveVE3Op6x9CgxuYa+iOIbnQLoi3jx3UyQOFi32TVUEa8wpOeNDnmhLlM5Cw/ILBw p6x0vGokwoV5AZUCfRWZSxpbS6k/xjuNzHhNtXYzzYcMjGltF6jUIeCgCK0WwpgPDuxB 4I7OEfcVKq8vXMrFJkfwYCX6pE8wlzt05cSCdmRnCDEtmtfkW7j1NzCDP2B3pFnwuT30 EkPQ== X-Gm-Message-State: AOJu0YxF6EQ6sNxoLyM2K/CzqGJ+RQ3vkgM/9lPpRFhCMld4WBGyU3VP TRtvqqVZbMawfQcRYAzcTDY/q41pZPRLOrdzfHE= X-Google-Smtp-Source: AGHT+IHxEGi+Bg3KG1HayON9OocqFOjyqBUNVB1u03CkEbJKEPbgNLnYzAnAM3lY1tq85s2xdtY4nw== X-Received: by 2002:a4a:2559:0:b0:56e:68a8:7f5d with SMTP id v25-20020a4a2559000000b0056e68a87f5dmr3567569ooe.3.1692376582516; Fri, 18 Aug 2023 09:36:22 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:bdfa:b54a:9d12:de38]) by smtp.gmail.com with ESMTPSA id f200-20020a4a58d1000000b005634e8c4bbdsm561531oob.11.2023.08.18.09.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 09:36:22 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next 3/5] selftest/tc-testing: cls_u32: add tests for classid Date: Fri, 18 Aug 2023 13:35:42 -0300 Message-Id: <20230818163544.351104-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818163544.351104-1-pctammela@mojatatu.com> References: <20230818163544.351104-1-pctammela@mojatatu.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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 As discussed in '3044b16e7c6f', cls_u32 was handling the use of classid incorrectly. Add a test to check if it's conforming to the correct behaviour. Signed-off-by: Pedro Tammela --- .../tc-testing/tc-tests/filters/u32.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json index bd64a4bf11ab..ddc7c355be0a 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json @@ -247,5 +247,30 @@ "teardown": [ "$TC qdisc del dev $DEV1 ingress" ] + }, + { + "id": "0c37", + "name": "Try to delete class referenced by u32 after a replace", + "category": [ + "filter", + "u32" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "$TC qdisc add dev $DEV1 parent root handle 10: drr", + "$TC class add dev $DEV1 parent root classid 1 drr", + "$TC filter add dev $DEV1 parent 10: prio 1 u32 match icmp type 1 0xff classid 10:1 action ok", + "$TC filter replace dev $DEV1 parent 10: prio 1 u32 match icmp type 1 0xff classid 10:1 action drop" + ], + "cmdUnderTest": "$TC class delete dev $DEV1 parent 10: classid 10:1", + "expExitCode": "2", + "verifyCmd": "$TC class show dev $DEV1", + "matchPattern": "class drr 10:1", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $DEV1 parent root drr" + ] } ] From patchwork Fri Aug 18 16:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13357987 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 313D36110 for ; Fri, 18 Aug 2023 16:36:28 +0000 (UTC) Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE1A3AAE for ; Fri, 18 Aug 2023 09:36:27 -0700 (PDT) Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-56d6dfa1f3cso690326eaf.0 for ; Fri, 18 Aug 2023 09:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1692376586; x=1692981386; 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=WLmjnO5KUtCrD/gaeJk57IaZoZ7aWFu8I5CCnY6/uVk=; b=XU7JYY0TnevfzpItaBh75PH5kC5FAnGNsSJfJdBypXtBNDMgLqqWIipjjbzZIPmkeI fWxu/fEIGsWmdzUqib7TE9QTgz0BhKSED1Eqn2BRUsTmWbpbWuus5sRlBTNgeInzl8Jf cATGykyZPAkwt2TUdRCnaGNmzbjYXC15lspOsnLn4XC0wpiQOU9McqlI9y4JmTOrmnCr ieOE3blJnOIbPXf+EEgwzNCJMKJ3kcjjVdzs8uXKlpBEn06zdQ++3z9wPW4F56OV6BSh UFUP5hq7+rih0zg6JkYUzB6Ewr4HORmC1D2myowDSj48Mvua5srMY3MVR7z43vB9CCrT DwWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692376586; x=1692981386; 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=WLmjnO5KUtCrD/gaeJk57IaZoZ7aWFu8I5CCnY6/uVk=; b=i9FR/w9FVhwCPsyWM3M7vLavk9tUz629qcyHAlHpm7W8Q3NTSJNH/NjyqH+/0CFyNK IjBFR+bJM8UUXdeIIXXwXWYXGPhCi/U8Y9FcMLm8t28wupcIZiQqUSlzi3waqhfadxfw 70kbIwzNwB4NAcsxz1TTiffrVVu+jYrSqm0hR9fVkIxPyMzxN921oGGD+xRa55qFoK4r R2nNXZY/4mmV+/I7/XdpmeF5Mb6VZe9PSk0GQSq81vSKU9x8FVYPrGR7orHiaVQdMnbn sHy7kvgf84MdVXmpUHuwCMwmhWr7fcSZMKTSeI+z2zM/JsWYaAReba2Nw8WoYsu49Luq gCPw== X-Gm-Message-State: AOJu0Yz9mUZh/ZtkXIYvwOIF3VTd3EkmR0LhwJpl+iqgQS+RO3kJGb4D iAgrOkVnPVdrIPji16eBvv5r1HlyGjr43BGCx50= X-Google-Smtp-Source: AGHT+IFv39JRhX7Y5v45WIPO8y+vQVffZpfNA/IW1o6clNhy5C/pp0Rzbhy2bOmItoU0P4b3Bh29MA== X-Received: by 2002:a05:6820:292:b0:56d:e414:d14 with SMTP id q18-20020a056820029200b0056de4140d14mr3592929ood.8.1692376586162; Fri, 18 Aug 2023 09:36:26 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:bdfa:b54a:9d12:de38]) by smtp.gmail.com with ESMTPSA id f200-20020a4a58d1000000b005634e8c4bbdsm561531oob.11.2023.08.18.09.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 09:36:25 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next 4/5] net/sched: cls_route: make netlink errors meaningful Date: Fri, 18 Aug 2023 13:35:43 -0300 Message-Id: <20230818163544.351104-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818163544.351104-1-pctammela@mojatatu.com> References: <20230818163544.351104-1-pctammela@mojatatu.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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 Use netlink extended ack and parsing policies to return more meaningful errors instead of the relying solely on errnos. Signed-off-by: Pedro Tammela --- net/sched/cls_route.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 1e20bbd687f1..b34cf02c6c51 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -400,30 +400,32 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, if (new && handle & 0x8000) return -EINVAL; to = nla_get_u32(tb[TCA_ROUTE4_TO]); - if (to > 0xFF) - return -EINVAL; nhandle = to; } + if (tb[TCA_ROUTE4_FROM] && tb[TCA_ROUTE4_IIF]) { + NL_SET_ERR_MSG(extack, + "'from' and 'fromif' are mutually exclusive"); + return -EINVAL; + } + if (tb[TCA_ROUTE4_FROM]) { - if (tb[TCA_ROUTE4_IIF]) - return -EINVAL; id = nla_get_u32(tb[TCA_ROUTE4_FROM]); - if (id > 0xFF) - return -EINVAL; nhandle |= id << 16; } else if (tb[TCA_ROUTE4_IIF]) { id = nla_get_u32(tb[TCA_ROUTE4_IIF]); - if (id > 0x7FFF) - return -EINVAL; nhandle |= (id | 0x8000) << 16; } else nhandle |= 0xFFFF << 16; if (handle && new) { nhandle |= handle & 0x7F00; - if (nhandle != handle) + if (nhandle != handle) { + NL_SET_ERR_MSG_FMT(extack, + "Unexpected handle %x (expected %x)", + handle, nhandle); return -EINVAL; + } } if (!nhandle) { @@ -478,7 +480,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb, struct route4_filter __rcu **fp; struct route4_filter *fold, *f1, *pfp, *f = NULL; struct route4_bucket *b; - struct nlattr *opt = tca[TCA_OPTIONS]; struct nlattr *tb[TCA_ROUTE4_MAX + 1]; unsigned int h, th; int err; @@ -489,10 +490,12 @@ static int route4_change(struct net *net, struct sk_buff *in_skb, return -EINVAL; } - if (opt == NULL) + if (NL_REQ_ATTR_CHECK(extack, NULL, tca, TCA_OPTIONS)) { + NL_SET_ERR_MSG_MOD(extack, "missing options"); return -EINVAL; + } - err = nla_parse_nested_deprecated(tb, TCA_ROUTE4_MAX, opt, + err = nla_parse_nested_deprecated(tb, TCA_ROUTE4_MAX, tca[TCA_OPTIONS], route4_policy, NULL); if (err < 0) return err; From patchwork Fri Aug 18 16:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13357988 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 ACE566110 for ; Fri, 18 Aug 2023 16:36:31 +0000 (UTC) Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF30D3AAE for ; Fri, 18 Aug 2023 09:36:30 -0700 (PDT) Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-56d455462c2so719634eaf.2 for ; Fri, 18 Aug 2023 09:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1692376590; x=1692981390; 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=emxBtvBizp53ATR2wa3AwEpTdXwAhDnSB3z3aMLT9nc=; b=Wax79MQD6Ul2/+RFyLa59dv0fDV3OgJjnjumnvHUmjrE8bXvKtrj6m+JeRtantaoug V8OMFg6A7hs5ht+xnmgwDoUkfzcrvZM8Ee1UlaN3sQPCCYH1dOKyv2N8U0tPDye/Oup8 V5XRhEsY5ujGQ/4FE/t6Cc6Ns3kf50337uJz8VaJqv3FxSc7DD9gl0HhAo4GNnDtX5w/ UXVF/tvDdDxuQZ2AUqyFQXssZtHK2UBPf68E45wSBPB45k13bcXANiz1a3S9QZ2WmzXZ MNGnes9eS/d6UoraAJtbnfh3K71s8cWhpYgHMJv0/N706w09wGYKs9KT7tRURyht6g/4 tMJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692376590; x=1692981390; 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=emxBtvBizp53ATR2wa3AwEpTdXwAhDnSB3z3aMLT9nc=; b=Hbh7lLuVx/7Fzz3SNVtpp9NCLB6kOec7vVGalCn/cRJxLBgnrbSlJVdMpKmCxUJeqJ xDovZEaPLd9CZTKoTvmZC0MclNnrPkhNSHwb5S5eB56h2HkZfld1C2tcla5mQuSNptnG TsSngNqPArO2sG9fIODw1TdbSnfr0Et1sYsJTb86ShKfH+UP4/h7UwBPQaQiKBRvonfG QV8lTwt5dWZVgHnh7Prckz7vWGQT0yn9n8zLB01cXCWkEXFQYQKVnIQD1Uo6alrRvEdF aC2zBba6WzzJdZodR/L+I0tcc7o7urPH5h1OEDjbqKSZ9LCY1xRNcItDMxj8lyp/Zflo 1DZA== X-Gm-Message-State: AOJu0YyCr+wgsqNvVmypYP+ANmakbUzzMAwt9tbLUs18eIdhgLWub5+8 vZEIesGEM5miGei9HzBbUJxT3j1j2W1DpPegSY8= X-Google-Smtp-Source: AGHT+IG3A6+qYo3A2jUDdbnnMKzzTMxmmlB2aRQAH2YrOCdMIelpN2MMS4qZksaobs72YKSyDsCFIw== X-Received: by 2002:a4a:6c16:0:b0:56e:a14a:f04e with SMTP id q22-20020a4a6c16000000b0056ea14af04emr957539ooc.9.1692376589947; Fri, 18 Aug 2023 09:36:29 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:bdfa:b54a:9d12:de38]) by smtp.gmail.com with ESMTPSA id f200-20020a4a58d1000000b005634e8c4bbdsm561531oob.11.2023.08.18.09.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 09:36:29 -0700 (PDT) From: Pedro Tammela To: netdev@vger.kernel.org Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, shaozhengchao@huawei.com, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next 5/5] selftests/tc-testing: cls_u32: update tests Date: Fri, 18 Aug 2023 13:35:44 -0300 Message-Id: <20230818163544.351104-6-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230818163544.351104-1-pctammela@mojatatu.com> References: <20230818163544.351104-1-pctammela@mojatatu.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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 Update the u32 tests to conform to the new syntax of a terminal flowid Signed-off-by: Pedro Tammela --- .../selftests/tc-testing/tc-tests/filters/u32.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json index ddc7c355be0a..d4b4c767d6c9 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/u32.json @@ -15,7 +15,7 @@ "cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.1/32 flowid 1:1 action ok", "expExitCode": "0", "verifyCmd": "$TC filter show dev $DEV1 ingress", - "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1.*match 7f000001/ffffffff at 12)", + "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 \\*flowid 1:1.*match 7f000001/ffffffff at 12)", "matchCount": "3", "teardown": [ "$TC qdisc del dev $DEV1 ingress" @@ -60,7 +60,7 @@ "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.2/32 indev notexist20 flowid 1:2 action ok", "expExitCode": "2", "verifyCmd": "$TC filter show dev $DEV1 ingress", - "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:3.*match 7f000003/ffffffff at 12)", + "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 \\*flowid 1:3.*match 7f000003/ffffffff at 12)", "matchCount": "3", "teardown": [ "$TC qdisc del dev $DEV1 ingress" @@ -196,7 +196,7 @@ "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 98 u32 ht 43:1 match tcp src 23 FFFF classid 1:4", "expExitCode": "2", "verifyCmd": "$TC filter show dev $DEV1 ingress", - "matchPattern": "filter protocol ip pref 99 u32 chain (0[ ]+$|0 fh (43|800): ht divisor 1|0 fh 43::800 order 2048 key ht 43 bkt 0 flowid 1:3.*match 00160000/ffff0000 at nexthdr\\+0)", + "matchPattern": "filter protocol ip pref 99 u32 chain (0[ ]+$|0 fh (43|800): ht divisor 1|0 fh 43::800 order 2048 key ht 43 bkt 0 \\*flowid 1:3.*match 00160000/ffff0000 at nexthdr\\+0)", "matchCount": "4", "teardown": [ "$TC qdisc del dev $DEV1 ingress" @@ -219,7 +219,7 @@ "cmdUnderTest": "bash -c \"for mask in ff ffff ffffff ffffffff ff00ff ff0000ff ffff00ff; do $TC filter add dev $DEV1 ingress prio 99 u32 ht 1: sample u32 0x10203040 \\$mask match u8 0 0 classid 1:1; done\"", "expExitCode": "0", "verifyCmd": "$TC filter show dev $DEV1 ingress", - "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 40 flowid 1:1", + "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 40 \\*flowid 1:1", "matchCount": "7", "teardown": [ "$TC qdisc del dev $DEV1 ingress" @@ -242,7 +242,7 @@ "cmdUnderTest": "bash -c \"for mask in 70 f0 ff0 fff0 ff00f0; do $TC filter add dev $DEV1 ingress prio 99 u32 ht 1: sample u32 0x10203040 \\$mask match u8 0 0 classid 1:1; done\"", "expExitCode": "0", "verifyCmd": "$TC filter show dev $DEV1 ingress", - "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 4 flowid 1:1", + "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 4 \\*flowid 1:1", "matchCount": "5", "teardown": [ "$TC qdisc del dev $DEV1 ingress"