mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Matthieu Baerts <matthieu.baerts@tessares.net>
To: Dmytro Shytyi <dmytro@shytyi.net>, mptcp@lists.linux.dev
Subject: Re: [RFC PATCH mptcp-next v7 06/11] add mptcp_setsockopt_fastopen
Date: Tue, 20 Sep 2022 11:37:32 +0200	[thread overview]
Message-ID: <fc096cda-4522-ca8e-1c2f-a0d036923f11@tessares.net> (raw)
In-Reply-To: <20220917222853.2406-7-dmytro@shytyi.net>

Hi Dmytro,

On 18/09/2022 00:28, Dmytro Shytyi wrote:
> Add set MPTFO socket option for MPTCP.

It is often very helpful to not just mention what you are doing here
(e.g. add XXX) but explain the reason why you are doing this. Getting
the reason is often not clear when looking at a commit diff so it is a
very valuable info to add in a commit description.

For example here, it could be nice to explain this option is needed for
the listen socket only to accept TFO. And also why you are changing the
values directly, what it is similar to, etc. etc.

> 
> Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
> ---
>  net/mptcp/fastopen.c | 28 ++++++++++++++++++++++++++++
>  net/mptcp/protocol.h |  2 ++
>  net/mptcp/sockopt.c  |  3 +++
>  3 files changed, 33 insertions(+)
> 
> diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c
> index 50b5c3376672..436e773d798a 100644
> --- a/net/mptcp/fastopen.c
> +++ b/net/mptcp/fastopen.c
> @@ -63,3 +63,31 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
>  	ret = -EFAULT;
>  	return ret;
>  }
> +
> +int mptcp_setsockopt_sol_tcp_fastopen(struct mptcp_sock *msk, sockptr_t optval,
> +				      unsigned int optlen)
> +{
> +	struct sock *sk = (struct sock *)msk;
> +	struct net *net = sock_net(sk);
> +	int val;
> +	int ret;
> +
> +	ret = 0;
> +
> +	if (copy_from_sockptr(&val, optval, sizeof(val)))
> +		return -EFAULT;
> +
> +	lock_sock(sk);
> +
> +	if (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE |
> +	    TCPF_LISTEN))) {
> +		tcp_fastopen_init_key_once(net);
> +		fastopen_queue_tune(sk, val);

Can you not call tcp_setsockopt() here instead of copying what is done
in do_tcp_setsockopt()?

It would be simpler and easier to maintain I think.


Also, in general for the series, may you add 'mptcp:' prefix in the git
commit titles?

What is important too is to add comments if what you are doing is
similar to what is done in TCP, e.g. similar to XXX() in tcp_XXX.c? You
can add a short comment in the code and explain why you are doing that
and not call TCP functions in the git commit description for example.
That would help a lot reviewers and maintainers later.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

  parent reply	other threads:[~2022-09-20  9:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-17 22:28 [RFC PATCH mptcp-next v7 00/11] mptcp: Fast Open Mechanism Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 01/11] Add separate fastopen.c file Dmytro Shytyi
2022-09-19 10:21   ` Paolo Abeni
2022-09-20 13:29     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 02/11] add mptcp_stream_connect to protocol.h Dmytro Shytyi
2022-09-19 10:19   ` Paolo Abeni
2022-09-20 13:30     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 03/11] Initiator: MSG_FASTOPEN sendto(). request cookie Dmytro Shytyi
2022-09-19 10:35   ` Paolo Abeni
2022-09-19 10:44     ` Paolo Abeni
2022-09-19 11:22       ` Matthieu Baerts
2022-09-20 13:32         ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 04/11] rfree(), rmem_uncharge() prototypes to protocol.h Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 05/11] Initiator: add locks() to mptcp_sendmsg_fastopen Dmytro Shytyi
2022-09-19 10:46   ` Paolo Abeni
2022-09-20 13:33     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 06/11] add mptcp_setsockopt_fastopen Dmytro Shytyi
2022-09-19 10:48   ` Paolo Abeni
2022-09-20 13:33     ` Dmytro Shytyi
2022-09-20  9:37   ` Matthieu Baerts [this message]
2022-09-20 13:34     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 07/11] mptfo variables for msk, options. Fix loop retrans Dmytro Shytyi
2022-09-19 11:11   ` Paolo Abeni
2022-09-19 11:26     ` Paolo Abeni
2022-09-20 16:32       ` Christoph Paasch
2022-09-20 13:40     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 08/11] Fix unxpctd val of subflow->map_seq(dscrd packet) Dmytro Shytyi
2022-09-19 11:27   ` Paolo Abeni
2022-09-19 11:31     ` Matthieu Baerts
2022-09-19 14:02       ` Paolo Abeni
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 09/11] Listener: Add received skb to msk Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 10/11] mptcp_fastopen_add_skb() helpers (skb to msk) Dmytro Shytyi
2022-09-19 14:06   ` Paolo Abeni
2022-09-20 13:36     ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 11/11] selftests: mptfo initiator/listener Dmytro Shytyi
2022-09-19 14:11   ` Paolo Abeni

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=fc096cda-4522-ca8e-1c2f-a0d036923f11@tessares.net \
    --to=matthieu.baerts@tessares.net \
    --cc=dmytro@shytyi.net \
    --cc=mptcp@lists.linux.dev \
    /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).