Skip to content

Commit

Permalink
Fix Missing Policy Routes
Browse files Browse the repository at this point in the history
Issue: networkservicemesh#685

Try to delete the rule even if the route deletion fails.
For example when the belonging interface is deleted in parallel.
  • Loading branch information
ljkiraly committed Oct 28, 2024
1 parent d88619c commit 5add802
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 5add802

Please sign in to comment.