aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Tan <samueltan@google.com>2015-08-26 14:53:50 -0700
committerSamuel Tan <samueltan@google.com>2015-08-26 16:18:20 -0700
commitc9637dfcff101b45b9a7aeac4e0e7237d829a59a (patch)
tree53bd45693fdb007bd475fae7be87715228fdb39e
parent400e4d5be8159b314dbaa692587f8431579f3f98 (diff)
downloaddhcpcd-6.8.2-c9637dfcff101b45b9a7aeac4e0e7237d829a59a.tar.gz
dhcpcd-6.8.2: assign interface index in get_interface
In if_discover, the interface struct's index member (ifp->index) is assigned from the sll_ifindex member of of ifa->if_addr (see if.c:490). However, this member is not set in the get_interface function of ifaddrs.c. This unitialized interface index member is later used to bind a socket and send messages on it, which leads to errors. Assign the interface index of selected interface in get_interface to fix this. BUG: 22956197 Change-Id: I41da8fc7abdf3f5fc05c1dc0446d2a1d9dc7557d
-rw-r--r--ifaddrs.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ifaddrs.c b/ifaddrs.c
index a88bcc1..1a27d8f 100644
--- a/ifaddrs.c
+++ b/ifaddrs.c
@@ -84,6 +84,7 @@ struct ifaddrs *get_interface(const char *name, sa_family_t family)
memset(hwaddr, 0, sizeof(struct sockaddr_ll));
hwaddr->sll_family = family;
/* hwaddr->sll_protocol = ETHERTYPE_IP; */
+ ifc_get_ifindex(ifa->ifa_name, &hwaddr->sll_ifindex);
hwaddr->sll_hatype = ARPHRD_ETHER;
hwaddr->sll_halen = ETH_ALEN;
memcpy(hwaddr->sll_addr, hwbuf, ETH_ALEN);