🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6166

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

#6166
From: "Kumar Kartikeya Dwivedi"
Date: Wed, 21 Oct 2026 19:50
112 lines
15781 bytes
On Wed Oct 21, 2026 at 8:57 PM CEST, Andrii Nakryiko wrote:
> On Wed, Oct 21, 2026 at 11:39 AM Mahe Tardy <mahe.tardy@gmail.com> wrote:
>>
>> 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.
>
> agreed
>
>>
>> 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?
>>
>
> I'd send a follow up in the next few days, it can go in as a fix for
> kfunc in rc1 or something, unless others have differing opinions on
> this
>

Another option is to add dynptr variants of both, a pattern we have in other
APIs as well, so there would be no rush. We just have two more kfuncs:
bpf_ksock_send_dynptr() and bpf_ksock_sendto_dynptr().

>> >
>> > > +                                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: <DMARZV0CMCU6.B7GRUVI8S0WT@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-350223-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> <atkG-5eqB8LfVxSa@gmail.com> <CAEf4BzYA79tg5C+uzo3S5=MRgM_O7VMYtOwW59QMieJoFNOpVg@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-350223-linux-kernel-netdev=dewy.ru
From: memxor@gmail.com ("Kumar Kartikeya Dwivedi")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf-next v2 1/3] bpf: add bpf_ksock_sendto() kfunc
Date: Wed, 21 Oct 2026 21:50:15 +0200
Organization: Usenet Network
Message-ID: <DMARZV0CMCU6.B7GRUVI8S0WT@gmail.com>
References: <20261020155848.75711-1-mahe.tardy@gmail.com>
 <20261020155848.75711-2-mahe.tardy@gmail.com>
 <CAEf4BzapP4Hng7bO8crK4SLg_PMH33oKo8esFo1ur5-QewNfig@mail.gmail.com>
 <atkG-5eqB8LfVxSa@gmail.com>
 <CAEf4BzYA79tg5C+uzo3S5=MRgM_O7VMYtOwW59QMieJoFNOpVg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="48958"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:sfRpfJ4/2mzPinEi1cKWc/DWvWo= sha256:z5NNxjmXvs+q2zQyZdcxcPk0RMbCwMUrHEpRr2EZ7jM=
	sha1:Zza6JYJElKlt1OIgRXOSMGtGC/c= sha256:CvNvwAVwhoqkgZZ7nyMerHI+nbwcLWGBOaxRSlDzj5M=
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 CEB6F1110FF; Wed, 21 Oct 2026 22:50:38 +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 v0U7s6KRUxZV;
	Wed, 21 Oct 2026 22:50:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350223-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 DFBFB1110E9; Wed, 21 Oct 2026 22:50:27 +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 1463B34D3F; Wed, 21 Oct 2026 19:50:21 +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=1792612219;
	b=cepCzRYb8eL7Q3LbE9VO5RoI50sQtmrZcXheYJN0qosiPQynatCodxbkrYwx7U8adkZD
	 GwxuBGRlW4ZY7bG0pZ0E88CZdXFJtp6stbcoocjBGou0zjTI3EYCkPFAshjHNZleeSMEl
	 sblcZqHWfLHq+yw9RMK8uaJcqrlTtJMcrSQN1VKc6DNmC08CcxRyJNxGWMTMAIR6JyyS0
	 N83oPDY5jHT72IKuYw6zw1yrdacTwBKAphRHAGn6y8CtZMpSA72Vkt2AOtgTVaCnOwdVv
	 x7dt642pD/Rm6RK6XuMj1A5ojCxvD0DL54Dty1Iovd9ICuF9mbne99hxxi7fhq2i3/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792612219;
	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:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id:
	 Cc:Subject:From:To:X-Mailer:References:In-Reply-To;
	bh=rfoJ05UONkmwL2VwlQYGmz6+VLrAyTICL7RfJCuaVwE=;
	b=r0l72tcglraOX4jSnqzbEBhtLjXM5biBvINGTEDAOgRaGAS7BSTypYOFZYxlg1LVvzy1
	 WxdUjQdQ2UVuPMq3TAdNi/1gWAKodtzczYt7sYZ43hm0YIUFRiDQh3sH2WyDCaJUaV+IP
	 TU7/U4e8b+nMwbRHz0l2suxwrHN7J+l85cB8Oq/GdlRthzvafjtZdcqe1W1UpoxHkq2oL
	 8UsKneFpnjRZ2SnoDzh3b16XsWzHK7koVMd6GEF3oE/B8MQQwF1HzzIKqSCtwyWs4apPu
	 J7gyyGcWo6TyUeM5pnbUHS/+d+Yna3hRhoqHmGtoIO4vzogWjIw1rvTQJnWkfCUyrpA==
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=goQQtm4q;
	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 B9164606A324;
	Wed, 21 Oct 2026 19:50:19 +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=goQQtm4q
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.136
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792612218;
	b=0+2egqBhRzE4AQull2egzczpUYKCW/PuMqNylsZF6SxOoymVE5woUdD52aFI7V6KqtZm
	 rXvpGQr7r9DJJuv3+/HWwbqxaLz+RPxVl36SO4T6NoLmTujpuH7LxMxzIGkRzOBL/cZse
	 BwFcd20UQMpPOd0JRSNBp88hrU8SdKFeKFDgtphISsBheEAjjG+Tfhcr9kBiAMa9j/hpj
	 nFqCNAwO3Cc3WmJICsn8ZI1kI3KQajgO8Ut+GEvlKLuHLG8og8VQATazgriWPDTKQXyvX
	 Vs+4UnMQ5SiEa8xLeL1mCkOdaUXmze1aDuYxVFjwS118bz3q5xg/6uqSuimUdBO+HFA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792612218;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id:
	 Cc:Subject:From:To:X-Mailer:References:In-Reply-To;
	bh=rfoJ05UONkmwL2VwlQYGmz6+VLrAyTICL7RfJCuaVwE=;
	b=ErFO475ik/kekMU5nSI5gRYftOzf1pp7Y4aoW86HRc5e6cWG3X5hYBKTU+pjzZMULMIC
	 Tf1Lui09DCRfyAgZruLZcJmxKIbci0G1KwrmZxroPkjXS3VzWxvodJmjNmRRtJw04vFOQ
	 YmUZzwRviGgmYJjxgUEkx2vO9Ngwm/iueHS+ddco4aAnBtXr3YWna9KuJpwrr06MGKQJZ
	 4CNnMoLExWhVBHcZTUHFmamBGWyLYnlo/V/JCiKP9nzbKyAnpcDUEbgITTvOZ7PVLlf0j
	 lryu8jGTvU4AKHzqggqDBSWGCxQZPzigApir36RcWZKz+jHAmOnf+An2APtPOkYVCzA==
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=goQQtm4q;
	arc=none smtp.remote-ip=74.125.224.136
X-Received: from mail-yx2-f8.google.com (mail-yx2-f8.google.com [74.125.224.136])
	(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 7BEF9606A31A
	for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 19:50:18 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7BEF9606A31A
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-yx2-f8.google.com with SMTP id 00721157ae682-8b0c81dcf98so3464287b3.1
        for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 12:50:18 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792612217; x=1793217017; darn=vger.kernel.org;
        h=in-reply-to:references:to:from:subject:cc:message-id:date
         :content-type:content-transfer-encoding:mime-version:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=rfoJ05UONkmwL2VwlQYGmz6+VLrAyTICL7RfJCuaVwE=;
        b=goQQtm4qVsIdcw0groGw6hqMcB3SQa/Z4bQ20PwJKf8Rv6WFQJgPFRiA1hteBDZCeS
         gsWC5P20bRBiDI/gBfL6YqjJ+W8ofEetzDpyLAp/8t7wBZVwciOw9iCtdxjzD23LcWXp
         VvL1kZqz9a6DKpffHdurAZtrtCSuKKTOtZurqYALIR/kRh53Vdu8lntJsJHylM8X5eFW
         eqYjppKuKAREzt/DyG8uBijR2qYrTQ5UoJuETr6C/2HEiTgy5jPsylbYHftKp/i+T+7q
         s/JCJ0it/OyzfY3dD+cJbXriL69Tkeu9rjVzMiWXfwQp4kraYGIvaXL/fCVtTC+xyxQf
         gDfw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792612217; x=1793217017;
        h=in-reply-to:references:to:from:subject:cc:message-id:date
         :content-type:content-transfer-encoding:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=rfoJ05UONkmwL2VwlQYGmz6+VLrAyTICL7RfJCuaVwE=;
        b=FB/YDvWOgjN6RWRR8XpL5zhLQuRoovuKOLfSWQsfPAQfg6snKgjrnHz3eSIQ7Gi+Ui
         c748crBTUlcfZxIOZqlmuj4HAtPmcdgxaEhq4OCR4RABD622dMY4/IaFCmkpdqoOOXKw
         fQb3RJGx7fI9s1viYCShcfl0Z9sXrQhvHt8sagg2g2AR65YIRVp1GM91jp5dGKFJNxEW
         y5sg/mkAecgkf27N5q9OtmN3Q8g8TWrOHK6wQxY3rtDrecSDVrFPnK6buZSu5acf2kr7
         NN2hVAAIHWpb+D4GvqE0RcT0/zTKHWX7L0HfJx+28pMO6RSGV9HWycBGVN7qIfopKy0p
         Xq0Q==
X-Forwarded-Encrypted: i=1; AKwUvBwYcprjgZdafwV2d01+j4qoGotPehpEpTLRTBkDEm+N4BSTdrydr/rZorq0O/V/N/0gqsEt5Pc=@vger.kernel.org
X-Gm-Message-State: AFq9FYKDeO2JfPl6M4RitzqsAcvXGwN9lvdvC2/FBNUBriL0Y5dxWZUo
	4PAwVOSmgKs01kQJv6rgKlXYJ+9E9mAEuKoN0y8qTSkzcLhN911/KkSW
X-Gm-Gg: AYBFou0k3mHE4deve4cAqpsYsvDq2b/ANJAbp0F4PTp6JEt4NOGKZwivGUryqShFit3
	KViQKt0P2Y/SugYzbjHBS3qGzQYY9dNT+UKsvcD10X5OmMZlbNmsklEZUVQvGn8y+VkIbBcjXbx
	QefSdkwKoRKTLytaDXj1t9efiLy0upw8X2UES8l3vzlmvl0YI+V5qwyguAKWI0x+qmWvX3npXIw
	0ydb+IgE+nZRWKlfsCENhKk+tTv3oXWJYORMdmxiBpMiwr/En68Hi9QGhe8KASca2LhFj7YovbV
	aYlXPqlbVL/Qw08/QQ5SkcVlAIu1MFsAsZckG+oVvudhIA7kOIR/8v7jlziTCAdhMFHjIgJM4rS
	/HfjiBnOtRLPijk+3i7x6h79amlkMSRSAFd417alOPAmm8/7TKYp6+vmErR4HjCh5UGQrEe47Cn
	I6uS7d1MXrt/eZ/e0FMGqZTccQw74zY/CQMNNguS8L9mJAPLBgTk/q1lurhlGh8ydRw7GKcm6zW
	MLzGStDv2RfT7R65tu9kGWE537aF6QK4nprJ2dwdobrVL48RKW4ujKomRkK/VwmMcv7qpN1gIEb
	KAeVkd1ELGzk3z7vA7fgT22Xa6u727+D33mWD2yB0ilpfodnJj1F3U2kH2Xe6ns=
X-Received: by 2002:a05:690c:6d83:b0:8ac:6e11:3dee with SMTP id 00721157ae682-8b133c990ffmr18942997b3.10.1792612217411;
        Wed, 21 Oct 2026 12:50:17 -0700 (PDT)
X-Received: from localhost ([2a03:2880:10ff:5a::])
        by smtp.gmail.com with ESMTPSA id 00721157ae682-8b130074aa6sm16117427b3.10.2026.10.21.12.50.15
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 21 Oct 2026 12:50:16 -0700 (PDT)
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-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>,
 <emil@etsalapatis.com>, <almagui@kernel.org>
X-Mailer: aerc 0.22.0
X-In-Reply-To: <CAEf4BzYA79tg5C+uzo3S5=MRgM_O7VMYtOwW59QMieJoFNOpVg@mail.gmail.com>