1 From fe89d58ea8627c66feffa81997daa024834eeb15 Mon Sep 17 00:00:00 2001
2 From: Pavel Zhukov <pzhukov@redhat.com>
3 Date: Thu, 21 Feb 2019 10:33:06 +0100
4 Subject: [PATCH 13/28] DHCPv6 over PPP support (#626514)
8 client/dhclient.c | 17 ++++++++++++++---
9 common/bpf.c | 16 ++++++++++++++++
10 common/lpf.c | 16 ++++++++++++++++
11 includes/dhcp.h | 2 ++
12 includes/dhcpd.h | 2 +-
13 server/dhcpv6.c | 3 +++
14 7 files changed, 54 insertions(+), 5 deletions(-)
16 diff --git a/client/dhc6.c b/client/dhc6.c
17 index 35cf3d0..88fd07d 100644
20 @@ -5737,7 +5737,8 @@ make_client6_options(struct client_state *client, struct option_state **op,
22 if ((oc = lookup_option(&dhcpv6_universe, *op,
23 D6O_CLIENTID)) == NULL) {
24 - if (!option_cache(&oc, &default_duid, NULL, clientid_option,
25 + if (default_duid.len == 0 ||
26 + !option_cache(&oc, &default_duid, NULL, clientid_option,
28 log_fatal("Failure assembling a DUID.");
30 diff --git a/client/dhclient.c b/client/dhclient.c
31 index b49fcb3..a99e21f 100644
32 --- a/client/dhclient.c
33 +++ b/client/dhclient.c
34 @@ -1223,8 +1223,8 @@ main(int argc, char **argv) {
35 if (default_duid.buffer != NULL)
36 data_string_forget(&default_duid, MDL);
38 - form_duid(&default_duid, MDL);
39 - write_duid(&default_duid);
40 + if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
41 + write_duid(&default_duid);
45 @@ -4202,7 +4202,7 @@ write_options(struct client_state *client, struct option_state *options,
46 * is not how it is intended. Upcoming rearchitecting the client should
47 * address this "one daemon model."
51 form_duid(struct data_string *duid, const char *file, int line)
53 struct interface_info *ip;
54 @@ -4215,6 +4215,15 @@ form_duid(struct data_string *duid, const char *file, int line)
56 log_fatal("Impossible condition at %s:%d.", MDL);
58 + while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
59 + /* Try the other interfaces */
60 + log_debug("Cannot form default DUID from interface %s.", ip->name);
64 + return ISC_R_UNEXPECTED;
67 if ((ip->hw_address.hlen == 0) ||
68 (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
69 log_fatal("Impossible hardware address length at %s:%d.", MDL);
70 @@ -4260,6 +4269,8 @@ form_duid(struct data_string *duid, const char *file, int line)
71 log_info("Created duid %s.", str);
75 + return ISC_R_SUCCESS;
78 /* Write the default DUID to the lease store. */
79 diff --git a/common/bpf.c b/common/bpf.c
80 index d2a0549..aede242 100644
83 @@ -650,6 +650,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
84 memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
89 + if (local_family != AF_INET6)
90 + log_fatal("Unsupported device type %d for \"%s\"",
91 + sa->sdl_type, name);
93 + hw->hbuf[0] = HTYPE_RESERVED;
94 + /* 0xdeadbeef should never occur on the wire,
95 + * and is a signature that something went wrong.
100 + hw->hbuf[4] = 0xef;
104 log_fatal("Unsupported device type %d for \"%s\"",
106 diff --git a/common/lpf.c b/common/lpf.c
107 index bd20b3f..bb8822a 100644
110 @@ -563,6 +563,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
111 hw->hbuf[0] = HTYPE_FDDI;
112 memcpy(&hw->hbuf[1], sa->sa_data, 6);
114 +#if defined(ARPHRD_PPP)
116 + if (local_family != AF_INET6)
117 + log_fatal("Unsupported device type %d for \"%s\"",
118 + sa->sa_family, name);
120 + hw->hbuf[0] = HTYPE_RESERVED;
121 + /* 0xdeadbeef should never occur on the wire,
122 + * and is a signature that something went wrong.
124 + hw->hbuf[1] = 0xde;
125 + hw->hbuf[2] = 0xad;
126 + hw->hbuf[3] = 0xbe;
127 + hw->hbuf[4] = 0xef;
131 log_fatal("Unsupported device type %ld for \"%s\"",
132 (long int)sa->sa_family, name);
133 diff --git a/includes/dhcp.h b/includes/dhcp.h
134 index 5a73129..7202f1d 100644
135 --- a/includes/dhcp.h
136 +++ b/includes/dhcp.h
137 @@ -80,6 +80,8 @@ struct dhcp_packet {
138 * is no standard for this so we
139 * just steal a type */
141 +#define HTYPE_RESERVED 0 /* RFC 5494 */
143 /* Magic cookie validating dhcp options field (and bootp vendor
144 extensions field). */
145 #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
146 diff --git a/includes/dhcpd.h b/includes/dhcpd.h
147 index 25e1c72..4c5e877 100644
148 --- a/includes/dhcpd.h
149 +++ b/includes/dhcpd.h
150 @@ -3071,7 +3071,7 @@ void client_dns_remove(struct client_state *client, struct iaddr *addr);
152 void dhcpv4_client_assignments(void);
153 void dhcpv6_client_assignments(void);
154 -void form_duid(struct data_string *duid, const char *file, int line);
155 +isc_result_t form_duid(struct data_string *duid, const char *file, int line);
157 void dhcp4o6_start(void);
159 diff --git a/server/dhcpv6.c b/server/dhcpv6.c
160 index 0ea0532..7d61dc5 100644
161 --- a/server/dhcpv6.c
162 +++ b/server/dhcpv6.c
163 @@ -482,6 +482,9 @@ generate_new_server_duid(void) {
164 if (p->hw_address.hlen > 0) {
167 + if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
168 + log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
172 return ISC_R_UNEXPECTED;