Skip to content

Commit

Permalink
Revert "fix"
Browse files Browse the repository at this point in the history
This reverts commit 404d384.
  • Loading branch information
Geliang Tang committed Nov 28, 2024
1 parent 333cccc commit dcb329c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
6 changes: 3 additions & 3 deletions include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5796,11 +5796,11 @@ union bpf_attr {
*
* **-ENOENT** if the bpf_local_storage cannot be found.
*
* void *bpf_mptcp_ssk_cast(void *s, int type)
* void *bpf_mptcp_ssk_cast(void *sk)
* Description
* Dynamically cast a *s* pointer to a *sock* pointer.
* Dynamically cast a *sk* pointer to a *sock* pointer.
* Return
* *s* if casting is valid, or **NULL** otherwise.
* *sk* if casting is valid, or **NULL** otherwise.
*/
#define ___BPF_FUNC_MAPPER(FN, ctx...) \
FN(unspec, 0, ##ctx) \
Expand Down
21 changes: 3 additions & 18 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,25 +281,11 @@ static struct bpf_struct_ops bpf_mptcp_pm_ops = {

/* MPTCP BPF packet scheduler */

enum mptcp_cast_type {
MPTCP_TYPE_SUBSOCKET = 1,
MPTCP_TYPE_SUBFLOW,
};

BPF_CALL_2(bpf_mptcp_ssk_cast, void *, s, enum mptcp_cast_type, type)
BPF_CALL_1(bpf_mptcp_ssk_cast, struct sock *, sk)
{
BTF_TYPE_EMIT(struct sock);

if (type == MPTCP_TYPE_SUBSOCKET) {
struct sock *sk = (struct sock *)s;

if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
return (unsigned long)sk;
} else if (type == MPTCP_TYPE_SUBFLOW) {
struct mptcp_subflow_context *subflow = (struct mptcp_subflow_context *)s;

return (unsigned long)mptcp_subflow_tcp_sock(subflow);
}
if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
return (unsigned long)sk;
return (unsigned long)NULL;
}

Expand All @@ -308,7 +294,6 @@ static const struct bpf_func_proto bpf_mptcp_ssk_cast_proto = {
.gpl_only = false,
.ret_type = RET_PTR_TO_BTF_ID_OR_NULL,
.arg1_type = ARG_ANYTHING,
.arg2_type = ARG_ANYTHING,
.ret_btf_id = &btf_sock_ids[BTF_SOCK_TYPE_SOCK],
};

Expand Down
6 changes: 3 additions & 3 deletions tools/include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5796,11 +5796,11 @@ union bpf_attr {
*
* **-ENOENT** if the bpf_local_storage cannot be found.
*
* void *bpf_mptcp_ssk_cast(void *s, int type)
* void *bpf_mptcp_ssk_cast(void *sk)
* Description
* Dynamically cast a *s* pointer to a *sock* pointer.
* Dynamically cast a *sk* pointer to a *sock* pointer.
* Return
* *s* if casting is valid, or **NULL** otherwise.
* *sk* if casting is valid, or **NULL** otherwise.
*/
#define ___BPF_FUNC_MAPPER(FN, ctx...) \
FN(unspec, 0, ##ctx) \
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk)
bpf_for_each(mptcp_subflow, subflow, msk) {
bool backup = subflow->backup || subflow->request_bkup;

ssk = bpf_mptcp_ssk_cast(subflow, MPTCP_TYPE_SUBFLOW);
if (!ssk || !mptcp_subflow_active(subflow))
ssk = mptcp_subflow_tcp_sock(subflow);
if (!mptcp_subflow_active(subflow))
continue;

nr_active += !backup;
Expand All @@ -108,7 +108,7 @@ int BPF_PROG(bpf_burst_get_send, struct mptcp_sock *msk)
if (!nr_active)
send_info[SSK_MODE_ACTIVE].ssk = send_info[SSK_MODE_BACKUP].ssk;

ssk = bpf_mptcp_ssk_cast(send_info[SSK_MODE_ACTIVE].ssk, MPTCP_TYPE_SUBSOCKET);
ssk = bpf_mptcp_ssk_cast(send_info[SSK_MODE_ACTIVE].ssk);
if (!ssk || !sk_stream_memory_free(ssk))
return -1;

Expand Down Expand Up @@ -139,7 +139,7 @@ int BPF_PROG(bpf_burst_get_retrans, struct mptcp_sock *msk)
int min_stale_count = INT_MAX;

bpf_for_each(mptcp_subflow, subflow, msk) {
struct sock *ssk = bpf_mptcp_ssk_cast(subflow, MPTCP_TYPE_SUBFLOW);
struct sock *ssk = bpf_mptcp_subflow_tcp_sock(subflow);

if (!ssk || !mptcp_subflow_active(subflow))
continue;
Expand Down

0 comments on commit dcb329c

Please sign in to comment.