Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mptcp: token kunit: set protocol

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 <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240223-upstream-net-next-20240223-misc-improvements-v1-2-b6c8a10396bd@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Matthieu Baerts (NGI0) and committed by
Jakub Kicinski
28de50ee 9da74836

+6 -1
+6 -1
net/mptcp/token_test.c
··· 52 52 static struct mptcp_sock *build_msk(struct kunit *test) 53 53 { 54 54 struct mptcp_sock *msk; 55 + struct sock *sk; 55 56 56 57 msk = kunit_kzalloc(test, sizeof(struct mptcp_sock), GFP_USER); 57 58 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, msk); 58 59 refcount_set(&((struct sock *)msk)->sk_refcnt, 1); 59 60 sock_net_set((struct sock *)msk, &init_net); 60 61 62 + sk = (struct sock *)msk; 63 + 61 64 /* be sure the token helpers can dereference sk->sk_prot */ 62 - ((struct sock *)msk)->sk_prot = &tcp_prot; 65 + sk->sk_prot = &tcp_prot; 66 + sk->sk_protocol = IPPROTO_MPTCP; 67 + 63 68 return msk; 64 69 } 65 70