All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Daurnimator <quae@daurnimator.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	William Ahern <william@25thandclement.com>,
	"Santi T." <santitm99@gmail.com>,
	mtk.manpages@gmail.com
Subject: Re: EINVAL when using connect() for udp sockets
Date: Fri, 24 Mar 2017 16:19:20 -0700	[thread overview]
Message-ID: <1490397560.24891.0.camel@edumazet-glaptop3.roam.corp.google.com> (raw)
In-Reply-To: <CAM_iQpVVBfwd7P0-dY08Bw7QNr_w77va4AEMFj5xMuOddQoq2g@mail.gmail.com>

On Fri, 2017-03-24 at 15:34 -0700, Cong Wang wrote:
> (Cc'ing Michael Kerrisk)
> 
> On Wed, Mar 22, 2017 at 10:18 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > On Thu, 2017-03-23 at 13:22 +1100, Daurnimator wrote:
> >> On 9 March 2017 at 14:10, Daurnimator <quae@daurnimator.com> wrote:
> >> > When debugging https://github.com/daurnimator/lua-http/issues/73 which
> >> > uses https://github.com/wahern/dns we ran into an issue where modern
> >> > linux kernels return EINVAL if you try and re-use a udp socket.
> >> > The issue seems to occur if you go from a local destination ip to a
> >> > non-local one.
> >>
> >> Did anyone get a chance to look into this issue?
> >
> > I believe man page is not complete.
> >
> > A disconnect is needed before another connect()
> 
> Is it? Making connect() reentrant is reasonable for connection-less
> protocol like UDP, but I don't dig POSIX for the details. If so we need
> something like below...
> 
> --- a/net/ipv4/datagram.c
> +++ b/net/ipv4/datagram.c
> @@ -40,7 +40,7 @@ int __ip4_datagram_connect(struct sock *sk, struct
> sockaddr *uaddr, int addr_len
>         sk_dst_reset(sk);
> 
>         oif = sk->sk_bound_dev_if;
> -       saddr = inet->inet_saddr;
> +       saddr = inet->inet_saddr = 0;
>         if (ipv4_is_multicast(usin->sin_addr.s_addr)) {
>                 if (!oif)
>                         oif = inet->mc_index;

Wont this break bind() ?

  reply	other threads:[~2017-03-24 23:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09  3:10 EINVAL when using connect() for udp sockets Daurnimator
2017-03-23  2:22 ` Daurnimator
2017-03-23  5:18   ` Eric Dumazet
2017-03-24 22:34     ` Cong Wang
2017-03-24 23:19       ` Eric Dumazet [this message]
2017-03-28  4:22         ` Cong Wang
2017-03-28 23:11           ` Eric Dumazet
2017-03-28 23:44             ` Daurnimator
2017-03-28 23:45               ` Daurnimator
2017-03-29  0:52             ` Eric Dumazet
2017-03-30 23:36               ` Cong Wang
2017-03-31  0:02                 ` Eric Dumazet
2017-03-31 16:52                   ` Cong Wang
2017-03-31 17:00                     ` Cong Wang
2017-04-28  2:55                     ` Daurnimator
2017-04-28  4:48                       ` Eric Dumazet
2017-09-04 13:23                         ` Daurnimator

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=1490397560.24891.0.camel@edumazet-glaptop3.roam.corp.google.com \
    --to=eric.dumazet@gmail.com \
    --cc=mtk.manpages@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=quae@daurnimator.com \
    --cc=santitm99@gmail.com \
    --cc=william@25thandclement.com \
    --cc=xiyou.wangcong@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.