Blame SOURCES/dhcp-IPoIB-log-id.patch

324fcf
--- a/server/dhcp.c     2017-07-14 15:32:14.611104590 +0200
324fcf
+++ b/server/dhcp.c	2017-07-14 15:34:17.508858018 +0200
324fcf
@@ -87,6 +87,42 @@
324fcf
 
324fcf
 static TIME leaseTimeCheck(TIME calculated, TIME alternate);
324fcf
 
324fcf
+char *print_client_identifier_from_packet (packet)
324fcf
+	struct packet *packet;
324fcf
+{
324fcf
+	struct option_cache *oc;
324fcf
+	struct data_string client_identifier;
324fcf
+	char *ci;
324fcf
+
324fcf
+	memset (&client_identifier, 0, sizeof client_identifier);
324fcf
+
324fcf
+	oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+			DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+	if (oc &&
324fcf
+	    evaluate_option_cache (&client_identifier,
324fcf
+				    packet, (struct lease *)0,
324fcf
+				    (struct client_state *)0,
324fcf
+				    packet -> options,
324fcf
+				    (struct option_state *)0,
324fcf
+				    &global_scope, oc, MDL)) {
324fcf
+		ci = print_hw_addr (HTYPE_INFINIBAND, client_identifier.len, client_identifier.data);
324fcf
+		data_string_forget (&client_identifier, MDL);
324fcf
+		return ci;
324fcf
+	} else
324fcf
+		return "\"no client id\"";
324fcf
+}
324fcf
+
324fcf
+char *print_hw_addr_or_client_id (packet)
324fcf
+	struct packet *packet;
324fcf
+{
324fcf
+	if (packet -> raw -> htype == HTYPE_INFINIBAND)
324fcf
+		return print_client_identifier_from_packet (packet);
324fcf
+	else
324fcf
+		return print_hw_addr (packet -> raw -> htype,
324fcf
+				      packet -> raw -> hlen,
324fcf
+				      packet -> raw -> chaddr);
324fcf
+}
324fcf
+
324fcf
 void
324fcf
 dhcp (struct packet *packet) {
324fcf
 	int ms_nulltp = 0;
324fcf
@@ -129,9 +165,7 @@
324fcf
 
324fcf
 		log_info("%s from %s via %s: %s", s,
324fcf
 			 (packet->raw->htype
324fcf
-			  ? print_hw_addr(packet->raw->htype,
324fcf
-					  packet->raw->hlen,
324fcf
-					  packet->raw->chaddr)
324fcf
+			  ? print_hw_addr_or_client_id(packet)
324fcf
 			  : "<no identifier>"),
324fcf
 			 packet->raw->giaddr.s_addr
324fcf
 			 ? inet_ntoa(packet->raw->giaddr)
324fcf
@@ -328,9 +362,7 @@
324fcf
 #endif
324fcf
 	snprintf (msgbuf, sizeof msgbuf, "DHCPDISCOVER from %s %s%s%svia %s",
324fcf
 		 (packet -> raw -> htype
324fcf
-		  ? print_hw_addr (packet -> raw -> htype,
324fcf
-				   packet -> raw -> hlen,
324fcf
-				   packet -> raw -> chaddr)
324fcf
+		  ? print_hw_addr_or_client_id (packet)
324fcf
 		  : (lease
324fcf
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
324fcf
 		     : "<no identifier>")),
324fcf
@@ -542,9 +574,7 @@
324fcf
 		 "DHCPREQUEST for %s%s from %s %s%s%svia %s",
324fcf
 		 piaddr (cip), smbuf,
324fcf
 		 (packet -> raw -> htype
324fcf
-		  ? print_hw_addr (packet -> raw -> htype,
324fcf
-				   packet -> raw -> hlen,
324fcf
-				   packet -> raw -> chaddr)
324fcf
+		  ? print_hw_addr_or_client_id(packet)
324fcf
 		  : (lease
324fcf
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
324fcf
 		     : "<no identifier>")),
324fcf
@@ -785,9 +815,7 @@
324fcf
 	if ((oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 				 DHO_DHCP_REQUESTED_ADDRESS))) {
324fcf
 		log_info ("DHCPRELEASE from %s specified requested-address.",
324fcf
-		      print_hw_addr (packet -> raw -> htype,
324fcf
-				     packet -> raw -> hlen,
324fcf
-				     packet -> raw -> chaddr));
324fcf
+		      print_hw_addr_or_client_id(packet));
324fcf
 	}
324fcf
 
324fcf
 	oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
@@ -879,9 +907,7 @@
324fcf
 		 "DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)",
324fcf
 		 cstr,
324fcf
 		 (packet -> raw -> htype
324fcf
-		  ? print_hw_addr (packet -> raw -> htype,
324fcf
-				   packet -> raw -> hlen,
324fcf
-				   packet -> raw -> chaddr)
324fcf
+		  ? print_hw_addr_or_client_id(packet)
324fcf
 		  : (lease
324fcf
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
324fcf
 		     : "<no identifier>")),
324fcf
@@ -986,9 +1012,7 @@
324fcf
 		 "DHCPDECLINE of %s from %s %s%s%svia %s",
324fcf
 		 piaddr (cip),
324fcf
 		 (packet -> raw -> htype
324fcf
-		  ? print_hw_addr (packet -> raw -> htype,
324fcf
-				   packet -> raw -> hlen,
324fcf
-				   packet -> raw -> chaddr)
324fcf
+		  ? print_hw_addr_or_client_id(packet)
324fcf
 		  : (lease
324fcf
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
324fcf
 		     : "<no identifier>")),
324fcf
@@ -1707,8 +1731,7 @@
324fcf
 	/* Report what we're sending. */
324fcf
 	snprintf(msgbuf, sizeof msgbuf, "DHCPACK to %s (%s) via", piaddr(cip),
324fcf
 		 (packet->raw->htype && packet->raw->hlen) ?
324fcf
-			print_hw_addr(packet->raw->htype, packet->raw->hlen,
324fcf
-				      packet->raw->chaddr) :
324fcf
+			print_hw_addr_or_client_id(packet) :
324fcf
 			"<no client hardware address>");
324fcf
 	log_info("%s %s", msgbuf, gip.len ? piaddr(gip) :
324fcf
 					    packet->interface->name);
324fcf
@@ -1886,9 +1909,7 @@
324fcf
 #endif
324fcf
 	log_info ("DHCPNAK on %s to %s via %s",
324fcf
 	      piaddr (*cip),
324fcf
-	      print_hw_addr (packet -> raw -> htype,
324fcf
-			     packet -> raw -> hlen,
324fcf
-			     packet -> raw -> chaddr),
324fcf
+	      print_hw_addr_or_client_id(packet),
324fcf
 	      packet -> raw -> giaddr.s_addr
324fcf
 	      ? inet_ntoa (packet -> raw -> giaddr)
324fcf
 	      : packet -> interface -> name);
324fcf
@@ -3897,7 +3918,7 @@
324fcf
 		   ? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
324fcf
 		   : "BOOTREPLY"),
324fcf
 		  piaddr (lease -> ip_addr),
324fcf
-		  (lease -> hardware_addr.hlen
324fcf
+		  (lease -> hardware_addr.hlen > 1
324fcf
 		   ? print_hw_addr (lease -> hardware_addr.hbuf [0],
324fcf
 				    lease -> hardware_addr.hlen - 1,
324fcf
 				    &lease -> hardware_addr.hbuf [1])
324fcf
@@ -4450,10 +4471,7 @@
324fcf
 			if (uid_lease) {
324fcf
 			    if (uid_lease->binding_state == FTS_ACTIVE) {
324fcf
 				log_error ("client %s has duplicate%s on %s",
324fcf
-					   (print_hw_addr
324fcf
-					    (packet -> raw -> htype,
324fcf
-					     packet -> raw -> hlen,
324fcf
-					     packet -> raw -> chaddr)),
324fcf
+					   (print_hw_addr_or_client_id(packet)),
324fcf
 					   " leases",
324fcf
 					   (ip_lease -> subnet ->
324fcf
 					    shared_network -> name));
324fcf
@@ -4620,9 +4638,7 @@
324fcf
 			log_error("uid lease %s for client %s is duplicate "
324fcf
 				  "on %s",
324fcf
 				  piaddr(uid_lease->ip_addr),
324fcf
-				  print_hw_addr(packet->raw->htype,
324fcf
-						packet->raw->hlen,
324fcf
-						packet->raw->chaddr),
324fcf
+				  print_hw_addr_or_client_id(packet),
324fcf
 				  uid_lease->subnet->shared_network->name);
324fcf
 
324fcf
 			if (!packet -> raw -> ciaddr.s_addr &&