Skip to content

Commit

Permalink
bpf: Export more helpers used by mptcp_address test
Browse files Browse the repository at this point in the history
The mptcp_address bpf_iter should be invoked under holding the msk pm lock,
so spin_lock_bh() and spin_unlock_bh() are needed in BPF program to hold
or release the msk pm lock.

And bpf_ipv6_addr_v4mapped() helper is also needed by the mptcp_address
bpf_iter selftest program.

This patch adds the corresponding BPF wrappers for these helpers and adds
them to the mptcp common kfunc_set.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Oct 22, 2024
1 parent 5350ef4 commit 782c987
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,24 @@ __bpf_kfunc static void bpf_mptcp_sock_release(struct mptcp_sock *msk)
WARN_ON_ONCE(!sk || !refcount_dec_not_one(&sk->sk_refcnt));
}

__bpf_kfunc static void bpf_spin_lock_bh(spinlock_t *lock)
{
spin_lock_bh(lock);
}

__bpf_kfunc static void bpf_spin_unlock_bh(spinlock_t *lock)
{
spin_unlock_bh(lock);
}

__bpf_kfunc static bool bpf_ipv6_addr_v4mapped(const struct mptcp_addr_info *a)
{
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
return ipv6_addr_v4mapped(&a->addr6);
#endif
return false;
}

__bpf_kfunc struct mptcp_subflow_context *
bpf_mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos)
{
Expand Down Expand Up @@ -352,6 +370,9 @@ BTF_ID_FLAGS(func, bpf_iter_mptcp_address_next, KF_ITER_NEXT | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_iter_mptcp_address_destroy, KF_ITER_DESTROY)
BTF_ID_FLAGS(func, bpf_mptcp_sock_acquire, KF_ACQUIRE | KF_RET_NULL)
BTF_ID_FLAGS(func, bpf_mptcp_sock_release, KF_RELEASE)
BTF_ID_FLAGS(func, bpf_spin_lock_bh)
BTF_ID_FLAGS(func, bpf_spin_unlock_bh)
BTF_ID_FLAGS(func, bpf_ipv6_addr_v4mapped)
BTF_KFUNCS_END(bpf_mptcp_common_kfunc_ids)

static const struct btf_kfunc_id_set bpf_mptcp_common_kfunc_set = {
Expand Down

0 comments on commit 782c987

Please sign in to comment.