From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id 9BC799C1525 for ; Fri, 11 Nov 2022 10:38:14 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AhnIctxe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668159494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CuzRwI1mSTi/386dr9HtHu+gFAxlK7t/8OnS9h0/MI8=; b=AhnIctxeCpN8RqRjsz/pQFU3vd7pUSZcStlVe43xd+0Mya5BN5YJGYgW2hwvaOXB7WgLYi F3d99aBORvAZc+4klCjqu4PKlg9bZ5+V9Wk4zEiqQ7HDFsxTh/CcAQnoEorUWIE6jiVCWZ DpO5Oqvz0GArLtPTtc2AOxOvGYOJMtA= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-211-ct1LxL8uMrWfnKbx4CbcUQ-1; Fri, 11 Nov 2022 04:38:12 -0500 X-MC-Unique: ct1LxL8uMrWfnKbx4CbcUQ-1 Received: by mail-ej1-f69.google.com with SMTP id qk31-20020a1709077f9f00b00791a3e02c80so2770572ejc.21 for ; Fri, 11 Nov 2022 01:38:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CuzRwI1mSTi/386dr9HtHu+gFAxlK7t/8OnS9h0/MI8=; b=QFIMfWup7B0dYkq0dhpeUPXSYL2++0TMBlushbdZjjSk7g09iTvWQa1b6Qt8j8kE// Zejz66UbAoa9PcLoutygHKNqCRrqGA9iEvuumxjt4cIrQ3z009HkBMQxJAm7dP3rYrSZ 6Bv17TlSwIz931qWkxpE+lJr3uzZ6rnfdcsQ95Sdgm3FQRqiSGD+PXmllkZURlgdCU9Q SZDF4HZRKBvmzVv9fz+otJrzw8zpPA02iNswaA/Rs+d9ld+REGcgAU/v65dgbM8xsLip bH4cHw84yvt5cUYwawk/vbUo+RebocRj7G8LPCiOXEXtUuJbsw/UeN3Nux5eajqurZKj ahcg== X-Gm-Message-State: ANoB5plkFgt0OPd3N8p5zzM2y7+1XVWp/2qWQyWsy389zPsNeTKr2QoU mMNu5DGvCMWQHRooEtW8exaDxLzx6fV806M/yQNTdUz5ovyOxjiVvAYZoGABCUNzY47SpN8cNd0 lAA8aKhvwn0gJkfIHHBIQ X-Received: by 2002:a05:6402:34f:b0:460:12ef:cc45 with SMTP id r15-20020a056402034f00b0046012efcc45mr731703edw.249.1668159491245; Fri, 11 Nov 2022 01:38:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BoVg5/sQIOxSVn1Wrw0hWRqLlG7VKbMrBd99qOGof+9QDVLhrIqKUJpzb0Jcybgy+fNljWA== X-Received: by 2002:a05:6402:34f:b0:460:12ef:cc45 with SMTP id r15-20020a056402034f00b0046012efcc45mr731679edw.249.1668159490817; Fri, 11 Nov 2022 01:38:10 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id eg25-20020a056402289900b00457b5ba968csm875513edb.27.2022.11.11.01.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 01:38:10 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 3E3EE7A689F; Fri, 11 Nov 2022 10:37:53 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Martin KaFai Lau , Stanislav Fomichev In-Reply-To: References: <20221104032532.1615099-1-sdf@google.com> <20221104032532.1615099-7-sdf@google.com> <187e89c3-d7de-7bec-c72e-d9d6eb5bcca0@linux.dev> <9a8fefe4-2fcb-95b7-cda0-06509feee78e@linux.dev> <6f57370f-7ec3-07dd-54df-04423cab6d1f@linux.dev> <87leokz8lq.fsf@toke.dk> <5a23b856-88a3-a57a-2191-b673f4160796@linux.dev> <32f81955-8296-6b9a-834a-5184c69d3aac@linux.dev> <87y1siyjf6.fsf@toke.dk> <87o7texv08.fsf@toke.dk> <87eduaxsep.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 11 Nov 2022 10:37:53 +0100 Message-ID: <87o7td7rwu.fsf@toke.dk> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HHBN4WB6QSUEYMDPQK4P4FOY3RWO5DTM X-Message-ID-Hash: HHBN4WB6QSUEYMDPQK4P4FOY3RWO5DTM X-MailFrom: toke@redhat.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: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, 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, bpf@vger.kernel.org X-Mailman-Version: 3.3.6 Precedence: list Subject: [xdp-hints] Re: [RFC bpf-next v2 06/14] xdp: Carry over xdp metadata into skb context List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Martin KaFai Lau writes: > On 11/10/22 4:10 PM, Toke H=C3=B8iland-J=C3=B8rgensen wrote: >>> The problem with AF_XDP is that, IIUC, it doesn't have a data_meta >>> pointer in the userspace. >>> >>> You get an rx descriptor where the address points to the 'data': >>> | 256 bytes headroom where metadata can go | data | >>=20 >> Ah, I was missing the bit where the data pointer actually points at >> data, not the start of the buf. Oops, my bad! >>=20 >>> So you have (at most) 256 bytes of headroom, some of that might be the >>> metadata, but you really don't know where it starts. But you know it >>> definitely ends where the data begins. >>> >>> So if we have the following, we can locate skb_metadata: >>> | 256-sizeof(skb_metadata) headroom | custom metadata | skb_metadata | = data | >>> data - sizeof(skb_metadata) will get you there >>> >>> But if it's the other way around, the program has to know >>> sizeof(custom metadata) to locate skb_metadata: >>> | 256-sizeof(skb_metadata) headroom | skb_metadata | custom metadata | = data | >>> >>> Am I missing something here? >>=20 >> Hmm, so one could argue that the only way AF_XDP can consume custom >> metadata today is if it knows out of band what the size of it is. And if >> it knows that, it can just skip over it to go back to the skb_metadata, >> no? > > +1 I replied with a similar point in another email. I also think we > can safely assume this. Great! >>=20 >> The only problem left then is if there were multiple XDP programs called >> in sequence (whether before a redirect, or by libxdp chaining or tail >> calls), and the first one resized the metadata area without the last one >> knowing about it. For this, we could add a CLOBBER_PROGRAM_META flag to >> the skb_metadata helper which if set will ensure that the program >> metadata length is reset to 0? > > How is it different from the same xdp prog calling bpf_xdp_adjust_meta() = and=20 > bpf_xdp_metadata_export_to_skb() multiple times. The earlier stored=20 > skb_metadata needs to be moved during the latter bpf_xdp_adjust_meta(). = The=20 > latter bpf_xdp_metadata_export_to_skb() will overwrite the earlier skb_me= tadata. Well, it would just be a convenience flag, so instead of doing: metalen =3D ctx->data - ctx->data_meta; if (metalen) xdp_adjust_meta(-metalen); bpf_xdp_metadata_export_to_skb(ctx); you could just do: bpf_xdp_metadata_export_to_skb(ctx, CLOBBER_PROGRAM_META); and the kernel would do the check+move for you. But, well, the couple of extra instructions to do the check in BPF is probably fine. (I'm talking here about a program that wants to make sure that any custom metadata that may have been added by an earlier program is removed before redirecting to an XSK socket; I expect we'd want to do something like this in the default program in libxdp). -Toke