netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Neal Cardwell <ncardwell@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Mina Almasry <almasrymina@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next/net 5/6] bpf: Introduce SK_BPF_BYPASS_PROT_MEM.
Date: Wed, 15 Oct 2025 12:00:18 -0700	[thread overview]
Message-ID: <e8aeb1b8-06f0-4eb3-a1ef-26b943d1c6b4@linux.dev> (raw)
In-Reply-To: <20251014235604.3057003-6-kuniyu@google.com>

On 10/14/25 4:54 PM, Kuniyuki Iwashima wrote:
>   BPF_CALL_5(bpf_sock_create_getsockopt, struct sock *, sk, int, level,
>   	   int, optname, char *, optval, int, optlen)
>   {
> +	if (level == SOL_SOCKET && optname == SK_BPF_BYPASS_PROT_MEM)
> +		return sk_bpf_set_get_bypass_prot_mem(sk, optval, optlen, true);

The optval (ARG_PTR_TO_UNINIT_MEM) needs to be initialized for error case.
The __bpf_getsockopt below does that but it returns early here.
I changed to this:

	if (level == SOL_SOCKET && optname == SK_BPF_BYPASS_PROT_MEM) {
		int err = sk_bpf_set_get_bypass_prot_mem(sk, optval, optlen, true);

		if (err)
			memset(optval, 0, optlen);

		return err;
	}

> +
>   	return __bpf_getsockopt(sk, level, optname, optval, optlen);
>   }
>   
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index 6829936d33f58..9b17d937edf73 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -7200,6 +7200,7 @@ enum {
>   	TCP_BPF_SYN_MAC         = 1007, /* Copy the MAC, IP[46], and TCP header */
>   	TCP_BPF_SOCK_OPS_CB_FLAGS = 1008, /* Get or Set TCP sock ops flags */
>   	SK_BPF_CB_FLAGS		= 1009, /* Get or set sock ops flags in socket */
> +	SK_BPF_BYPASS_PROT_MEM	= 1010, /* Get or Set sk->sk_bypass_prot_mem */
>   };
>   
>   enum {


  reply	other threads:[~2025-10-15 19:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 23:54 [PATCH v2 bpf-next/net 0/6] bpf: Allow opt-out from sk->sk_prot->memory_allocated Kuniyuki Iwashima
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 1/6] tcp: Save lock_sock() for memcg in inet_csk_accept() Kuniyuki Iwashima
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 2/6] net: Allow opt-out from global protocol memory accounting Kuniyuki Iwashima
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 3/6] net: Introduce net.core.bypass_prot_mem sysctl Kuniyuki Iwashima
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 4/6] bpf: Support bpf_setsockopt() for BPF_CGROUP_INET_SOCK_CREATE Kuniyuki Iwashima
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 5/6] bpf: Introduce SK_BPF_BYPASS_PROT_MEM Kuniyuki Iwashima
2025-10-15 19:00   ` Martin KaFai Lau [this message]
2025-10-14 23:54 ` [PATCH v2 bpf-next/net 6/6] selftest: bpf: Add test for sk->sk_bypass_prot_mem Kuniyuki Iwashima
2025-10-15 19:07   ` Martin KaFai Lau
2025-10-15 20:41     ` Kuniyuki Iwashima
2025-10-16  6:50 ` [PATCH v2 bpf-next/net 0/6] bpf: Allow opt-out from sk->sk_prot->memory_allocated patchwork-bot+netdevbpf

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=e8aeb1b8-06f0-4eb3-a1ef-26b943d1c6b4@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=almasrymina@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=shakeel.butt@linux.dev \
    --cc=willemb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).