Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: fix compilation error without MPTCP
Browse files Browse the repository at this point in the history
Fixing these errors:

  net/socket.c: In function '__sock_create':
  net/socket.c:1416:13: error: 'sysctl_mptcp_enabled' undeclared (first use in this function)
   1416 |         if (sysctl_mptcp_enabled && old_protocol == IPPROTO_MPTCP &&
        |             ^~~~~~~~~~~~~~~~~~~~
  net/socket.c:1416:13: note: each undeclared identifier is reported only once for each function it appears in
  net/socket.c:1418:17: error: implicit declaration of function 'mptcp_enable_sock'; did you mean 'mptcp_del_sock'? [-Werror=implicit-function-declaration]
   1418 |                 mptcp_enable_sock(sock->sk);
        |                 ^~~~~~~~~~~~~~~~~
        |                 mptcp_del_sock
  cc1: some warnings being treated as errors
  make[2]: *** [scripts/Makefile.build:262: net/socket.o] Error 1

sysctl_mptcp_enabled is an external variable, only defined if
CONFIG_MPTCP is set. We could create new functions doing nothing but the
two undeclared identifiers are only used here. It looks then OK to add
a new 'ifdef' here, clearly showing nothing is done when MPTCP is not
enabled.

Fixes: 8785d11 ("mptcp: Allow using IPPROTO_MPTCP")
Reviewed-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
matttbe committed Jan 24, 2023
1 parent 2895708 commit ebbb755
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,9 +1424,11 @@ int __sock_create(struct net *net, int family, int type, int protocol,
if (err < 0)
goto out_module_put;

#ifdef CONFIG_MPTCP
if (sysctl_mptcp_enabled && old_protocol == IPPROTO_MPTCP &&
type == SOCK_STREAM && (family == AF_INET || family == AF_INET6))
mptcp_enable_sock(sock->sk);
#endif

/*
* Now to bump the refcnt of the [loadable] module that owns this
Expand Down

0 comments on commit ebbb755

Please sign in to comment.