public inbox for passt-user@passt.top
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Juan Orti <jorti@pm.me>
Cc: David Gibson <david@gibson.dropbear.id.au>,
	"passt-user@passt.top" <passt-user@passt.top>
Subject: Re: IPv6 UDP not working
Date: Mon, 29 May 2023 00:08:56 +0200	[thread overview]
Message-ID: <20230529000856.6e846656@elisabeth> (raw)
In-Reply-To: <WHlyhD5T65ltZwbmE6P6VYj_LrRtssLIZRrtTQZxo0Ru6q6zzIRHi0OxNX7UaWOwunTU0YRWu12pdbgv5f6Ruza9IoTnzD22uUF20f_r4qg=@pm.me>

On Sun, 28 May 2023 16:27:13 +0000
Juan Orti <jorti@pm.me> wrote:

> ------- Original Message -------
> El domingo, 28 de mayo de 2023 a las 16:38, Stefano Brivio <sbrivio@redhat.com> escribió:
> 
> > I guess that might come from the IPV6_PKTINFO ancillary data
> > (cmsg_type 0x32) -- I'm not sure how and why it's used here as strace
> > doesn't dump the CMSG_DATA content, but, having a look at
> > ip6_datagram_send_ctl() (net/ipv6/datagram.c), EINVAL might come from:
> > 
> > 1. a link-local address being passed along... I doubt that's the case
> > 
> > 2. a non-local address (or one we can't bind to anyway) being used. To
> > check if we're in this case, it would be helpful if you could share
> > the addressing information from the container (ip -6 address show),
> > and if you could try 'sysctl -w net.ipv6.ip_nonlocal_bind = 1',
> > again from the container.  
> 
> 
> net.ipv6.ip_nonlocal_bind=1 is not helping. This is the container network config:
> 
> # ip -6 address show
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
>     inet6 ::1/128 scope host 
>        valid_lft forever preferred_lft forever
> 2: enp88s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 state UNKNOWN qlen 1000
>     inet6 fddc:f797:78ef:70::5/64 scope global flags 02 
>        valid_lft forever preferred_lft forever
>     inet6 fe80::5cef:4eff:fe6c:551f/64 scope link 
>        valid_lft forever preferred_lft forever
> 
> # ip -6 r show table all
> fddc:f797:78ef:70::/64 dev enp88s0  metric 256 
> fe80::/64 dev enp88s0  metric 256 
> default via fe80::ea9f:80ff:fe5d:3d6e dev enp88s0  metric 1024 
> local ::1 dev lo table local  metric 0 
> local fddc:f797:78ef:70::5 dev enp88s0 table local  metric 0 
> local fe80::5cef:4eff:fe6c:551f dev enp88s0 table local  metric 0 
> multicast ff00::/8 dev enp88s0 table local  metric 256 
> 
> 
> With a tcpdump inside the container I can see that the incoming packets are actually arriving with the link-local address as the destination (is this expected?).
> 
> 16:18:26.248659 IP6 (hlim 255, next-header UDP (17) payload length: 63) fddc:f797:78ef:10::b46.42091 > fe80::5cef:4eff:fe6c:551f.53: [udp sum ok] 6215+ [1au] A? www.google.com. (55)

Hmm, it depends:
  https://passt.top/passt/tree/udp.c?id=e3b19530e4a689f9f8e417ebf737dfca2340342b#n646

I'm not sure what's the original source address of our DNS query (you
can find that out with tcpdump in the parent namespace).

For example, if it's a loopback address, we go ahead and try to convert
both source and destination address to our notion of (observed)
link-local addresses, because we can't use a loopback address on a
non-loopback interface (non-lo in the container).

But I guess in this case it's not a loopback address: the default
gateway address, copied to the container, is fe80::ea9f:80ff:fe5d:3d6e,
which is a link-local address, but we don't use it, so I assume we
end up either in the IN6_IS_ADDR_LINKLOCAL(src) condition, or in the
final 'else' clause.

At that point, the address we've seen the guest using becomes our
destination address. It can even be a link-local address if we haven't
observed a unicast address used, yet. It would be interesting to see
what happens if you generate traffic, from the container, coming from
fddc:f797:78ef:70::5, before a DNS query is sent (a TCP request via
IPv6 should be enough).

I'm not swearing on the correctness of this logic, it's a result of
handling several corner cases, it's rather ugly at the moment, and David
is currently considering how to clean that up.

By the way, this might also happen to be "fixed" on HEAD, as there we
copy all the addresses and all the routes, by default, from the parent
namespace to the container namespace.

> 16:18:31.253942 IP6 (hlim 255, next-header UDP (17) payload length: 63) fddc:f797:78ef:10::b46.34965 > fe80::5cef:4eff:fe6c:551f.53: [udp sum ok] 6215+ [1au] A? www.google.com. (55)
> 16:18:36.257294 IP6 (hlim 255, next-header UDP (17) payload length: 63) fddc:f797:78ef:10::b46.55302 > fe80::5cef:4eff:fe6c:551f.53: [udp sum ok] 6215+ [1au] A? www.google.com. (55)
> 
> 
> TCP also uses the link-local address, however it works:

...yes, as far as I know there are no normative references preventing a
non-link-local address from contacting a link-local one.

This just happens to be a problem because AdguardHome uses
IPV6_PKTINFO, with that same address I guess, in its sendmsg(), and for
some reason I didn't really investigate that leads to EINVAL on Linux,
but it looks like an implementation detail (specific to UDP) to me.

-- 
Stefano


      reply	other threads:[~2023-05-28 22:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <o0t07HOIe1WVorR4ppjQtAzY-E0bv5xAt-6UHTffXL_jo2sor1DmCVar_CuqwchJNLRUt8Q3mK3eZfQdJh0ryvXvuf-ewSHRBT5MhOoglDw=@pm.me>
2023-05-28  5:23 ` IPv6 UDP not working David Gibson
2023-05-28 10:12   ` Juan Orti
2023-05-28 10:50     ` Juan Orti
2023-05-28 14:38       ` Stefano Brivio
2023-05-28 16:27         ` Juan Orti
2023-05-28 22:08           ` Stefano Brivio [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=20230529000856.6e846656@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=jorti@pm.me \
    --cc=passt-user@passt.top \
    /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 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 IMAP folder(s).