Skip to content

Commit

Permalink
Fix Deletion of IPv6 default policy routes
Browse files Browse the repository at this point in the history
On Deletion, the default route got its dst attribute replaced with an
empty IPv4 address even with IPv6.
  • Loading branch information
LionelJouin committed Nov 16, 2023
1 parent 8c11691 commit 8e02860
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8e02860

Please sign in to comment.