[ovs-dev] [PATCH 01/26] ofproto-dpif-xlate: Initialize '*xout' all together at beginning.
Ben Pfaff
blp at nicira.com
Thu Jul 30 06:42:21 UTC 2015
To my mind, this is a good way to ensure that '*xout' gets initialized
properly in every execution. By using an initializer rather than a
series of assignment statements, we can be assured that every member
gets initialized.
This commit makes xlate_actions() more expensive because struct
xlate_out is large and this assignment will initialize all of it due to
C rules. Later commits will fix this up by removing all of the large
members, reducing xlate_out to only a few bytes total.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
ofproto/ofproto-dpif-xlate.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 125d4c6..b6d5d15 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4720,6 +4720,17 @@ too_many_output_actions(const struct ofpbuf *odp_actions OVS_UNUSED)
void
xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
{
+ *xout = (struct xlate_out) {
+ .slow = 0,
+ .fail_open = false,
+ .has_learn = false,
+ .has_normal = false,
+ .has_fin_timeout = false,
+ .nf_output_iface = NF_OUT_DROP,
+ .mirrors = 0,
+ .n_recircs = 0,
+ };
+
struct xlate_cfg *xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp);
struct flow_wildcards *wc = NULL;
struct flow *flow = &xin->flow;
@@ -4760,13 +4771,6 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
ctx.xin = xin;
ctx.xout = xout;
- ctx.xout->slow = 0;
- ctx.xout->has_learn = false;
- ctx.xout->has_normal = false;
- ctx.xout->has_fin_timeout = false;
- ctx.xout->nf_output_iface = NF_OUT_DROP;
- ctx.xout->mirrors = 0;
- ctx.xout->n_recircs = 0;
xout->odp_actions = xin->odp_actions;
if (!xout->odp_actions) {
--
2.1.3
More information about the dev
mailing list