Skip to content

Commit

Permalink
mptcp: token kunit: set protocol
Browse files Browse the repository at this point in the history
As it would be done when initiating an MPTCP sock.

This is not strictly needed for this test, but it will be when a later
patch will check if the right protocol is being used when calling
mptcp_sk().

Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Link: https://lore.kernel.org/r/20240223-upstream-net-next-20240223-misc-improvements-v1-2-b6c8a10396bd@kernel.org
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
matttbe authored and kuba-moo committed Feb 27, 2024
1 parent 9da7483 commit 28de50e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/mptcp/token_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ static struct mptcp_subflow_context *build_ctx(struct kunit *test)
static struct mptcp_sock *build_msk(struct kunit *test)
{
struct mptcp_sock *msk;
struct sock *sk;

msk = kunit_kzalloc(test, sizeof(struct mptcp_sock), GFP_USER);
KUNIT_EXPECT_NOT_ERR_OR_NULL(test, msk);
refcount_set(&((struct sock *)msk)->sk_refcnt, 1);
sock_net_set((struct sock *)msk, &init_net);

sk = (struct sock *)msk;

/* be sure the token helpers can dereference sk->sk_prot */
((struct sock *)msk)->sk_prot = &tcp_prot;
sk->sk_prot = &tcp_prot;
sk->sk_protocol = IPPROTO_MPTCP;

return msk;
}

Expand Down

0 comments on commit 28de50e

Please sign in to comment.