From: Mahe Tardy <mahe.tardy@gmail.com>
To: Stanislav Fomichev <sdf.kernel@gmail.com>
Cc: bpf@vger.kernel.org, andrew+netdev@lunn.ch, andrii@kernel.org,
ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net,
eddyz87@gmail.com, edumazet@google.com, john.fastabend@gmail.com,
kuba@kernel.org, liamwisehart@meta.com, martin.lau@linux.dev,
pabeni@redhat.com, song@kernel.org, netdev@vger.kernel.org,
ameryhung@gmail.com, kuniyu@google.com
Subject: Re: [PATCH bpf-next v2 2/5] bpf: Add ksock kfuncs
Date: Thu, 23 Jul 2026 11:52:04 +0200 [thread overview]
Message-ID: <amHkRPNLKl8dQomb@gmail.com> (raw)
In-Reply-To: <amELAv1bgc9DP6WT@devvm7509.cco0.facebook.com>
On Wed, Jul 22, 2026 at 11:27:32AM -0700, Stanislav Fomichev wrote:
> On 07/22, Mahe Tardy wrote:
> > Add BPF kfuncs that allow BPF LSM programs to create and use sockets for
> > sending data. This provides a mechanism for BPF programs to emit
> > telemetry. For this first patch set, it's restricted to SOCK_DGRAM
> > socket types with IPPROTO_UDP protocol but could be easily extended to
> > SOCK_STREAM and IPPROTO_TCP in the future.
> >
[...]
> > +
> > +/**
> > + * struct bpf_ksock_addr_opts - BPF kernel socket address parameters
> > + * @family: Address family: AF_INET or AF_INET6.
> > + * @reserved: Must be zero. Reserved for future use.
> > + * @port: Port in host byte order.
> > + * @scope_id: IPv6 scope ID for scoped AF_INET6 addresses, or zero.
> > + * Must be zero when family=AF_INET.
> > + * @ipv4_addr: IPv4 address in network byte order. Used when family=AF_INET.
> > + * @ipv6_addr: IPv6 address (16 bytes, network byte order). Used when family=AF_INET6.
> > + */
> > +struct bpf_ksock_addr_opts {
> > + __u8 family;
> > + __u8 reserved;
> > + __u16 port;
> > + __u32 scope_id;
> > +
> > + union {
> > + __be32 ipv4_addr;
> > + __u32 ipv6_addr[4]; /* in6_addr; network order */
> > + };
> > +};
>
> Do you add these because of BTF type checking? Can we have something a bit
> more orthodox like:
>
> union bpf_sockaddr {
> struct sockaddr_in sin;
> struct sockaddr_in6 sin6;
> };
>
> ?
>
> I hope we can just pass these to sock_create and make it do all the input
> checking..
Yeah probably, I didn't think about this too much. I inherited it from
the netpoll tentative where Daniel suggested to take inspiration from
the fib lookup helpers[^1], which made sense for the netpoll call. If we
can simplify this we can get rid of bpf_ksock_parse_addr(). Let me try.
[^1]: https://lore.kernel.org/bpf/4b64ecd8-eade-4676-822e-da73abe2421d@iogearbox.net/
next prev parent reply other threads:[~2026-07-23 9:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 10:44 [PATCH bpf-next v2 0/5] Introduce bpf_ksock Mahe Tardy
2026-07-22 10:44 ` [PATCH bpf-next v2 1/5] net: Add __sys_connect_socket() helper Mahe Tardy
2026-07-22 10:44 ` [PATCH bpf-next v2 2/5] bpf: Add ksock kfuncs Mahe Tardy
2026-07-22 18:27 ` Stanislav Fomichev
2026-07-23 9:52 ` Mahe Tardy [this message]
2026-07-22 10:44 ` [PATCH bpf-next v2 3/5] selftests/bpf: Add ksock kfunc test Mahe Tardy
2026-07-22 10:44 ` [PATCH bpf-next v2 4/5] selftests/bpf: Add ksock LSM recursion test Mahe Tardy
2026-07-22 10:44 ` [PATCH bpf-next v2 5/5] selftests/bpf: Add ksock test for async callback guard Mahe Tardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=amHkRPNLKl8dQomb@gmail.com \
--to=mahe.tardy@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=liamwisehart@meta.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf.kernel@gmail.com \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox