From fc07ac507db8e6dc607d0f950936e810889d2603 Mon Sep 17 00:00:00 2001 From: Git Sagar Date: Sat, 6 Jun 2026 22:58:00 +0530 Subject: [PATCH] dhcp: generate fresh xid per exchange New random transaction ID for each DHCP exchange (initial and renewal) to avoid matching stale responses from previous transactions. Co-Authored-By: Claude Opus 4.6 (1M context) --- pkg/dhcp/dhcp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/dhcp/dhcp.go b/pkg/dhcp/dhcp.go index a5be160..7108eed 100644 --- a/pkg/dhcp/dhcp.go +++ b/pkg/dhcp/dhcp.go @@ -96,6 +96,7 @@ func (c *Client) FeedFrame(frame []byte) { // sendFrame is called to transmit each Ethernet frame through the tunnel. // Returns the lease on success. func (c *Client) Run(sendFrame func([]byte) error, timeout time.Duration) (*Lease, error) { + c.xid = rand.Uint32() // Send DISCOVER disc := c.buildDiscover() if err := sendFrame(disc); err != nil { @@ -154,6 +155,7 @@ func (c *Client) Run(sendFrame func([]byte) error, timeout time.Duration) (*Leas // In RENEWING state: ciaddr = current IP, no requested-IP or server-ID options. // Returns the renewed lease on ACK, or error on NAK/timeout. func (c *Client) Renew(currentIP net.IP, sendFrame func([]byte) error, timeout time.Duration) (*Lease, error) { + c.xid = rand.Uint32() var ciaddr [4]byte copy(ciaddr[:], currentIP.To4())