dhcp6: work around ipv6ZoneCache issue (fixes tests)

This commit is contained in:
Michael Stapelberg 2018-06-02 17:33:01 +02:00
parent ddc110e826
commit aec417cfbc

View File

@ -50,6 +50,11 @@ type Client struct {
}
func NewClient(cfg ClientConfig) (*Client, error) {
iface, err := net.InterfaceByName(cfg.InterfaceName)
if err != nil {
return nil, err
}
// if no LocalAddr is specified, get the interface's link-local address
laddr := cfg.LocalAddr
if laddr == nil {
@ -60,7 +65,11 @@ func NewClient(cfg ClientConfig) (*Client, error) {
laddr = &net.UDPAddr{
IP: *llAddr,
Port: dhcpv6.DefaultClientPort,
Zone: cfg.InterfaceName,
// HACK: Zone should ideally be cfg.InterfaceName, but Gos
// ipv6ZoneCache is only updated every 60s, so the addition of the
// veth interface will not be picked up for all tests after the
// first test.
Zone: strconv.Itoa(iface.Index),
}
}