From 5565c0ce720d76ac24599b3d894a27c12aebb172 Mon Sep 17 00:00:00 2001 From: Jiří Popelka Date: Apr 19 2010 10:33:46 +0000 Subject: - Fill in Elapsed Time Option in Release/Decline messages (#582939) --- diff --git a/dhcp-4.1.1-manpages.patch b/dhcp-4.1.1-manpages.patch index 1d1f988..61cb06c 100644 --- a/dhcp-4.1.1-manpages.patch +++ b/dhcp-4.1.1-manpages.patch @@ -460,20 +460,24 @@ diff -up dhcp-4.1.1/client/dhclient.8.man dhcp-4.1.1/client/dhclient.8 diff -up dhcp-4.1.1/client/dhclient.conf.5.man dhcp-4.1.1/client/dhclient.conf.5 --- dhcp-4.1.1/client/dhclient.conf.5.man 2009-07-23 21:02:09.000000000 +0200 +++ dhcp-4.1.1/client/dhclient.conf.5 2010-02-25 17:43:16.000000000 +0100 -@@ -186,9 +186,9 @@ responding to the client send the client +@@ -184,11 +184,12 @@ are called \fIDHCP Options\fR. DHCP Opt + The request statement causes the client to request that any server + responding to the client send the client its values for the specified options. Only the option names should be specified in the request - statement - not option parameters. By default, the DHCP server +-statement - not option parameters. By default, the DHCP server ++statement - not option parameters. By default, the DHCPv4 client requests the subnet-mask, broadcast-address, time-offset, routers, -domain-name, domain-name-servers and host-name options. Note that if -you enter a 'request' statement, you over-ride this default and these -options will not be requested. -+domain-name, domain-name-servers, host-name, nis-domain, nis-servers, ntp-servers, -+and interface-mtu options. Note that if you enter a 'request' statement, ++domain-name, domain-name-servers, host-name, nis-domain, nis-servers, ++ntp-servers and interface-mtu options. The DHCPv6 client requests by default ++name-servers and domain-search. Note that if you enter a 'request' statement, +you over-ride this default and these options will not be requested. .PP In some cases, it may be desirable to send no parameter request list at all. To do this, simply write the request statement but specify -@@ -239,17 +239,6 @@ than the default requested lease time, w +@@ -239,17 +240,6 @@ than the default requested lease time, w obvious use for this statement is to send information to the server that will allow it to differentiate between this client and other clients or kinds of clients. @@ -491,7 +495,7 @@ diff -up dhcp-4.1.1/client/dhclient.conf.5.man dhcp-4.1.1/client/dhclient.conf.5 .SH DYNAMIC DNS The client now has some very limited support for doing DNS updates when a lease is acquired. This is prototypical, and probably doesn't -@@ -659,6 +659,18 @@ database and will record the media type +@@ -659,6 +649,18 @@ database and will record the media type Whenever the client tries to renew the lease, it will use that same media type. The lease must expire before the client will go back to cycling through media types. @@ -510,7 +514,7 @@ diff -up dhcp-4.1.1/client/dhclient.conf.5.man dhcp-4.1.1/client/dhclient.conf.5 .SH SAMPLE The following configuration file is used on a laptop running NetBSD 1.3. The laptop has an IP alias of 192.5.5.213, and has one -@@ -680,10 +692,10 @@ interface "ep0" { +@@ -680,10 +682,10 @@ interface "ep0" { send host-name "andare.fugue.com"; send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; send dhcp-lease-time 3600; diff --git a/dhcp-4.1.1-release6-elapsed.patch b/dhcp-4.1.1-release6-elapsed.patch new file mode 100644 index 0000000..a0b4aa0 --- /dev/null +++ b/dhcp-4.1.1-release6-elapsed.patch @@ -0,0 +1,46 @@ +diff -up dhcp-4.1.1/client/dhc6.c.release6-elapsed dhcp-4.1.1/client/dhc6.c +--- dhcp-4.1.1/client/dhc6.c.release6-elapsed 2010-04-19 11:55:59.000000000 +0200 ++++ dhcp-4.1.1/client/dhc6.c 2010-04-19 12:00:00.000000000 +0200 +@@ -2174,7 +2174,7 @@ do_release6(void *input) + struct client_state *client; + struct data_string ds; + int send_ret; +- struct timeval tv; ++ struct timeval elapsed, tv; + + client = input; + +@@ -2194,6 +2194,14 @@ do_release6(void *input) + client->start_time.tv_usec = cur_tv.tv_usec; + } + ++ /* elapsed = cur - start */ ++ elapsed.tv_sec = cur_tv.tv_sec - client->start_time.tv_sec; ++ elapsed.tv_usec = cur_tv.tv_usec - client->start_time.tv_usec; ++ if (elapsed.tv_usec < 0) { ++ elapsed.tv_sec -= 1; ++ elapsed.tv_usec += 1000000; ++ } ++ + /* + * Don't use unicast as we don't know if we still have an + * available address with enough scope. +@@ -2210,6 +2218,18 @@ do_release6(void *input) + ds.buffer->data[0] = DHCPV6_RELEASE; + memcpy(ds.buffer->data + 1, client->dhcpv6_transaction_id, 3); + ++ /* Form an elapsed option. */ ++ /* Maximum value is 65535 1/100s coded as 0xffff. */ ++ if ((elapsed.tv_sec < 0) || (elapsed.tv_sec > 655) || ++ ((elapsed.tv_sec == 655) && (elapsed.tv_usec > 350000))) { ++ client->elapsed = 0xffff; ++ } else { ++ client->elapsed = elapsed.tv_sec * 100; ++ client->elapsed += elapsed.tv_usec / 10000; ++ } ++ ++ client->elapsed = htons(client->elapsed); ++ + log_debug("XMT: Forming Release."); + make_client6_options(client, &client->sent_options, + client->active_lease, DHCPV6_RELEASE); diff --git a/dhcp-4.1.1-sendDecline.patch b/dhcp-4.1.1-sendDecline.patch index f8c096f..d5d4feb 100644 --- a/dhcp-4.1.1-sendDecline.patch +++ b/dhcp-4.1.1-sendDecline.patch @@ -1,6 +1,6 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c --- dhcp-4.1.1/client/dhc6.c.sendDecline 2009-07-25 00:04:51.000000000 +0200 -+++ dhcp-4.1.1/client/dhc6.c 2010-03-24 10:41:31.000000000 +0100 ++++ dhcp-4.1.1/client/dhc6.c 2010-04-19 11:42:42.000000000 +0200 @@ -95,6 +95,8 @@ void do_select6(void *input); void do_refresh6(void *input); static void do_release6(void *input); @@ -45,7 +45,7 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c - if (client->active_lease == NULL) - return; + if ((client->state == S_STOPPED) || -+ (client->state == S_DECLINED)) { ++ (client->state == S_DECLINED)) { + + if (client->active_lease != NULL) { + dhc6_lease_destroy(&client->active_lease, MDL); @@ -79,7 +79,7 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c } /* XXX: maybe we should loop on the old values instead? */ -@@ -4509,6 +4524,134 @@ start_bound(struct client_state *client) +@@ -4509,6 +4524,151 @@ start_bound(struct client_state *client) dhc6_check_times(client); } @@ -122,7 +122,7 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c + struct client_state *client; + struct data_string ds; + int send_ret; -+ struct timeval tv; ++ struct timeval elapsed, tv; + + client = input; + @@ -142,6 +142,14 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c + client->start_time.tv_usec = cur_tv.tv_usec; + } + ++ /* elapsed = cur - start */ ++ elapsed.tv_sec = cur_tv.tv_sec - client->start_time.tv_sec; ++ elapsed.tv_usec = cur_tv.tv_usec - client->start_time.tv_usec; ++ if (elapsed.tv_usec < 0) { ++ elapsed.tv_sec -= 1; ++ elapsed.tv_usec += 1000000; ++ } ++ + memset(&ds, 0, sizeof(ds)); + if (!buffer_allocate(&ds.buffer, 4, MDL)) { + log_error("Unable to allocate memory for Decline."); @@ -153,6 +161,18 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c + ds.buffer->data[0] = DHCPV6_DECLINE; + memcpy(ds.buffer->data + 1, client->dhcpv6_transaction_id, 3); + ++ /* Form an elapsed option. */ ++ /* Maximum value is 65535 1/100s coded as 0xffff. */ ++ if ((elapsed.tv_sec < 0) || (elapsed.tv_sec > 655) || ++ ((elapsed.tv_sec == 655) && (elapsed.tv_usec > 350000))) { ++ client->elapsed = 0xffff; ++ } else { ++ client->elapsed = elapsed.tv_sec * 100; ++ client->elapsed += elapsed.tv_usec / 10000; ++ } ++ ++ client->elapsed = htons(client->elapsed); ++ + log_debug("XMT: Forming Decline."); + make_client6_options(client, &client->sent_options, + client->active_lease, DHCPV6_DECLINE); @@ -203,9 +223,6 @@ diff -up dhcp-4.1.1/client/dhc6.c.sendDecline dhcp-4.1.1/client/dhc6.c + if (client->active_lease != NULL) { + dhc6_lease_destroy(&client->active_lease, MDL); + client->active_lease = NULL; -+ /* We should never wait for nothing!? */ -+ if (stopping_finished()) -+ exit(0); + } + start_init6(client); + return; diff --git a/dhcp.spec b/dhcp.spec index 40bab26..b2b9244 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -13,7 +13,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: %{basever} -Release: 15%{?dist} +Release: 16%{?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. @@ -57,6 +57,7 @@ Patch21: %{name}-4.1.1-logpid.patch Patch22: %{name}-4.1.1-UseMulticast.patch Patch23: %{name}-4.1.1-sendDecline.patch Patch24: %{name}-4.1.1-retransmission.patch +Patch25: %{name}-4.1.1-release6-elapsed.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf @@ -224,6 +225,9 @@ libdhcpctl and libomapi static libraries are also included in this package. # upon reaching the MRD rather than at some point after it (#559153) %patch24 -p1 -b .retransmission +# Fill in Elapsed Time Option in Release message (#582939) +%patch25 -p1 -b .release6-elapsed + # Copy in documentation and example scripts for LDAP patch to dhcpd %{__install} -p -m 0755 ldap-for-dhcp-%{ldappatchver}/dhcpd-conf-to-ldap contrib/ @@ -506,6 +510,9 @@ fi %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %changelog +* Mon Apr 19 2010 Jiri Popelka - 12:4.1.1-16 +- Fill in Elapsed Time Option in Release/Decline messages (#582939) + * Thu Mar 25 2010 Jiri Popelka - 12:4.1.1-15 - In client initiated message exchanges stop retransmission upon reaching the MRD rather than at some point after it (#559153)