Skip to content

Commit

Permalink
unix: fix wrong MAC of uv_interface_address
Browse files Browse the repository at this point in the history
fix a wrong `if` in `uv_interface_address` about MAC.

Fixes: nodejs/node#13581
Fixes: libuv#829
  • Loading branch information
XadillaX committed Jun 10, 2017
1 parent 57f4180 commit bae5620
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/unix/bsd-ifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) {
return 0;
}

static int uv__ifphys_exclude(struct ifaddrs *ent) {
if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
return 1;
if (ent->ifa_addr == NULL)
return 1;
if (ent->ifa_addr->sa_family != AF_LINK)
return 1;

return 0;
}

int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
struct ifaddrs* addrs;
struct ifaddrs* ent;
Expand Down Expand Up @@ -102,7 +113,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {

/* Fill in physical addresses for each interface */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
if (uv__ifaddr_exclude(ent))
if (uv__ifphys_exclude(ent))
continue;

address = *addresses;
Expand Down

0 comments on commit bae5620

Please sign in to comment.