Skip to content

Commit 66a8216

Browse files
committed
fix(linux_networking.go): filter routes to be deleted by table
Previously we were accidentally deleting all routes that were found, this mimics the previous functionality better by only deleting external IPs that were found in the externalIPRouteTable that are no longer in the activeExternalIPs map. Also improves logging around any routes that are deleted as this is likely of interest to all kube-router administrators.
1 parent f871817 commit 66a8216

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/controllers/proxy/linux_networking.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,18 @@ func (ln *linuxNetworking) setupRoutesForExternalIPForDSR(serviceInfoMap service
631631
}
632632

633633
// check if there are any pbr in externalIPRouteTableID for external IP's
634-
routes, err := netlink.RouteList(nil, nFamily)
634+
nRoute := &netlink.Route{
635+
Family: nFamily,
636+
Table: externalIPRouteTableID,
637+
}
638+
routes, err := netlink.RouteListFiltered(nFamily, nRoute, netlink.RT_FILTER_TABLE)
635639
if err != nil {
636640
return fmt.Errorf("failed to list route for external IP's due to: %s", err)
637641
}
638642
for idx, route := range routes {
639643
ip := route.Src.String()
640644
if !activeExternalIPs[ip] {
645+
klog.Infof("Deleting route: %+v in custom route table for external IP's as it is not active", route)
641646
err = netlink.RouteDel(&routes[idx])
642647
if err != nil {
643648
klog.Errorf("Failed to del route for %v in custom route table for external IP's due to: %s",

0 commit comments

Comments
 (0)