|
|
f9ed25 |
From 234747fbfd6c6429619ba843713d5b39fb4a513d Mon Sep 17 00:00:00 2001
|
|
|
f9ed25 |
From: Pavel Zhukov <pzhukov@redhat.com>
|
|
|
f9ed25 |
Date: Thu, 21 Feb 2019 10:33:06 +0100
|
|
|
f9ed25 |
Subject: [PATCH 13/26] DHCPv6 over PPP support (#626514)
|
|
|
f9ed25 |
Cc: pzhukov@redhat.com
|
|
|
f9ed25 |
|
|
|
f9ed25 |
---
|
|
|
f9ed25 |
client/dhc6.c | 3 ++-
|
|
|
f9ed25 |
client/dhclient.c | 17 ++++++++++++++---
|
|
|
f9ed25 |
common/bpf.c | 16 ++++++++++++++++
|
|
|
f9ed25 |
common/lpf.c | 16 ++++++++++++++++
|
|
|
f9ed25 |
includes/dhcp.h | 2 ++
|
|
|
f9ed25 |
includes/dhcpd.h | 2 +-
|
|
|
f9ed25 |
server/dhcpv6.c | 3 +++
|
|
|
f9ed25 |
7 files changed, 54 insertions(+), 5 deletions(-)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/client/dhc6.c b/client/dhc6.c
|
|
|
f9ed25 |
index 16a0838..3171828 100644
|
|
|
f9ed25 |
--- a/client/dhc6.c
|
|
|
f9ed25 |
+++ b/client/dhc6.c
|
|
|
f9ed25 |
@@ -5744,7 +5744,8 @@ make_client6_options(struct client_state *client, struct option_state **op,
|
|
|
f9ed25 |
*/
|
|
|
f9ed25 |
if ((oc = lookup_option(&dhcpv6_universe, *op,
|
|
|
f9ed25 |
D6O_CLIENTID)) == NULL) {
|
|
|
f9ed25 |
- if (!option_cache(&oc, &default_duid, NULL, clientid_option,
|
|
|
f9ed25 |
+ if (default_duid.len == 0 ||
|
|
|
f9ed25 |
+ !option_cache(&oc, &default_duid, NULL, clientid_option,
|
|
|
f9ed25 |
MDL))
|
|
|
f9ed25 |
log_fatal("Failure assembling a DUID.");
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/client/dhclient.c b/client/dhclient.c
|
|
|
f9ed25 |
index 5d3f5bc..301132c 100644
|
|
|
f9ed25 |
--- a/client/dhclient.c
|
|
|
f9ed25 |
+++ b/client/dhclient.c
|
|
|
f9ed25 |
@@ -1202,8 +1202,8 @@ main(int argc, char **argv) {
|
|
|
f9ed25 |
if (default_duid.buffer != NULL)
|
|
|
f9ed25 |
data_string_forget(&default_duid, MDL);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
- form_duid(&default_duid, MDL);
|
|
|
f9ed25 |
- write_duid(&default_duid);
|
|
|
f9ed25 |
+ if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
|
|
|
f9ed25 |
+ write_duid(&default_duid);
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -3956,7 +3956,7 @@ write_options(struct client_state *client, struct option_state *options,
|
|
|
f9ed25 |
* is not how it is intended. Upcoming rearchitecting the client should
|
|
|
f9ed25 |
* address this "one daemon model."
|
|
|
f9ed25 |
*/
|
|
|
f9ed25 |
-void
|
|
|
f9ed25 |
+isc_result_t
|
|
|
f9ed25 |
form_duid(struct data_string *duid, const char *file, int line)
|
|
|
f9ed25 |
{
|
|
|
f9ed25 |
struct interface_info *ip;
|
|
|
f9ed25 |
@@ -3969,6 +3969,15 @@ form_duid(struct data_string *duid, const char *file, int line)
|
|
|
f9ed25 |
if (ip == NULL)
|
|
|
f9ed25 |
log_fatal("Impossible condition at %s:%d.", MDL);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+ while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
|
|
|
f9ed25 |
+ /* Try the other interfaces */
|
|
|
f9ed25 |
+ log_debug("Cannot form default DUID from interface %s.", ip->name);
|
|
|
f9ed25 |
+ ip = ip->next;
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ if (ip == NULL) {
|
|
|
f9ed25 |
+ return ISC_R_UNEXPECTED;
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
if ((ip->hw_address.hlen == 0) ||
|
|
|
f9ed25 |
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
|
|
|
f9ed25 |
log_fatal("Impossible hardware address length at %s:%d.", MDL);
|
|
|
f9ed25 |
@@ -4014,6 +4023,8 @@ form_duid(struct data_string *duid, const char *file, int line)
|
|
|
f9ed25 |
log_info("Created duid %s.", str);
|
|
|
f9ed25 |
dfree(str, MDL);
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
+ return ISC_R_SUCCESS;
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
|
|
|
f9ed25 |
/* Write the default DUID to the lease store. */
|
|
|
f9ed25 |
diff --git a/common/bpf.c b/common/bpf.c
|
|
|
f9ed25 |
index 67b6d64..ffbd09a 100644
|
|
|
f9ed25 |
--- a/common/bpf.c
|
|
|
f9ed25 |
+++ b/common/bpf.c
|
|
|
f9ed25 |
@@ -650,6 +650,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
|
|
|
f9ed25 |
memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
#endif /* IFT_FDDI */
|
|
|
f9ed25 |
+#if defined(IFT_PPP)
|
|
|
f9ed25 |
+ case IFT_PPP:
|
|
|
f9ed25 |
+ if (local_family != AF_INET6)
|
|
|
f9ed25 |
+ log_fatal("Unsupported device type %d for \"%s\"",
|
|
|
f9ed25 |
+ sa->sdl_type, name);
|
|
|
f9ed25 |
+ hw->hlen = 0;
|
|
|
f9ed25 |
+ hw->hbuf[0] = HTYPE_RESERVED;
|
|
|
f9ed25 |
+ /* 0xdeadbeef should never occur on the wire,
|
|
|
f9ed25 |
+ * and is a signature that something went wrong.
|
|
|
f9ed25 |
+ */
|
|
|
f9ed25 |
+ hw->hbuf[1] = 0xde;
|
|
|
f9ed25 |
+ hw->hbuf[2] = 0xad;
|
|
|
f9ed25 |
+ hw->hbuf[3] = 0xbe;
|
|
|
f9ed25 |
+ hw->hbuf[4] = 0xef;
|
|
|
f9ed25 |
+ break;
|
|
|
f9ed25 |
+#endif
|
|
|
f9ed25 |
default:
|
|
|
f9ed25 |
log_fatal("Unsupported device type %d for \"%s\"",
|
|
|
f9ed25 |
sa->sdl_type, name);
|
|
|
f9ed25 |
diff --git a/common/lpf.c b/common/lpf.c
|
|
|
f9ed25 |
index 82a279b..b0ed01c 100644
|
|
|
f9ed25 |
--- a/common/lpf.c
|
|
|
f9ed25 |
+++ b/common/lpf.c
|
|
|
f9ed25 |
@@ -563,6 +563,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
|
|
|
f9ed25 |
hw->hbuf[0] = HTYPE_FDDI;
|
|
|
f9ed25 |
memcpy(&hw->hbuf[1], sa->sa_data, 6);
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
+#if defined(ARPHRD_PPP)
|
|
|
f9ed25 |
+ case ARPHRD_PPP:
|
|
|
f9ed25 |
+ if (local_family != AF_INET6)
|
|
|
f9ed25 |
+ log_fatal("Unsupported device type %d for \"%s\"",
|
|
|
f9ed25 |
+ sa->sa_family, name);
|
|
|
f9ed25 |
+ hw->hlen = 0;
|
|
|
f9ed25 |
+ hw->hbuf[0] = HTYPE_RESERVED;
|
|
|
f9ed25 |
+ /* 0xdeadbeef should never occur on the wire,
|
|
|
f9ed25 |
+ * and is a signature that something went wrong.
|
|
|
f9ed25 |
+ */
|
|
|
f9ed25 |
+ hw->hbuf[1] = 0xde;
|
|
|
f9ed25 |
+ hw->hbuf[2] = 0xad;
|
|
|
f9ed25 |
+ hw->hbuf[3] = 0xbe;
|
|
|
f9ed25 |
+ hw->hbuf[4] = 0xef;
|
|
|
f9ed25 |
+ break;
|
|
|
f9ed25 |
+#endif
|
|
|
f9ed25 |
default:
|
|
|
f9ed25 |
log_fatal("Unsupported device type %ld for \"%s\"",
|
|
|
f9ed25 |
(long int)sa->sa_family, name);
|
|
|
f9ed25 |
diff --git a/includes/dhcp.h b/includes/dhcp.h
|
|
|
f9ed25 |
index 95bf539..4cc547a 100644
|
|
|
f9ed25 |
--- a/includes/dhcp.h
|
|
|
f9ed25 |
+++ b/includes/dhcp.h
|
|
|
f9ed25 |
@@ -80,6 +80,8 @@ struct dhcp_packet {
|
|
|
f9ed25 |
* is no standard for this so we
|
|
|
f9ed25 |
* just steal a type */
|
|
|
f9ed25 |
|
|
|
f9ed25 |
+#define HTYPE_RESERVED 0 /* RFC 5494 */
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
/* Magic cookie validating dhcp options field (and bootp vendor
|
|
|
f9ed25 |
extensions field). */
|
|
|
f9ed25 |
#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
|
|
|
f9ed25 |
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
|
|
|
f9ed25 |
index 2ac39ae..faa9251 100644
|
|
|
f9ed25 |
--- a/includes/dhcpd.h
|
|
|
f9ed25 |
+++ b/includes/dhcpd.h
|
|
|
f9ed25 |
@@ -3051,7 +3051,7 @@ void client_dns_remove(struct client_state *client, struct iaddr *addr);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
void dhcpv4_client_assignments(void);
|
|
|
f9ed25 |
void dhcpv6_client_assignments(void);
|
|
|
f9ed25 |
-void form_duid(struct data_string *duid, const char *file, int line);
|
|
|
f9ed25 |
+isc_result_t form_duid(struct data_string *duid, const char *file, int line);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
void dhcp4o6_start(void);
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/server/dhcpv6.c b/server/dhcpv6.c
|
|
|
f9ed25 |
index a7110f9..c5ce7e8 100644
|
|
|
f9ed25 |
--- a/server/dhcpv6.c
|
|
|
f9ed25 |
+++ b/server/dhcpv6.c
|
|
|
f9ed25 |
@@ -482,6 +482,9 @@ generate_new_server_duid(void) {
|
|
|
f9ed25 |
if (p->hw_address.hlen > 0) {
|
|
|
f9ed25 |
break;
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
+ if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
|
|
|
f9ed25 |
+ log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
if (p == NULL) {
|
|
|
f9ed25 |
return ISC_R_UNEXPECTED;
|
|
|
f9ed25 |
--
|
|
|
f9ed25 |
2.14.5
|
|
|
f9ed25 |
|