On 2016/04/12 13:00, Martin Pieuchot wrote:
> Relying on the "scopeid" field is not a viable long-term solution.  I'm
> spending too much time these days trying to figure out which interface
> correspond to which index.
> 
> Here's a difference in output, then the diff itself.  ok?
> 
> @@ -1,31 +1,29 @@
>  lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
> +     index 4
>       priority: 0
>       groups: lo
>       inet6 ::1 prefixlen 128
>       inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
>       inet 127.0.0.1 netmask 0xff000000
>  em0: 
> flags=18b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST,MPSAFE> 
> mtu 1500
> -     lladdr f0:de:f9:1d:88:53
> +     index 1 lladdr f0:de:f9:1d:88:53

This will break scripts, e.g. "awk '/lladdr/ {print $2}'"

I would expect putting it after lladdr would be better for the sort
of scripts a user is likely to write, but bsd.rd would need a change
if that was done, it uses sed 's/.*lladdr \(.*\)/\1/p;d'

On a new line would be safer.

>       priority: 0
>       trunk: trunkdev trunk0
>       media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
>       status: active
>  iwn0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
> -     lladdr f0:de:f9:1d:88:53
> +     index 2 lladdr f0:de:f9:1d:88:53
>       priority: 4
>       trunk: trunkdev trunk0
>       groups: wlan
>       media: IEEE802.11 autoselect (HT-MCS6 mode 11n)
>       status: active
>  enc0: flags=0<>
> +     index 3
>       priority: 0
>       groups: enc
>       status: active
>  trunk0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
> -     lladdr f0:de:f9:1d:88:53
> +     index 5 lladdr f0:de:f9:1d:88:53
>       priority: 0
>       trunk: trunkproto failover
>               trunkport iwn0 
> @@ -35,13 +33,12 @@
>       status: active
>       inet 192.168.178.68 netmask 0xffffff00 broadcast 192.168.178.255
>  tap0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
> -     lladdr fe:e1:ba:d0:d4:e7
> +     index 6 lladdr fe:e1:ba:d0:d4:e7
>       priority: 0
>       groups: tap
>       status: no carrier
>       inet 172.172.0.1 netmask 0xffff0000 broadcast 172.172.255.255
>       inet6 fe80::fce1:baff:fed0:d4e7%tap0 prefixlen 64 scopeid 0x6
>  pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33144
> +     index 7
>       priority: 0
>       groups: pflog
> 
> Index: ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.319
> diff -u -p -r1.319 ifconfig.c
> --- ifconfig.c        6 Apr 2016 11:48:51 -0000       1.319
> +++ ifconfig.c        12 Apr 2016 10:52:51 -0000
> @@ -2916,11 +2916,16 @@ status(int link, struct sockaddr_dl *sdl
>       if (showcapsflag)
>               printifhwfeatures(NULL, 1);
>  #endif
> -     if (sdl != NULL && sdl->sdl_alen &&
> -         (sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_CARP))
> -             (void)printf("\tlladdr %s\n", ether_ntoa(
> -                 (struct ether_addr *)LLADDR(sdl)));
> -
> +     if (sdl != NULL) {
> +             printf("\tindex %u", sdl->sdl_index);
> +             if ((sdl->sdl_alen > 0) &&
> +                 (sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_CARP)) {
> +                     printf(" lladdr %s",
> +                         ether_ntoa((struct ether_addr *)LLADDR(sdl)),
> +                         sdl->sdl_index);
> +             }
> +             printf("\n");
> +     }
>  #ifndef SMALL
>       (void) memset(&ifrdesc, 0, sizeof(ifrdesc));
>       (void) strlcpy(ifrdesc.ifr_name, name, sizeof(ifrdesc.ifr_name));
> 

Reply via email to