From: Ben Pfaff Date: Tue, 13 Apr 2010 23:49:22 +0000 (-0700) Subject: dpif: Make dpif_flow_get() results predictable on error. X-Git-Tag: v1.0.0~156 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b843fa1b41a6e9ed362e0414f0b3f6b42bfa3e66;p=sliver-openvswitch.git dpif: Make dpif_flow_get() results predictable on error. If dpif_flow_get()'s caller is less cautious than it should be, then it will get surprising results when it looks at the returned flow on error. This commit at least gives it plausible results. --- diff --git a/lib/dpif.c b/lib/dpif.c index 8e5cf9ffc..186f165c1 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -724,6 +724,11 @@ dpif_flow_get(const struct dpif *dpif, struct odp_flow *flow) if (!error) { error = flow->stats.error; } + if (error) { + /* Make the results predictable on error. */ + memset(&flow->stats, 0, sizeof flow->stats); + flow->n_actions = 0; + } if (should_log_flow_message(error)) { log_flow_operation(dpif, "flow_get", error, flow); }