All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
@ 2023-05-24 13:13 Cambda Zhu
  2023-05-26 11:35 ` Jason Xing
  2023-05-27  2:41 ` Jakub Kicinski
  0 siblings, 2 replies; 4+ messages in thread
From: Cambda Zhu @ 2023-05-24 13:13 UTC (permalink / raw)
  To: netdev, Eric Dumazet, Paolo Abeni, Jason Xing
  Cc: Xuan Zhuo, Dust Li, Tony Lu, Cambda Zhu, Jack Yang

This patch replaces the tp->mss_cache check in getting TCP_MAXSEG
with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since
tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if
it's zero is probably a bug.

With this change, getting TCP_MAXSEG before connecting will return
default MSS normally, and return user_mss if user_mss is set.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Jack Yang <mingliang@linux.alibaba.com>
Suggested-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/netdev/CANn89i+3kL9pYtkxkwxwNMzvC_w3LNUum_2=3u+UyLBmGmifHA@mail.gmail.com/#t
Signed-off-by: Cambda Zhu <cambda@linux.alibaba.com>
Link: https://lore.kernel.org/netdev/14D45862-36EA-4076-974C-EA67513C92F6@linux.alibaba.com/
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
---
v2:
- Update Fixes tag with commit in current tree.
- Add Jason's Reviewed-by tag.

v1:
- Return default MSS if user_mss not set for backwards compatibility.
- Send patch to net instead of net-next, with Fixes tag.
- Add Eric's tags.
---
 net/ipv4/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4d6392c16b7a..3e01a58724b8 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -4081,7 +4081,8 @@ int do_tcp_getsockopt(struct sock *sk, int level,
 	switch (optname) {
 	case TCP_MAXSEG:
 		val = tp->mss_cache;
-		if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
+		if (tp->rx_opt.user_mss &&
+		    ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
 			val = tp->rx_opt.user_mss;
 		if (tp->repair)
 			val = tp->rx_opt.mss_clamp;
-- 
2.16.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
  2023-05-24 13:13 [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set Cambda Zhu
@ 2023-05-26 11:35 ` Jason Xing
  2023-05-27  2:41 ` Jakub Kicinski
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Xing @ 2023-05-26 11:35 UTC (permalink / raw)
  To: Cambda Zhu
  Cc: netdev, Eric Dumazet, Paolo Abeni, Xuan Zhuo, Dust Li, Tony Lu,
	Jack Yang, David Miller, dsahern, Jakub Kicinski

On Wed, May 24, 2023 at 9:14 PM Cambda Zhu <cambda@linux.alibaba.com> wrote:
>
> This patch replaces the tp->mss_cache check in getting TCP_MAXSEG
> with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since
> tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if
> it's zero is probably a bug.
>
> With this change, getting TCP_MAXSEG before connecting will return
> default MSS normally, and return user_mss if user_mss is set.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: Jack Yang <mingliang@linux.alibaba.com>
> Suggested-by: Eric Dumazet <edumazet@google.com>
> Link: https://lore.kernel.org/netdev/CANn89i+3kL9pYtkxkwxwNMzvC_w3LNUum_2=3u+UyLBmGmifHA@mail.gmail.com/#t
> Signed-off-by: Cambda Zhu <cambda@linux.alibaba.com>
> Link: https://lore.kernel.org/netdev/14D45862-36EA-4076-974C-EA67513C92F6@linux.alibaba.com/
> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
> ---
> v2:
> - Update Fixes tag with commit in current tree.
> - Add Jason's Reviewed-by tag.
>
> v1:
> - Return default MSS if user_mss not set for backwards compatibility.
> - Send patch to net instead of net-next, with Fixes tag.
> - Add Eric's tags.
> ---
>  net/ipv4/tcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 4d6392c16b7a..3e01a58724b8 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -4081,7 +4081,8 @@ int do_tcp_getsockopt(struct sock *sk, int level,
>         switch (optname) {
>         case TCP_MAXSEG:
>                 val = tp->mss_cache;
> -               if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
> +               if (tp->rx_opt.user_mss &&
> +                   ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
>                         val = tp->rx_opt.user_mss;
>                 if (tp->repair)
>                         val = tp->rx_opt.mss_clamp;
> --
> 2.16.6
>

Ah, I just realised that you didn't CC other maintainers though
reading the patchwork. Please run this command [1] before you submit a
patch next time.

[1]: $./scripts/get_maintainer.pl net/ipv4/tcp.c

+CC kuba, davem, dsahern

Thanks,
Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
  2023-05-24 13:13 [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set Cambda Zhu
  2023-05-26 11:35 ` Jason Xing
@ 2023-05-27  2:41 ` Jakub Kicinski
  2023-05-27  4:20   ` Cambda Zhu
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-05-27  2:41 UTC (permalink / raw)
  To: Cambda Zhu
  Cc: netdev, Eric Dumazet, Paolo Abeni, Jason Xing, Xuan Zhuo,
	Dust Li, Tony Lu, Jack Yang

On Wed, 24 May 2023 21:13:31 +0800 Cambda Zhu wrote:
> This patch replaces the tp->mss_cache check in getting TCP_MAXSEG
> with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since
> tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if
> it's zero is probably a bug.
> 
> With this change, getting TCP_MAXSEG before connecting will return
> default MSS normally, and return user_mss if user_mss is set.

Hi, your patch was marked as "Changes requested" by DaveM (I think).
Presumably because of the missing CCs. Would you mind resending one
more time with the fuller CC list?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set
  2023-05-27  2:41 ` Jakub Kicinski
@ 2023-05-27  4:20   ` Cambda Zhu
  0 siblings, 0 replies; 4+ messages in thread
From: Cambda Zhu @ 2023-05-27  4:20 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, Eric Dumazet, Paolo Abeni, Jason Xing, Xuan Zhuo,
	Dust Li, Tony Lu, Jack Yang


> On May 27, 2023, at 10:41, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Wed, 24 May 2023 21:13:31 +0800 Cambda Zhu wrote:
>> This patch replaces the tp->mss_cache check in getting TCP_MAXSEG
>> with tp->rx_opt.user_mss check for CLOSE/LISTEN sock. Since
>> tp->mss_cache is initialized with TCP_MSS_DEFAULT, checking if
>> it's zero is probably a bug.
>> 
>> With this change, getting TCP_MAXSEG before connecting will return
>> default MSS normally, and return user_mss if user_mss is set.
> 
> Hi, your patch was marked as "Changes requested" by DaveM (I think).
> Presumably because of the missing CCs. Would you mind resending one
> more time with the fuller CC list?

I have resubmitted the patch and hope I got everything right this time :)

Thanks!

Cambda

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-27  4:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 13:13 [PATCH net v2] tcp: Return user_mss for TCP_MAXSEG in CLOSE/LISTEN state if user_mss set Cambda Zhu
2023-05-26 11:35 ` Jason Xing
2023-05-27  2:41 ` Jakub Kicinski
2023-05-27  4:20   ` Cambda Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.