Blame SOURCES/dhcp-PPP.patch

26a25c
diff -up dhcp-4.3.4/client/dhc6.c.PPP dhcp-4.3.4/client/dhc6.c
26a25c
--- dhcp-4.3.4/client/dhc6.c.PPP	2016-04-29 12:46:29.824988665 +0200
26a25c
+++ dhcp-4.3.4/client/dhc6.c	2016-04-29 12:46:29.828988666 +0200
26a25c
@@ -5641,7 +5641,8 @@ make_client6_options(struct client_state
26a25c
 	 */
26a25c
 	if ((oc = lookup_option(&dhcpv6_universe, *op,
26a25c
 				D6O_CLIENTID)) == NULL) {
26a25c
-		if (!option_cache(&oc, &default_duid, NULL, clientid_option,
26a25c
+		if (default_duid.len == 0 ||
26a25c
+		    !option_cache(&oc, &default_duid, NULL, clientid_option,
26a25c
 				  MDL))
26a25c
 			log_fatal("Failure assembling a DUID.");
26a25c
 
26a25c
diff -up dhcp-4.3.4/client/dhclient.c.PPP dhcp-4.3.4/client/dhclient.c
26a25c
--- dhcp-4.3.4/client/dhclient.c.PPP	2016-04-29 12:46:29.815988664 +0200
26a25c
+++ dhcp-4.3.4/client/dhclient.c	2016-04-29 12:46:29.830988666 +0200
26a25c
@@ -1077,8 +1077,8 @@ main(int argc, char **argv) {
26a25c
 			if (default_duid.buffer != NULL)
26a25c
 				data_string_forget(&default_duid, MDL);
26a25c
 
26a25c
-			form_duid(&default_duid, MDL);
26a25c
-			write_duid(&default_duid);
26a25c
+			if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
26a25c
+				write_duid(&default_duid);
26a25c
 		}
26a25c
 	}
26a25c
 
26a25c
@@ -3808,7 +3808,7 @@ write_options(struct client_state *clien
26a25c
  * is not how it is intended.  Upcoming rearchitecting the client should
26a25c
  * address this "one daemon model."
26a25c
  */
26a25c
-void
26a25c
+isc_result_t
26a25c
 form_duid(struct data_string *duid, const char *file, int line)
26a25c
 {
26a25c
 	struct interface_info *ip;
26a25c
@@ -3821,6 +3821,15 @@ form_duid(struct data_string *duid, cons
26a25c
 	if (ip == NULL)
26a25c
 		log_fatal("Impossible condition at %s:%d.", MDL);
26a25c
 
26a25c
+	while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
26a25c
+		/* Try the other interfaces */
26a25c
+		log_debug("Cannot form default DUID from interface %s.", ip->name);
26a25c
+		ip = ip->next;
26a25c
+	}
26a25c
+	if (ip == NULL) {
26a25c
+		return ISC_R_UNEXPECTED;
26a25c
+	}
26a25c
+
26a25c
 	if ((ip->hw_address.hlen == 0) ||
26a25c
 	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
26a25c
 		log_fatal("Impossible hardware address length at %s:%d.", MDL);
26a25c
@@ -3866,6 +3875,8 @@ form_duid(struct data_string *duid, cons
26a25c
 		log_info("Created duid %s.", str);
26a25c
 		dfree(str, MDL);
26a25c
 	}
26a25c
+	
26a25c
+	return ISC_R_SUCCESS;
26a25c
 }
26a25c
 
26a25c
 /* Write the default DUID to the lease store. */
26a25c
diff -up dhcp-4.3.4/common/bpf.c.PPP dhcp-4.3.4/common/bpf.c
26a25c
--- dhcp-4.3.4/common/bpf.c.PPP	2016-04-29 12:46:29.794988660 +0200
26a25c
+++ dhcp-4.3.4/common/bpf.c	2016-04-29 12:46:29.830988666 +0200
26a25c
@@ -599,6 +599,22 @@ get_hw_addr(const char *name, struct har
26a25c
                         memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
26a25c
                         break;
26a25c
 #endif /* IFT_FDDI */
26a25c
+#if defined(IFT_PPP)
26a25c
+                case IFT_PPP:
26a25c
+                        if (local_family != AF_INET6)
26a25c
+                             log_fatal("Unsupported device type %d for \"%s\"",
26a25c
+                                        sa->sdl_type, name);
26a25c
+                        hw->hlen = 0;
26a25c
+                        hw->hbuf[0] = HTYPE_RESERVED;
26a25c
+                        /* 0xdeadbeef should never occur on the wire,
26a25c
+                         *  and is a signature that something went wrong.
26a25c
+                         */
26a25c
+                        hw->hbuf[1] = 0xde;
26a25c
+                        hw->hbuf[2] = 0xad;
26a25c
+                        hw->hbuf[3] = 0xbe;
26a25c
+                        hw->hbuf[4] = 0xef;
26a25c
+                        break;
26a25c
+#endif
26a25c
                 default:
26a25c
                         log_fatal("Unsupported device type %d for \"%s\"",
26a25c
                                   sa->sdl_type, name);
26a25c
diff -up dhcp-4.3.4/common/lpf.c.PPP dhcp-4.3.4/common/lpf.c
26a25c
--- dhcp-4.3.4/common/lpf.c.PPP	2016-03-22 14:16:51.000000000 +0100
26a25c
+++ dhcp-4.3.4/common/lpf.c	2016-04-29 12:46:29.830988666 +0200
26a25c
@@ -548,6 +548,22 @@ get_hw_addr(const char *name, struct har
26a25c
 			hw->hbuf[0] = HTYPE_FDDI;
26a25c
 			memcpy(&hw->hbuf[1], sa->sa_data, 6);
26a25c
 			break;
26a25c
+#if defined(ARPHRD_PPP)
26a25c
+		case ARPHRD_PPP:
26a25c
+			if (local_family != AF_INET6)
26a25c
+				log_fatal("Unsupported device type %d for \"%s\"",
26a25c
+				           sa->sa_family, name);
26a25c
+			hw->hlen = 0;
26a25c
+			hw->hbuf[0] = HTYPE_RESERVED;
26a25c
+			/* 0xdeadbeef should never occur on the wire,
26a25c
+			 * and is a signature that something went wrong.
26a25c
+			 */
26a25c
+			hw->hbuf[1] = 0xde;
26a25c
+			hw->hbuf[2] = 0xad;
26a25c
+			hw->hbuf[3] = 0xbe;
26a25c
+			hw->hbuf[4] = 0xef;
26a25c
+			break;
26a25c
+#endif
26a25c
 		default:
26a25c
 			log_fatal("Unsupported device type %ld for \"%s\"",
26a25c
 				  (long int)sa->sa_family, name);
26a25c
diff -up dhcp-4.3.4/includes/dhcpd.h.PPP dhcp-4.3.4/includes/dhcpd.h
26a25c
--- dhcp-4.3.4/includes/dhcpd.h.PPP	2016-04-29 12:46:29.831988667 +0200
26a25c
+++ dhcp-4.3.4/includes/dhcpd.h	2016-04-29 12:47:13.167995959 +0200
26a25c
@@ -2990,7 +2990,7 @@ void client_dns_remove(struct client_sta
26a25c
 
26a25c
 void dhcpv4_client_assignments(void);
26a25c
 void dhcpv6_client_assignments(void);
26a25c
-void form_duid(struct data_string *duid, const char *file, int line);
26a25c
+isc_result_t form_duid(struct data_string *duid, const char *file, int line);
26a25c
 
26a25c
 void dhcp4o6_start(void);
26a25c
 
26a25c
diff -up dhcp-4.3.4/includes/dhcp.h.PPP dhcp-4.3.4/includes/dhcp.h
26a25c
--- dhcp-4.3.4/includes/dhcp.h.PPP	2016-04-29 12:46:29.822988665 +0200
26a25c
+++ dhcp-4.3.4/includes/dhcp.h	2016-04-29 12:46:29.832988667 +0200
26a25c
@@ -81,6 +81,8 @@ struct dhcp_packet {
26a25c
 					 * is no standard for this so we
26a25c
 					 * just steal a type            */
26a25c
 
26a25c
+#define HTYPE_RESERVED	0		/* RFC 5494 */
26a25c
+
26a25c
 /* Magic cookie validating dhcp options field (and bootp vendor
26a25c
    extensions field). */
26a25c
 #define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
26a25c
diff -up dhcp-4.3.4/server/dhcpv6.c.PPP dhcp-4.3.4/server/dhcpv6.c
26a25c
--- dhcp-4.3.4/server/dhcpv6.c.PPP	2016-03-22 14:16:51.000000000 +0100
26a25c
+++ dhcp-4.3.4/server/dhcpv6.c	2016-04-29 12:46:29.833988667 +0200
26a25c
@@ -454,6 +454,9 @@ generate_new_server_duid(void) {
26a25c
 		if (p->hw_address.hlen > 0) {
26a25c
 			break;
26a25c
 		}
26a25c
+		if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
26a25c
+			log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
26a25c
+		}
26a25c
 	}
26a25c
 	if (p == NULL) {
26a25c
 		return ISC_R_UNEXPECTED;