Florian Obser <[email protected]> wrote: > On Sun, Dec 20, 2020 at 02:34:09PM +0100, Claudio Jeker wrote: > > On Sun, Dec 20, 2020 at 01:39:57PM +0100, Otto Moerbeek wrote: > > > Hi, > > > > > > scope is there, just not shown. While there, use proper constants for > > > two sizes. > > > > > > -Otto > > > > > > > > > Index: ktrstruct.c > > > =================================================================== > > > RCS file: /cvs/src/usr.bin/kdump/ktrstruct.c,v > > > retrieving revision 1.28 > > > diff -u -p -r1.28 ktrstruct.c > > > --- ktrstruct.c 17 Nov 2018 20:46:12 -0000 1.28 > > > +++ ktrstruct.c 20 Dec 2020 12:34:34 -0000 > > > @@ -90,7 +90,7 @@ ktrsockaddr(struct sockaddr *sa) > > > switch(sa->sa_family) { > > > case AF_INET: { > > > struct sockaddr_in *sa_in; > > > - char addr[64]; > > > + char addr[INET_ADDRSTRLEN]; > > > > > > sa_in = (struct sockaddr_in *)sa; > > > check_sockaddr_len(in); > > > @@ -100,12 +100,15 @@ ktrsockaddr(struct sockaddr *sa) > > > } > > > case AF_INET6: { > > > struct sockaddr_in6 *sa_in6; > > > - char addr[64]; > > > + char addr[INET6_ADDRSTRLEN], scope[12] = { 0 }; > > > > > > sa_in6 = (struct sockaddr_in6 *)sa; > > > check_sockaddr_len(in6); > > > inet_ntop(AF_INET6, &sa_in6->sin6_addr, addr, sizeof addr); > > > - printf("[%s]:%u", addr, htons(sa_in6->sin6_port)); > > > + if (sa_in6->sin6_scope_id) > > > + snprintf(scope, sizeof(scope), "%%%u", > > > + sa_in6->sin6_scope_id); > > > > Would it make sense to use if_indextoname() here to translate the string > > into an interface name? The snprintf would still be needed for the case > > where NULL is returned by if_indextoname(). > > (I had already OK'ed this off-list.) > > I had thought about this as well, at that point we might as well use > getnameinfo(3). > > However, when we run kdump the interface might no longer exist or > maybe we run kdump on a different host with different interfaces.
If this is going to come up often, the kernel could add an additional record which describes it. But don't we wish this scope-id didn't exist?
