tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: IPv6 problems.... (dhcpcd weirdness, rshd fails, etc.)



At Tue, 18 Nov 2025 10:42:41 +0100, Ted Lemon <mellon%fugue.com@localhost> wrote:
Subject: Re: IPv6 problems.... (dhcpcd weirdness, rshd fails, etc.)
>
> On 18 Nov 2025, at 10:39, Ted Lemon <mellon%fugue.com@localhost> wrote:
> >
> >  if (IN6_IS_ADDR_LINKLOCAL(&sa1->sin6_addr)) {
>
> This is what I get for sending code I'm in the middle of writing:
> the above doesn't make sense in context. The code snippet should
> actually be:
>
>                 server->server_address.sa.sa_family = AF_INET6;
>                 server->server_address.sin6.sin6_addr =
>                 response->rr.data.aaaa;
>                 if
>                     (IN6_IS_ADDR_LINKLOCAL(&server->server_address.sin6_addr))
>                     { server->server_address.sin6.sin6_scope_id =
>                     response->interface_index;
>                 }
>

Hmmm....  I think that gives me a better idea of what to look for, thanks!

So the following compiles, but I don't know yet if it fixes the problem
and won't be able to test for a bit:

--- lib/libc/netrcmd.c.~1.71.~	2015-02-19 20:58:57.000000000 -0800
+++ lib/libc/netrcmd.c	2025-11-18 18:03:06.845451361 -0800
@@ -542,9 +542,12 @@
 		sa->sa_len =
 #endif
 		salen = sizeof(struct sockaddr_in6);
-		if (addr)
+		if (addr) {
 			((struct sockaddr_in6 *)(void *)sa)->sin6_addr =
 			    ((struct sockaddr_in6 *)addr)->sin6_addr;
+			((struct sockaddr_in6 *)(void *)sa)->sin6_scope_id =
+			    ((struct sockaddr_in6 *)addr)->sin6_scope_id;
+		}
 		portp = &((struct sockaddr_in6 *)(void *)sa)->sin6_port;
 		break;
 #endif


But maybe the sin6_scope_id field gets lost earlier (too?)?

It seems silly to me that the kernel can't figure this out itself when
it knows the address explicitly and completely as it does in this case.
I'm pretty sure you can't have the same address on two different
interfaces no matter what family they belong to.  The log message
showing the incoming connection even shows the interface name.

> > Nov 15 21:17:32 once inetd[10044]: connection from fe80::1030:c7e5:ac6d:b5ce%bge0(fe80::1030:c7e5:ac6d:b5ce%bge0), service shell (tcp6)
> > Nov 15 21:17:32 once rshd[10044]: can't get stderr port: Can't assign requested address

I see there's also inet6_getscopeid(3) that seems to just look in the
address to get the id.

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpk3qZ1nPLqf.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index