Index: sbin/ifconfig/ifconfig.c =================================================================== --- sbin/ifconfig/ifconfig.c +++ sbin/ifconfig/ifconfig.c @@ -1410,7 +1410,28 @@ } } else warn("unable to allocate memory for interface" - "description"); + " description"); + break; + } + for (;;) { + if ((descr = reallocf(descr, descrlen)) != NULL) { + ifr.ifr_buffer.buffer = descr; + ifr.ifr_buffer.length = descrlen; + if (ioctl(s, SIOCGIFDNAME, &ifr) == 0) { + if (ifr.ifr_buffer.buffer == descr) { + if (strlen(descr) > 0 && strncmp(name, + descr, descrlen) != 0) { + printf("\tinitname: %s\n", + descr); + } + } else if (ifr.ifr_buffer.length > descrlen) { + descrlen = ifr.ifr_buffer.length; + continue; + } + } + } else + warn("unable to allocate memory for interface" + " initname"); break; } Index: sys/net/if.c =================================================================== --- sys/net/if.c +++ sys/net/if.c @@ -2708,6 +2708,28 @@ ifp->if_flags &= ~IFF_RENAMING; break; + case SIOCGIFDNAME: + error = 0; + if (ifp->if_dname == NULL || ifp->if_dunit == IF_DUNIT_NONE) { + error = ENOMSG; + } else { + descrlen = snprintf(new_name, sizeof(new_name), "%s%u", + ifp->if_dname, ifp->if_dunit); + if (descrlen < 0) { + error = ENOMSG; + break; + } + /* space for terminating nul */ + descrlen++; + if (ifr_buffer_get_length(ifr) < descrlen) + ifr_buffer_set_buffer_null(ifr); + else + error = copyout(new_name, + ifr_buffer_get_buffer(ifr), descrlen); + ifr_buffer_set_length(ifr, descrlen); + } + break; + #ifdef VIMAGE case SIOCSIFVNET: error = priv_check(td, PRIV_NET_SETIFVNET); Index: sys/sys/sockio.h =================================================================== --- sys/sys/sockio.h +++ sys/sys/sockio.h @@ -147,4 +147,6 @@ #define SIOCGIFDOWNREASON _IOWR('i', 154, struct ifdownreason) +#define SIOCGIFDNAME _IOWR('i', 155, struct ifreq) /* get ifnet dname + dunit */ + #endif /* !_SYS_SOCKIO_H_ */