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

c360e8
diff -up dhcp-4.2.5/server/dhcp.c.IPoIB-log-id dhcp-4.2.5/server/dhcp.c
c360e8
--- dhcp-4.2.5/server/dhcp.c.IPoIB-log-id	2014-09-08 14:50:39.000000000 +0200
c360e8
+++ dhcp-4.2.5/server/dhcp.c	2014-09-08 15:06:28.367697349 +0200
c360e8
@@ -80,6 +80,42 @@ const int dhcp_type_name_max = ((sizeof
c360e8
 # define send_packet trace_packet_send
c360e8
 #endif
c360e8
 
c360e8
+char *print_client_identifier_from_packet (packet)
c360e8
+	struct packet *packet;
c360e8
+{
c360e8
+	struct option_cache *oc;
c360e8
+	struct data_string client_identifier;
c360e8
+	char *ci;
c360e8
+
c360e8
+	memset (&client_identifier, 0, sizeof client_identifier);
c360e8
+
c360e8
+	oc = lookup_option (&dhcp_universe, packet -> options,
c360e8
+			DHO_DHCP_CLIENT_IDENTIFIER);
c360e8
+	if (oc &&
c360e8
+	    evaluate_option_cache (&client_identifier,
c360e8
+				    packet, (struct lease *)0,
c360e8
+				    (struct client_state *)0,
c360e8
+				    packet -> options,
c360e8
+				    (struct option_state *)0,
c360e8
+				    &global_scope, oc, MDL)) {
c360e8
+		ci = print_hw_addr (HTYPE_INFINIBAND, client_identifier.len, client_identifier.data);
c360e8
+		data_string_forget (&client_identifier, MDL);
c360e8
+		return ci;
c360e8
+	} else
c360e8
+		return "\"no client id\"";
c360e8
+}
c360e8
+
c360e8
+char *print_hw_addr_or_client_id (packet)
c360e8
+	struct packet *packet;
c360e8
+{
c360e8
+	if (packet -> raw -> htype == HTYPE_INFINIBAND)
c360e8
+		return print_client_identifier_from_packet (packet);
c360e8
+	else
c360e8
+		return print_hw_addr (packet -> raw -> htype,
c360e8
+				      packet -> raw -> hlen,
c360e8
+				      packet -> raw -> chaddr);
c360e8
+}
c360e8
+
c360e8
 void
c360e8
 dhcp (struct packet *packet) {
c360e8
 	int ms_nulltp = 0;
c360e8
@@ -108,9 +144,7 @@ dhcp (struct packet *packet) {
c360e8
 		
c360e8
 		log_info("%s from %s via %s: %s", s,
c360e8
 			 (packet->raw->htype
c360e8
-			  ? print_hw_addr(packet->raw->htype,
c360e8
-					  packet->raw->hlen,
c360e8
-					  packet->raw->chaddr)
c360e8
+			  ? print_hw_addr_or_client_id (packet)
c360e8
 			  : "<no identifier>"),
c360e8
 			 packet->raw->giaddr.s_addr
c360e8
 			 ? inet_ntoa(packet->raw->giaddr)
c360e8
@@ -294,9 +328,7 @@ void dhcpdiscover (packet, ms_nulltp)
c360e8
 	 */
c360e8
 	snprintf (msgbuf, sizeof msgbuf, "DHCPDISCOVER from %s %s%s%svia %s",
c360e8
 		 (packet -> raw -> htype
c360e8
-		  ? print_hw_addr (packet -> raw -> htype,
c360e8
-				   packet -> raw -> hlen,
c360e8
-				   packet -> raw -> chaddr)
c360e8
+		  ? print_hw_addr_or_client_id (packet)
c360e8
 		  : (lease
c360e8
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
c360e8
 		     : "<no identifier>")),
c360e8
@@ -490,9 +522,7 @@ void dhcprequest (packet, ms_nulltp, ip_
c360e8
 		 "DHCPREQUEST for %s%s from %s %s%s%svia %s",
c360e8
 		 piaddr (cip), smbuf,
c360e8
 		 (packet -> raw -> htype
c360e8
-		  ? print_hw_addr (packet -> raw -> htype,
c360e8
-				   packet -> raw -> hlen,
c360e8
-				   packet -> raw -> chaddr)
c360e8
+		  ? print_hw_addr_or_client_id (packet)
c360e8
 		  : (lease
c360e8
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
c360e8
 		     : "<no identifier>")),
c360e8
@@ -735,9 +765,7 @@ void dhcprelease (packet, ms_nulltp)
c360e8
 	if ((oc = lookup_option (&dhcp_universe, packet -> options,
c360e8
 				 DHO_DHCP_REQUESTED_ADDRESS))) {
c360e8
 		log_info ("DHCPRELEASE from %s specified requested-address.",
c360e8
-		      print_hw_addr (packet -> raw -> htype,
c360e8
-				     packet -> raw -> hlen,
c360e8
-				     packet -> raw -> chaddr));
c360e8
+		      print_hw_addr_or_client_id (packet));
c360e8
 	}
c360e8
 
c360e8
 	oc = lookup_option (&dhcp_universe, packet -> options,
c360e8
@@ -811,9 +839,7 @@ void dhcprelease (packet, ms_nulltp)
c360e8
 		 "DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)",
c360e8
 		 cstr,
c360e8
 		 (packet -> raw -> htype
c360e8
-		  ? print_hw_addr (packet -> raw -> htype,
c360e8
-				   packet -> raw -> hlen,
c360e8
-				   packet -> raw -> chaddr)
c360e8
+		  ? print_hw_addr_or_client_id (packet)
c360e8
 		  : (lease
c360e8
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
c360e8
 		     : "<no identifier>")),
c360e8
@@ -906,9 +932,7 @@ void dhcpdecline (packet, ms_nulltp)
c360e8
 		 "DHCPDECLINE of %s from %s %s%s%svia %s",
c360e8
 		 piaddr (cip),
c360e8
 		 (packet -> raw -> htype
c360e8
-		  ? print_hw_addr (packet -> raw -> htype,
c360e8
-				   packet -> raw -> hlen,
c360e8
-				   packet -> raw -> chaddr)
c360e8
+		  ? print_hw_addr_or_client_id(packet)
c360e8
 		  : (lease
c360e8
 		     ? print_hex_1(lease->uid_len, lease->uid, 60)
c360e8
 		     : "<no identifier>")),
c360e8
@@ -1348,8 +1372,7 @@ void dhcpinform (packet, ms_nulltp)
c360e8
 	/* Report what we're sending. */
c360e8
 	snprintf(msgbuf, sizeof msgbuf, "DHCPACK to %s (%s) via", piaddr(cip),
c360e8
 		 (packet->raw->htype && packet->raw->hlen) ?
c360e8
-			print_hw_addr(packet->raw->htype, packet->raw->hlen,
c360e8
-				      packet->raw->chaddr) :
c360e8
+			print_hw_addr_or_client_id(packet) :
c360e8
 			"<no client hardware address>");
c360e8
 	log_info("%s %s", msgbuf, gip.len ? piaddr(gip) :
c360e8
 					    packet->interface->name);
c360e8
@@ -1493,9 +1516,7 @@ void nak_lease (packet, cip)
c360e8
 	/* Report what we're sending... */
c360e8
 	log_info ("DHCPNAK on %s to %s via %s",
c360e8
 	      piaddr (*cip),
c360e8
-	      print_hw_addr (packet -> raw -> htype,
c360e8
-			     packet -> raw -> hlen,
c360e8
-			     packet -> raw -> chaddr),
c360e8
+	      print_hw_addr_or_client_id (packet),
c360e8
 	      packet -> raw -> giaddr.s_addr
c360e8
 	      ? inet_ntoa (packet -> raw -> giaddr)
c360e8
 	      : packet -> interface -> name);
c360e8
@@ -3214,7 +3235,7 @@ void dhcp_reply (lease)
c360e8
 		   ? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
c360e8
 		   : "BOOTREPLY"),
c360e8
 		  piaddr (lease -> ip_addr),
c360e8
-		  (lease -> hardware_addr.hlen
c360e8
+		  (lease -> hardware_addr.hlen > 1
c360e8
 		   ? print_hw_addr (lease -> hardware_addr.hbuf [0],
c360e8
 				    lease -> hardware_addr.hlen - 1,
c360e8
 				    &lease -> hardware_addr.hbuf [1])
c360e8
@@ -3772,10 +3793,7 @@ int find_lease (struct lease **lp,
c360e8
 			if (uid_lease) {
c360e8
 			    if (uid_lease->binding_state == FTS_ACTIVE) {
c360e8
 				log_error ("client %s has duplicate%s on %s",
c360e8
-					   (print_hw_addr
c360e8
-					    (packet -> raw -> htype,
c360e8
-					     packet -> raw -> hlen,
c360e8
-					     packet -> raw -> chaddr)),
c360e8
+					   (print_hw_addr_or_client_id(packet)),
c360e8
 					   " leases",
c360e8
 					   (ip_lease -> subnet ->
c360e8
 					    shared_network -> name));
c360e8
@@ -3942,9 +3960,7 @@ int find_lease (struct lease **lp,
c360e8
 			log_error("uid lease %s for client %s is duplicate "
c360e8
 				  "on %s",
c360e8
 				  piaddr(uid_lease->ip_addr),
c360e8
-				  print_hw_addr(packet->raw->htype,
c360e8
-						packet->raw->hlen,
c360e8
-						packet->raw->chaddr),
c360e8
+				  print_hw_addr_or_client_id(packet),
c360e8
 				  uid_lease->subnet->shared_network->name);
c360e8
 
c360e8
 			if (!packet -> raw -> ciaddr.s_addr &&