From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by mail.toke.dk (Postfix) with ESMTPS id 17AF4A1779E for ; Thu, 6 Jul 2023 19:27:55 +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=jR014TIB Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3a3790a0a48so865456b6e.1 for ; Thu, 06 Jul 2023 10:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688664470; x=1691256470; 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=7QHS/VR07ajDiBHiAQaH4sBwoJmZUdR5Oe/340tdBJA=; b=jR014TIBx34PqhIfwNlZl/SjjekJltkMg1drpzGydi51tnvz8hKLC0v7cExjUF6690 r1nfr5OFVUlR360Lp/b7zv0149q5k/u9hxoGqjUM2PoTKGjx/LXI1pbTzGiA6ZcEG4bl 8PjBab5Kqi322RN7XLEJ2mRCI7lkGtnrSgnqiaOXIzvU6ydAg5xFIHyir+SCS3jXPLDT Ph7AyZ3gTQwEei/p4ocdb9TXokOwem4IXuF6UMqnaGkJJYOCWJSN5foqwVybokuZL0rq lVUAJgqEyIavAvWEKKInA/LQfJABHaxaQC50tRt5vrfZn/j6QXMwCBghC2cdCP+mqfnc qPAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688664470; x=1691256470; 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=7QHS/VR07ajDiBHiAQaH4sBwoJmZUdR5Oe/340tdBJA=; b=adk5FGsfj5vqjC5igXOo9JOdYBA7bClEVtO7A1NuELuUqkVQWaGXmcegLZnpoOceDp DXurvjC6c1U+lUNNWWF0XCfUNM3WuDaOZdnUOUyYNVvtd0f8rT2TG2oZkOHfUj/Xi473 YEFYXZNYR/G8kdGTgxjMRdh9iR0Z1I/taeSFYFOQTEEaEg+ETRrfnN1OR4unRzMzcPId fXixcrB/MGwdneo1XdRs/PJKJLOwknqALla0t4xStQFM1wi0lvolOVWeYTo9ELSkqMfS iOWDlyxDC+ImuJVTUSrlAfE+tceBypIDSxbvnkq+1M43RjmXupdiMKHvQJ0M0faFdbaU amNg== X-Gm-Message-State: ABy/qLbbic2M55y5Fsl7HPZ1v/Gogipzm7FF+4lhohJwhibbXkjb34dp g4lVnp2outncovt6WGUQlP4Rq6wzw32N/Wgn60O6YA== X-Google-Smtp-Source: APBJJlFIBlvITdvF2gXEv0dJNHSb23rnclHLcMLWJSjHrRYlj43avwfou8Ov/vAFOC9XZxqGtvSsG97E0OPBUAdYH1U= X-Received: by 2002:a05:6808:b0a:b0:3a3:9f5a:c308 with SMTP id s10-20020a0568080b0a00b003a39f5ac308mr1965956oij.20.1688664469737; Thu, 06 Jul 2023 10:27:49 -0700 (PDT) MIME-Version: 1.0 References: <20230703181226.19380-1-larysa.zaremba@intel.com> <20230703181226.19380-19-larysa.zaremba@intel.com> In-Reply-To: From: Stanislav Fomichev Date: Thu, 6 Jul 2023 10:27:38 -0700 Message-ID: To: Larysa Zaremba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UKGG7B5N57P5K6QIDJCOBOAN54CNO6WH X-Message-ID-Hash: UKGG7B5N57P5K6QIDJCOBOAN54CNO6WH 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 , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v2 18/20] selftests/bpf: Use AF_INET for TX 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 Thu, Jul 6, 2023 at 7:15=E2=80=AFAM Larysa Zaremba wrote: > > On Wed, Jul 05, 2023 at 10:39:35AM -0700, Stanislav Fomichev wrote: > > On 07/03, Larysa Zaremba wrote: > > > The easiest way to simulate stripped VLAN tag in veth is to send a pa= cket > > > from VLAN interface, attached to veth. Unfortunately, this approach i= s > > > incompatible with AF_XDP on TX side, because VLAN interfaces do not h= ave > > > such feature. > > > > > > Replace AF_XDP packet generation with sending the same datagram via > > > AF_INET socket. > > > > > > This does not change the packet contents or hints values with one not= able > > > exception: rx_hash_type, which previously was expected to be 0, now i= s > > > expected be at least XDP_RSS_TYPE_L4. > > > > > > Also, usage of AF_INET requires a little more complicated namespace s= etup, > > > therefore open_netns() helper function is divided into smaller reusab= le > > > pieces. > > > > Ack, it's probably OK for now, but, FYI, I'm trying to extend this part > > with TX metadata: > > https://lore.kernel.org/bpf/20230621170244.1283336-10-sdf@google.com/ > > > > So probably long-term I'll switch it back to AF_XDP but will add > > support for requesting vlan TX "offload" from the veth. > > > > My bad for not reading your series. Amazing work as always! > > So, 'requesting vlan TX "offload"' with new hints capabilities? This woul= d be > pretty neat. > > But you think AF_INET TX is worth keeping for now, until TX hints are mat= ure? > > > > Signed-off-by: Larysa Zaremba > > > --- > > > tools/testing/selftests/bpf/network_helpers.c | 37 +++- > > > tools/testing/selftests/bpf/network_helpers.h | 3 + > > > .../selftests/bpf/prog_tests/xdp_metadata.c | 175 +++++++---------= -- > > > 3 files changed, 98 insertions(+), 117 deletions(-) > > > > > > diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/te= sting/selftests/bpf/network_helpers.c > > > index a105c0cd008a..19463230ece5 100644 > > > --- a/tools/testing/selftests/bpf/network_helpers.c > > > +++ b/tools/testing/selftests/bpf/network_helpers.c > > > @@ -386,28 +386,51 @@ char *ping_command(int family) > > > return "ping"; > > > } > > > > > > +int get_cur_netns(void) > > > +{ > > > + int nsfd; > > > + > > > + nsfd =3D open("/proc/self/ns/net", O_RDONLY); > > > + ASSERT_GE(nsfd, 0, "open /proc/self/ns/net"); > > > + return nsfd; > > > +} > > > + > > > +int get_netns(const char *name) > > > +{ > > > + char nspath[PATH_MAX]; > > > + int nsfd; > > > + > > > + snprintf(nspath, sizeof(nspath), "%s/%s", "/var/run/netns", name)= ; > > > + nsfd =3D open(nspath, O_RDONLY | O_CLOEXEC); > > > + ASSERT_GE(nsfd, 0, "open /proc/self/ns/net"); > > > + return nsfd; > > > +} > > > + > > > +int set_netns(int netns_fd) > > > +{ > > > + return setns(netns_fd, CLONE_NEWNET); > > > +} > > > > We have open_netns/close_netns in network_helpers.h that provide simila= r > > functionality, let's use them instead? > > > > I have divided open_netns() into smaller pieces (see below), because the = code I > have added into xdp_metadata looked better with those smaller pieces (I h= ad to > switch namespace several times). Forgot to reply to this part. I missed the fact that you're extending network_helpers, sorry. But why do we need extra namespaces at all?