BPF List
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: sdf@google.com, Martin KaFai Lau <kafai@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	kernel-team@fb.com, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH v3 bpf-next 00/15] bpf: net: Remove duplicated code from bpf_setsockopt()
Date: Tue, 16 Aug 2022 00:04:52 +0200	[thread overview]
Message-ID: <1b791103-1f8d-bc08-3f65-7c1b2316e2c3@iogearbox.net> (raw)
In-Reply-To: <YvU2md/W4YSlnkBH@google.com>

On 8/11/22 7:04 PM, sdf@google.com wrote:
> On 08/10, Martin KaFai Lau wrote:
>> The code in bpf_setsockopt() is mostly a copy-and-paste from
>> the sock_setsockopt(), do_tcp_setsockopt(), do_ipv6_setsockopt(),
>> and do_ip_setsockopt().  As the allowed optnames in bpf_setsockopt()
>> grows, so are the duplicated code.  The code between the copies
>> also slowly drifted.
> 
>> This set is an effort to clean this up and reuse the existing
>> {sock,do_tcp,do_ipv6,do_ip}_setsockopt() as much as possible.
> 
>> After the clean up, this set also adds a few allowed optnames
>> that we need to the bpf_setsockopt().
> 
>> The initial attempt was to clean up both bpf_setsockopt() and
>> bpf_getsockopt() together.  However, the patch set was getting
>> too long.  It is beneficial to leave the bpf_getsockopt()
>> out for another patch set.  Thus, this set is focusing
>> on the bpf_setsockopt().
> 
>> v3:
>> - s/in_bpf/has_current_bpf_ctx/ (Andrii)
>> - Add comments to has_current_bpf_ctx() and sockopt_lock_sock()
>>    (Stanislav)
>> - Use vmlinux.h in selftest and add defines to bpf_tracing_net.h
>>    (Stanislav)
>> - Use bpf_getsockopt(SO_MARK) in selftest (Stanislav)
>> - Use BPF_CORE_READ_BITFIELD in selftest (Yonghong)
> 
> Reviewed-by: Stanislav Fomichev <sdf@google.com>
> 
> (I didn't go super deep on the selftest)

Looks like that one throws a build error, fwiw:

https://github.com/kernel-patches/bpf/runs/7844497492?check_suite_focus=true

   [...]
     CLNG-BPF [test_maps] kfunc_call_test_subprog.o
     CLNG-BPF [test_maps] bpf_iter_test_kern6.o
   progs/setget_sockopt.c:39:33: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = SO_REUSEADDR, .flip = 1, },
                                          ^
   progs/setget_sockopt.c:42:33: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = SO_KEEPALIVE, .flip = 1, },
                                          ^
   progs/setget_sockopt.c:44:33: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = SO_REUSEPORT, .flip = 1, },
                                          ^
     CLNG-BPF [test_maps] btf__core_reloc_type_id.o
   progs/setget_sockopt.c:48:32: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = SO_TXREHASH, .flip = 1, },
                                         ^
   progs/setget_sockopt.c:53:32: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = TCP_NODELAY, .flip = 1, },
                                         ^
   progs/setget_sockopt.c:61:45: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = TCP_THIN_LINEAR_TIMEOUTS, .flip = 1, },
                                                      ^
   progs/setget_sockopt.c:75:39: error: implicit truncation from 'int' to bit-field changes value from 1 to -1 [-Werror,-Wbitfield-constant-conversion]
           { .opt = IPV6_AUTOFLOWLABEL, .flip = 1, },
                                                ^
   7 errors generated.
   make: *** [Makefile:521: /tmp/runner/work/bpf/bpf/tools/testing/selftests/bpf/setget_sockopt.o] Error 1
   make: *** Waiting for unfinished jobs....
   make: Leaving directory '/tmp/runner/work/bpf/bpf/tools/testing/selftests/bpf'
   Error: Process completed with exit code 2.

  reply	other threads:[~2022-08-16  2:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 19:07 [PATCH v3 bpf-next 00/15] bpf: net: Remove duplicated code from bpf_setsockopt() Martin KaFai Lau
2022-08-10 19:07 ` [PATCH v3 bpf-next 01/15] net: Add sk_setsockopt() to take the sk ptr instead of the sock ptr Martin KaFai Lau
2022-08-10 19:07 ` [PATCH v3 bpf-next 02/15] bpf: net: Avoid sk_setsockopt() taking sk lock when called from bpf Martin KaFai Lau
2022-08-16  3:32   ` Andrii Nakryiko
2022-08-10 19:07 ` [PATCH v3 bpf-next 03/15] bpf: net: Consider has_current_bpf_ctx() when testing capable() in sk_setsockopt() Martin KaFai Lau
2022-08-10 19:07 ` [PATCH v3 bpf-next 04/15] bpf: net: Change do_tcp_setsockopt() to use the sockopt's lock_sock() and capable() Martin KaFai Lau
2022-08-10 19:07 ` [PATCH v3 bpf-next 05/15] bpf: net: Change do_ip_setsockopt() " Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 06/15] bpf: net: Change do_ipv6_setsockopt() " Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 07/15] bpf: Initialize the bpf_run_ctx in bpf_iter_run_prog() Martin KaFai Lau
2022-08-16  3:33   ` Andrii Nakryiko
2022-08-10 19:08 ` [PATCH v3 bpf-next 08/15] bpf: Embed kernel CONFIG check into the if statement in bpf_setsockopt Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 09/15] bpf: Change bpf_setsockopt(SOL_SOCKET) to reuse sk_setsockopt() Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 10/15] bpf: Refactor bpf specific tcp optnames to a new function Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 11/15] bpf: Change bpf_setsockopt(SOL_TCP) to reuse do_tcp_setsockopt() Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 12/15] bpf: Change bpf_setsockopt(SOL_IP) to reuse do_ip_setsockopt() Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 13/15] bpf: Change bpf_setsockopt(SOL_IPV6) to reuse do_ipv6_setsockopt() Martin KaFai Lau
2022-08-10 19:08 ` [PATCH v3 bpf-next 14/15] bpf: Add a few optnames to bpf_setsockopt Martin KaFai Lau
2022-08-10 19:09 ` [PATCH v3 bpf-next 15/15] selftests/bpf: bpf_setsockopt tests Martin KaFai Lau
2022-08-11 17:04 ` [PATCH v3 bpf-next 00/15] bpf: net: Remove duplicated code from bpf_setsockopt() sdf
2022-08-15 22:04   ` Daniel Borkmann [this message]
2022-08-17  5:23     ` Martin KaFai Lau

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=1b791103-1f8d-bc08-3f65-7c1b2316e2c3@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kafai@fb.com \
    --cc=kernel-team@fb.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@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