Skip to content

Commit 6284877

Browse files
fsgh42smira
authored andcommitted
fix: use correct dhcp option for unicast dhcp renewal
Talos attempts to do unicast DHCP renewal, if possible. However, if the DHCP server announces a PXE server in DHCP replies, talos erroneously send packets to this server, instead of the actual DHCP server. Because it falls back to broadcast, this issue did not surface. On networks where the PXE server has a different IP than the DHCP server (not uncommon in commercial and homelab setups), talos continuously logged this error: ``` got an error while processing the request: no matching response packet received ``` Use Option 54 (`server-identifier`) as the unicast destination, not `siaddr` (`ServerIPAddr`), which indicates the the PXE `next server` field (RFC 2131 §2) and is not the correct field to use in this context. Signed-off-by: Fritz Schaal <fritz.schaal@siderolabs.com> (cherry picked from commit 55b8721)
1 parent dcf23be commit 6284877

File tree

1 file changed

+4
-4
lines changed
  • internal/app/machined/pkg/controllers/network/operator

1 file changed

+4
-4
lines changed

internal/app/machined/pkg/controllers/network/operator/dhcp4.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,15 @@ func (d *DHCP4) parseNetworkConfigFromAck(ack *dhcpv4.DHCPv4, useHostname bool)
463463
func (d *DHCP4) newClient() (*nclient4.Client, error) {
464464
var clientOpts []nclient4.ClientOpt
465465

466-
// We have an existing lease, target the server with unicast
467-
if d.lease != nil && !d.lease.ACK.ServerIPAddr.IsUnspecified() {
466+
// We have an existing lease, target the server with unicast.
467+
if d.lease != nil && d.lease.ACK.ServerIdentifier() != nil {
468468
// RFC 2131, section 4.3.2:
469469
// DHCPREQUEST generated during RENEWING state:
470470
// ... This message will be unicast, so no relay
471471
// agents will be involved in its transmission.
472472
clientOpts = append(clientOpts,
473473
nclient4.WithServerAddr(&net.UDPAddr{
474-
IP: d.lease.ACK.ServerIPAddr,
474+
IP: d.lease.ACK.ServerIdentifier(),
475475
Port: nclient4.ServerPort,
476476
}),
477477
// WithUnicast must be specified manually, WithServerAddr is not enough
@@ -556,7 +556,7 @@ func (d *DHCP4) requestRenew(ctx context.Context, hostname network.HostnameStatu
556556
addresses := d.AddressSpecs()
557557

558558
switch {
559-
case d.lease != nil && !d.lease.ACK.ServerIPAddr.IsUnspecified():
559+
case d.lease != nil && d.lease.ACK.ServerIdentifier() != nil:
560560
d.logger.Debug("DHCP RENEW", zap.String("link", d.linkName))
561561
d.lease, err = client.Renew(ctx, d.lease, mods...)
562562
case d.lease != nil && d.lease.Offer != nil:

0 commit comments

Comments
 (0)