]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - dhcp/patches/dhcp-4.2.5-PPP.patch
dhcp: Update to 4.2.5.
[people/ms/ipfire-3.x.git] / dhcp / patches / dhcp-4.2.5-PPP.patch
1 diff -up dhcp-4.2.4b1/client/dhc6.c.PPP dhcp-4.2.4b1/client/dhc6.c
2 --- dhcp-4.2.4b1/client/dhc6.c.PPP 2012-04-16 17:37:23.243618764 +0200
3 +++ dhcp-4.2.4b1/client/dhc6.c 2012-04-16 17:37:23.252618638 +0200
4 @@ -133,7 +133,7 @@ extern int stateless;
5 * is not how it is intended. Upcoming rearchitecting the client should
6 * address this "one daemon model."
7 */
8 -void
9 +isc_result_t
10 form_duid(struct data_string *duid, const char *file, int line)
11 {
12 struct interface_info *ip;
13 @@ -145,6 +145,15 @@ form_duid(struct data_string *duid, cons
14 if (ip == NULL)
15 log_fatal("Impossible condition at %s:%d.", MDL);
16
17 + while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
18 + /* Try the other interfaces */
19 + log_debug("Cannot form default DUID from interface %s.", ip->name);
20 + ip = ip->next;
21 + }
22 + if (ip == NULL) {
23 + return ISC_R_UNEXPECTED;
24 + }
25 +
26 if ((ip->hw_address.hlen == 0) ||
27 (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
28 log_fatal("Impossible hardware address length at %s:%d.", MDL);
29 @@ -180,6 +189,8 @@ form_duid(struct data_string *duid, cons
30 memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
31 ip->hw_address.hlen - 1);
32 }
33 +
34 + return ISC_R_SUCCESS;
35 }
36
37 /*
38 @@ -5130,7 +5141,8 @@ make_client6_options(struct client_state
39 */
40 if ((oc = lookup_option(&dhcpv6_universe, *op,
41 D6O_CLIENTID)) == NULL) {
42 - if (!option_cache(&oc, &default_duid, NULL, clientid_option,
43 + if (default_duid.len == 0 ||
44 + !option_cache(&oc, &default_duid, NULL, clientid_option,
45 MDL))
46 log_fatal("Failure assembling a DUID.");
47
48 diff -up dhcp-4.2.4b1/client/dhclient.c.PPP dhcp-4.2.4b1/client/dhclient.c
49 --- dhcp-4.2.4b1/client/dhclient.c.PPP 2012-04-16 17:37:23.214619170 +0200
50 +++ dhcp-4.2.4b1/client/dhclient.c 2012-04-16 17:37:23.254618610 +0200
51 @@ -919,8 +919,8 @@ main(int argc, char **argv) {
52 if (default_duid.buffer != NULL)
53 data_string_forget(&default_duid, MDL);
54
55 - form_duid(&default_duid, MDL);
56 - write_duid(&default_duid);
57 + if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
58 + write_duid(&default_duid);
59 }
60
61 for (ip = interfaces ; ip != NULL ; ip = ip->next) {
62 diff -up dhcp-4.2.4b1/common/bpf.c.PPP dhcp-4.2.4b1/common/bpf.c
63 --- dhcp-4.2.4b1/common/bpf.c.PPP 2012-04-16 17:37:23.175619716 +0200
64 +++ dhcp-4.2.4b1/common/bpf.c 2012-04-16 17:37:23.255618596 +0200
65 @@ -599,6 +599,22 @@ get_hw_addr(const char *name, struct har
66 memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
67 break;
68 #endif /* IFT_FDDI */
69 +#if defined(IFT_PPP)
70 + case IFT_PPP:
71 + if (local_family != AF_INET6)
72 + log_fatal("Unsupported device type %d for \"%s\"",
73 + sa->sdl_type, name);
74 + hw->hlen = 0;
75 + hw->hbuf[0] = HTYPE_RESERVED;
76 + /* 0xdeadbeef should never occur on the wire,
77 + * and is a signature that something went wrong.
78 + */
79 + hw->hbuf[1] = 0xde;
80 + hw->hbuf[2] = 0xad;
81 + hw->hbuf[3] = 0xbe;
82 + hw->hbuf[4] = 0xef;
83 + break;
84 +#endif
85 default:
86 log_fatal("Unsupported device type %d for \"%s\"",
87 sa->sdl_type, name);
88 diff -up dhcp-4.2.4b1/common/lpf.c.PPP dhcp-4.2.4b1/common/lpf.c
89 --- dhcp-4.2.4b1/common/lpf.c.PPP 2012-04-16 17:37:23.155619996 +0200
90 +++ dhcp-4.2.4b1/common/lpf.c 2012-04-16 17:37:23.256618582 +0200
91 @@ -503,6 +503,22 @@ get_hw_addr(const char *name, struct har
92 hw->hbuf[0] = HTYPE_FDDI;
93 memcpy(&hw->hbuf[1], sa->sa_data, 6);
94 break;
95 +#if defined(ARPHRD_PPP)
96 + case ARPHRD_PPP:
97 + if (local_family != AF_INET6)
98 + log_fatal("Unsupported device type %d for \"%s\"",
99 + sa->sa_family, name);
100 + hw->hlen = 0;
101 + hw->hbuf[0] = HTYPE_RESERVED;
102 + /* 0xdeadbeef should never occur on the wire,
103 + * and is a signature that something went wrong.
104 + */
105 + hw->hbuf[1] = 0xde;
106 + hw->hbuf[2] = 0xad;
107 + hw->hbuf[3] = 0xbe;
108 + hw->hbuf[4] = 0xef;
109 + break;
110 +#endif
111 default:
112 log_fatal("Unsupported device type %ld for \"%s\"",
113 (long int)sa->sa_family, name);
114 diff -up dhcp-4.2.4b1/includes/dhcpd.h.PPP dhcp-4.2.4b1/includes/dhcpd.h
115 --- dhcp-4.2.4b1/includes/dhcpd.h.PPP 2012-04-16 17:37:23.239618820 +0200
116 +++ dhcp-4.2.4b1/includes/dhcpd.h 2012-04-16 17:37:23.257618568 +0200
117 @@ -2760,7 +2760,7 @@ void dhcpv4_client_assignments(void);
118 void dhcpv6_client_assignments(void);
119
120 /* dhc6.c */
121 -void form_duid(struct data_string *duid, const char *file, int line);
122 +isc_result_t form_duid(struct data_string *duid, const char *file, int line);
123 void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
124 void start_init6(struct client_state *client);
125 void start_info_request6(struct client_state *client);
126 diff -up dhcp-4.2.4b1/includes/dhcp.h.PPP dhcp-4.2.4b1/includes/dhcp.h
127 --- dhcp-4.2.4b1/includes/dhcp.h.PPP 2012-04-16 17:37:23.000000000 +0200
128 +++ dhcp-4.2.4b1/includes/dhcp.h 2012-04-16 17:38:34.675618138 +0200
129 @@ -85,6 +85,8 @@ struct dhcp_packet {
130 * is no standard for this so we
131 * just steal a type */
132
133 +#define HTYPE_RESERVED 0 /* RFC 5494 */
134 +
135 /* Magic cookie validating dhcp options field (and bootp vendor
136 extensions field). */
137 #define DHCP_OPTIONS_COOKIE "\143\202\123\143"
138 diff -up dhcp-4.2.4b1/server/dhcpv6.c.PPP dhcp-4.2.4b1/server/dhcpv6.c
139 --- dhcp-4.2.4b1/server/dhcpv6.c.PPP 2012-04-16 17:37:23.218619114 +0200
140 +++ dhcp-4.2.4b1/server/dhcpv6.c 2012-04-16 17:37:23.260618526 +0200
141 @@ -300,6 +300,9 @@ generate_new_server_duid(void) {
142 if (p->hw_address.hlen > 0) {
143 break;
144 }
145 + if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
146 + log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
147 + }
148 }
149 if (p == NULL) {
150 return ISC_R_UNEXPECTED;