Weird.  I have a feeling there is some reason for this hiding back
around 2000.  Which is wrong now.  But I think originally the idea
was to stop filling people's screens full of the stupid irrelevant
inet6 stuff [1]

But the diff is really really crazy.  It is like you are avoiding
removing some historical logic.  I have a feeling a couple of people
need to dig into this and find why it did what it did, and decide it
is BS.

[1] "inet6 is too good and original, and using arp would be terrible, so
we must invent a new thing that uses multicast, even if it has side
effects that if you enable an interface for inet6, even without an
address, you get a very long line that wraps, and then the person trying
to review their inet4 configuration on a machine with 3 interfaces
cannot read it on a 80x24 screen because the details they are looking
scroll off the top".  Really I think this was our logic, which was caused
by a ridiculous design choice.

Jan Klemkow <j.klem...@wemelug.de> wrote:

> Hi,
> 
> ifconfig doesn't print ipv6 addresses if its used with media option.
> 
> # ifconfig -A
> vio0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>       ...
>       inet 10.0.1.65 netmask 0xffffff00 broadcast 10.0.1.255
>       inet6 fe80::5054:ff:fe6a:b6fd%vio0 prefixlen 64 scopeid 0x1
>       inet6 fc00:1::1 prefixlen 64
>       inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
> 
> # ifconfig -A media
> vio0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
>       ...
>       supported media:
>               media autoselect
>       inet 10.0.1.65 netmask 0xffffff00 broadcast 10.0.1.255
>       inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
> 
> As the diff below shows, afp is NULL by default, but set to inet if
> there is an additional program parameter.  At the end, no specific
> address family is assumed if afp is NULL.  Thus, the diff below
> introduces a new variable to remember if a specific address family was
> set by the user or not for printing all interface addresses.
> 
> The regression test of ifconfig(8) is passing with the diff below.
n> 
> ok?
> 
> bye,
> Jan
> 
> Index: ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.461
> diff -u -p -r1.461 ifconfig.c
> --- ifconfig.c        18 Jan 2023 21:57:10 -0000      1.461
> +++ ifconfig.c        23 Jan 2023 12:11:30 -0000
> @@ -746,6 +746,7 @@ const struct afswtch {
>  };
>  
>  const struct afswtch *afp;   /*the address family being set or asked about*/
> +const struct afswtch *pafp;  /*the address family being used for printing*/
>  
>  char joinname[IEEE80211_NWID_LEN];
>  size_t joinlen;
> @@ -840,7 +841,7 @@ main(int argc, char *argv[])
>       if (argc > 0) {
>               for (afp = rafp = afs; rafp->af_name; rafp++)
>                       if (strcmp(rafp->af_name, *argv) == 0) {
> -                             afp = rafp;
> +                             pafp = afp = rafp;
>                               argc--;
>                               argv++;
>                               break;
> @@ -1216,7 +1217,7 @@ printif(char *name, int ifaliases)
>                           (ifa->ifa_addr->sa_family == AF_INET &&
>                           ifaliases == 0 && noinet == 0))
>                               continue;
> -                     if ((p = afp) != NULL) {
> +                     if ((p = pafp) != NULL) {
>                               if (ifa->ifa_addr->sa_family == p->af_af)
>                                       p->af_status(1);
>                       } else {
> @@ -3514,7 +3515,7 @@ status(int link, struct sockaddr_dl *sdl
>  
>   proto_status:
>       if (link == 0) {
> -             if ((p = afp) != NULL) {
> +             if ((p = pafp) != NULL) {
>                       p->af_status(1);
>               } else for (p = afs; p->af_name; p++) {
>                       ifr.ifr_addr.sa_family = p->af_af;
> 

Reply via email to