[ovs-dev] [netlink v5 39/61] ofproto: Generalize facet_put__() so that it is more useful.
Ben Pfaff
blp at nicira.com
Thu Jan 27 00:23:22 UTC 2011
This immediately makes it useful in facet_revalidate(). An upcoming
patch will add one more user.
This commit should not change any externally visible behavior. It
is a pure code refactoring.
Reviewed by Ethan Jackson <ethan at nicira.com>.
---
ofproto/ofproto.c | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index dd49225..2f6ca08 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2308,17 +2308,24 @@ facet_make_actions(struct ofproto *p, struct facet *facet,
static int
facet_put__(struct ofproto *ofproto, struct facet *facet,
- enum dpif_flow_put_flags flags)
+ const struct nlattr *actions, size_t actions_len,
+ struct dpif_flow_stats *stats)
{
uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
+ enum dpif_flow_put_flags flags;
struct ofpbuf key;
+ flags = DPIF_FP_CREATE | DPIF_FP_MODIFY;
+ if (stats) {
+ flags |= DPIF_FP_ZERO_STATS;
+ }
+
ofpbuf_use_stack(&key, keybuf, sizeof keybuf);
odp_flow_key_from_flow(&key, &facet->flow);
assert(key.base == keybuf);
return dpif_flow_put(ofproto->dpif, flags, key.data, key.size,
- facet->actions, facet->actions_len, NULL);
+ actions, actions_len, stats);
}
/* If 'facet' is installable, inserts or re-inserts it into 'p''s datapath. If
@@ -2327,14 +2334,12 @@ facet_put__(struct ofproto *ofproto, struct facet *facet,
static void
facet_install(struct ofproto *p, struct facet *facet, bool zero_stats)
{
- if (facet->may_install) {
- enum dpif_flow_put_flags flags = DPIF_FP_CREATE | DPIF_FP_MODIFY;
- if (zero_stats) {
- flags |= DPIF_FP_ZERO_STATS;
- }
- if (!facet_put__(p, facet, flags)) {
- facet->installed = true;
- }
+ struct dpif_flow_stats stats;
+
+ if (facet->may_install
+ && !facet_put__(p, facet, facet->actions, facet->actions_len,
+ zero_stats ? &stats : NULL)) {
+ facet->installed = true;
}
}
@@ -2501,18 +2506,10 @@ facet_revalidate(struct ofproto *ofproto, struct facet *facet)
* to talk to the datapath. */
if (actions_changed || ctx.may_set_up_flow != facet->installed) {
if (ctx.may_set_up_flow) {
- uint32_t keybuf[ODPUTIL_FLOW_KEY_U32S];
struct dpif_flow_stats stats;
- struct ofpbuf key;
-
- ofpbuf_use_stack(&key, keybuf, sizeof keybuf);
- odp_flow_key_from_flow(&key, &facet->flow);
-
- dpif_flow_put(ofproto->dpif,
- DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_ZERO_STATS,
- key.data, key.size,
- odp_actions->data, odp_actions->size, &stats);
+ facet_put__(ofproto, facet,
+ odp_actions->data, odp_actions->size, &stats);
facet_update_stats(ofproto, facet, &stats);
} else {
facet_uninstall(ofproto, facet);
--
1.7.1
More information about the dev
mailing list