# getifaddrs returning wrong number of interfaces



## bv_arvind (Dec 23, 2011)

Hi,

 I try to run through the linked list returned by *getifaddrs* and do some operation for each. But I observe the linked list to contain wrong number of interfaces. I see a few interfaces appearing twice (same name) and I am not sure how this could happen. I count the interfaces at the device attach point and I don't see any issue. Any thoughts on this?

Thanks
Arvind


----------



## SirDice (Dec 25, 2011)

Interfaces can have multiple IP addresses. And if I read getifaddrs(3) correctly an interface's MAC address will show up as a separate entry.


----------



## bv_arvind (Jan 4, 2012)

Not sure I understood you right. I have no IP address configured on any of the interfaces and I try to read the linked list returned by getifaddrs. I could not find out the point at which these extra interfaces were getting appended to the list (code search took me nowhere).


----------



## SirDice (Jan 5, 2012)

As I understood the man page getifaddrs(3) returns a list with all addresses on all interfaces, that includes MAC, IPv4 and IPv6 addresses. Each address will have its own entry in the list.


----------

