(SIGAR-142) loosen net_interface_list filters
This commit is contained in:
parent
64a6f41925
commit
fb9a5f3357
|
@ -2456,6 +2456,26 @@ static int sigar_ifmsg_init(sigar_t *sigar)
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int has_ifaddr(char *name)
|
||||||
|
{
|
||||||
|
int sock, status;
|
||||||
|
struct ifreq ifr;
|
||||||
|
|
||||||
|
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
SIGAR_SSTRCPY(ifr.ifr_name, name);
|
||||||
|
if (ioctl(sock, SIOCGIFADDR, &ifr) == 0) {
|
||||||
|
status = SIGAR_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(sock);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
||||||
{
|
{
|
||||||
char *end = sigar->ifconf_buf + sigar->ifconf_len;
|
char *end = sigar->ifconf_buf + sigar->ifconf_len;
|
||||||
|
@ -2490,14 +2510,20 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
||||||
if (sdl->sdl_family != AF_LINK) {
|
if (sdl->sdl_family != AF_LINK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!((sdl->sdl_type == IFT_ETHER) ||
|
|
||||||
(sdl->sdl_type == IFT_LOOP)))
|
|
||||||
{
|
|
||||||
continue; /* XXX deal w/ other weirdo interfaces */
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (iter->type) {
|
switch (iter->type) {
|
||||||
case IFMSG_ITER_LIST:
|
case IFMSG_ITER_LIST:
|
||||||
|
if (sdl->sdl_type == IFT_OTHER) {
|
||||||
|
if (has_ifaddr(sdl->sdl_data) != SIGAR_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!((sdl->sdl_type == IFT_ETHER) ||
|
||||||
|
(sdl->sdl_type == IFT_LOOP)))
|
||||||
|
{
|
||||||
|
break; /* XXX deal w/ other weirdo interfaces */
|
||||||
|
}
|
||||||
|
|
||||||
SIGAR_NET_IFLIST_GROW(iter->data.iflist);
|
SIGAR_NET_IFLIST_GROW(iter->data.iflist);
|
||||||
|
|
||||||
/* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */
|
/* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */
|
||||||
|
|
Loading…
Reference in New Issue