From c78e1e4656dac59cf29bca92da423d94f48fd3f5 Mon Sep 17 00:00:00 2001 From: Akhil Velagapudi <4@4khil.com> Date: Wed, 22 Jun 2022 21:10:47 -0700 Subject: [PATCH] Use the same options for acquiring, renewing lease Currently, hostname is set in the original DHCPREQUEST but not the renewal. With some DHCP server implementations (such as FreeBSD dhcpd), this leads to the hostname being cleared in the lease table. This behavior is inconsistent with other DHCP clients such as dhclient which set the hostname on the renewal request as well. To fix, use the same options for acquire and renew. This is compatible with RFC 2131 (see table 5). Signed-off-by: Akhil Velagapudi <4@4khil.com> --- plugins/ipam/dhcp/lease.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ipam/dhcp/lease.go b/plugins/ipam/dhcp/lease.go index f8311e571..a64931bfa 100644 --- a/plugins/ipam/dhcp/lease.go +++ b/plugins/ipam/dhcp/lease.go @@ -308,7 +308,7 @@ func (l *DHCPLease) maintain() { log.Printf("%v: %v", l.clientID, err) if time.Now().After(l.rebindingTime) { - log.Printf("%v: renawal time expired, rebinding", l.clientID) + log.Printf("%v: renewal time expired, rebinding", l.clientID) state = leaseStateRebinding } } else { @@ -356,7 +356,7 @@ func (l *DHCPLease) renew() error { } defer c.Close() - opts := l.getOptionsWithClientId() + opts := l.getAllOptions() pkt, err := backoffRetry(l.resendMax, func() (*dhcp4.Packet, error) { ok, ack, err := DhcpRenew(c, *l.ack, opts) switch {