|
|
f9ed25 |
From 01ce61b8a0331a2f068ca2191bfb897b505c1b9d Mon Sep 17 00:00:00 2001
|
|
|
f9ed25 |
From: Pavel Zhukov <pzhukov@redhat.com>
|
|
|
f9ed25 |
Date: Thu, 21 Feb 2019 10:42:50 +0100
|
|
|
f9ed25 |
Subject: [PATCH 20/26] Discover all hwaddress for xid uniqueness
|
|
|
f9ed25 |
Cc: pzhukov@redhat.com
|
|
|
f9ed25 |
|
|
|
f9ed25 |
---
|
|
|
f9ed25 |
common/discover.c | 2 ++
|
|
|
f9ed25 |
common/lpf.c | 27 ++++++++++++++++++++++-----
|
|
|
f9ed25 |
includes/dhcpd.h | 3 +++
|
|
|
f9ed25 |
3 files changed, 27 insertions(+), 5 deletions(-)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/common/discover.c b/common/discover.c
|
|
|
f9ed25 |
index 056342c..e66e1c5 100644
|
|
|
f9ed25 |
--- a/common/discover.c
|
|
|
f9ed25 |
+++ b/common/discover.c
|
|
|
f9ed25 |
@@ -648,6 +648,8 @@ discover_interfaces(int state) {
|
|
|
f9ed25 |
interface_dereference(&tmp, MDL);
|
|
|
f9ed25 |
tmp = interfaces; /* XXX */
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
+ if (tmp != NULL)
|
|
|
f9ed25 |
+ try_hw_addr(tmp);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
if (dhcp_interface_discovery_hook) {
|
|
|
f9ed25 |
(*dhcp_interface_discovery_hook)(tmp);
|
|
|
f9ed25 |
diff --git a/common/lpf.c b/common/lpf.c
|
|
|
f9ed25 |
index b732a86..a708a5d 100644
|
|
|
f9ed25 |
--- a/common/lpf.c
|
|
|
f9ed25 |
+++ b/common/lpf.c
|
|
|
f9ed25 |
@@ -699,8 +699,22 @@ ioctl_get_ll(char *name)
|
|
|
f9ed25 |
return sll;
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+// define ?
|
|
|
f9ed25 |
+void try_hw_addr(struct interface_info *info){
|
|
|
f9ed25 |
+ get_hw_addr2(info);
|
|
|
f9ed25 |
+};
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
void
|
|
|
f9ed25 |
get_hw_addr(struct interface_info *info)
|
|
|
f9ed25 |
+{
|
|
|
f9ed25 |
+ if (get_hw_addr2(info) == ISC_R_NOTFOUND){
|
|
|
f9ed25 |
+ log_fatal("Unsupported device type for \"%s\"",
|
|
|
f9ed25 |
+ info->name);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+}
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+isc_result_t
|
|
|
f9ed25 |
+get_hw_addr2(struct interface_info *info)
|
|
|
f9ed25 |
{
|
|
|
f9ed25 |
struct hardware *hw = &info->hw_address;
|
|
|
f9ed25 |
char *name = info->name;
|
|
|
f9ed25 |
@@ -710,7 +724,8 @@ get_hw_addr(struct interface_info *info)
|
|
|
f9ed25 |
int sll_allocated = 0;
|
|
|
f9ed25 |
char *dup = NULL;
|
|
|
f9ed25 |
char *colon = NULL;
|
|
|
f9ed25 |
-
|
|
|
f9ed25 |
+ isc_result_t result = ISC_R_SUCCESS;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
if (getifaddrs(&ifaddrs) == -1)
|
|
|
f9ed25 |
log_fatal("Failed to get interfaces");
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -794,14 +809,16 @@ get_hw_addr(struct interface_info *info)
|
|
|
f9ed25 |
hw->hbuf[4] = 0xef;
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
#endif
|
|
|
f9ed25 |
- default:
|
|
|
f9ed25 |
- freeifaddrs(ifaddrs);
|
|
|
f9ed25 |
- log_fatal("Unsupported device type %hu for \"%s\"",
|
|
|
f9ed25 |
- sll->sll_hatype, name);
|
|
|
f9ed25 |
+ default:
|
|
|
f9ed25 |
+ log_error("Unsupported device type %hu for \"%s\"",
|
|
|
f9ed25 |
+ sll->sll_hatype, name);
|
|
|
f9ed25 |
+ result = ISC_R_NOTFOUND;
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
|
|
|
f9ed25 |
if (sll_allocated)
|
|
|
f9ed25 |
dfree(sll, MDL);
|
|
|
f9ed25 |
freeifaddrs(ifaddrs);
|
|
|
f9ed25 |
+ return result;
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
#endif
|
|
|
f9ed25 |
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
|
|
|
f9ed25 |
index 0c1a0aa..635c510 100644
|
|
|
f9ed25 |
--- a/includes/dhcpd.h
|
|
|
f9ed25 |
+++ b/includes/dhcpd.h
|
|
|
f9ed25 |
@@ -2637,7 +2637,10 @@ void print_dns_status (int, struct dhcp_ddns_cb *, isc_result_t);
|
|
|
f9ed25 |
#endif
|
|
|
f9ed25 |
const char *print_time(TIME);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
void get_hw_addr(struct interface_info *info);
|
|
|
f9ed25 |
+void try_hw_addr(struct interface_info *info);
|
|
|
f9ed25 |
+isc_result_t get_hw_addr2(struct interface_info *info);
|
|
|
f9ed25 |
char *buf_to_hex (const unsigned char *s, unsigned len,
|
|
|
f9ed25 |
const char *file, int line);
|
|
|
f9ed25 |
char *format_lease_id(const unsigned char *s, unsigned len, int format,
|
|
|
f9ed25 |
--
|
|
|
f9ed25 |
2.14.5
|
|
|
f9ed25 |
|