From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <pabeni@redhat.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>,
<edumazet@google.com>, <kuba@kernel.org>, <kuniyu@amazon.com>,
<mathew.j.martineau@linux.intel.com>,
<matthieu.baerts@tessares.net>, <mptcp@lists.linux.dev>,
<netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v2 1/2] net: introduce and use custom sockopt socket flag
Date: Thu, 20 Oct 2022 11:19:26 -0700 [thread overview]
Message-ID: <20221020181926.192-1-kuniyu@amazon.com> (raw)
In-Reply-To: <dc549a4d5c1d2031c64794c8e12bed55afb85c3e.1666287924.git.pabeni@redhat.com>
From: Paolo Abeni <pabeni@redhat.com>
Date: Thu, 20 Oct 2022 19:48:51 +0200
> We will soon introduce custom setsockopt for UDP sockets, too.
> Instead of doing even more complex arbitrary checks inside
> sock_use_custom_sol_socket(), add a new socket flag and set it
> for the relevant socket types (currently only MPTCP).
>
> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> include/linux/net.h | 1 +
> net/mptcp/protocol.c | 4 ++++
> net/socket.c | 8 +-------
> 3 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/net.h b/include/linux/net.h
> index 711c3593c3b8..59350fd85823 100644
> --- a/include/linux/net.h
> +++ b/include/linux/net.h
> @@ -41,6 +41,7 @@ struct net;
> #define SOCK_NOSPACE 2
> #define SOCK_PASSCRED 3
> #define SOCK_PASSSEC 4
> +#define SOCK_CUSTOM_SOCKOPT 5
>
> #ifndef ARCH_HAS_SOCKET_TYPES
> /**
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index f599ad44ed24..0448a5c3da3c 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2708,6 +2708,8 @@ static int mptcp_init_sock(struct sock *sk)
> if (ret)
> return ret;
>
> + set_bit(SOCK_CUSTOM_SOCKOPT, &sk->sk_socket->flags);
> +
> /* fetch the ca name; do it outside __mptcp_init_sock(), so that clone will
> * propagate the correct value
> */
> @@ -3684,6 +3686,8 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,
> struct mptcp_subflow_context *subflow;
> struct sock *newsk = newsock->sk;
>
> + set_bit(SOCK_CUSTOM_SOCKOPT, &newsock->flags);
> +
> lock_sock(newsk);
>
> /* PM/worker can now acquire the first subflow socket
> diff --git a/net/socket.c b/net/socket.c
> index 00da9ce3dba0..55c5d536e5f6 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -2199,13 +2199,7 @@ SYSCALL_DEFINE4(recv, int, fd, void __user *, ubuf, size_t, size,
>
> static bool sock_use_custom_sol_socket(const struct socket *sock)
> {
> - const struct sock *sk = sock->sk;
> -
> - /* Use sock->ops->setsockopt() for MPTCP */
> - return IS_ENABLED(CONFIG_MPTCP) &&
> - sk->sk_protocol == IPPROTO_MPTCP &&
> - sk->sk_type == SOCK_STREAM &&
> - (sk->sk_family == AF_INET || sk->sk_family == AF_INET6);
> + return test_bit(SOCK_CUSTOM_SOCKOPT, &sock->flags);
> }
>
> /*
> --
> 2.37.3
next prev parent reply other threads:[~2022-10-20 18:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 17:48 [PATCH net-next v2 0/2] udp: avoid false sharing on receive Paolo Abeni
2022-10-20 17:48 ` [PATCH net-next v2 1/2] net: introduce and use custom sockopt socket flag Paolo Abeni
2022-10-20 18:11 ` Eric Dumazet
2022-10-20 18:19 ` Kuniyuki Iwashima [this message]
2022-10-20 17:48 ` [PATCH net-next v2 2/2] udp: track the forward memory release threshold in an hot cacheline Paolo Abeni
2022-10-20 18:10 ` Eric Dumazet
2022-10-20 18:20 ` Kuniyuki Iwashima
2022-10-24 10:30 ` [PATCH net-next v2 0/2] udp: avoid false sharing on receive patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221020181926.192-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).