Commit 3aa36249 authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

mptcp: avoid ssock usage in mptcp_pm_nl_create_listen_socket()

This is one of the few remaining spots actually manipulating the
first subflow socket. We can leverage the recently introduced
inet helpers to get rid of ssock there.

No functional changes intended.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f0bc514b
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/inet.h> #include <linux/inet.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <net/tcp.h> #include <net/tcp.h>
#include <net/inet_common.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <net/mptcp.h> #include <net/mptcp.h>
#include <net/genetlink.h> #include <net/genetlink.h>
...@@ -1005,8 +1006,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, ...@@ -1005,8 +1006,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
bool is_ipv6 = sk->sk_family == AF_INET6; bool is_ipv6 = sk->sk_family == AF_INET6;
int addrlen = sizeof(struct sockaddr_in); int addrlen = sizeof(struct sockaddr_in);
struct sockaddr_storage addr; struct sockaddr_storage addr;
struct sock *newsk, *ssk;
struct socket *ssock; struct socket *ssock;
struct sock *newsk;
int backlog = 1024; int backlog = 1024;
int err; int err;
...@@ -1042,18 +1043,23 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, ...@@ -1042,18 +1043,23 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
if (entry->addr.family == AF_INET6) if (entry->addr.family == AF_INET6)
addrlen = sizeof(struct sockaddr_in6); addrlen = sizeof(struct sockaddr_in6);
#endif #endif
err = kernel_bind(ssock, (struct sockaddr *)&addr, addrlen); ssk = mptcp_sk(newsk)->first;
if (ssk->sk_family == AF_INET)
err = inet_bind_sk(ssk, (struct sockaddr *)&addr, addrlen);
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
else if (ssk->sk_family == AF_INET6)
err = inet6_bind_sk(ssk, (struct sockaddr *)&addr, addrlen);
#endif
if (err) if (err)
return err; return err;
inet_sk_state_store(newsk, TCP_LISTEN); inet_sk_state_store(newsk, TCP_LISTEN);
err = kernel_listen(ssock, backlog); lock_sock(ssk);
if (err) err = __inet_listen_sk(ssk, backlog);
return err; if (!err)
mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED);
mptcp_event_pm_listener(ssock->sk, MPTCP_EVENT_LISTENER_CREATED); release_sock(ssk);
return err;
return 0;
} }
int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment