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) <noreply@anthropic.com>
This commit is contained in:
parent
b3f4c5f42b
commit
fc07ac507d
1 changed files with 2 additions and 0 deletions
|
|
@ -96,6 +96,7 @@ func (c *Client) FeedFrame(frame []byte) {
|
||||||
// sendFrame is called to transmit each Ethernet frame through the tunnel.
|
// sendFrame is called to transmit each Ethernet frame through the tunnel.
|
||||||
// Returns the lease on success.
|
// Returns the lease on success.
|
||||||
func (c *Client) Run(sendFrame func([]byte) error, timeout time.Duration) (*Lease, error) {
|
func (c *Client) Run(sendFrame func([]byte) error, timeout time.Duration) (*Lease, error) {
|
||||||
|
c.xid = rand.Uint32()
|
||||||
// Send DISCOVER
|
// Send DISCOVER
|
||||||
disc := c.buildDiscover()
|
disc := c.buildDiscover()
|
||||||
if err := sendFrame(disc); err != nil {
|
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.
|
// In RENEWING state: ciaddr = current IP, no requested-IP or server-ID options.
|
||||||
// Returns the renewed lease on ACK, or error on NAK/timeout.
|
// 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) {
|
func (c *Client) Renew(currentIP net.IP, sendFrame func([]byte) error, timeout time.Duration) (*Lease, error) {
|
||||||
|
c.xid = rand.Uint32()
|
||||||
var ciaddr [4]byte
|
var ciaddr [4]byte
|
||||||
copy(ciaddr[:], currentIP.To4())
|
copy(ciaddr[:], currentIP.To4())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue