[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <661856692c8af_36e52529467@willemb.c.googlers.com.notmuch>
Date: Thu, 11 Apr 2024 17:30:17 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Yick Xie <yick.xie@...il.com>,
willemb@...gle.com,
davem@...emloft.net,
willemdebruijn.kernel@...il.com
Cc: netdev@...r.kernel.org
Subject: Re: [BUG report] GSO cmsg always turns UDP into unconnected
Yick Xie wrote:
> Greetings,
>
> If "udp_cmsg_send()" returned 0 (i.e. only SOL_UDP cmsg), "connected"
> would still be set to 0, later inevitably "ip_route_output_flow()".
> In other words, a connected UDP works as unconnected.
>
> A potential fix like this:
>
> ```
> https://github.com/torvalds/linux/blob/20cb38a7af88dc40095da7c2c9094da3873fea23/net/ipv4/udp.c#L1043
> @@ 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;
> }
> ```
This is not actually a bug, is it?
It is not necessary to a do a route lookup if only udp_cmsg_send is
called. But neither is it for some cases of ip_cmsg_send and
__sock_cmsg_send (which it calls in turn), say SO_TXTIME.
The suggested patch is a nice optimization to use the cached route.
Do send it.
Powered by blists - more mailing lists