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?
Thanks,
Daniel