🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6150

Re: [PATCH bpf-next v2 1/3] bpf: add bpf_ksock_sendto() kfunc

#6150
From: Mahe Tardy
Date: Wed, 21 Oct 2026 18:39
78 lines
14887 bytes
On Wed, Oct 21, 2026 at 10:56:23AM -0700, Andrii Nakryiko wrote:
> On Tue, Oct 20, 2026 at 8:59 AM Mahe Tardy <mahe.tardy@gmail.com> wrote:
> >
> > The motivation is to plumb more of the socket API into ksock, thus
> > supporting sendto() in addition to send() which makes a lot of sense in
> > the context of UDP sockets which are the only type currently supported.
> > This is useful when ksock is used to reply to specific addresses or send
> > to multiple addresses.
> >
> > Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
> > ---
> >  net/core/bpf_ksock.c | 96 +++++++++++++++++++++++++++++++-------------
> >  1 file changed, 69 insertions(+), 27 deletions(-)
> >

[...]

> >
> > -       return ret;
> > +/**
> > + * bpf_ksock_sendto() - Send data through a BPF kernel socket to a remote address.
> > + * @ks:                The BPF kernel socket context. Must be an acquired reference.
> > + * @data:      Pointer to the data to send.
> > + * @data__sz:  Size of the data to send.
> > + * @addr__nullable: Pointer to an IPv4 or IPv6 socket address, or NULL to use
> > + *                the connected destination.
> > + * @addr__sz:  Size of the address union, ignored when the address is NULL.
> > + *
> > + * Sends data to the specified address, or to the connected destination when
> > + * the address is NULL, best-effort and nonblocking. This may sleep
> > + * (kernel_sendmsg), so it can only be called from sleepable BPF programs.
> > + *
> > + * Return: Number of bytes sent on success, negative errno on error.
> > + */
> > +__bpf_kfunc int bpf_ksock_sendto(struct bpf_ksock *ks, const void *data, u32 data__sz,
> 
> This would limit API to fixed-sized data only. Have you considered
> passing dynptr as a source of data, so you can send a wider variety of
> data? I don't have a strong opinion whether we should add a separate
> API or convert this one into dynptr, but I do think that having
> ability to work with variable-sized data is super useful and should be
> added early on.

Oh wow this is really cool that you send this now. I was working this
afternoon on trying to see if a ksock sendmsg() would make sense, but
with these static buffer limitations as arguments, it actually didn't.
I'm not familiar with dynptr so I didn't think about it, but after a
quick check it looks like it would be a good match with the ksock API!

As I understand, since bpf_ksock_send() is already part of 7.3, it's
best to not touch it, and having a simple send() available with a
fixed-size data might make sense.

But since bpf_ksock_sendto() was just merged, we could make it evolve to
use dynptr perhaps? How much time do we have for something which was
merged yesterday to be part of a release? Is it going to be send with
the 7.4 pull soon?

> 
> > +                                const union bpf_ksock_addr *addr__nullable,
> > +                                u32 addr__sz)
> > +{
> > +       return ksock_sendto(ks, data, data__sz, addr__nullable, addr__sz);
> >  }
> >
> >  __bpf_kfunc_end_defs();
> > @@ -255,6 +296,7 @@ BTF_KFUNCS_START(ksock_kfunc_btf_ids)
> >  BTF_ID_FLAGS(func, bpf_ksock_release, KF_RELEASE)
> >  BTF_ID_FLAGS(func, bpf_ksock_acquire, KF_ACQUIRE | KF_RCU | KF_RET_NULL)
> >  BTF_ID_FLAGS(func, bpf_ksock_send, KF_SLEEPABLE)
> > +BTF_ID_FLAGS(func, bpf_ksock_sendto, KF_SLEEPABLE)
> >  BTF_KFUNCS_END(ksock_kfunc_btf_ids)
> >
> >  #ifdef CONFIG_BPF_LSM
> > --
> > 2.43.0
> >
Technical Details
Message-ID: <atkG-5eqB8LfVxSa@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350190-linux-kernel-netdev=dewy.ru
References: <20261020155848.75711-1-mahe.tardy@gmail.com> <20261020155848.75711-2-mahe.tardy@gmail.com> <CAEf4BzapP4Hng7bO8crK4SLg_PMH33oKo8esFo1ur5-QewNfig@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350190-linux-kernel-netdev=dewy.ru
From: mahe.tardy@gmail.com (Mahe Tardy)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf-next v2 1/3] bpf: add bpf_ksock_sendto() kfunc
Date: Wed, 21 Oct 2026 20:39:55 +0200
Organization: Usenet Network
Message-ID: <atkG-5eqB8LfVxSa@gmail.com>
References: <20261020155848.75711-1-mahe.tardy@gmail.com>
 <20261020155848.75711-2-mahe.tardy@gmail.com>
 <CAEf4BzapP4Hng7bO8crK4SLg_PMH33oKo8esFo1ur5-QewNfig@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="35780"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9QrYcLeT3Yua4FYaHvgVUBWFUuw= sha256:cnYqzepDsDu9nYggBn7McfXCtZlNQTA7FwWZBozW9q0=
	sha1:zbALgRrQY1kalnR5HfhvS+jJFzk= sha256:wIrxzDETUrb9hRwtK+0MpUl/STw9b/W8LJKYnO5+wyg=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 8F6931110DD; Wed, 21 Oct 2026 21:40:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id AYZcaTJAmHAe;
	Wed, 21 Oct 2026 21:40:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350190-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id B98B91110DB; Wed, 21 Oct 2026 21:40:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 24C5C348E9; Wed, 21 Oct 2026 18:40:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792608001;
	b=AOHs7AycnfJWAJDLDmtn6NfLea7ck/VZ+FqC/xd7G4lmGRbchnSodJNZ1lC5jDVVgUIq
	 8zu6FcQIckAfKGHu3uPRBy6p0iXTtU8AjSwKiDr65rjiQp60orh22f6YIqQ5E2Ijul9f7
	 lliZMB3z7a0DlD5tFiirRyDGI9LzHD3mahjy/SRu14SO48cOfd60OYpb4GTMKxSPDrana
	 SNZO9+cjxEmpvEd5YiEwI4tmftbgR1qsEYesBmqLWpxdmmRBEUV/g/mMUmNjltlvYfQyo
	 QN7oCIB5GU5x5T4dP3yC87nJ0GbfMRbUKNlamn0iZsdD0CUtBzYSFU4X8FVGEKby4mw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792608001;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Subject:Message-ID:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Disposition:Content-Transfer-Encoding:In-Reply-To;
	bh=FXnb5Rj5qfGts0gZYr/0A/mHLeDZB3dODomhDKpmTdk=;
	b=YhdWmA+CTnLU974NHL8PbdnbcDDenZwIMfRU8MNpOLNsTWAMFX29qNNa06bx/LxrTNIO
	 UR0I1IPz7/CqHo+phAuePV42g1qr71orCmqDjTZfeYAGGOoPElVycUb6xXKPOUbFVcuHq
	 mOCGWwbtBVxZAnXGWlFhOQJtV3bl3JqHdVDt10Z6j0kyEF6lvgoGt/kA0HsxsH6OO78Vq
	 aijCmMhbV2UjwjE06k+61onEf5LtX2gxEBgJd0r9aQM/iU0Ze5S3yg241i035AkYlA8l8
	 X1SjdWqVYK1VIW2jG4XT3gqG5YyMkQYeyB3FTZNq+tIIkNCJP7K1A8XRsQCMoCyHEAA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b="D1i/BJq9";
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 200F2606A325;
	Wed, 21 Oct 2026 18:40:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=D1i/BJq9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792608000;
	b=RQ3tOV6NBFDtCPfdHRIGLX0lp0tx8aEnMr39WdQgL6zpo7L4tlpSwEUL/Ows+Oxmb58p
	 hCuoY+e6vtMeaHzpJkZv4yxnqe6TwlcKI9uqxmnz3w2GeRa2iZbu1JoihKpugf9aUciCr
	 fQPOqK2aFxj/L5BUVrnPqjrhRi8diCevyJOb9brCsicRp1jscf88DX91qadWwclFql/TF
	 W31CzViHFRlI2IxcYy8/NavStyIoJQLo01APcX41oA/JadFAhPRjN24Ic+STivY0/MX8C
	 9q7qpENfbyufQnTEIxUMCJ32dwXWFbNRGk6KaWVqOTpAaWeWf7KIDdcRyrCcKz3xOAA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792608000;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:Content-Transfer-Encoding:
	 In-Reply-To;
	bh=FXnb5Rj5qfGts0gZYr/0A/mHLeDZB3dODomhDKpmTdk=;
	b=z9uV2SFwCVLmeas7oaLKnktni6m6HCIVcUySYDv5x4LqJnLLdhd5ZBIqcLer82RPSaDl
	 hYUBw0EpNf82DxEYpvUYVZl8YdkUaB00u5PNDP9SpGXPqefKZxMfzcovpVIwCrVf5Ybym
	 r8Bvs8iW6nNsIuu37oclTskMfO+AdO8bRI2bSceRSPyfK+S9wm9UNq7n60JXdysfq7q04
	 fOVVNzbnG1OIxkhktnGkuJaxfQbMOsxc9Ux7Qj6FBh0QVw+FGfEXyqhutI5TWLvIfHBa4
	 qRtPk3N8gGUwieA4olPjEo304V+syjwgVECXN6/1ygbf2DTbyv2IL08XEb62m3Z2t2A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b="D1i/BJq9";
	arc=none smtp.remote-ip=209.85.221.51
X-Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33B6C606A31A
	for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 18:39:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33B6C606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-48bbb06e746so651908f8f.3
        for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 11:39:58 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792607997; x=1793212797; darn=vger.kernel.org;
        h=in-reply-to:content-transfer-encoding:content-disposition
         :content-type:mime-version:references:message-id:subject:cc:to:from
         :date:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=FXnb5Rj5qfGts0gZYr/0A/mHLeDZB3dODomhDKpmTdk=;
        b=D1i/BJq9eVs8XTcuhNqhkUYYw8TrAvsxkc9Ut9kiL6tbt0z5RB940/ahJed2a0/ZCc
         yF0oL3uN6pWw1lKve4dSejB2JxLl1/QzCYGZNDf4aMc9rPit+a1kn0IK6eg2IL0foh64
         u0fuONvYxKsrOO3Vxw8IiNzdBR/qmPQUXP29NN2IT1i0EObFTwOqkS2IJpvkLdmdUyPb
         vuk6y4jSgLjCEymCqAzmvfkOfD5BMnKf/Ura/Aav9bNR8L+wAOigT/HMXHIO4GM3klfH
         LzKp8O+BPHkxuLTP00Z4fPrBD8XtGxB3FNS/ML7ASlVbLin806NRRLngIsM3ETOxqKtj
         oMBQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792607997; x=1793212797;
        h=in-reply-to:content-transfer-encoding:content-disposition
         :content-type:mime-version:references:message-id:subject:cc:to:from
         :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to:content-type;
        bh=FXnb5Rj5qfGts0gZYr/0A/mHLeDZB3dODomhDKpmTdk=;
        b=Ce2T9YFDayC0tpSgqSboZJu4/iv6F4sUnQ2zinqcstT3q3tpn7pTN9a9zRVUmbmQ6w
         ABj/aVl0/2Q6Pux48GzQXuJgwhW/zQKVN2W+6ibQD9Agjpoa48Rp+M+YQd1fwYVGfWLW
         jcRWW970Bftd8jD5o3xFun7YDDqmH1mjIjUx3B5yTrUD0sloqfuTWwZxJsviKbif4AFO
         GpBYPcPl5t63hMfhZG+MEC6S/SV7tV4fhqPrlJSmT5rRLFdpyJVukjfGNICnkmKxaec1
         qHrY2XA1Zh1vW8GEL+ICBak8X2LtGILcFbMkrhLRW0vA1GZ9zugYFUS5N0DO+sIqlR3Q
         QcfQ==
X-Forwarded-Encrypted: i=1; AKwUvBz78ESRJ6qPgBaIVQyerM6zAnt5SmSeABF3gVqkQL2GTaaWiLYn/MRqrMdlYj9XLyN9m1wGIL0=@vger.kernel.org
X-Gm-Message-State: AFq9FYIWtZA+4tsqdjDzGbeoFK8YB1JeaPgEqWHHI1C4b/v0RXbig1+R
	CXHM+RtrKV5QDMvzvZYxFCUaEzN21KKEvOtAx5DZrkywzkBiukk+0c6uU4VOXYWVi38=
X-Gm-Gg: AYBFou3GcEcxsiisnkgox0MwtEIT5PTp2N816Em/UZkcYzSxTUUCNNYEQZhz1Rqbluy
	FwptFWl88ay4/lnATelXrOVmhsZUaYzjjoojn9HF137P6fsxn7p0RtPQak0v+Qtp0MEAtuy+5F7
	2AMAjIFUbzhaeKrDYRg5BBjPi8zS7U1isGtebMWCgLJCH0Vosj4zxaBGr3svJUz1+W6z6xaxfWU
	LGsCkKVj7YZzD6Nw/Ot6lJAWhJ3HeSODI1kCngIaUd9xb/6S9U/dXefmUArW28wtHU4fecy3eKU
	MOfPMgic5kNg3ac71TSg8FajsjDFGpz6shtGwxl+5W/H13P0lOEF7FYHiJ1W2+vkGeyGhWahHz3
	FYu145s1EfjvFifpOTtbloz5lcWA6VhVEi/8SoLt2TIReT2mptor1Dg7CbAZmZ1awBFvQQWtZ3n
	FCOks2dRHIDk9SeaprEjCJ3nh4+YjJ5PwxobJqRuFOynYpWN35rgibTUuxrwzcAvvUTo5fN4ttO
	ZlrcT2ilx4VCTSqEAonN96DgM5K+bUxl8WRTlMYY5LoLXTVRpHR1Ak+OyE7HYVB3FxK8wm5oM0Y
	QBqwW+yhV2vp0DYMDOJVXTIHBVuVO/R1ftBqW0A=
X-Received: by 2002:a05:600c:8b4c:b0:4a1:fb01:13 with SMTP id 5b1f17b1804b1-4a1fdd15484mr62637735e9.18.1792607997368;
        Wed, 21 Oct 2026 11:39:57 -0700 (PDT)
X-Received: from gmail.com (deskosmtp.auranext.com. [195.134.167.217])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a203a447c8sm10641255e9.12.2026.10.21.11.39.56
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 21 Oct 2026 11:39:56 -0700 (PDT)
X-Cc: bpf@vger.kernel.org, andrii@kernel.org, ast@kernel.org,
	daniel@iogearbox.net, davem@davemloft.net, willemb@google.com,
	eddyz87@gmail.com, edumazet@google.com, john.fastabend@gmail.com,
	kuba@kernel.org, horms@kernel.org, liamwisehart@meta.com,
	martin.lau@linux.dev, pabeni@redhat.com, song@kernel.org,
	netdev@vger.kernel.org, sdf.kernel@gmail.com,
	yonghong.song@linux.dev, jolsa@kernel.org, kuniyu@google.com,
	memxor@gmail.com, emil@etsalapatis.com, almagui@kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <CAEf4BzapP4Hng7bO8crK4SLg_PMH33oKo8esFo1ur5-QewNfig@mail.gmail.com>