<div dir="auto">(To be clear: I'm not feeding you the answer in pieces... I only know pieces of the answer. If I knew what the code should look like, I'd send a patch ðŸ˜)</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 10, 2018, 15:56 enh <<a href="mailto:enh@google.com">enh@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> why/how does ping ::1 work<br>
<br>
link-local addresses<br>
(<a href="https://tools.ietf.org/html/rfc4291?referring_site=bodynav#section-2.5.6" rel="noreferrer noreferrer" target="_blank">https://tools.ietf.org/html/rfc4291?referring_site=bodynav#section-2.5.6</a>)<br>
are unrelated to the loopback address<br>
(<a href="https://tools.ietf.org/html/rfc4291?referring_site=bodynav#section-2.5.3" rel="noreferrer noreferrer" target="_blank">https://tools.ietf.org/html/rfc4291?referring_site=bodynav#section-2.5.3</a>).<br>
<br>
ping6 with just -I should not work, but ping6 with just % should.<br>
(both together is fine too.) sin6_scope_id needs to be set to<br>
correspond to the interface.<br>
<br>
IPv6 is a sizeable bag of worms.<br>
On Mon, Jul 9, 2018 at 4:42 PM Rob Landley <<a href="mailto:rob@landley.net" target="_blank" rel="noreferrer">rob@landley.net</a>> wrote:<br>
><br>
><br>
><br>
> On 07/09/2018 04:49 PM, enh wrote:<br>
> > On Fri, Jul 6, 2018 at 6:16 PM Rob Landley <<a href="mailto:rob@landley.net" target="_blank" rel="noreferrer">rob@landley.net</a>> wrote:<br>
> >><br>
> >> On 07/06/2018 03:19 PM, enh wrote:<br>
> >>> they said they'd be much more worried about whether we use IP_RECVERR<br>
> >>> and parse ICMP errors correctly,<br>
> >><br>
> >> I don't think we do but I'll throw it on the todo heap. I'm not 100% sure what<br>
> >> "correctly" means here, but I can try to research it.<br>
> >><br>
> >>> or do link-local ping correctly...<br>
> >><br>
> >> Again, define "correctly"...?<br>
> >><br>
> >> (I can ping ::1 and ping 127.0.0.1 but I dunno if it's doing something wrong?)<br>
> ><br>
> > <a href="https://en.wikipedia.org/wiki/Link-local_address#IPv6" rel="noreferrer noreferrer" target="_blank">https://en.wikipedia.org/wiki/Link-local_address#IPv6</a><br>
><br>
> This can of worms?<br>
><br>
> <a href="https://twitter.com/RichFelker/status/982286128593043456" rel="noreferrer noreferrer" target="_blank">https://twitter.com/RichFelker/status/982286128593043456</a><br>
><br>
> (I've always considered ipv6 a poster child for the second system effect.)<br>
><br>
> > try `ifconfig -a | grep link`<br>
><br>
> No output. (Using ubuntu's ifconfig or toybox's.) Ah: case insensitive grep.<br>
><br>
> > and then compare `ping6 $that_address`<br>
> > (which should fail) against `ping6 -I $that_interface $that_address`<br>
><br>
> Sigh. I had -I working at one point... wait,<br>
><br>
>  Â printf("ntop=%s\n", ntop(sa));<br>
>  Â if (TT.I && bind(TT.sock, sa, sizeof(src_addr))) perror_exit("bind");<br>
><br>
> $ ./ping -I wlan0 fe80::6627:37ff:fe21:64bf<br>
> ntop=fe80::6627:37ff:fe21:64bf<br>
> Ping fe80::6627:37ff:fe21:64bf (fe80::6627:37ff:fe21:64bf) from wlan0<br>
> (fe80::6627:37ff:fe21:64bf): 56(84) bytes.<br>
> ping: sendto: Invalid argument<br>
><br>
> What am I doing wrong? I'm binding to the same IP address I'm trying to ping,<br>
> how is sendto() giving me an invalid argument error? strace says:<br>
><br>
> socket(PF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = 3<br>
> bind(3, {sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6,<br>
> "fe80::6627:37ff:fe21:64bf", &sin6_addr), sin6_flowinfo=0,<br>
> sin6_scope_id=if_nametoindex("wlan0")}, 28) = 0<br>
> sendto(3,<br>
> "\200\0002(\236+\1\0000\311\3412\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,<br>
> 64, 0, {sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6,<br>
> "fe80::6627:37ff:fe21:64bf", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28)<br>
> = -1 EINVAL (Invalid argument)<br>
><br>
> Opened with v6, bound with v6... Sigh, do I have the destination packet<br>
> misformatted for v6? If so, why/how does ping ::1 work?<br>
><br>
> Hmmm... And this is why I have systems built for qemu, so I can STICK PRINTKs<br>
> INTO THE KERNEL. Grrr...<br>
><br>
> > and `ping6 $that_address%$that_interface`.<br>
><br>
> I'm guessing percent is a synonym for -I so this is basically the same issue,<br>
> modulo implementing %?<br>
><br>
> Rob<br>
</blockquote></div>