Skip to content

Commit

Permalink
bpf: Add accesses to bpf_skc_to_tcp_sock
Browse files Browse the repository at this point in the history
Squash to "bpf: Add bpf_mptcp_sched_ops" II

As is reported in torvalds#417 by sferlin, we can't access tcp_sock fields in
BPF schedulers.

I gave two suggestions in the comments of torvalds#417 to solve it:

1. Move the helpers which needs to access tcp_sock fields like
tcp_packets_in_flight() into the kernel space, call the helpers in BPF
context.
2. Add more helpers in the kernel space to access more tcp_sock fields,
call the helpers in BPF context.

Although these can solve this issue to some extent, but they aren't the
best solutions.

A better one is using bpf_skc_to_tcp_sock() to get the tcp_sock instead
of using tcp_sk():

    tp = bpf_skc_to_tcp_sock(sk);

Then we can access every fields of tp and keep sferlin's patch as is.

But this needs to add accesses to call bpf_skc_to_tcp_sock() in BPF
schedulers.

Closes: multipath-tcp/mptcp_net-next#417
Cc: [email protected]
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Aug 2, 2023
1 parent b981164 commit ae1d233
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id,
return &bpf_sk_storage_get_proto;
case BPF_FUNC_sk_storage_delete:
return &bpf_sk_storage_delete_proto;
case BPF_FUNC_skc_to_tcp6_sock:
return &bpf_skc_to_tcp6_sock_proto;
case BPF_FUNC_skc_to_tcp_sock:
return &bpf_skc_to_tcp_sock_proto;
default:
return bpf_base_func_proto(func_id);
}
Expand Down

0 comments on commit ae1d233

Please sign in to comment.