diff --git a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go index dc6e640c..2472da12 100644 --- a/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go +++ b/pkg/kernel/networkservice/connectioncontextkernel/ipcontext/iprule/common.go @@ -246,17 +246,12 @@ func del(ctx context.Context, conn *networkservice.Connection, tableIDs *Map) er return errors.WithStack(err) } defer netlinkHandle.Close() - ps, ok := tableIDs.Load(conn.GetId()) + ps, ok := tableIDs.LoadAndDelete(conn.GetId()) if ok { for tableID, policy := range ps { if err := delRule(ctx, netlinkHandle, policy, tableID); err != nil { return errors.WithStack(err) } - delete(ps, tableID) - tableIDs.Store(conn.GetId(), ps) - } - if len(ps) == 0 { - tableIDs.Delete(conn.GetId()) } } }