ofproto-dpif-xlate: Put recirc_state, not recirc_id_node, in xlate_in.
authorBen Pfaff <blp@ovn.org>
Thu, 21 Jan 2016 00:53:01 +0000 (16:53 -0800)
committerBen Pfaff <blp@ovn.org>
Thu, 21 Jan 2016 21:51:03 +0000 (13:51 -0800)
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>
ofproto/ofproto-dpif-rid.h
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif-xlate.h

index 04ec037..85ec24a 100644 (file)
@@ -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_);
index b505206..240bd92 100644 (file)
@@ -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
index 8ab4b2a..6549191 100644 (file)
@@ -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:");
 
index a135d8f..3b06285 100644 (file)
@@ -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 *,