From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by mail.toke.dk (Postfix) with ESMTPS id B2147A1B5E5 for ; Fri, 21 Jul 2023 18:44:30 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=mPrQK5Y3 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-77acb04309dso96438039f.2 for ; Fri, 21 Jul 2023 09:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689957869; x=1690562669; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=V4OProLwa1HBsCbSYEasskJSriVq6OZzQbg8GckWVaw=; b=mPrQK5Y3TwhUK0ThN4Jk2VHYg6uJxld5kkrt77HnmDbGjnA/6+yVY1PMnYBViHNexJ yBcdUFmia72m/UkL0qM2PuGiK6/tNarHCQ88f138vL1b6HdiC9T0kKFzKtblVMjcQJ6F aSTJj/So3ncOWlKabQiDB3Z2M0OFnse0LemYP+nGIUb1F/bNryeQmVVsZg/KBDVuJvNS n7LwAGwSUGyaTJDy0ikdvFhFKevCNonJDgiiFTDrvAIMnbGbAPRVFcVWTvJFzNPF3XQn yuFkjhSIWWfJOyov7ztZg4apNm8mclf9Qhz41oK80SaLFOh+khEaCjpeTjQHv2nLzb7K v3Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689957869; x=1690562669; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V4OProLwa1HBsCbSYEasskJSriVq6OZzQbg8GckWVaw=; b=E4bjOmE1vKz48hX7PitYyxOeJ/JVKYXF18/Eg0TiazAvlFskR6QmJOBhkmqze9Zxvz qCmLBE4URoBrkVuNtunmPqcKLWIQ5gWSDoqkbHhJBnPTBqzjNKMruP9KWUcNEq/iPWkc 2TjbSjzcddBtzx0KJQJpfRaPOjhw+spnAcbSlomztic9WIu2VO6r4jhXwwLpfjMO2vv2 w1BcN8cCL8kv70rCdR5k3R5Cr0GYDQyjy3ku8pX0XwRD19WoBS3FVVV9KZ8vuANvu0cE CXBG6eHtwkO6cvqVpcVikklvgoBSE9thutJPUiMaA+4LcrTKJZUuaRkRZvSbJYinZ9+3 kA7w== X-Gm-Message-State: ABy/qLbnOEoKBOmr3zDVLrST6IShaxB1dmrSF20Csf48wcmdC24bnnTY k/sFNFIVzyvtZ1UfG4bCBHjrPrQYIcwdNeLo2sXWNQ== X-Google-Smtp-Source: APBJJlHiHToCKJWM9rth8/IfAfW5ySm0aJOdUu3O0OXip58+wsj8VD+/EygYvpU+NnZ1V7pWWzJXxib5ErH3P1cA63Q= X-Received: by 2002:a05:6e02:1d88:b0:348:90c2:ba0a with SMTP id h8-20020a056e021d8800b0034890c2ba0amr502473ila.32.1689957868798; Fri, 21 Jul 2023 09:44:28 -0700 (PDT) MIME-Version: 1.0 References: <20230719183734.21681-1-larysa.zaremba@intel.com> <20230719183734.21681-21-larysa.zaremba@intel.com> In-Reply-To: From: Stanislav Fomichev Date: Fri, 21 Jul 2023 09:44:17 -0700 Message-ID: To: "Zaremba, Larysa" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WEC3QWBECEIO6CAV4Q3WF5N2JO46L32J X-Message-ID-Hash: WEC3QWBECEIO6CAV4Q3WF5N2JO46L32J X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "bpf@vger.kernel.org" , "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" , "haoluo@google.com" , "jolsa@kernel.org" , David Ahern , Jakub Kicinski , Willem de Bruijn , "Brouer, Jesper" , "Burakov, Anatoly" , "Lobakin, Aleksander" , Magnus Karlsson , "Tahhan, Maryam" , "xdp-hints@xdp-project.net" , "netdev@vger.kernel.org" X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v3 20/21] selftests/bpf: Check VLAN tag and proto in xdp_metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, Jul 21, 2023 at 12:47=E2=80=AFAM Zaremba, Larysa wrote: > > On Thu, Jul 20, 2023 at 03:14:15PM -0700, Stanislav Fomichev wrote: > > On 07/19, Larysa Zaremba wrote: > > > Verify, whether VLAN tag and proto are set correctly. > > > > > > To simulate "stripped" VLAN tag on veth, send test packet from VLAN > > > interface. > > > > > > Signed-off-by: Larysa Zaremba > > > > Acked-by: Stanislav Fomichev > > > > > --- > > > .../selftests/bpf/prog_tests/xdp_metadata.c | 22 +++++++++++++++++= -- > > > .../selftests/bpf/progs/xdp_metadata.c | 4 ++++ > > > 2 files changed, 24 insertions(+), 2 deletions(-) > > > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/= tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > > > index 1877e5c6d6c7..6665cf0c59cc 100644 > > > --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > > > +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > > > @@ -38,7 +38,15 @@ > > > #define TX_MAC "00:00:00:00:00:01" > > > #define RX_MAC "00:00:00:00:00:02" > > > > > > +#define VLAN_ID 59 > > > +#define VLAN_ID_STR "59" > > > > I was looking whether we have some str(x) macro in the selftests, > > but doesn't look like we have any... > > > > I could add one, if you could hint me at the file, where it would need to= go. > Or just add it locally for now? Up to you. I feel like it's fine as is. I was expecting to find something like the following in tools/testing/selftests/bpf/testing_helpers.h: #define __TO_STR(x) #x #define TO_STR(x) __TO_STR(x) We have similar patterns in: tools/testing/selftests/bpf/sdt.h (_SDT_ARG_CONSTRAINT_STRING) tools/testing/selftests/kvm/x86_64/smm_test.c (XSTR) tools/tracing/rtla/src/utils.c (STR) But nothing "generic" it seems... > > > +#define VLAN_PROTO "802.1Q" > > > +#define VLAN_PID htons(ETH_P_8021Q) > > > +#define TX_NAME_VLAN TX_NAME "." VLAN_ID_STR > > > +#define RX_NAME_VLAN RX_NAME "." VLAN_ID_STR > > > + > > > #define XDP_RSS_TYPE_L4 BIT(3) > > > +#define VLAN_VID_MASK 0xfff > > > > > > struct xsk { > > > void *umem_area; > > > @@ -215,6 +223,12 @@ static int verify_xsk_metadata(struct xsk *xsk) > > > if (!ASSERT_NEQ(meta->rx_hash_type & XDP_RSS_TYPE_L4, 0, "rx_hash= _type")) > > > return -1; > > > > > > + if (!ASSERT_EQ(meta->rx_vlan_tci & VLAN_VID_MASK, VLAN_ID, "rx_vl= an_tci")) > > > + return -1; > > > + > > > + if (!ASSERT_EQ(meta->rx_vlan_proto, VLAN_PID, "rx_vlan_proto")) > > > + return -1; > > > + > > > xsk_ring_cons__release(&xsk->rx, 1); > > > refill_rx(xsk, comp_addr); > > > > > > @@ -248,10 +262,14 @@ void test_xdp_metadata(void) > > > > > > SYS(out, "ip link set dev " TX_NAME " address " TX_MAC); > > > SYS(out, "ip link set dev " TX_NAME " up"); > > > - SYS(out, "ip addr add " TX_ADDR "/" PREFIX_LEN " dev " TX_NAME); > > > + > > > + SYS(out, "ip link add link " TX_NAME " " TX_NAME_VLAN > > > + " type vlan proto " VLAN_PROTO " id " VLAN_ID_STR); > > > + SYS(out, "ip link set dev " TX_NAME_VLAN " up"); > > > + SYS(out, "ip addr add " TX_ADDR "/" PREFIX_LEN " dev " TX_NAME_VL= AN); > > > > > > /* Avoid ARP calls */ > > > - SYS(out, "ip -4 neigh add " RX_ADDR " lladdr " RX_MAC " dev " TX_= NAME); > > > + SYS(out, "ip -4 neigh add " RX_ADDR " lladdr " RX_MAC " dev " TX_= NAME_VLAN); > > > close_netns(tok); > > > > > > tok =3D open_netns(RX_NETNS_NAME); > > > diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools= /testing/selftests/bpf/progs/xdp_metadata.c > > > index d151d406a123..d3111649170e 100644 > > > --- a/tools/testing/selftests/bpf/progs/xdp_metadata.c > > > +++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c > > > @@ -23,6 +23,9 @@ extern int bpf_xdp_metadata_rx_timestamp(const stru= ct xdp_md *ctx, > > > __u64 *timestamp) __ksym; > > > extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 = *hash, > > > enum xdp_rss_hash_type *rss_type) __k= sym; > > > +extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx, > > > + __u16 *vlan_tci, > > > + __be16 *vlan_proto) __ksym; > > > > > > SEC("xdp") > > > int rx(struct xdp_md *ctx) > > > @@ -57,6 +60,7 @@ int rx(struct xdp_md *ctx) > > > meta->rx_timestamp =3D 1; > > > > > > bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type= ); > > > + bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_tci, &meta->rx_v= lan_proto); > > > > > > return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); > > > } > > > -- > > > 2.41.0 > > > > >