From: Ethan Jackson Date: Tue, 28 May 2013 20:29:50 +0000 (-0700) Subject: ofproto-dpif: Avoid redundant facet_find() in facet_lookup_valid(). X-Git-Tag: sliver-openvswitch-1.10.90-3~6^2~199 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5bf64ade7ffc49b90090f4b9ab8e8d61787edd5f;p=sliver-openvswitch.git ofproto-dpif: Avoid redundant facet_find() in facet_lookup_valid(). Suggested-by: Ben Pfaff Signed-off-by: Ethan Jackson --- diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index ae59eda02..01eeed998 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -515,7 +515,7 @@ static struct facet *facet_find(struct ofproto_dpif *, const struct flow *, uint32_t hash); static struct facet *facet_lookup_valid(struct ofproto_dpif *, const struct flow *, uint32_t hash); -static void facet_revalidate(struct facet *); +static bool facet_revalidate(struct facet *); static bool facet_check_consistency(struct facet *); static void facet_flush_stats(struct facet *); @@ -4894,10 +4894,8 @@ facet_lookup_valid(struct ofproto_dpif *ofproto, const struct flow *flow, if (facet && (ofproto->backer->need_revalidate || tag_set_intersects(&ofproto->backer->revalidate_set, - facet->tags))) { - facet_revalidate(facet); - - /* facet_revalidate() may have destroyed 'facet'. */ + facet->tags)) + && !facet_revalidate(facet)) { facet = facet_find(ofproto, flow, hash); } @@ -5069,8 +5067,10 @@ facet_check_consistency(struct facet *facet) * where it is and recompiles its actions anyway. * * - If any of 'facet''s subfacets correspond to a new flow according to - * ofproto_receive(), 'facet' is removed. */ -static void + * ofproto_receive(), 'facet' is removed. + * + * Returns true if 'facet' is still valid. False if 'facet' was removed. */ +static bool facet_revalidate(struct facet *facet) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto); @@ -5105,7 +5105,7 @@ facet_revalidate(struct facet *facet) || recv_ofproto != ofproto || memcmp(&recv_flow, &facet->flow, sizeof recv_flow)) { facet_remove(facet); - return; + return false; } } @@ -5185,6 +5185,8 @@ facet_revalidate(struct facet *facet) facet->used = new_rule->up.created; facet->prev_used = facet->used; } + + return true; } /* Updates 'facet''s used time. Caller is responsible for calling