Skip to content

Commit 88a619f

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: update bpf_mptcp_sock_from_subflow
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]>
1 parent b80a541 commit 88a619f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

include/net/mptcp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ static inline void mptcpv6_handle_mapped(struct sock *sk, bool mapped) { }
322322
#endif
323323

324324
#if defined(CONFIG_MPTCP) && defined(CONFIG_BPF_SYSCALL)
325-
struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk);
325+
struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk);
326326
#else
327-
static inline struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) { return NULL; }
327+
static inline struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk) { return NULL; }
328328
#endif
329329

330330
#if !IS_ENABLED(CONFIG_MPTCP)

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11836,7 +11836,7 @@ const struct bpf_func_proto bpf_skc_to_unix_sock_proto = {
1183611836
BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk)
1183711837
{
1183811838
BTF_TYPE_EMIT(struct mptcp_sock);
11839-
return (unsigned long)bpf_mptcp_sock_from_subflow(sk);
11839+
return (unsigned long)bpf_mptcp_sock_from_sock(sk);
1184011840
}
1184111841

1184211842
const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {

net/mptcp/bpf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops = {
188188
};
189189
#endif /* CONFIG_BPF_JIT */
190190

191-
struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
191+
struct mptcp_sock *bpf_mptcp_sock_from_sock(struct sock *sk)
192192
{
193+
if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_MPTCP)
194+
return mptcp_sk(sk);
193195
if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
194196
return mptcp_sk(mptcp_subflow_ctx(sk)->conn);
195197

0 commit comments

Comments
 (0)