diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go index 3763cf3..32f4453 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go @@ -329,14 +329,16 @@ func delRuleOnly(ctx context.Context, handle *netlink.Handle, policy *networkser return nil } -func delRule(ctx context.Context, handle *netlink.Handle, policy *networkservice.PolicyRoute, tableID, linkIndex int, nsRTableKey netnsRTableNextID, nsRTableNextIDToConnID *genericsync.Map[netnsRTableNextID, string]) error { - if err := flushTable(ctx, handle, tableID, linkIndex); err != nil { - return err +func delRule(ctx context.Context, handle *netlink.Handle, policy *networkservice.PolicyRoute, tableID, linkIndex int, nsRTableKey netnsRTableNextID, nsRTableNextIDToConnID *genericsync.Map[netnsRTableNextID, string]) (err error) { + if err = flushTable(ctx, handle, tableID, linkIndex); err == nil { + nsRTableNextIDToConnID.Delete(nsRTableKey) } - nsRTableNextIDToConnID.Delete(nsRTableKey) - - return delRuleOnly(ctx, handle, policy) + if errDelRule := delRuleOnly(ctx, handle, policy); errDelRule != nil { + return errDelRule + } + return err } + func flushTable(ctx context.Context, handle *netlink.Handle, tableID, linkIndex int) error { routes, err := handle.RouteListFiltered(netlink.FAMILY_ALL, &netlink.Route{