On 12/04/16(Tue) 14:03, Stuart Henderson wrote: > On 2016/04/12 14:18, Claudio Jeker wrote: > > On Tue, Apr 12, 2016 at 01:47:53PM +0200, Stefan Sperling wrote: > > > On Tue, Apr 12, 2016 at 12:27:10PM +0100, Stuart Henderson wrote: > > > > 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. > > > > > > How about appending to the flags line, like this? > > > > > > lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768 index 4 > > > > > > > Or on the line with priority? The risk of breaking scripts that way is > > probably smaller. > > I'd be happier with priority, the flags line can get quite long these days!
Like that? em0: flags=18b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST,MPSAFE> mtu 1500 lladdr f1:ce:f9:1d:77:49 index 1 priority 0 trunk: trunkdev trunk0 media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) status: active 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 14:25:03 -0000 @@ -2929,8 +2929,14 @@ status(int link, struct sockaddr_dl *sdl strlen(ifrdesc.ifr_data)) printf("\tdescription: %s\n", ifrdesc.ifr_data); - if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) - printf("\tpriority: %d\n", ifrdesc.ifr_metric); + if (sdl != NULL) + printf("\tindex %u", sdl->sdl_index); + if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) { + printf("%cpriority %d\n", (sdl != NULL) ? ' ' : '\t', + ifrdesc.ifr_metric); + } else if (sdl != NULL) { + putchar('\n'); + } (void) memset(&ikardesc, 0, sizeof(ikardesc)); (void) strlcpy(ikardesc.ikar_name, name, sizeof(ikardesc.ikar_name)); if (ioctl(s, SIOCGETKALIVE, &ikardesc) == 0 &&