gpxe-cid.patch: don't get hw address twice
This commit is contained in:
parent
c0272c7d8a
commit
47fd457046
@ -73,60 +73,11 @@ diff -up dhcp-4.2.2/client/dhclient.c.gpxe-cid dhcp-4.2.2/client/dhclient.c
|
||||
diff -up dhcp-4.2.2/common/lpf.c.gpxe-cid dhcp-4.2.2/common/lpf.c
|
||||
--- dhcp-4.2.2/common/lpf.c.gpxe-cid 2011-09-16 18:23:20.183453996 +0200
|
||||
+++ dhcp-4.2.2/common/lpf.c 2011-09-16 18:25:28.235804421 +0200
|
||||
@@ -591,6 +591,37 @@ void maybe_setup_fallback ()
|
||||
return sll;
|
||||
}
|
||||
|
||||
+static unsigned char * get_ib_hw_addr(char * name)
|
||||
+{
|
||||
+ struct ifaddrs *ifaddrs = NULL;
|
||||
+ struct ifaddrs *ifa = NULL;
|
||||
+ struct sockaddr_ll *sll = NULL;
|
||||
+ static unsigned char hw_addr[8];
|
||||
+
|
||||
+ if (getifaddrs(&ifaddrs) == -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
+ if (ifa->ifa_addr == NULL)
|
||||
+ continue;
|
||||
+ if (ifa->ifa_addr->sa_family != AF_PACKET)
|
||||
+ continue;
|
||||
+ if (ifa->ifa_flags & IFF_LOOPBACK)
|
||||
+ continue;
|
||||
+ if (strcmp(ifa->ifa_name, name) == 0) {
|
||||
+ sll = (struct sockaddr_ll *)(void *)ifa->ifa_addr;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (sll == NULL) {
|
||||
+ freeifaddrs(ifaddrs);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memcpy(hw_addr, &sll->sll_addr[sll->sll_halen - 8], 8);
|
||||
+ freeifaddrs(ifaddrs);
|
||||
+ return (unsigned char *)&hw_addr;
|
||||
+}
|
||||
+
|
||||
void
|
||||
get_hw_addr(struct interface_info *info)
|
||||
{
|
||||
@@ -599,6 +630,7 @@ get_hw_addr(struct interface_info *info)
|
||||
struct ifaddrs *ifaddrs = NULL;
|
||||
struct ifaddrs *ifa = NULL;
|
||||
struct sockaddr_ll *sll = NULL;
|
||||
+ unsigned char *hw_addr;
|
||||
|
||||
if (getifaddrs(&ifaddrs) == -1)
|
||||
log_fatal("Failed to get interfaces");
|
||||
@@ -660,6 +692,10 @@ get_hw_addr(struct interface_info *info)
|
||||
@@ -698,6 +698,7 @@ get_hw_addr(struct interface_info *info)
|
||||
|
||||
hw->hlen = 1;
|
||||
hw->hbuf[0] = HTYPE_INFINIBAND;
|
||||
+ hw_addr = get_ib_hw_addr(name);
|
||||
+ if (!hw_addr)
|
||||
+ log_fatal("Failed getting %s hw addr", name);
|
||||
+ memcpy (&hw->hbuf [1], hw_addr, 8);
|
||||
+ memcpy(&hw->hbuf[1], &sll->sll_addr[sll->sll_halen - 8], 8);
|
||||
break;
|
||||
#if defined(ARPHRD_PPP)
|
||||
case ARPHRD_PPP:
|
||||
|
@ -378,7 +378,7 @@ diff -up dhcp-4.2.4/common/lpf.c.lpf-ib dhcp-4.2.4/common/lpf.c
|
||||
+ continue;
|
||||
+
|
||||
+ if (strcmp((*ifa)->ifa_name, name) == 0)
|
||||
+ return (struct sockaddr_ll *)(*ifa)->ifa_addr;
|
||||
+ return (struct sockaddr_ll *)(void *)(*ifa)->ifa_addr;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
|
Loading…
Reference in New Issue
Block a user