@@ -1909,12 +1909,10 @@ populate_xcache(struct udpif *udpif, struct udpif_key *ukey,
}
static enum reval_result
-revalidate_ukey__(struct udpif *udpif, struct udpif_key *ukey,
+revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey,
uint16_t tcp_flags, struct ofpbuf *odp_actions,
- uint64_t reval_seq, struct recirc_refs *recircs)
- OVS_REQUIRES(ukey->mutex)
+ struct recirc_refs *recircs, struct xlate_cache *xcache)
{
- bool need_revalidate = (ukey->reval_seq != reval_seq);
struct xlate_out *xoutp;
struct netflow *netflow;
struct flow_wildcards dp_mask, wc;
@@ -1922,30 +1920,19 @@ revalidate_ukey__(struct udpif *udpif, struct udpif_key *ukey,
struct reval_context ctx = {
.odp_actions = odp_actions,
.netflow = &netflow,
- .wc = need_revalidate ? &wc : NULL,
+ .xcache = xcache,
+ .wc = &wc,
};
result = UKEY_DELETE;
xoutp = NULL;
netflow = NULL;
- if (need_revalidate) {
- xlate_cache_clear(ukey->xcache);
- }
- if (!ukey->xcache) {
- ukey->xcache = xlate_cache_new();
- }
- ctx.xcache = ukey->xcache;
if (xlate_ukey(udpif, ukey, tcp_flags, &ctx)) {
goto exit;
}
xoutp = &ctx.xout;
- if (!need_revalidate) {
- result = UKEY_KEEP;
- goto exit;
- }
-
if (xoutp->slow) {
ofpbuf_clear(odp_actions);
compose_slow_path(udpif, xoutp, &ctx.flow, ctx.flow.in_port.odp_port,
@@ -2027,34 +2014,28 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey,
? stats->n_bytes - ukey->stats.n_bytes
: 0);
- if (need_revalidate
- && !should_revalidate(udpif, push.n_packets, ukey->stats.used)) {
- goto exit;
- }
-
- /* We will push the stats, so update the ukey stats cache. */
- if (!push.n_packets && !need_revalidate) {
+ if (need_revalidate) {
+ if (should_revalidate(udpif, push.n_packets, ukey->stats.used)) {
+ if (!ukey->xcache) {
+ ukey->xcache = xlate_cache_new();
+ } else {
+ xlate_cache_clear(ukey->xcache);
+ }
+ result = revalidate_ukey__(udpif, ukey, push.tcp_flags,
+ odp_actions, recircs, ukey->xcache);
+ } /* else delete; too expensive to revalidate */
+ } else if (!push.n_packets || ukey->xcache
+ || !populate_xcache(udpif, ukey, push.tcp_flags)) {
result = UKEY_KEEP;
- goto exit;
}
- if (!need_revalidate) {
- if (!push.n_packets || ukey->xcache
- || !populate_xcache(udpif, ukey, push.tcp_flags)) {
- result = UKEY_KEEP;
- goto exit;
- }
- }
-
- result = revalidate_ukey__(udpif, ukey, push.tcp_flags, odp_actions,
- reval_seq, recircs);
-exit:
/* Stats for deleted flows will be attributed upon flow deletion. Skip. */
if (result != UKEY_DELETE) {
xlate_push_stats(ukey->xcache, &push);
ukey->stats = *stats;
ukey->reval_seq = reval_seq;
}
+
return result;
}
Simplify the remaining bits of the original revalidation codepath to only handle the "full-revalidation" case. Make the 'ukey' parameter purely const by pushing the only piece that gets changed into a separate argument. Signed-off-by: Joe Stringer <joe@ovn.org> --- ofproto/ofproto-dpif-upcall.c | 53 ++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 36 deletions(-)