From 7caf8ab713f505a4f2512cf2c89a537ed4489ec1 Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Feb 18 2014 15:26:06 +0000 Subject: IPoIB: add GUID/DUID to dhcpd logs (#1064416) --- diff --git a/dhcp-IPoIB-log-id.patch b/dhcp-IPoIB-log-id.patch new file mode 100644 index 0000000..3cf52f8 --- /dev/null +++ b/dhcp-IPoIB-log-id.patch @@ -0,0 +1,263 @@ +diff -up dhcp-4.3.0/common/lpf.c.IPoIB-log-id dhcp-4.3.0/common/lpf.c +--- dhcp-4.3.0/common/lpf.c.IPoIB-log-id 2014-02-18 15:52:12.292569480 +0100 ++++ dhcp-4.3.0/common/lpf.c 2014-02-18 15:52:12.297569411 +0100 +@@ -164,6 +164,8 @@ int if_register_lpf (info) + void if_register_send (info) + struct interface_info *info; + { ++ int hlen; ++ + /* If we're using the lpf API for sending and receiving, + we don't need to register this interface twice. */ + #ifndef USE_LPF_RECEIVE +@@ -171,11 +173,15 @@ void if_register_send (info) + #else + info -> wfdesc = info -> rfdesc; + #endif ++ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) ++ hlen = 9; ++ else ++ hlen = info -> hw_address.hlen; + if (!quiet_interface_discovery) + log_info ("Sending on LPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], +- info -> hw_address.hlen - 1, ++ hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? +@@ -185,6 +191,10 @@ void if_register_send (info) + void if_deregister_send (info) + struct interface_info *info; + { ++ int hlen = info -> hw_address.hlen; ++ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) ++ hlen = 9; ++ + /* don't need to close twice if we are using lpf for sending and + receiving */ + #ifndef USE_LPF_RECEIVE +@@ -197,7 +207,7 @@ void if_deregister_send (info) + log_info ("Disabling output on LPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], +- info -> hw_address.hlen - 1, ++ hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? +@@ -224,7 +234,7 @@ static void lpf_gen_filter_setup (struct + void if_register_receive (info) + struct interface_info *info; + { +- int val; ++ int val, hlen; + + /* Open a LPF device and hang it on this interface... */ + info -> rfdesc = if_register_lpf (info); +@@ -236,7 +246,9 @@ void if_register_receive (info) + if (errno != ENOPROTOOPT) + log_fatal ("Failed to set auxiliary packet data: %m"); + } +- } ++ hlen = info -> hw_address.hlen; ++ } else ++ hlen = 9; + + #if defined (HAVE_TR_SUPPORT) + if (info -> hw_address.hbuf [0] == HTYPE_IEEE802) +@@ -249,7 +261,7 @@ void if_register_receive (info) + log_info ("Listening on LPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], +- info -> hw_address.hlen - 1, ++ hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? +@@ -259,6 +271,10 @@ void if_register_receive (info) + void if_deregister_receive (info) + struct interface_info *info; + { ++ int hlen = info -> hw_address.hlen; ++ if (info->hw_address.hbuf[0] == HTYPE_INFINIBAND) ++ hlen = 9; ++ + /* for LPF this is simple, packet filters are removed when sockets + are closed */ + close (info -> rfdesc); +@@ -267,7 +283,7 @@ void if_deregister_receive (info) + log_info ("Disabling input on LPF/%s/%s%s%s", + info -> name, + print_hw_addr (info -> hw_address.hbuf [0], +- info -> hw_address.hlen - 1, ++ hlen - 1, + &info -> hw_address.hbuf [1]), + (info -> shared_network ? "/" : ""), + (info -> shared_network ? +diff -up dhcp-4.3.0/server/dhcp.c.IPoIB-log-id dhcp-4.3.0/server/dhcp.c +--- dhcp-4.3.0/server/dhcp.c.IPoIB-log-id 2014-02-18 15:52:12.204570695 +0100 ++++ dhcp-4.3.0/server/dhcp.c 2014-02-18 15:52:12.299569383 +0100 +@@ -74,6 +74,42 @@ const int dhcp_type_name_max = ((sizeof + # define send_packet trace_packet_send + #endif + ++char *print_client_identifier_from_packet (packet) ++ struct packet *packet; ++{ ++ struct option_cache *oc; ++ struct data_string client_identifier; ++ char *ci; ++ ++ memset (&client_identifier, 0, sizeof client_identifier); ++ ++ oc = lookup_option (&dhcp_universe, packet -> options, ++ DHO_DHCP_CLIENT_IDENTIFIER); ++ if (oc && ++ evaluate_option_cache (&client_identifier, ++ packet, (struct lease *)0, ++ (struct client_state *)0, ++ packet -> options, ++ (struct option_state *)0, ++ &global_scope, oc, MDL)) { ++ ci = print_hw_addr (HTYPE_INFINIBAND, client_identifier.len, client_identifier.data); ++ data_string_forget (&client_identifier, MDL); ++ return ci; ++ } else ++ return "\"no client id\""; ++} ++ ++char *print_hw_addr_or_client_id (packet) ++ struct packet *packet; ++{ ++ if (packet -> raw -> htype == HTYPE_INFINIBAND) ++ return print_client_identifier_from_packet (packet); ++ else ++ return print_hw_addr (packet -> raw -> htype, ++ packet -> raw -> hlen, ++ packet -> raw -> chaddr); ++} ++ + void + dhcp (struct packet *packet) { + int ms_nulltp = 0; +@@ -102,9 +138,7 @@ dhcp (struct packet *packet) { + + log_info("%s from %s via %s: %s", s, + (packet->raw->htype +- ? print_hw_addr(packet->raw->htype, +- packet->raw->hlen, +- packet->raw->chaddr) ++ ? print_hw_addr_or_client_id(packet) + : ""), + packet->raw->giaddr.s_addr + ? inet_ntoa(packet->raw->giaddr) +@@ -286,9 +320,7 @@ void dhcpdiscover (packet, ms_nulltp) + */ + snprintf (msgbuf, sizeof msgbuf, "DHCPDISCOVER from %s %s%s%svia %s", + (packet -> raw -> htype +- ? print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr) ++ ? print_hw_addr_or_client_id (packet) + : (lease + ? print_hex_1(lease->uid_len, lease->uid, 60) + : "")), +@@ -478,9 +510,7 @@ void dhcprequest (packet, ms_nulltp, ip_ + "DHCPREQUEST for %s%s from %s %s%s%svia %s", + piaddr (cip), smbuf, + (packet -> raw -> htype +- ? print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr) ++ ? print_hw_addr_or_client_id(packet) + : (lease + ? print_hex_1(lease->uid_len, lease->uid, 60) + : "")), +@@ -719,9 +749,7 @@ void dhcprelease (packet, ms_nulltp) + if ((oc = lookup_option (&dhcp_universe, packet -> options, + DHO_DHCP_REQUESTED_ADDRESS))) { + log_info ("DHCPRELEASE from %s specified requested-address.", +- print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr)); ++ print_hw_addr_or_client_id(packet)); + } + + oc = lookup_option (&dhcp_universe, packet -> options, +@@ -795,9 +823,7 @@ void dhcprelease (packet, ms_nulltp) + "DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)", + cstr, + (packet -> raw -> htype +- ? print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr) ++ ? print_hw_addr_or_client_id(packet) + : (lease + ? print_hex_1(lease->uid_len, lease->uid, 60) + : "")), +@@ -886,9 +912,7 @@ void dhcpdecline (packet, ms_nulltp) + "DHCPDECLINE of %s from %s %s%s%svia %s", + piaddr (cip), + (packet -> raw -> htype +- ? print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr) ++ ? print_hw_addr_or_client_id(packet) + : (lease + ? print_hex_1(lease->uid_len, lease->uid, 60) + : "")), +@@ -1541,8 +1565,7 @@ void dhcpinform (packet, ms_nulltp) + /* Report what we're sending. */ + snprintf(msgbuf, sizeof msgbuf, "DHCPACK to %s (%s) via", piaddr(cip), + (packet->raw->htype && packet->raw->hlen) ? +- print_hw_addr(packet->raw->htype, packet->raw->hlen, +- packet->raw->chaddr) : ++ print_hw_addr_or_client_id(packet) : + ""); + log_info("%s %s", msgbuf, gip.len ? piaddr(gip) : + packet->interface->name); +@@ -1682,9 +1705,7 @@ void nak_lease (packet, cip) + /* Report what we're sending... */ + log_info ("DHCPNAK on %s to %s via %s", + piaddr (*cip), +- print_hw_addr (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr), ++ print_hw_addr_or_client_id(packet), + packet -> raw -> giaddr.s_addr + ? inet_ntoa (packet -> raw -> giaddr) + : packet -> interface -> name); +@@ -3468,7 +3489,7 @@ void dhcp_reply (lease) + ? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER") + : "BOOTREPLY"), + piaddr (lease -> ip_addr), +- (lease -> hardware_addr.hlen ++ (lease -> hardware_addr.hlen > 1 + ? print_hw_addr (lease -> hardware_addr.hbuf [0], + lease -> hardware_addr.hlen - 1, + &lease -> hardware_addr.hbuf [1]) +@@ -4022,10 +4043,7 @@ int find_lease (struct lease **lp, + if (uid_lease) { + if (uid_lease->binding_state == FTS_ACTIVE) { + log_error ("client %s has duplicate%s on %s", +- (print_hw_addr +- (packet -> raw -> htype, +- packet -> raw -> hlen, +- packet -> raw -> chaddr)), ++ (print_hw_addr_or_client_id(packet)), + " leases", + (ip_lease -> subnet -> + shared_network -> name)); +@@ -4192,9 +4210,7 @@ int find_lease (struct lease **lp, + log_error("uid lease %s for client %s is duplicate " + "on %s", + piaddr(uid_lease->ip_addr), +- print_hw_addr(packet->raw->htype, +- packet->raw->hlen, +- packet->raw->chaddr), ++ print_hw_addr_or_client_id(packet), + uid_lease->subnet->shared_network->name); + + if (!packet -> raw -> ciaddr.s_addr && diff --git a/dhcp-duidv4.patch b/dhcp-duidv4.patch index 2f51ecb..97138ae 100644 --- a/dhcp-duidv4.patch +++ b/dhcp-duidv4.patch @@ -1,6 +1,6 @@ diff -up dhcp-4.3.0/client/dhclient.8.duidv4 dhcp-4.3.0/client/dhclient.8 ---- dhcp-4.3.0/client/dhclient.8.duidv4 2014-02-17 16:57:43.000000000 +0100 -+++ dhcp-4.3.0/client/dhclient.8 2014-02-17 17:15:25.366604705 +0100 +--- dhcp-4.3.0/client/dhclient.8.duidv4 2014-02-18 15:52:44.564123664 +0100 ++++ dhcp-4.3.0/client/dhclient.8 2014-02-18 15:52:44.629122766 +0100 @@ -454,6 +454,9 @@ used to construct a RFC4361 style client in the client's messages. This client id can be overridden by setting a client id in the configuration file. Overridding the @@ -12,8 +12,8 @@ diff -up dhcp-4.3.0/client/dhclient.8.duidv4 dhcp-4.3.0/client/dhclient.8 .BI \-I Use the standard DDNS scheme from RFCs 4701 & 4702. diff -up dhcp-4.3.0/client/dhclient.c.duidv4 dhcp-4.3.0/client/dhclient.c ---- dhcp-4.3.0/client/dhclient.c.duidv4 2014-02-17 16:57:43.000000000 +0100 -+++ dhcp-4.3.0/client/dhclient.c 2014-02-17 17:07:24.503358565 +0100 +--- dhcp-4.3.0/client/dhclient.c.duidv4 2014-02-18 15:52:44.626122807 +0100 ++++ dhcp-4.3.0/client/dhclient.c 2014-02-18 15:52:44.630122752 +0100 @@ -72,7 +72,7 @@ struct sockaddr_in sockaddr_broadcast; struct in_addr giaddr; struct data_string default_duid; @@ -32,7 +32,7 @@ diff -up dhcp-4.3.0/client/dhclient.c.duidv4 dhcp-4.3.0/client/dhclient.c } /* Individual States: -@@ -3314,6 +3314,7 @@ form_duid(struct data_string *duid, cons +@@ -3299,6 +3299,7 @@ form_duid(struct data_string *duid, cons { struct interface_info *ip; int len; @@ -40,7 +40,7 @@ diff -up dhcp-4.3.0/client/dhclient.c.duidv4 dhcp-4.3.0/client/dhclient.c /* For now, just use the first interface on the list. */ ip = interfaces; -@@ -3337,6 +3338,11 @@ form_duid(struct data_string *duid, cons +@@ -3322,6 +3323,11 @@ form_duid(struct data_string *duid, cons if (duid_type == 0) duid_type = stateless ? DUID_LL : DUID_LLT; @@ -52,7 +52,7 @@ diff -up dhcp-4.3.0/client/dhclient.c.duidv4 dhcp-4.3.0/client/dhclient.c /* * 2 bytes for the 'duid type' field. * 2 bytes for the 'htype' field. -@@ -3344,7 +3350,7 @@ form_duid(struct data_string *duid, cons +@@ -3329,7 +3335,7 @@ form_duid(struct data_string *duid, cons * enough bytes for the hardware address (note that hw_address has * the 'htype' on byte zero). */ @@ -61,7 +61,7 @@ diff -up dhcp-4.3.0/client/dhclient.c.duidv4 dhcp-4.3.0/client/dhclient.c if (duid_type == DUID_LLT) len += 4; if (!buffer_allocate(&duid->buffer, len, MDL)) -@@ -3358,12 +3364,12 @@ form_duid(struct data_string *duid, cons +@@ -3343,12 +3349,12 @@ form_duid(struct data_string *duid, cons putUShort(duid->buffer->data + 2, ip->hw_address.hbuf[0]); putULong(duid->buffer->data + 4, cur_time - DUID_TIME_EPOCH); memcpy(duid->buffer->data + 8, ip->hw_address.hbuf + 1, diff --git a/dhcp.spec b/dhcp.spec index 810c73f..e0e2efa 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -18,7 +18,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: 4.3.0 -Release: 3%{?dist} +Release: 4%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -62,23 +62,23 @@ Patch22: dhcp-honor-expired.patch Patch23: dhcp-PPP.patch Patch24: dhcp-paranoia.patch Patch25: dhcp-lpf-ib.patch -Patch26: dhcp-improved-xid.patch -Patch27: dhcp-gpxe-cid.patch -Patch28: dhcp-systemtap.patch -Patch29: dhcp-dhclient-decline-onetry.patch -Patch30: dhcp-log_perror.patch -Patch31: dhcp-getifaddrs.patch -Patch32: dhcp-omapi-leak.patch -Patch33: dhcp-failOverPeer.patch -Patch34: dhcp-interval.patch -Patch35: dhcp-conflex-do-forward-updates.patch -Patch36: dhcp-dupl-key.patch -Patch37: dhcp-range6.patch -Patch38: dhcp-next-server.patch -Patch39: dhcp-no-subnet-error2info.patch -Patch40: dhcp-ffff-checksum.patch -Patch41: dhcp-duidv4.patch - +Patch26: dhcp-IPoIB-log-id.patch +Patch27: dhcp-improved-xid.patch +Patch28: dhcp-gpxe-cid.patch +Patch29: dhcp-duidv4.patch +Patch30: dhcp-systemtap.patch +Patch31: dhcp-dhclient-decline-onetry.patch +Patch32: dhcp-log_perror.patch +Patch33: dhcp-getifaddrs.patch +Patch34: dhcp-omapi-leak.patch +Patch35: dhcp-failOverPeer.patch +Patch36: dhcp-interval.patch +Patch37: dhcp-conflex-do-forward-updates.patch +Patch38: dhcp-dupl-key.patch +Patch39: dhcp-range6.patch +Patch40: dhcp-next-server.patch +Patch41: dhcp-no-subnet-error2info.patch +Patch42: dhcp-ffff-checksum.patch BuildRequires: autoconf BuildRequires: automake @@ -282,62 +282,65 @@ rm -rf includes/isc-dhcp # IPoIB support (#660681) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #24249]) %patch25 -p1 -b .lpf-ib -%patch26 -p1 -b .improved-xid -#%%patch27 -p1 -b .gpxe-cid +# add GUID/DUID to dhcpd logs (#1064416) +%patch26 -p1 -b .IPoIB-log-id +%patch27 -p1 -b .improved-xid +# create client identifier per rfc4390 +#%%patch28 -p1 -b .gpxe-cid (not needed as we use DUIDs - see next patch) +# Turn on creating/sending of DUID as client identifier with DHCPv4 clients (#560361c#40, rfc4361) +%patch29 -p1 -b .duidv4 # http://sourceware.org/systemtap/wiki/SystemTap -%patch28 -p1 -b .systemtap +%patch30 -p1 -b .systemtap # Send DHCPDECLINE and exit(2) when duplicate address was detected and # dhclient had been started with '-1' (#756759). # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #26735]) -%patch29 -p1 -b .decline-onetry +%patch31 -p1 -b .decline-onetry # Don't send log messages to the standard error descriptor by default (#790387) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #28049]) -%patch30 -p1 -b .log_perror +%patch32 -p1 -b .log_perror # Use getifaddrs() to scan for interfaces on Linux (#449946) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #28761]) -%patch31 -p1 -b .getifaddrs +%patch33 -p1 -b .getifaddrs # Fix several memory leaks in omapi (#978420) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #33990]) -%patch32 -p1 -b .leak +%patch34 -p1 -b .leak # Dhcpd does not correctly follow DhcpFailOverPeerDN (#838400) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #30402]) -%patch33 -p1 -b .failOverPeer +%patch35 -p1 -b .failOverPeer # isc_time_nowplusinterval() is not safe with 64-bit time_t (#662254, #789601) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #28038]) -%patch34 -p1 -b .interval +%patch36 -p1 -b .interval # do-forward-updates statement wasn't recognized (#863646) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #31328]) -%patch35 -p1 -b .forward-updates +%patch37 -p1 -b .forward-updates # multiple key statements in zone definition causes inappropriate error (#873794) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #31892]) -%patch36 -p1 -b .dupl-key +%patch38 -p1 -b .dupl-key # Make sure range6 is correct for subnet6 where it's declared (#902966) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #32453]) -%patch37 -p1 -b .range6 +%patch39 -p1 -b .range6 # Expose next-server DHCPv4 option to dhclient script # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #33098]) -%patch38 -p1 -b .next-server +%patch40 -p1 -b .next-server # 'No subnet declaration for ' should be info, not error. -%patch39 -p1 -b .error2info +%patch41 -p1 -b .error2info # dhcpd rejects the udp packet with checksum=0xffff (#1015997) # (Submitted to dhcp-bugs@isc.org - [ISC-Bugs #25587]) -%patch40 -p1 -b .ffff +%patch42 -p1 -b .ffff -# Turn on using of DUID with DHCPv4 clients (#560361,c#40) -%patch41 -p1 -b .duidv4 # Update paths in all man pages for page in client/dhclient.conf.5 client/dhclient.leases.5 \ @@ -600,6 +603,9 @@ done %changelog +* Tue Feb 18 2014 Jiri Popelka - 12:4.3.0-4 +- IPoIB: add GUID/DUID to dhcpd logs (#1064416) + * Mon Feb 17 2014 Jiri Popelka - 12:4.3.0-3 - don't try to run tests because there's no atf package since F21