summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2016-01-20 16:53:01 -0800
committerBen Pfaff <blp@ovn.org>2016-01-21 13:51:03 -0800
commit29b1ea3f2e14162f11c6cd8f25a2f68a3ad754df (patch)
tree909d32fb717c570e188bd4801bc24e8c7f127159 /ofproto
parentaa07423103f0593e040240313f94e89ad43e674c (diff)
downloadopenvswitch-29b1ea3f2e14162f11c6cd8f25a2f68a3ad754df.tar.gz
ofproto-dpif-xlate: Put recirc_state, not recirc_id_node, in xlate_in.
This will make it possible, in an upcoming commit, to construct a recirc_state locally on the stack to pass to xlate_actions(). It would also be possible to construct and pass a recirc_id_node on the stack, but the translation process only uses the recirc_state anyway. The alternative here of having upcall_xlate() know that it can recover the recirc_id_node from the recirc_state isn't great either; it's debatable which is the better approach. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/ofproto-dpif-rid.h6
-rw-r--r--ofproto/ofproto-dpif-upcall.c4
-rw-r--r--ofproto/ofproto-dpif-xlate.c13
-rw-r--r--ofproto/ofproto-dpif-xlate.h2
4 files changed, 18 insertions, 7 deletions
diff --git a/ofproto/ofproto-dpif-rid.h b/ofproto/ofproto-dpif-rid.h
index 04ec03720..85ec24a93 100644
--- a/ofproto/ofproto-dpif-rid.h
+++ b/ofproto/ofproto-dpif-rid.h
@@ -184,6 +184,12 @@ void recirc_free_ofproto(struct ofproto_dpif *, const char *ofproto_name);
const struct recirc_id_node *recirc_id_node_find(uint32_t recirc_id);
+static inline struct recirc_id_node *
+recirc_id_node_from_state(const struct recirc_state *state)
+{
+ return CONTAINER_OF(state, struct recirc_id_node, state);
+}
+
static inline bool recirc_id_node_try_ref_rcu(const struct recirc_id_node *n_)
{
struct recirc_id_node *node = CONST_CAST(struct recirc_id_node *, n_);
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index b50520609..240bd92d1 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1074,8 +1074,8 @@ upcall_xlate(struct udpif *udpif, struct upcall *upcall,
* upcalls using recirculation ID for which no context can be
* found). We may still execute the flow's actions even if we
* don't install the flow. */
- upcall->recirc = xin.recirc;
- upcall->have_recirc_ref = recirc_id_node_try_ref_rcu(xin.recirc);
+ upcall->recirc = recirc_id_node_from_state(xin.recirc);
+ upcall->have_recirc_ref = recirc_id_node_try_ref_rcu(upcall->recirc);
}
} else {
/* For non-miss upcalls, we are either executing actions (one of which
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 8ab4b2aeb..65491918a 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -4828,9 +4828,14 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto,
xin->odp_actions = odp_actions;
/* Do recirc lookup. */
- xin->recirc = flow->recirc_id
- ? recirc_id_node_find(flow->recirc_id)
- : NULL;
+ xin->recirc = NULL;
+ if (flow->recirc_id) {
+ const struct recirc_id_node *node
+ = recirc_id_node_find(flow->recirc_id);
+ if (node) {
+ xin->recirc = &node->state;
+ }
+ }
}
void
@@ -5138,7 +5143,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
COVERAGE_INC(xlate_actions);
if (xin->recirc) {
- const struct recirc_state *state = &xin->recirc->state;
+ const struct recirc_state *state = xin->recirc;
xlate_report(&ctx, "Restoring state post-recirculation:");
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index a135d8f4d..3b062850d 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -142,7 +142,7 @@ struct xlate_in {
/* The recirculation context related to this translation, as returned by
* xlate_lookup. */
- const struct recirc_id_node *recirc;
+ const struct recirc_state *recirc;
};
void xlate_ofproto_set(struct ofproto_dpif *, const char *name, struct dpif *,