All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Yick Xie <yick.xie@gmail.com>,
	 willemb@google.com,  davem@davemloft.net,
	 willemdebruijn.kernel@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [BUG report] GSO cmsg always turns UDP into unconnected
Date: Thu, 11 Apr 2024 17:30:17 -0400	[thread overview]
Message-ID: <661856692c8af_36e52529467@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <CADaRJKtHCvBH_GJkqF2+NjaLg6uzo4-8s6YDuzT=HzJdDM4hHg@mail.gmail.com>

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.




      reply	other threads:[~2024-04-11 21:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 17:53 [BUG report] GSO cmsg always turns UDP into unconnected Yick Xie
2024-04-11 21:30 ` Willem de Bruijn [this message]

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=661856692c8af_36e52529467@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=yick.xie@gmail.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 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.