Blame SOURCES/dhcp-4.2.5-PPP.patch

54343e
diff -up dhcp-4.2.4b1/client/dhc6.c.PPP dhcp-4.2.4b1/client/dhc6.c
54343e
--- dhcp-4.2.4b1/client/dhc6.c.PPP	2012-04-16 17:37:23.243618764 +0200
54343e
+++ dhcp-4.2.4b1/client/dhc6.c	2012-04-16 17:37:23.252618638 +0200
54343e
@@ -133,7 +133,7 @@ extern int stateless;
54343e
  * is not how it is intended.  Upcoming rearchitecting the client should
54343e
  * address this "one daemon model."
54343e
  */
54343e
-void
54343e
+isc_result_t
54343e
 form_duid(struct data_string *duid, const char *file, int line)
54343e
 {
54343e
 	struct interface_info *ip;
54343e
@@ -145,6 +145,15 @@ form_duid(struct data_string *duid, cons
54343e
 	if (ip == NULL)
54343e
 		log_fatal("Impossible condition at %s:%d.", MDL);
54343e
 
54343e
+	while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
54343e
+		/* Try the other interfaces */
54343e
+		log_debug("Cannot form default DUID from interface %s.", ip->name);
54343e
+		ip = ip->next;
54343e
+	}
54343e
+	if (ip == NULL) {
54343e
+		return ISC_R_UNEXPECTED;
54343e
+	}
54343e
+
54343e
 	if ((ip->hw_address.hlen == 0) ||
54343e
 	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
54343e
 		log_fatal("Impossible hardware address length at %s:%d.", MDL);
54343e
@@ -180,6 +189,8 @@ form_duid(struct data_string *duid, cons
54343e
 		memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
54343e
 		       ip->hw_address.hlen - 1);
54343e
 	}
54343e
+
54343e
+	return ISC_R_SUCCESS;
54343e
 }
54343e
 
54343e
 /*
54343e
@@ -5130,7 +5141,8 @@ make_client6_options(struct client_state
54343e
 	 */
54343e
 	if ((oc = lookup_option(&dhcpv6_universe, *op,
54343e
 				D6O_CLIENTID)) == NULL) {
54343e
-		if (!option_cache(&oc, &default_duid, NULL, clientid_option,
54343e
+		if (default_duid.len == 0 ||
54343e
+		    !option_cache(&oc, &default_duid, NULL, clientid_option,
54343e
 				  MDL))
54343e
 			log_fatal("Failure assembling a DUID.");
54343e
 
54343e
diff -up dhcp-4.2.4b1/client/dhclient.c.PPP dhcp-4.2.4b1/client/dhclient.c
54343e
--- dhcp-4.2.4b1/client/dhclient.c.PPP	2012-04-16 17:37:23.214619170 +0200
54343e
+++ dhcp-4.2.4b1/client/dhclient.c	2012-04-16 17:37:23.254618610 +0200
54343e
@@ -919,8 +919,8 @@ main(int argc, char **argv) {
54343e
 			if (default_duid.buffer != NULL)
54343e
 				data_string_forget(&default_duid, MDL);
54343e
 
54343e
-			form_duid(&default_duid, MDL);
54343e
-			write_duid(&default_duid);
54343e
+			if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
54343e
+				write_duid(&default_duid);
54343e
 		}
54343e
 
54343e
 		for (ip = interfaces ; ip != NULL ; ip = ip->next) {
54343e
diff -up dhcp-4.2.4b1/common/bpf.c.PPP dhcp-4.2.4b1/common/bpf.c
54343e
--- dhcp-4.2.4b1/common/bpf.c.PPP	2012-04-16 17:37:23.175619716 +0200
54343e
+++ dhcp-4.2.4b1/common/bpf.c	2012-04-16 17:37:23.255618596 +0200
54343e
@@ -599,6 +599,22 @@ get_hw_addr(const char *name, struct har
54343e
                         memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
54343e
                         break;
54343e
 #endif /* IFT_FDDI */
54343e
+#if defined(IFT_PPP)
54343e
+                case IFT_PPP:
54343e
+                        if (local_family != AF_INET6)
54343e
+                             log_fatal("Unsupported device type %d for \"%s\"",
54343e
+                                        sa->sdl_type, name);
54343e
+                        hw->hlen = 0;
54343e
+                        hw->hbuf[0] = HTYPE_RESERVED;
54343e
+                        /* 0xdeadbeef should never occur on the wire,
54343e
+                         *  and is a signature that something went wrong.
54343e
+                         */
54343e
+                        hw->hbuf[1] = 0xde;
54343e
+                        hw->hbuf[2] = 0xad;
54343e
+                        hw->hbuf[3] = 0xbe;
54343e
+                        hw->hbuf[4] = 0xef;
54343e
+                        break;
54343e
+#endif
54343e
                 default:
54343e
                         log_fatal("Unsupported device type %d for \"%s\"",
54343e
                                   sa->sdl_type, name);
54343e
diff -up dhcp-4.2.4b1/common/lpf.c.PPP dhcp-4.2.4b1/common/lpf.c
54343e
--- dhcp-4.2.4b1/common/lpf.c.PPP	2012-04-16 17:37:23.155619996 +0200
54343e
+++ dhcp-4.2.4b1/common/lpf.c	2012-04-16 17:37:23.256618582 +0200
54343e
@@ -503,6 +503,22 @@ get_hw_addr(const char *name, struct har
54343e
 			hw->hbuf[0] = HTYPE_FDDI;
54343e
 			memcpy(&hw->hbuf[1], sa->sa_data, 6);
54343e
 			break;
54343e
+#if defined(ARPHRD_PPP)
54343e
+		case ARPHRD_PPP:
54343e
+			if (local_family != AF_INET6)
54343e
+				log_fatal("Unsupported device type %d for \"%s\"",
54343e
+				           sa->sa_family, name);
54343e
+			hw->hlen = 0;
54343e
+			hw->hbuf[0] = HTYPE_RESERVED;
54343e
+			/* 0xdeadbeef should never occur on the wire,
54343e
+			 * and is a signature that something went wrong.
54343e
+			 */
54343e
+			hw->hbuf[1] = 0xde;
54343e
+			hw->hbuf[2] = 0xad;
54343e
+			hw->hbuf[3] = 0xbe;
54343e
+			hw->hbuf[4] = 0xef;
54343e
+			break;
54343e
+#endif
54343e
 		default:
54343e
 			log_fatal("Unsupported device type %ld for \"%s\"",
54343e
 				  (long int)sa->sa_family, name);
54343e
diff -up dhcp-4.2.4b1/includes/dhcpd.h.PPP dhcp-4.2.4b1/includes/dhcpd.h
54343e
--- dhcp-4.2.4b1/includes/dhcpd.h.PPP	2012-04-16 17:37:23.239618820 +0200
54343e
+++ dhcp-4.2.4b1/includes/dhcpd.h	2012-04-16 17:37:23.257618568 +0200
54343e
@@ -2760,7 +2760,7 @@ void dhcpv4_client_assignments(void);
54343e
 void dhcpv6_client_assignments(void);
54343e
 
54343e
 /* dhc6.c */
54343e
-void form_duid(struct data_string *duid, const char *file, int line);
54343e
+isc_result_t form_duid(struct data_string *duid, const char *file, int line);
54343e
 void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
54343e
 void start_init6(struct client_state *client);
54343e
 void start_info_request6(struct client_state *client);
54343e
diff -up dhcp-4.2.4b1/includes/dhcp.h.PPP dhcp-4.2.4b1/includes/dhcp.h
54343e
--- dhcp-4.2.4b1/includes/dhcp.h.PPP	2012-04-16 17:37:23.000000000 +0200
54343e
+++ dhcp-4.2.4b1/includes/dhcp.h	2012-04-16 17:38:34.675618138 +0200
54343e
@@ -85,6 +85,8 @@ struct dhcp_packet {
54343e
 					 * is no standard for this so we
54343e
 					 * just steal a type            */
54343e
 
54343e
+#define HTYPE_RESERVED	0		/* RFC 5494 */
54343e
+
54343e
 /* Magic cookie validating dhcp options field (and bootp vendor
54343e
    extensions field). */
54343e
 #define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
54343e
diff -up dhcp-4.2.4b1/server/dhcpv6.c.PPP dhcp-4.2.4b1/server/dhcpv6.c
54343e
--- dhcp-4.2.4b1/server/dhcpv6.c.PPP	2012-04-16 17:37:23.218619114 +0200
54343e
+++ dhcp-4.2.4b1/server/dhcpv6.c	2012-04-16 17:37:23.260618526 +0200
54343e
@@ -300,6 +300,9 @@ generate_new_server_duid(void) {
54343e
 		if (p->hw_address.hlen > 0) {
54343e
 			break;
54343e
 		}
54343e
+		if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
54343e
+			log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
54343e
+		}
54343e
 	}
54343e
 	if (p == NULL) {
54343e
 		return ISC_R_UNEXPECTED;