Commit fafee3b
feat(dhcp): enable --debug option for dhcpcd (#6693)
The primary motivation for this extra detail is to capture the
flow when multiple DISCOVER requests are required, similar to
what we see in dhclient today so we can better understand how
time is spent in dhcpcd.
Without debug:
```
2026-01-28 18:19:59,156 - azure.py[DEBUG]: dhcp client stderr for interface=eth0: dhcpcd-10.0.6 starting
DUID 00:01:00:01:31:0d:0f:cd:60:45:bd:86:6f:e1
eth0: IAID bd:86:6f:e1
eth0: soliciting a DHCP lease
eth0: offered 10.0.0.4 from 168.63.129.16 LVL101082702015SOC
eth0: leased 10.0.0.4 for infinity
eth0: adding route to 10.0.0.0/16
eth0: adding default route via 10.0.0.1
eth0: adding host route to 168.63.129.16 via 10.0.0.1
eth0: adding host route to 169.254.169.254 via 10.0.0.1
```
With debug:
```
2026-01-28 19:52:56,822 - performance.py[DEBUG]: Running ['dhcpcd', '--ipv4only', '--waitip', '--persistent', '--noarp', '--debug', '--script=/bin/true', 'eth0'] took 0.128 seconds
2026-01-28 19:52:56,822 - azure.py[DEBUG]: dhcp client stdout for interface=eth0:
2026-01-28 19:52:56,822 - azure.py[DEBUG]: dhcp client stderr for interface=eth0: dhcpcd-10.0.6 starting
spawned manager process on PID 527
chrooting as dhcpcd to /usr/lib/dhcpcd
sandbox: seccomp
spawned privileged proxy on PID 528
spawned controller proxy on PID 529
eth0: executing: /bin/true PREINIT
eth0: executing: /bin/true CARRIER
DUID 00:01:00:01:31:0d:25:98:60:45:bd:86:6f:e1
eth0: IAID bd:86:6f:e1
eth0: delaying IPv4 for 0.0 seconds
eth0: reading lease: /var/lib/dhcpcd/eth0.lease
eth0: soliciting a DHCP lease
eth0: spawned BPF BOOTP on PID 535
eth0: sending DISCOVER (xid 0x3793814b), next in 4.6 seconds
eth0: offered 10.0.0.4 from 168.63.129.16 LVL101082702015SOC
eth0: process BPF BOOTP already started on pid 535
eth0: sending REQUEST (xid 0x3793814b), next in 4.4 seconds
eth0: acknowledged 10.0.0.4 from 168.63.129.16 LVL101082702015SOC
eth0: leased 10.0.0.4 for infinity
eth0: writing lease: /var/lib/dhcpcd/eth0.lease
eth0: adding IP address 10.0.0.4/16 broadcast 10.0.255.255
eth0: using Classless Static Routes
eth0: adding route to 10.0.0.0/16
eth0: adding default route via 10.0.0.1
eth0: adding host route to 168.63.129.16 via 10.0.0.1
eth0: adding host route to 169.254.169.254 via 10.0.0.1
eth0: executing: /bin/true BOUND
forked to background
```
One interesting detail I noticed is that a persistent lease file
may be used for reboots and DISCOVER is skipped:
```
2026-01-28 19:49:57,987 - performance.py[DEBUG]: Running ['dhcpcd', '--ipv4only', '--waitip', '--persistent', '--noarp', '--debug', '--script=/bin/true', 'eth0'] took 0.386 seconds
2026-01-28 19:49:57,987 - azure.py[DEBUG]: dhcp client stdout for interface=eth0:
2026-01-28 19:49:57,987 - azure.py[DEBUG]: dhcp client stderr for interface=eth0: dhcpcd-10.0.6 starting
chrooting as dhcpcd to /usr/lib/dhcpcd
sandbox: seccomp
spawned manager process on PID 527
spawned privileged proxy on PID 528
spawned controller proxy on PID 529
DUID 00:01:00:01:31:0d:0f:cd:60:45:bd:86:6f:e1
eth0: executing: /bin/true PREINIT
eth0: executing: /bin/true CARRIER
eth0: IAID bd:86:6f:e1
eth0: delaying IPv4 for 0.4 seconds
eth0: reading lease: /var/lib/dhcpcd/eth0.lease
eth0: rebinding lease of 10.0.0.4
eth0: spawned BPF ARP 10.0.0.4 on PID 545
eth0: sending REQUEST (xid 0x3740297a), next in 4.5 seconds
eth0: spawned BPF BOOTP on PID 546
eth0: acknowledged 10.0.0.4 from 168.63.129.16 LVL101082702015SOC
eth0: leased 10.0.0.4 for infinity
eth0: writing lease: /var/lib/dhcpcd/eth0.lease
eth0: adding IP address 10.0.0.4/16 broadcast 10.0.255.255
eth0: using Classless Static Routes
eth0: adding route to 10.0.0.0/16
eth0: adding default route via 10.0.0.1
eth0: adding host route to 168.63.129.16 via 10.0.0.1
eth0: adding host route to 169.254.169.254 via 10.0.0.1
eth0: executing: /bin/true REBOOT
forked to background
```
The --debug option has been around forever for dhcpcd so it should
be safe. We can see it the oldest tagged version in git and
Ubuntu 14.04's manpage:
https://manpages.ubuntu.com/manpages//trusty/man8/dhcpcd-bin.8.html
Signed-off-by: Chris Patterson <cpatterson@microsoft.com>1 parent 80bead0 commit fafee3b
2 files changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
| 664 | + | |
664 | 665 | | |
665 | 666 | | |
666 | 667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1330 | 1330 | | |
1331 | 1331 | | |
1332 | 1332 | | |
| 1333 | + | |
1333 | 1334 | | |
1334 | 1335 | | |
1335 | 1336 | | |
| |||
1376 | 1377 | | |
1377 | 1378 | | |
1378 | 1379 | | |
| 1380 | + | |
1379 | 1381 | | |
1380 | 1382 | | |
1381 | 1383 | | |
| |||
0 commit comments