]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/dhcp-4.2.0-PPP.patch
glibc: Backport hotfixes from RHEL
[people/pmueller/ipfire-2.x.git] / src / patches / dhcp-4.2.0-PPP.patch
CommitLineData
78ab9b04
MT
1diff -up dhcp-4.2.0-P1/client/dhc6.c.PPP dhcp-4.2.0-P1/client/dhc6.c
2--- dhcp-4.2.0-P1/client/dhc6.c.PPP 2010-11-05 10:47:37.000000000 +0100
3+++ dhcp-4.2.0-P1/client/dhc6.c 2010-11-09 15:54:12.000000000 +0100
4@@ -129,7 +129,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@@ -141,6 +141,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@@ -176,6 +185,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@@ -5289,7 +5300,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
48diff -up dhcp-4.2.0-P1/client/dhclient.c.PPP dhcp-4.2.0-P1/client/dhclient.c
49--- dhcp-4.2.0-P1/client/dhclient.c.PPP 2010-11-05 10:47:37.000000000 +0100
50+++ dhcp-4.2.0-P1/client/dhclient.c 2010-11-09 15:37:26.000000000 +0100
51@@ -911,8 +911,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) {
62diff -up dhcp-4.2.0-P1/common/bpf.c.PPP dhcp-4.2.0-P1/common/bpf.c
63--- dhcp-4.2.0-P1/common/bpf.c.PPP 2010-11-05 10:47:37.000000000 +0100
64+++ dhcp-4.2.0-P1/common/bpf.c 2010-11-09 15:42:42.000000000 +0100
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);
88diff -up dhcp-4.2.0-P1/common/lpf.c.PPP dhcp-4.2.0-P1/common/lpf.c
89--- dhcp-4.2.0-P1/common/lpf.c.PPP 2010-11-05 10:47:37.000000000 +0100
90+++ dhcp-4.2.0-P1/common/lpf.c 2010-11-09 15:45:40.000000000 +0100
91@@ -502,6 +502,22 @@ get_hw_addr(const char *name, struct har
92 hw->hbuf[0] = HTYPE_FDDI;
93 memcpy(&hw->hbuf[1], sa->sa_data, 16);
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);
114diff -up dhcp-4.2.0-P1/includes/dhcpd.h.PPP dhcp-4.2.0-P1/includes/dhcpd.h
115--- dhcp-4.2.0-P1/includes/dhcpd.h.PPP 2010-11-05 10:47:37.000000000 +0100
116+++ dhcp-4.2.0-P1/includes/dhcpd.h 2010-11-09 15:46:58.000000000 +0100
117@@ -2733,7 +2733,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);
126diff -up dhcp-4.2.0-P1/includes/dhcp.h.PPP dhcp-4.2.0-P1/includes/dhcp.h
127--- dhcp-4.2.0-P1/includes/dhcp.h.PPP 2010-11-05 10:47:37.000000000 +0100
128+++ dhcp-4.2.0-P1/includes/dhcp.h 2010-11-09 15:48:53.000000000 +0100
129@@ -80,6 +80,8 @@ struct dhcp_packet {
130 #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */
131 #define HTYPE_FDDI 8 /* FDDI... */
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"
138diff -up dhcp-4.2.0-P1/server/dhcpv6.c.PPP dhcp-4.2.0-P1/server/dhcpv6.c
139--- dhcp-4.2.0-P1/server/dhcpv6.c.PPP 2010-11-05 10:47:37.000000000 +0100
140+++ dhcp-4.2.0-P1/server/dhcpv6.c 2010-11-09 15:50:17.000000000 +0100
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;