fix: dhcpv6 leasetime segfault loop

We are trying to get an IP-address lifetime, but we do not have it yet.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
Serge Logvinov 2022-05-12 09:43:47 +00:00 committed by Andrey Smirnov
parent afb679586a
commit 91a49c4e7c
No known key found for this signature in database
GPG Key ID: 7B26396447AB6DFD

View File

@ -145,7 +145,7 @@ func (d *DHCP6) TimeServerSpecs() []network.TimeServerSpecSpec {
return d.timeservers
}
func (d *DHCP6) parseReply(reply *dhcpv6.Message) {
func (d *DHCP6) parseReply(reply *dhcpv6.Message) (leaseTime time.Duration) {
d.mu.Lock()
defer d.mu.Unlock()
@ -165,6 +165,8 @@ func (d *DHCP6) parseReply(reply *dhcpv6.Message) {
ConfigLayer: network.ConfigOperator,
},
}
leaseTime = reply.Options.OneIANA().Options.OneAddress().ValidLifetime
} else {
d.addresses = nil
}
@ -215,6 +217,8 @@ func (d *DHCP6) parseReply(reply *dhcpv6.Message) {
} else {
d.timeservers = nil
}
return leaseTime
}
func (d *DHCP6) renew(ctx context.Context) (time.Duration, error) {
@ -243,9 +247,7 @@ func (d *DHCP6) renew(ctx context.Context) (time.Duration, error) {
d.logger.Debug("DHCP6 REPLY", zap.String("link", d.linkName), zap.String("dhcp", collapseSummary(reply.Summary())))
d.parseReply(reply)
return reply.Options.OneIANA().Options.OneAddress().ValidLifetime, nil
return d.parseReply(reply), nil
}
func (d *DHCP6) waitIPv6LinkReady(ctx context.Context, iface *net.Interface) error {