From f57d05e02a0c4dc9e64c8bccab604c5f9583692f Mon Sep 17 00:00:00 2001 From: Frederik Schwan Date: Thu, 30 Apr 2020 02:13:58 +0200 Subject: [PATCH] fix: ipv6 static default gateway not set if gateway is a LL unicast address The source address is set by default, which leads to RNETLINK errors, when the Global Unicast Address is passed as a Source to a LL Unicast Gateway. Errors of RTNETLINK are now logged. Signed-off-by: Frederik Schwan --- internal/app/networkd/pkg/nic/nic.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/app/networkd/pkg/nic/nic.go b/internal/app/networkd/pkg/nic/nic.go index 37cb12095..0dc939b20 100644 --- a/internal/app/networkd/pkg/nic/nic.go +++ b/internal/app/networkd/pkg/nic/nic.go @@ -367,9 +367,15 @@ func (n *NetworkInterface) configureInterface(method address.Addressing, link *n gw = nil } - // Any errors here would be non-fatal, so we'll just ignore them - //nolint: errcheck - n.rtnlConn.RouteAddSrc(method.Link(), *r.Dest, method.Address(), gw) + src := method.Address() + // if destination is the ipv6 route,and gateway is LL do not pass a src address to set the default geteway + if net.IPv6zero.Equal(r.Dest.IP) && gw.IsLinkLocalUnicast() { + src = nil + } + + if err := n.rtnlConn.RouteAddSrc(method.Link(), *r.Dest, src, gw); err != nil { + log.Println("failed to configure route: " + err.Error()) + } } return nil