netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] udp: don't be set unconnected if only UDP cmsg
@ 2024-04-14 19:52 Yick Xie
  2024-04-15 14:11 ` Willem de Bruijn
  0 siblings, 1 reply; 4+ messages in thread
From: Yick Xie @ 2024-04-14 19:52 UTC (permalink / raw)
  To: willemdebruijn.kernel, willemb; +Cc: netdev, davem

If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg),
"connected" should not be set to 0. Otherwise it stops
the connected socket from using the cached route.

Signed-off-by: Yick Xie <yick.xie@gmail.com>
---
 net/ipv4/udp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index c02bf011d4a6..420905be5f30 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1123,16 +1123,17 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
 	if (msg->msg_controllen) {
 		err = udp_cmsg_send(sk, msg, &ipc.gso_size);
-		if (err > 0)
+		if (err > 0) {
 			err = ip_cmsg_send(sk, msg, &ipc,
 					   sk->sk_family == AF_INET6);
+			connected = 0;
+		}
 		if (unlikely(err < 0)) {
 			kfree(ipc.opt);
 			return err;
 		}
 		if (ipc.opt)
 			free = 1;
-		connected = 0;
 	}
 	if (!ipc.opt) {
 		struct ip_options_rcu *inet_opt;
-- 
2.34.1


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

* Re: [PATCH net] udp: don't be set unconnected if only UDP cmsg
  2024-04-14 19:52 [PATCH net] udp: don't be set unconnected if only UDP cmsg Yick Xie
@ 2024-04-15 14:11 ` Willem de Bruijn
  2024-04-15 23:30   ` Yick Xie
  0 siblings, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2024-04-15 14:11 UTC (permalink / raw)
  To: Yick Xie, willemdebruijn.kernel, willemb; +Cc: netdev, davem

Yick Xie wrote:
> If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg),
> "connected" should not be set to 0. Otherwise it stops
> the connected socket from using the cached route.
> 
> Signed-off-by: Yick Xie <yick.xie@gmail.com>

This either needs to target net-next, or have

Fixes: 2e8de8576343 ("udp: add gso segment cmsg")

I think it can be argued either way. This situation existed from the
start, and is true for other cmsg that don't affect routing as well.

If the impact of the route lookup is significant, it couls be argued
to be a performance bug.

I steer towards net-next. In which case it would be nice to also
move the ipc.opt branch and perhaps even exclude other common cmsgs,
such as SCM_TXTIME and SCM_TIMESTAMPING.

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

* Re: [PATCH net] udp: don't be set unconnected if only UDP cmsg
  2024-04-15 14:11 ` Willem de Bruijn
@ 2024-04-15 23:30   ` Yick Xie
  2024-04-16 14:51     ` Willem de Bruijn
  0 siblings, 1 reply; 4+ messages in thread
From: Yick Xie @ 2024-04-15 23:30 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: willemb, netdev, davem

On Mon, Apr 15, 2024 at 10:11 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> Yick Xie wrote:
> > If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg),
> > "connected" should not be set to 0. Otherwise it stops
> > the connected socket from using the cached route.
> >
> > Signed-off-by: Yick Xie <yick.xie@gmail.com>
>
> This either needs to target net-next, or have
>
> Fixes: 2e8de8576343 ("udp: add gso segment cmsg")

I should have added that, sorry for the mess.

> I think it can be argued either way. This situation existed from the
> start, and is true for other cmsg that don't affect routing as well.
>
> If the impact of the route lookup is significant, it couls be argued
> to be a performance bug.

With sendmsg(), any smaller gso_size could be picked up dynamically.
Then it depends, "ip_route_output_flow()" could be as expensive as
"ip_make_skb()".

> I steer towards net-next. In which case it would be nice to also
> move the ipc.opt branch and perhaps even exclude other common cmsgs,
> such as SCM_TXTIME and SCM_TIMESTAMPING.

Both are fine. Though could it be better to take an easy backporting at first?

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

* Re: [PATCH net] udp: don't be set unconnected if only UDP cmsg
  2024-04-15 23:30   ` Yick Xie
@ 2024-04-16 14:51     ` Willem de Bruijn
  0 siblings, 0 replies; 4+ messages in thread
From: Willem de Bruijn @ 2024-04-16 14:51 UTC (permalink / raw)
  To: Yick Xie, Willem de Bruijn; +Cc: willemb, netdev, davem

Yick Xie wrote:
> On Mon, Apr 15, 2024 at 10:11 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > Yick Xie wrote:
> > > If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg),
> > > "connected" should not be set to 0. Otherwise it stops
> > > the connected socket from using the cached route.
> > >
> > > Signed-off-by: Yick Xie <yick.xie@gmail.com>
> >
> > This either needs to target net-next, or have
> >
> > Fixes: 2e8de8576343 ("udp: add gso segment cmsg")
> 
> I should have added that, sorry for the mess.

No worries.

> > I think it can be argued either way. This situation existed from the
> > start, and is true for other cmsg that don't affect routing as well.
> >
> > If the impact of the route lookup is significant, it couls be argued
> > to be a performance bug.
> 
> With sendmsg(), any smaller gso_size could be picked up dynamically.
> Then it depends, "ip_route_output_flow()" could be as expensive as
> "ip_make_skb()".
> 
> > I steer towards net-next. In which case it would be nice to also
> > move the ipc.opt branch and perhaps even exclude other common cmsgs,
> > such as SCM_TXTIME and SCM_TIMESTAMPING.
> 
> Both are fine. Though could it be better to take an easy backporting at first?

Sounds good. Please just resend with the Fixes tag.

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

end of thread, other threads:[~2024-04-16 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-14 19:52 [PATCH net] udp: don't be set unconnected if only UDP cmsg Yick Xie
2024-04-15 14:11 ` Willem de Bruijn
2024-04-15 23:30   ` Yick Xie
2024-04-16 14:51     ` Willem de Bruijn

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).