Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7959822rwn; Wed, 14 Sep 2022 07:04:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IrpYqDS0yoPdA9NTI2hOHYi9gPPNuSV8WmBZYQF1gjc1q/oVnV5rgWdgFPGaEkWOfZTAC X-Received: by 2002:a17:907:7205:b0:770:86f1:ae6e with SMTP id dr5-20020a170907720500b0077086f1ae6emr25180040ejc.396.1663164245311; Wed, 14 Sep 2022 07:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663164245; cv=none; d=google.com; s=arc-20160816; b=gG1GoryylX5iSfiSBjCytaIGnb307eV+VuaEyO4RJY9NSnVWFePR6Nc55akP1Zkp5n Gkxd8vslktSappiYyLIzrDPYs97fKrO+/3xTrVsmJj1o+zWcGMeAw8PngiNiCZWYq02Y NqXDCEfSbANlRSyBWsiwyq8EtFFX6U5Lhz7v9GyunPrbzst6f9wP76dleN0ZleOKQejR Waf/G87pI6pbzDTwa1OPksGWMLRlGkM4HMl80zm9QATYrbItBfka3yD7Y8kqNFugkRXn fE6Q85cbkecLwvfLq4F2kxjQwBCgS33RTZYqDq4GDYaNknfMgl3sUDw9/yuw6Nus4oXB V4Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ecbcgh2XCDEUm+/ZfRl2Y++otYHA08IMV0flQG/03d0=; b=CpArSlHbCX4DEUmrc9OxV1zx8YSupoHUims17jk7IBGZO9gOM+V4iBolj8EbLw3WkC B3mLwiowVJQqiD09MRkQh4xU8bKIcMWo1RKNdnwfUO4jYVrgHCbE5BrbIdav74HijvAT dvxQrfzSQ3zAesksQbOARmT/6/4vf++FayOAjHAdmX8P8OC7I+ENFK2/YGTPigD8bzWY ihHeEupsQRgPCnkO/ixD9ApFFotu1avf3td9qnfx1BFQ0xyz8Lle44DN4D9LXm33fun9 24K1wi/cIHM7kcHVkOXG4e4jQhdqUFnWBEXKrdN3zzpQ8uUVEJJOhVYrnWHnAUjXAavw u5Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20210112.gappssmtp.com header.s=20210112 header.b=5Jq5xTvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a05640250c700b0043dfc949d31si13370952edb.25.2022.09.14.07.03.36; Wed, 14 Sep 2022 07:04:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mojatatu-com.20210112.gappssmtp.com header.s=20210112 header.b=5Jq5xTvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229459AbiINN7p (ORCPT + 99 others); Wed, 14 Sep 2022 09:59:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiINN7i (ORCPT ); Wed, 14 Sep 2022 09:59:38 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7928410E2 for ; Wed, 14 Sep 2022 06:59:30 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-127ba06d03fso41216124fac.3 for ; Wed, 14 Sep 2022 06:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=ecbcgh2XCDEUm+/ZfRl2Y++otYHA08IMV0flQG/03d0=; b=5Jq5xTvsbatkEnvLYlO8cJCA6nnkbYsZRKMR4rC5ok5aOzmad+yCdJcxNtKR2hI1/7 dky3w9E3OyZ0SpWi0TL+Yv0qYQ9p/qljlCf8hK2WAWO3dHdg0uplU5DrSWiHbJIf5oWs q+jZ5lf68Qz0CurUButJscXGCDR29OyE1TunaVjyiG91C81PsHHuKIdz4QwNMA8+oduB +DSeLTh/CwdiAhIKgptyZ6DAVry2zYPmOzxYPSLBkse6wQojfo8W8UJXLbYEi/06BJur TzfymoIdG+jq8TcynA0dLw2J+CG0qfPdAiU52RkBYjTSXXTfeayxArpV0v9LEoeOHkcT ebfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=ecbcgh2XCDEUm+/ZfRl2Y++otYHA08IMV0flQG/03d0=; b=jJDhfYae3ChIekq5/7ByvdOPxiKRp7Sp779rNW3kl/5OGsBpFuxSMzTXBXq35tRm/S ECJt1PF6G/bNWiTqaUJIQ0zfq4NKBFZ9bn9a5cW32a6hzzMQXMSK+qEa8sX7MhkVqXlU C/xPEGmFl9CiYtzTxSnej9VkFqcLayEGcZ/CDNoTTM8yMPU/fcBhoQcqgFVHQ3Xf/a7w skTlDsuxWWnbNvimemDPyANtQsFqC1Kp20GqzrN7LQTcQgOtspdJ7BwMGXEwPATi+9eX JwiJ3F7FEy0ZxPrrzs1nN75d2GZmN+EVDkvuhcQc4g7hqU8GnxxqBbtJRZzkeWWA5cg7 2GBw== X-Gm-Message-State: ACgBeo1G7Xfeo1ATn1SLdjLEuNnySYDxOiphJBbZtcVPAGX3W1hlm6Sh +XQ6m8uAyDy1xPYjns8ZLHNQOA== X-Received: by 2002:a05:6808:1985:b0:34f:c592:b8c2 with SMTP id bj5-20020a056808198500b0034fc592b8c2mr2056535oib.3.1663163969556; Wed, 14 Sep 2022 06:59:29 -0700 (PDT) Received: from ?IPV6:2804:1b3:7000:d095:41f2:210c:b643:8576? ([2804:1b3:7000:d095:41f2:210c:b643:8576]) by smtp.gmail.com with ESMTPSA id c8-20020a056870b28800b001275f056133sm8487765oao.51.2022.09.14.06.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Sep 2022 06:59:29 -0700 (PDT) Message-ID: Date: Wed, 14 Sep 2022 10:59:23 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH net-next 3/9] selftests/tc-testings: add selftests for bpf filter Content-Language: en-US To: Zhengchao Shao , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, weiyongjun1@huawei.com, yuehaibing@huawei.com References: <20220913042135.58342-1-shaozhengchao@huawei.com> <20220913042135.58342-4-shaozhengchao@huawei.com> From: Victor Nogueira In-Reply-To: <20220913042135.58342-4-shaozhengchao@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/09/2022 01:21, Zhengchao Shao wrote: > Test 23c3: Add cBPF filter with valid bytecode > Test 1563: Add cBPF filter with invalid bytecode > Test 2334: Add eBPF filter with valid object-file > Test 2373: Add eBPF filter with invalid object-file > Test 4423: Replace cBPF bytecode > Test 5122: Delete cBPF filter > Test e0a9: List cBPF filters > > Signed-off-by: Zhengchao Shao > --- > .../tc-testing/tc-tests/filters/bpf.json | 171 ++++++++++++++++++ > 1 file changed, 171 insertions(+) > create mode 100644 tools/testing/selftests/tc-testing/tc-tests/filters/bpf.json > > diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/bpf.json b/tools/testing/selftests/tc-testing/tc-tests/filters/bpf.json > new file mode 100644 > index 000000000000..c679588f65fd > --- /dev/null > +++ b/tools/testing/selftests/tc-testing/tc-tests/filters/bpf.json > @@ -0,0 +1,171 @@ > +[ > + { > + "id": "23c3", > + "name": "Add cBPF filter with valid bytecode", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { Just a nit-pick, there are some places where you are using tabs instead of spaces. Mostly when specifying the plugins, like in the line above. This goes for the other test patches in this set as well. > + "requires": "nsPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress" > + ], > + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + "expExitCode": "0", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + "matchCount": "1", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "1563", > + "name": "Add cBPF filter with invalid bytecode", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "nsPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress" > + ] > + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0'", > + "expExitCode": "2", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + "matchCount": "0", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "2334", > + "name": "Add eBPF filter with valid object-file", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "buildebpfPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress" > + ], > + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ok", > + "expExitCode": "0", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ok\\].*tag [0-9a-f]{16}( jited)?", > + "matchCount": "1", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "2373", > + "name": "Add eBPF filter with invalid object-file", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "buildebpfPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress" > + ], > + "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ko", > + "expExitCode": "1", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ko\\].*tag [0-9a-f]{16}( jited)?", > + "matchCount": "0", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "4423", > + "name": "Replace cBPF bytecode", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "nsPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress", > + [ > + "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + 0, > + 1, > + 255 > + ] > + ], > + "cmdUnderTest": "$TC filter replace dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'", > + "expExitCode": "0", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'", > + "matchCount": "1", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "5122", > + "name": "Delete cBPF filter", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "nsPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress", > + [ > + "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + 0, > + 1, > + 255 > + ] > + ], > + "cmdUnderTest": "$TC filter del dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "expExitCode": "0", > + "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf", > + "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + "matchCount": "0", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + }, > + { > + "id": "e0a9", > + "name": "List cBPF filters", > + "category": [ > + "filter", > + "bpf" > + ], > + "plugins": { > + "requires": "nsPlugin" > + }, > + "setup": [ > + "$TC qdisc add dev $DEV1 ingress", > + "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'", > + "$TC filter add dev $DEV1 parent ffff: handle 2 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'", > + "$TC filter add dev $DEV1 parent ffff: handle 100 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 33024,6 0 0 262144,6 0 0 0'" > + ], > + "cmdUnderTest": "$TC filter show dev $DEV1 parent ffff:", > + "expExitCode": "0", > + "verifyCmd": "$TC filter show dev $DEV1 parent ffff:", > + "matchPattern": "filter protocol ip pref 100 bpf chain [0-9]+ handle", > + "matchCount": "3", > + "teardown": [ > + "$TC qdisc del dev $DEV1 ingress" > + ] > + } > +]