From patchwork Mon Sep 11 21:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13380166 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 BFD2879FA for ; Mon, 11 Sep 2023 22:00:03 +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 67B09659E for ; Mon, 11 Sep 2023 14:59:34 -0700 (PDT) Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5733789a44cso2989056eaf.2 for ; Mon, 11 Sep 2023 14:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1694469483; x=1695074283; darn=vger.kernel.org; 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=Uc1jvCNkawSJrIew2eCalHZSjtXqZFta5jKv8McjwD4=; b=XHK6wMbXdlEr3da8Vk+kkislE3AFbfp5KWWZ98AAvE+Dv9hfFKprGymjtatfYSJjHN 7SjD9eGTZGRgfMZ95ivGeL1Tt1Kbx66tJGvxkcGLG53/BVxcNmlzC+OWYJu2sPFi6jiP 3FwOdnCUkl2P9bV31uI40qLqTHazIpUNOYhcPDzdMjOfjOuvVc5j8uomfI+3GeX71N75 uBMEnqtdPwlSrlhAkbpngYcb1FQ9JSkCmxTJEuR4T1vbYqjk1QWRd/DrZnb5H0MKoEFE BRC4QOA7QRA9ND71iaAJhVIHOeTjGu/ABs74etN9QY8GASjJ9op87VBCKqW3yNXB+AKE bPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694469483; x=1695074283; 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=Uc1jvCNkawSJrIew2eCalHZSjtXqZFta5jKv8McjwD4=; b=eLA84hW2vDBZ0Gb5OG78rXMy9Z0VwBf+7MUBAYBseOpCHqeRx4wkpnt/61KA0RcV52 o/7nK5vIRpgnEnVLBbWSQKmKP9RZFP0tavbkTto6xIqaMOnmNEXVT+uvwV5oEt/pSqlg 6O2bJPy2Lsd1fQmKPY738VYNaR1Bejb70zNZrRNTyfpxLKjDo3go8ZuSvW6FakbKaTa7 RLpRWTKvonvHqgV/5zpCo2a0kqwCjs36TFYJBVwchTdzWxWeXAZGBmKvFPJzBX3l+rtP rxtp1UrYjqsxDaZodY0Ra5V/Q0Z0Gyhx0Zb+MBY79F8zXo2Y9vydxLsujp4S0CmO9uVd XLuQ== X-Gm-Message-State: AOJu0Yy9wnYigW8MBlKuuA6fB0/rvibVHuEFqu20Rzdt5ZGdGUnqHGyA +/1ZFhzaDcYxscnIYplEuHTx8Q9XzPlL1p0IgIE= X-Google-Smtp-Source: AGHT+IGBaU2mYEnG1KyYC4Gds6CGOgZlPziXGYQphwsX0iVKhwhEzcJSgclF2lO7+L4Y0N0rv+UUrA== X-Received: by 2002:a05:6830:7:b0:6be:e412:22a with SMTP id c7-20020a056830000700b006bee412022amr12380124otp.10.1694469050839; Mon, 11 Sep 2023 14:50:50 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:accd:6e1c:69ae:3f11]) by smtp.gmail.com with ESMTPSA id 3-20020a4a0603000000b0057635c1a4f2sm3776869ooj.25.2023.09.11.14.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 14:50:50 -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, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next v3 1/4] selftests/tc-testing: cls_fw: add tests for classid Date: Mon, 11 Sep 2023 18:50:13 -0300 Message-Id: <20230911215016.1096644-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230911215016.1096644-1-pctammela@mojatatu.com> References: <20230911215016.1096644-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_NONE,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. Reviewed-by: Victor Nogueira 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 Mon Sep 11 21:50:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13380165 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 F27758838 for ; Mon, 11 Sep 2023 21:52:55 +0000 (UTC) Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA2712F8E8 for ; Mon, 11 Sep 2023 14:52:22 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6c0bbbbad81so3056093a34.3 for ; Mon, 11 Sep 2023 14:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1694469054; x=1695073854; darn=vger.kernel.org; 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=fRPkfE0BiV80wxpOBOz69UcDTsNr0cPpVoBtQmhjeJw=; b=ihdH3l6vUS1hp0yO7gHbjNOsrSztVzcFh0TS6SC0pi533fnR02DBc08h5j/9fFZ3dd Gg8uQEYmXLX9TfX7l8e8pl84Y5U8p9cEtRcHhAsynB4Xouxk0mMqtvjqgYtzBe4ZBsUK SWKE/moXiCHB+gs+JPC/DXRRaUPh1pjIlEyZ5HMoZJCgPqHY/UzVZK2ZxpYowVqYaTkI 3WQlK5qT7pQ5VdJJ2GqOte3GFogUV8V/UaONvchE6OmSMEFdMOIFnctJoEF9yvE9Txyh ZOCxee3zp2i4K4cdaRu3ekbsJSpObj3cAlrH/frMtJUh0aCELwTxpHG6Lj06zEE4Oilc dRHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694469054; x=1695073854; 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=fRPkfE0BiV80wxpOBOz69UcDTsNr0cPpVoBtQmhjeJw=; b=b2Y59wUXcK8j13I3TeyMuQ1LS9J+9tOTax1LWZ60cSd0yr07f5kto+LrWwpY6VATRE lWHyh2xFoBIM2x6KJm75rMRIadOXx/Yni+R6v9maZtJMdyoPSL8vCkc0Uxx4Q3kAVJOA 0rObyYx2FSUBRm1S35hUNrvYD//MBVHgqlNXWs5Dlf6X5ZFl1O3l6+6VE7jSU+XaUAoy wnWo80dU4O0PDiqz/ZH6brt8ZJklF/FGCmBthFc9zkoyOoVx9JqOUEWWcTMF07kLa+xT ZpLVXT0o5H8q2tiw6jDploO8ui+0MvsX2kg4jo7cXrfqeHBVARNUIXGAzr/6TzhsIhAa Yelw== X-Gm-Message-State: AOJu0Yxbz90speZEWovvoKdrTXLrwNaF5Z1IO4FLmd7ocvp6mQxnf+ck KAPo3ejkKEjypUsAzcS+Tri3x/eQfpSWW8b7oVE= X-Google-Smtp-Source: AGHT+IGTvs2hdrzCuWrTYeLlNwv2udurMrNIZiKhmbKz8aM3g7E63q8DRjPkOWlgXdpJELYucvZu9w== X-Received: by 2002:a9d:7497:0:b0:6bb:1c21:c52e with SMTP id t23-20020a9d7497000000b006bb1c21c52emr11321703otk.15.1694469053947; Mon, 11 Sep 2023 14:50:53 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:accd:6e1c:69ae:3f11]) by smtp.gmail.com with ESMTPSA id 3-20020a4a0603000000b0057635c1a4f2sm3776869ooj.25.2023.09.11.14.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 14:50:53 -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, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next v3 2/4] selftests/tc-testing: cls_route: add tests for classid Date: Mon, 11 Sep 2023 18:50:14 -0300 Message-Id: <20230911215016.1096644-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230911215016.1096644-1-pctammela@mojatatu.com> References: <20230911215016.1096644-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. Reviewed-by: Victor Nogueira 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 Mon Sep 11 21:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13380257 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 012718BFE for ; Mon, 11 Sep 2023 22:12:39 +0000 (UTC) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA4034A6F for ; Mon, 11 Sep 2023 15:12:09 -0700 (PDT) Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-64a0176b1easo30863826d6.3 for ; Mon, 11 Sep 2023 15:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1694469890; x=1695074690; darn=vger.kernel.org; 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=pdY4YC4aJGas0z16053mXqTDnRov5YqrsJzz/GcyDl4=; b=Jv/0jVWx3qrV+KpcZ8VHuEn6lfvDairPWXskDQSXP1XiBzvkaiD68wI58TbH5hV6bM NTpe6W64bdQDfwzYKJSmp+OSCu/ogYq+pXV6jFU0Ooa46+b8tnJjkiYRPHkjxTnNzvne z374pDyyM4S6twdwnLyRCrACT2W807FYw1ZeK3txRDEFP95xQIs45OFSAlk0xar+WH9b h+1RQHPH+Ov4XIV+kP7McC0U/caaP5MZHvkL3+HnGdmq54+63SVkeZ0iwqMAbt23hyTy Kvi+F3Vb1/eSKXqCaI+++yqUA4yhR6tBSXSiXe8EPWTAZ23bzuglP/lgbLf0dpj3Bhdp k+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694469890; x=1695074690; 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=pdY4YC4aJGas0z16053mXqTDnRov5YqrsJzz/GcyDl4=; b=SRELB6QfwfKqVLq0rMvyW/W+UGIn+3VURcrVToLs1iqPd0MRLk02MGH61/kJ7oVLjN kyywN+5P8SpbwjllJkoO5/UZlFfrwlgKEQ1AcnnU8YKEd35IGN/hDmdyA0As8hxcJ+vF wAYkkWBAwBPkAbrLNOlzElVF1U/fmIoVV1oxxKRY43p1mE9gGrlT1+4e/FFpO6JWitez knDBa7HjTDSzXPD74DIuwRhkSSY/zBULsH6nL7rbQCYvthi91y86I+feh86K8CzN64ev tLa8B1ihlTRjPs3vx1M7+VH4S5VdqUwhoqcdN3C9GhYJv+ctqR3gca2+dvV2JZzCBwtE 2ifg== X-Gm-Message-State: AOJu0YzFt/WKNZ9PcnxkCss/8anM/42KcIJEY4PGugSMsGnFBJkMR6T8 4saF2n6/JtgfUwPnaFqGWlepxZRVWimz/0ffJsU= X-Google-Smtp-Source: AGHT+IFx1Bq7WChHIoMItspZztW36XS7+DgaLdXH+4zRbbl+2qNQ2IMOS/BFz8VXoEoCoxxbt+Elnw== X-Received: by 2002:a4a:dfdc:0:b0:571:2b86:2050 with SMTP id p28-20020a4adfdc000000b005712b862050mr11149039ood.7.1694469057095; Mon, 11 Sep 2023 14:50:57 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:accd:6e1c:69ae:3f11]) by smtp.gmail.com with ESMTPSA id 3-20020a4a0603000000b0057635c1a4f2sm3776869ooj.25.2023.09.11.14.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 14:50:56 -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, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next v3 3/4] selftests/tc-testing: cls_u32: add tests for classid Date: Mon, 11 Sep 2023 18:50:15 -0300 Message-Id: <20230911215016.1096644-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230911215016.1096644-1-pctammela@mojatatu.com> References: <20230911215016.1096644-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,RCVD_IN_MSPIKE_H2,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. Reviewed-by: Victor Nogueira 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 Mon Sep 11 21:50:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13380207 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 ABB6B23D9 for ; Mon, 11 Sep 2023 22:05:56 +0000 (UTC) Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59AA13ADF for ; Mon, 11 Sep 2023 15:05:14 -0700 (PDT) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-58cd9d9dbf5so68520157b3.0 for ; Mon, 11 Sep 2023 15:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1694469529; x=1695074329; darn=vger.kernel.org; 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=sxvY65blzl7yOJ12jhRUnG33IHcZrwJ6B7wIwHp0ocg=; b=2eAcHZwN92N7ok6KnD9SWMFzn9TMS24h/krY85x31f27VxByXx+Ek1RGG7I1wDr9cB CCerUFFj33f9rap3fc+ME/Q28wOmvGO4bkBjg5Bxs9eN+XrGpuiP90HuVEIs0cT0CIPA AklvI/oLvXwjhTgyIYoq9sNqDWmlmWIpBiSvAarv5b1GA8Nu8iPOWEQQVCJjzgIJ88Yr 6CHnek+MkU4Rg5M+UqR/qk0utRrw7D8Qc9pcK+01HSm+lnj+XimcL0x65NKS/qxxngcu hjV1stasyr6cTXeq6SVoGu36Z3N2ms7VZ8brolwUcv14VwCTcbVh9v4SQJ+c6xgv08Ij XsnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694469529; x=1695074329; 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=sxvY65blzl7yOJ12jhRUnG33IHcZrwJ6B7wIwHp0ocg=; b=xP38ApCxtYldHWhk5VRQhJdI3yul7kI7vxQlMeG2qxJBSQoBUxouvErboQdJa24V0Q jM+muBM+gT7woDYlGfWtc8djV6EdUp4Hg8i3kR2/58J372Ca31mrK12F+ZqIXiNggm3O s4ciwclwDZp5td8bQsmAcviJYsdOaZi489X0WaLB47sOHDZNaoAAdFoi4NxJPv35L6c5 l4tOSdKcO1M2DEU0hDv881R3xlyNxP/gTw2TnBi2ITruJeCdl2Sq5iEUHt/zjOz47b2Q YfR8prP87l23JquMn0VLOTbRp3u//6QH2HkyOHG7/KiJhExb4kmYyfLOLnuAkKmuKDkC BInA== X-Gm-Message-State: AOJu0YyrAf5bcpeV5ohZcPOzdLc3D/S9C1KC9mx9w95abqx3KbhFDouC 8rGdzOAoXpi9HdgGTWJHdBdDJtAIJ+GIJay5wmg= X-Google-Smtp-Source: AGHT+IHy4lEtLffrKZvG1XzYpNxB7jmMxfx4Ikos50YLSoHGXUgDTGdB9CSOkpOliLatS9TYy3edRg== X-Received: by 2002:a05:6870:95a8:b0:1c5:dcd:5d64 with SMTP id k40-20020a05687095a800b001c50dcd5d64mr444750oao.7.1694469060341; Mon, 11 Sep 2023 14:51:00 -0700 (PDT) Received: from rogue-one.tail33bf8.ts.net ([2804:14d:5c5e:44fb:accd:6e1c:69ae:3f11]) by smtp.gmail.com with ESMTPSA id 3-20020a4a0603000000b0057635c1a4f2sm3776869ooj.25.2023.09.11.14.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 14:51:00 -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, victor@mojatatu.com, Pedro Tammela Subject: [PATCH net-next v3 4/4] net/sched: cls_route: make netlink errors meaningful Date: Mon, 11 Sep 2023 18:50:16 -0300 Message-Id: <20230911215016.1096644-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230911215016.1096644-1-pctammela@mojatatu.com> References: <20230911215016.1096644-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_MSPIKE_H2,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. Reviewed-by: Victor Nogueira Signed-off-by: Pedro Tammela --- net/sched/cls_route.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 1e20bbd687f1..484d8185b6b8 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -375,9 +375,9 @@ static int route4_delete(struct tcf_proto *tp, void *arg, bool *last, static const struct nla_policy route4_policy[TCA_ROUTE4_MAX + 1] = { [TCA_ROUTE4_CLASSID] = { .type = NLA_U32 }, - [TCA_ROUTE4_TO] = { .type = NLA_U32 }, - [TCA_ROUTE4_FROM] = { .type = NLA_U32 }, - [TCA_ROUTE4_IIF] = { .type = NLA_U32 }, + [TCA_ROUTE4_TO] = NLA_POLICY_MAX(NLA_U32, 0xFF), + [TCA_ROUTE4_FROM] = NLA_POLICY_MAX(NLA_U32, 0xFF), + [TCA_ROUTE4_IIF] = NLA_POLICY_MAX(NLA_U32, 0x7FFF), }; static int route4_set_parms(struct net *net, struct tcf_proto *tp, @@ -397,33 +397,37 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, return err; if (tb[TCA_ROUTE4_TO]) { - if (new && handle & 0x8000) + if (new && handle & 0x8000) { + NL_SET_ERR_MSG(extack, "Invalid handle"); 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_ATTR(extack, tb[TCA_ROUTE4_FROM], + "'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, + "Handle mismatch constructed: %x (expected: %x)", + handle, nhandle); return -EINVAL; + } } if (!nhandle) { @@ -478,7 +482,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 +492,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;