mptcp: token kunit: set protocol
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Fri, 23 Feb 2024 20:17:54 +0000 (21:17 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 27 Feb 2024 02:42:12 +0000 (18:42 -0800)
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>
net/mptcp/token_test.c

index bfff53e668da68297c1e5b9c92c8fab45595b402..4fc39fa2e262d260b42b6011e565f1f7b712f8c4 100644 (file)
@@ -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;
 }