Skip to content

Commit

Permalink
mptcp: update bpf_mptcp_sock_from_subflow
Browse files Browse the repository at this point in the history
The input parameter of bpf_mptcp_sock_from_subflow() is an msk subsocket
of type IPPROTO_TCP. This patch extends it to accept an IPPROTO_MPTCP
socket. With this change, the function name bpf_mptcp_sock_from_subflow
is no longer appropriate, and it is renamed to bpf_mptcp_sock_from_sock.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Dec 9, 2024
1 parent b80a541 commit 88a619f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/net/mptcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ static inline void mptcpv6_handle_mapped(struct sock *sk, bool mapped) { }
#endif

#if defined(CONFIG_MPTCP) && defined(CONFIG_BPF_SYSCALL)
struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk);
struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk);
#else
static inline struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) { return NULL; }
static inline struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk) { return NULL; }
#endif

#if !IS_ENABLED(CONFIG_MPTCP)
Expand Down
2 changes: 1 addition & 1 deletion net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -11836,7 +11836,7 @@ const struct bpf_func_proto bpf_skc_to_unix_sock_proto = {
BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk)
{
BTF_TYPE_EMIT(struct mptcp_sock);
return (unsigned long)bpf_mptcp_sock_from_subflow(sk);
return (unsigned long)bpf_mptcp_sock_from_sock(sk);
}

const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {
Expand Down
4 changes: 3 additions & 1 deletion net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops = {
};
#endif /* CONFIG_BPF_JIT */

struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk)
{
if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_MPTCP)
return mptcp_sk(sk);
if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
return mptcp_sk(mptcp_subflow_ctx(sk)->conn);

Expand Down

0 comments on commit 88a619f

Please sign in to comment.