From 840c44a7e3139b6370fa518ef8dfc41fb33df229 Mon Sep 17 00:00:00 2001 From: Lionel Jouin Date: Thu, 16 Nov 2023 18:36:33 +0100 Subject: [PATCH] Fix Deletion of IPv6 default policy routes On Deletion, the default route got its dst attribute replaced with an empty IPv4 address even with IPv6. Signed-off-by: Lionel Jouin --- .../connectioncontextkernel/ipcontext/iprule/common.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go index 17163995..24620c3c 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go @@ -350,7 +350,11 @@ func flushTable(ctx context.Context, handle *netlink.Handle, tableID, linkIndex for i := 0; i < len(routes); i++ { // This conditions means the default route. We should delete it properly if routes[i].Dst == nil { - routes[i].Dst = &net.IPNet{IP: net.IPv4zero, Mask: net.CIDRMask(0, 32)} + if routes[i].Family == netlink.FAMILY_V4 { + routes[i].Dst = &net.IPNet{IP: net.IPv4zero, Mask: net.CIDRMask(0, 32)} + } else if routes[i].Family == netlink.FAMILY_V6 { + routes[i].Dst = &net.IPNet{IP: net.IPv6zero, Mask: net.CIDRMask(0, 128)} + } } err := handle.RouteDel(&routes[i]) if err != nil {