Bekei Park via dev <[email protected]> writes: > A conntrack flush that matches on anything but a full 5-tuple (zone > with mark, labels or a partial tuple) is done by ct_dpif_flush_tuple(): > it dumps the zone and deletes the matching entries one by one. If one > of these deletes fails, the loop breaks and all the matching entries > that come later in the dump are left in the connection tracker. > > The dump is a snapshot. With the kernel datapath an entry can expire, > or be removed by someone else, after it was dumped and before its > delete is sent. That delete fails with ENOENT, so a single short-lived > entry is enough to cut the flush short. The window grows with the size > of the conntrack hash table, because the kernel walks all the buckets > while it fills a dump message. > > The error is also lost when the flush is requested with NXT_CT_FLUSH: > ofproto ignores the result of ct_dpif_flush(), so nothing is logged and > the controller cannot tell that entries were left behind.
Do you have plans to try and address this? This is probably important to include as separate patch with this work to help propagate the error message to the controller. > OVN relies on this path to remove the connections of an ECMP next hop > that went away (match on ct_label). The entries that survive keep > established connections pointed at the removed next hop. > > That this loop should not bail out on the first failure was already > noted when the flush learned to delete SCTP entries [0], but only that > one cause of a failed delete was removed. > > Treat ENOENT as success, since the entry is gone already, and do not > stop on other errors either: log them and return the first one after > the whole dump has been processed. > > Reproduced with the kernel datapath in a separate network namespace: > 60000 entries with a 15 second timeout and 2000 long-lived ones in one > zone, all with the same mark, and 'ovs-dpctl flush-conntrack zone=N > mark=M' started while the short-lived ones expire. Without the fix > the command fails with "No such file or directory" and most of the > long-lived entries remain (5 runs out of 5). With the fix all the > entries are removed (5 runs out of 5). > > [0] https://mail.openvswitch.org/pipermail/ovs-dev/2023-September/407696.html > > Fixes: a9ae73b916ba ("ofp, dpif: Allow CT flush based on partial match.") > Assisted-by: Claude Fable 5.2, Claude Code > Signed-off-by: Bekei Park <[email protected]> > --- > lib/ct-dpif.c | 22 +++++++++++++++++----- Please include a test for the ENOENT behavior, as well. > 1 file changed, 17 insertions(+), 5 deletions(-) > > diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c > index 5a836b668..055407298 100644 > --- a/lib/ct-dpif.c > +++ b/lib/ct-dpif.c > @@ -290,8 +290,10 @@ static int > ct_dpif_flush_tuple(struct dpif *dpif, const uint16_t *zone, > const struct ofp_ct_match *match) > { > + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5); > struct ct_dpif_dump_state *dump; > struct ct_dpif_entry cte; > + int flush_error = 0; > int error; > int tot_bkts; > > @@ -328,10 +330,20 @@ ct_dpif_flush_tuple(struct dpif *dpif, const uint16_t > *zone, > } > > if (ct_dpif_entry_cmp(&cte, match)) { > - error = dpif->dpif_class->ct_flush(dpif, &cte.zone, > - &cte.tuple_orig); > - if (error) { > - break; > + int err = dpif->dpif_class->ct_flush(dpif, &cte.zone, > + &cte.tuple_orig); > + > + /* The dump is a snapshot. An entry that expired or was removed > + * after it was dumped is already gone, which is what the flush > + * wants. Any other failure must not stop the flush either: the > + * remaining entries still have to be removed. */ > + if (err && err != ENOENT) { Previously, we had a built-in gate around all errors. I think ENOENT makes sense to 'drop', but the other errors may need to be considered more carefully. For example EOPNOTSUPP, or ENOBUFS are really truly 'show-stopper' errors, and we wouldn't want to continue processing the tuple flush in those cases. We don't want to flood the system with work it won't be able to complete. > + VLOG_WARN_RL(&rl, "%s: failed to flush a conntrack entry " > + "in zone %"PRIu16" (%s)", dpif_name(dpif), > + cte.zone, ovs_strerror(err)); You need to consider that this will also run against the usersapce conntracker. The relevant part:: int conntrack_flush_tuple(struct conntrack *ct, const struct ct_dpif_tuple *tuple, uint16_t zone) { ... if (conn) { conn_clean(ct, conn); } else { VLOG_WARN("Tuple not found"); return ENOENT; } } The issue I see is that we can now flood the log with the tuple-not-found log. I think that this change also needs to include a ratelimit for that. Maybe we could also reconsider whether to VLOG_WARN on a tuple-not-found at all (maybe VLOG_INFO_RL instead for that code). > + if (!flush_error) { > + flush_error = err; > + } > } > } > } > @@ -340,7 +352,7 @@ ct_dpif_flush_tuple(struct dpif *dpif, const uint16_t > *zone, > } > > ct_dpif_dump_done(dump); > - return error; > + return error ? error : flush_error; > } > > /* Flush the entries in the connection tracker used by 'dpif'. The _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
