public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliang.tang@suse.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org, ast@kernel.org,
	andrii@kernel.org, mptcp@lists.linux.dev,
	Nicolas Rybowski <nicolas.rybowski@tessares.net>,
	Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: Re: [PATCH bpf-next 2/7] bpf: add bpf_skc_to_mptcp_sock_proto
Date: Mon, 25 Apr 2022 11:35:42 -0700 (PDT)	[thread overview]
Message-ID: <b1ca1a8-8e54-b31d-3165-8cad22305b33@linux.intel.com> (raw)
In-Reply-To: <903108df-161e-515b-da3d-bff4fb49de39@iogearbox.net>

On Mon, 25 Apr 2022, Daniel Borkmann wrote:

> On 4/21/22 12:24 AM, Mat Martineau wrote:
> [...]
>>   static const struct bpf_func_proto *
>>   bpf_sk_base_func_proto(enum bpf_func_id func_id);
>> @@ -11279,6 +11280,19 @@ const struct bpf_func_proto 
>> bpf_skc_to_unix_sock_proto = {
>>   	.ret_btf_id		= &btf_sock_ids[BTF_SOCK_TYPE_UNIX],
>>   };
>>   +BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk)
>> +{
>> +	return (unsigned long)bpf_mptcp_sock_from_subflow(sk);
>> +}
>> +
>> +static const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {
>> +	.func		= bpf_skc_to_mptcp_sock,
>> +	.gpl_only	= false,
>> +	.ret_type	= RET_PTR_TO_BTF_ID_OR_NULL,
>> +	.arg1_type	= ARG_PTR_TO_SOCK_COMMON,
>> +	.ret_btf_id	= &btf_sock_ids[BTF_SOCK_TYPE_MPTCP],
>> +};
>
> BPF CI 
> (https://github.com/kernel-patches/bpf/runs/6136052684?check_suite_focus=true) 
> fails with:
>
>  #7   base:FAIL
>  libbpf: prog '_sockops': BPF program load failed: Invalid argument
>  libbpf: prog '_sockops': -- BEGIN PROG LOAD LOG --
>  0: R1=ctx(off=0,imm=0) R10=fp0
>  ; int op = (int)ctx->op;
>  0: (61) r2 = *(u32 *)(r1 +0)          ; R1=ctx(off=0,imm=0) 
> R2_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff))
>  ; if (op != BPF_SOCK_OPS_TCP_CONNECT_CB)
>  1: (56) if w2 != 0x3 goto pc+50       ; R2_w=3
>  ; sk = ctx->sk;
>  2: (79) r6 = *(u64 *)(r1 +184)        ; R1=ctx(off=0,imm=0) 
> R6_w=sock_or_null(id=1,off=0,imm=0)
>  ; if (!sk)
>  3: (15) if r6 == 0x0 goto pc+48       ; R6_w=sock(off=0,imm=0)
>  ; tcp_sk = bpf_tcp_sock(sk);
>  4: (bf) r1 = r6                       ; R1_w=sock(off=0,imm=0) 
> R6_w=sock(off=0,imm=0)
>  5: (85) call bpf_tcp_sock#96          ; 
> R0_w=tcp_sock_or_null(id=2,off=0,imm=0)
>  6: (bf) r7 = r0                       ; 
> R0=tcp_sock_or_null(id=2,off=0,imm=0) R7=tcp_sock_or_null(id=2,off=0,imm=0)
>  ; if (!tcp_sk)
>  7: (15) if r7 == 0x0 goto pc+44       ; R7=tcp_sock(off=0,imm=0)
>  ; if (!tcp_sk->is_mptcp) {
>  8: (61) r1 = *(u32 *)(r7 +112)        ; 
> R1_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff)) 
> R7=tcp_sock(off=0,imm=0)
>  ; if (!tcp_sk->is_mptcp) {
>  9: (56) if w1 != 0x0 goto pc+14 24: R0=tcp_sock(off=0,imm=0) 
> R1_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff)) R6=sock(off=0,imm=0) 
> R7=tcp_sock(off=0,imm=0) R10=fp0
>  ; msk = bpf_skc_to_mptcp_sock(sk);
>  24: (bf) r1 = r6                      ; R1_w=sock(off=0,imm=0) 
> R6=sock(off=0,imm=0)
>  25: (85) call bpf_skc_to_mptcp_sock#194
>  invalid return type 8 of func bpf_skc_to_mptcp_sock#194
>  processed 34 insns (limit 1000000) max_states_per_insn 0 total_states 3 
> peak_states 3 mark_read 1
>  -- END PROG LOAD LOG --
>  libbpf: failed to load program '_sockops'
>  libbpf: failed to load object './mptcp_sock.o'
>  run_test:FAIL:165
>  test_base:FAIL:227
>  (network_helpers.c:88: errno: Protocol not supported) Failed to create 
> server socket
>  test_base:FAIL:241
>  RTNETLINK answers: No such file or directory
>  Error talking to the kernel
> [...]
>
> Looking at bpf_skc_to_tcp6_sock(), do we similarly need a BTF_TYPE_EMIT() 
> here?
>

Geliang, in addition to the BTF_TYPE_EMIT() can you also take a look at 
the places in kernel/trace/bpf_trace.c and kernel/bpf/verifier.c where 
bpf_skc_to_tcp6_sock and bpf_skc_to_tcp6_sock_proto are referenced?

--
Mat Martineau
Intel

  parent reply	other threads:[~2022-04-25 18:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 22:24 [PATCH bpf-next 0/7] bpf: mptcp: Support for mptcp_sock and is_mptcp Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 1/7] bpf: expose is_mptcp flag to bpf_tcp_sock Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 2/7] bpf: add bpf_skc_to_mptcp_sock_proto Mat Martineau
2022-04-25 14:26   ` Daniel Borkmann
2022-04-25 14:29     ` Daniel Borkmann
2022-04-26  6:36       ` Andrii Nakryiko
2022-04-25 18:35     ` Mat Martineau [this message]
2022-04-25 14:33   ` Daniel Borkmann
2022-04-25 18:11     ` Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 3/7] selftests: bpf: add MPTCP test base Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 4/7] selftests: bpf: test bpf_skc_to_mptcp_sock Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 5/7] selftests: bpf: verify token of struct mptcp_sock Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 6/7] selftests: bpf: verify ca_name " Mat Martineau
2022-04-20 22:24 ` [PATCH bpf-next 7/7] selftests: bpf: verify first " Mat Martineau

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=b1ca1a8-8e54-b31d-3165-8cad22305b33@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=geliang.tang@suse.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.rybowski@tessares.net \
    /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