Package: dhcp3-client
Version: 3.1.1-1
Severity: wishlist
Tags: patch
User: [EMAIL PROTECTED]
Usertags: origin-ubuntu ubuntu-patch intrepid

A while ago, Peter Miller contributed a patch [1] to improve the IP
address logging in dhclient, which is useful for debugging problems.
It wasn't perfect [2], but I fixed that now; it works correctly for
renewing leases, too.

I sent it to dhcp-bugs@ when I applied it (no web archive of this
unfortunately), but I never heard back from it. Does upstream have a
bug tracker, which would be much better for forwarding patches to?

Thanks,

Martin

[1] https://launchpad.net/bugs/35265
[2] http://marc.info/?l=dhcp-users&m=121017450721761&w=2

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
#! /bin/sh /usr/share/dpatch/dpatch-run
## dhclient-more-debug.dpatch by  <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Show offered/requested client IP in log, for better debugging.
## DP: Ubuntu: https://launchpad.net/bugs/35265
## DP: Forwarded to [EMAIL PROTECTED], [EMAIL PROTECTED] by email.
## DP: Patch by Peter Miller <[EMAIL PROTECTED]>

@DPATCH@
diff -urNad dhcp3-3.1.1~/client/dhclient.c dhcp3-3.1.1/client/dhclient.c
--- dhcp3-3.1.1~/client/dhclient.c      2008-06-17 10:07:27.000000000 +0200
+++ dhcp3-3.1.1/client/dhclient.c       2008-06-17 10:15:02.000000000 +0200
@@ -741,13 +741,14 @@
                return;
        }
 
-       log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
-
        lease = packet_to_lease (packet, client);
        if (!lease) {
+               log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
                log_info ("packet_to_lease failed.");
                return;
        }
+       log_info("DHCPACK of %s from %s", piaddr(lease->address),
+           piaddr(packet -> client_addr));
 
        client -> new = lease;
 
@@ -1176,6 +1177,8 @@
                log_info ("%s: packet_to_lease failed.", obuf);
                return;
        }
+       sprintf(obuf, "%s of %s from %s", name, piaddr(lease->address),
+           piaddr (packet -> client_addr));
 
        /* If this lease was acquired through a BOOTREPLY, record that
           fact. */
@@ -1761,7 +1764,10 @@
                        client -> packet.secs = htons (65535);
        }
 
-       log_info ("DHCPREQUEST on %s to %s port %d",
+       log_info ("DHCPREQUEST of %s on %s to %s port %d", 
+              piaddr ((client -> state == S_BOUND || client -> state ==
+                      S_RENEWING || client -> state == S_REBINDING) ?
+                      client -> active -> address : client -> 
requested_address),
              client -> name ? client -> name : client -> interface -> name,
              inet_ntoa (destination.sin_addr),
              ntohs (destination.sin_port));
diff -urNad dhcp3-3.1.1~/common/inet.c dhcp3-3.1.1/common/inet.c
--- dhcp3-3.1.1~/common/inet.c  2008-06-17 10:07:10.000000000 +0200
+++ dhcp3-3.1.1/common/inet.c   2008-06-17 10:07:27.000000000 +0200
@@ -213,8 +213,11 @@
 char *piaddr (addr)
        struct iaddr addr;
 {
-       static char pbuf [4 * 16];
-       char *s = pbuf;
+       static int num;
+       static char pbuf[4][4 * 16];
+       char *base = pbuf[num];
+       char *s = base;
+       num = (num + 1) & 3;
        int i;
 
        if (addr.len > sizeof(addr.iabuf))
@@ -227,7 +230,7 @@
                sprintf (s, "%s%d", i ? "." : "", addr.iabuf [i]);
                s += strlen (s);
        }
-       return pbuf;
+       return base;
 }
 
 char *piaddrmask (struct iaddr addr, struct iaddr mask,

Attachment: signature.asc
Description: Digital signature

Reply via email to