tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

getifaddrs(3) returns 2 AF_LINK instances for the same interface



This happens in NetBSD-5 -> -current.
NetBSD-4 and FreeBSD-7 aren't affected.

#include <net/if.h>
#include <ifaddrs.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
        struct ifaddrs *ifaddrs, *ifa;

        if (getifaddrs(&ifaddrs) == -1)
                exit(EXIT_FAILURE);

        for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
                if (ifa->ifa_addr->sa_family != AF_LINK)
                        continue;
                printf ("%s %p\n", ifa->ifa_name, ifa);
        }
        freeifaddrs(ifaddrs);
        exit(0);
}

uberlaptop$ ./ifaddrs
bge0 0xbb902000
bge0 0xbb90201c
fwip0 0xbb902070
fwip0 0xbb90208c
iwi0 0xbb9020c4
iwi0 0xbb9020e0
lo0 0xbb902134
lo0 0xbb902150

Is this a bug or do I need to check something else?

Thanks

Roy


Home | Main Index | Thread Index | Old Index