]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/blob - dhcp/patches/0013-DHCPv6-over-PPP-support-626514.patch
dhcp: Update to 4.4.1
[people/stevee/ipfire-3.x.git] / dhcp / patches / 0013-DHCPv6-over-PPP-support-626514.patch
1 From 43332b29f0c8fef3ddd225e31f5f2b4ff8273b36 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/21] DHCPv6 over PPP support (#626514)
5 Cc: pzhukov@redhat.com
6
7 ---
8 client/dhc6.c | 3 ++-
9 client/dhclient.c | 17 ++++++++++++++---
10 common/bpf.c | 16 ++++++++++++++++
11 common/lpf.c | 16 ++++++++++++++++
12 includes/dhcp.h | 2 ++
13 includes/dhcpd.h | 2 +-
14 server/dhcpv6.c | 3 +++
15 7 files changed, 54 insertions(+), 5 deletions(-)
16
17 diff --git a/client/dhc6.c b/client/dhc6.c
18 index 16a0838..3171828 100644
19 --- a/client/dhc6.c
20 +++ b/client/dhc6.c
21 @@ -5744,7 +5744,8 @@ make_client6_options(struct client_state *client, struct option_state **op,
22 */
23 if ((oc = lookup_option(&dhcpv6_universe, *op,
24 D6O_CLIENTID)) == NULL) {
25 - if (!option_cache(&oc, &default_duid, NULL, clientid_option,
26 + if (default_duid.len == 0 ||
27 + !option_cache(&oc, &default_duid, NULL, clientid_option,
28 MDL))
29 log_fatal("Failure assembling a DUID.");
30
31 diff --git a/client/dhclient.c b/client/dhclient.c
32 index 5d3f5bc..301132c 100644
33 --- a/client/dhclient.c
34 +++ b/client/dhclient.c
35 @@ -1202,8 +1202,8 @@ main(int argc, char **argv) {
36 if (default_duid.buffer != NULL)
37 data_string_forget(&default_duid, MDL);
38
39 - form_duid(&default_duid, MDL);
40 - write_duid(&default_duid);
41 + if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
42 + write_duid(&default_duid);
43 }
44 }
45
46 @@ -3956,7 +3956,7 @@ write_options(struct client_state *client, struct option_state *options,
47 * is not how it is intended. Upcoming rearchitecting the client should
48 * address this "one daemon model."
49 */
50 -void
51 +isc_result_t
52 form_duid(struct data_string *duid, const char *file, int line)
53 {
54 struct interface_info *ip;
55 @@ -3969,6 +3969,15 @@ form_duid(struct data_string *duid, const char *file, int line)
56 if (ip == NULL)
57 log_fatal("Impossible condition at %s:%d.", MDL);
58
59 + while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
60 + /* Try the other interfaces */
61 + log_debug("Cannot form default DUID from interface %s.", ip->name);
62 + ip = ip->next;
63 + }
64 + if (ip == NULL) {
65 + return ISC_R_UNEXPECTED;
66 + }
67 +
68 if ((ip->hw_address.hlen == 0) ||
69 (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
70 log_fatal("Impossible hardware address length at %s:%d.", MDL);
71 @@ -4014,6 +4023,8 @@ form_duid(struct data_string *duid, const char *file, int line)
72 log_info("Created duid %s.", str);
73 dfree(str, MDL);
74 }
75 +
76 + return ISC_R_SUCCESS;
77 }
78
79 /* Write the default DUID to the lease store. */
80 diff --git a/common/bpf.c b/common/bpf.c
81 index 67b6d64..ffbd09a 100644
82 --- a/common/bpf.c
83 +++ b/common/bpf.c
84 @@ -650,6 +650,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
85 memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
86 break;
87 #endif /* IFT_FDDI */
88 +#if defined(IFT_PPP)
89 + case IFT_PPP:
90 + if (local_family != AF_INET6)
91 + log_fatal("Unsupported device type %d for \"%s\"",
92 + sa->sdl_type, name);
93 + hw->hlen = 0;
94 + hw->hbuf[0] = HTYPE_RESERVED;
95 + /* 0xdeadbeef should never occur on the wire,
96 + * and is a signature that something went wrong.
97 + */
98 + hw->hbuf[1] = 0xde;
99 + hw->hbuf[2] = 0xad;
100 + hw->hbuf[3] = 0xbe;
101 + hw->hbuf[4] = 0xef;
102 + break;
103 +#endif
104 default:
105 log_fatal("Unsupported device type %d for \"%s\"",
106 sa->sdl_type, name);
107 diff --git a/common/lpf.c b/common/lpf.c
108 index 82a279b..b0ed01c 100644
109 --- a/common/lpf.c
110 +++ b/common/lpf.c
111 @@ -563,6 +563,22 @@ get_hw_addr(const char *name, struct hardware *hw) {
112 hw->hbuf[0] = HTYPE_FDDI;
113 memcpy(&hw->hbuf[1], sa->sa_data, 6);
114 break;
115 +#if defined(ARPHRD_PPP)
116 + case ARPHRD_PPP:
117 + if (local_family != AF_INET6)
118 + log_fatal("Unsupported device type %d for \"%s\"",
119 + sa->sa_family, name);
120 + hw->hlen = 0;
121 + hw->hbuf[0] = HTYPE_RESERVED;
122 + /* 0xdeadbeef should never occur on the wire,
123 + * and is a signature that something went wrong.
124 + */
125 + hw->hbuf[1] = 0xde;
126 + hw->hbuf[2] = 0xad;
127 + hw->hbuf[3] = 0xbe;
128 + hw->hbuf[4] = 0xef;
129 + break;
130 +#endif
131 default:
132 log_fatal("Unsupported device type %ld for \"%s\"",
133 (long int)sa->sa_family, name);
134 diff --git a/includes/dhcp.h b/includes/dhcp.h
135 index 95bf539..4cc547a 100644
136 --- a/includes/dhcp.h
137 +++ b/includes/dhcp.h
138 @@ -80,6 +80,8 @@ struct dhcp_packet {
139 * is no standard for this so we
140 * just steal a type */
141
142 +#define HTYPE_RESERVED 0 /* RFC 5494 */
143 +
144 /* Magic cookie validating dhcp options field (and bootp vendor
145 extensions field). */
146 #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
147 diff --git a/includes/dhcpd.h b/includes/dhcpd.h
148 index 2ac39ae..faa9251 100644
149 --- a/includes/dhcpd.h
150 +++ b/includes/dhcpd.h
151 @@ -3051,7 +3051,7 @@ void client_dns_remove(struct client_state *client, struct iaddr *addr);
152
153 void dhcpv4_client_assignments(void);
154 void dhcpv6_client_assignments(void);
155 -void form_duid(struct data_string *duid, const char *file, int line);
156 +isc_result_t form_duid(struct data_string *duid, const char *file, int line);
157
158 void dhcp4o6_start(void);
159
160 diff --git a/server/dhcpv6.c b/server/dhcpv6.c
161 index a7110f9..c5ce7e8 100644
162 --- a/server/dhcpv6.c
163 +++ b/server/dhcpv6.c
164 @@ -482,6 +482,9 @@ generate_new_server_duid(void) {
165 if (p->hw_address.hlen > 0) {
166 break;
167 }
168 + if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
169 + log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
170 + }
171 }
172 if (p == NULL) {
173 return ISC_R_UNEXPECTED;
174 --
175 2.14.5