xlate configuration (via xcfg) is already holding the references, so
the callers of xlate_receive() can safely use the returned pointers
upto the point when they quiesce.  If the objects are needed for
longer term, the callers can take additional references themselves.

Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
---
 ofproto/ofproto-dpif-upcall.c |   17 +++++++----------
 ofproto/ofproto-dpif-xlate.c  |   11 ++++++-----
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index a7c845e..418597c 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -162,8 +162,8 @@ struct upcall {
     struct xlate_out xout;         /* Result of xlate_actions(). */
     struct ofpbuf put_actions;     /* Actions 'put' in the fastapath. */
 
-    struct dpif_ipfix *ipfix;      /* IPFIX reference or NULL. */
-    struct dpif_sflow *sflow;      /* SFlow reference or NULL. */
+    struct dpif_ipfix *ipfix;      /* IPFIX pointer or NULL. */
+    struct dpif_sflow *sflow;      /* SFlow pointer or NULL. */
 
     bool vsp_adjusted;             /* 'packet' and 'flow' were adjusted for
                                       VLAN splinters if true. */
@@ -813,6 +813,9 @@ compose_slow_path(struct udpif *udpif, struct xlate_out 
*xout,
     odp_put_userspace_action(pid, &cookie, sizeof cookie.slow_path, buf);
 }
 
+/* The upcall must be destroyed with upcall_uninit() before quiescing,
+ * as the referred objects are guaranteed to exist only until the calling
+ * thread quiesces. */
 static int
 upcall_receive(struct upcall *upcall, const struct dpif_backer *backer,
                const struct ofpbuf *packet, enum dpif_upcall_type type,
@@ -913,8 +916,6 @@ upcall_uninit(struct upcall *upcall)
             xlate_out_uninit(&upcall->xout);
         }
         ofpbuf_uninit(&upcall->put_actions);
-        dpif_ipfix_unref(upcall->ipfix);
-        dpif_sflow_unref(upcall->sflow);
     }
 }
 
@@ -1361,11 +1362,8 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key 
*ukey,
     ok = true;
 
 exit:
-    if (netflow) {
-        if (!ok) {
-            netflow_flow_clear(netflow, &flow);
-        }
-        netflow_unref(netflow);
+    if (netflow && !ok) {
+        netflow_flow_clear(netflow, &flow);
     }
     xlate_out_uninit(xoutp);
     return ok;
@@ -1451,7 +1449,6 @@ push_dump_ops__(struct udpif *udpif, struct dump_op *ops, 
size_t n_ops)
 
                 if (netflow) {
                     netflow_flow_clear(netflow, &flow);
-                    netflow_unref(netflow);
                 }
             }
         }
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index b3a8183..ffb2580 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -969,8 +969,9 @@ xlate_lookup_ofproto(const struct dpif_backer *backer, 
const struct flow *flow,
 /* Given a datapath and flow metadata ('backer', and 'flow' respectively),
  * optionally populates 'ofproto' with the ofproto_dpif, 'ofp_in_port' with the
  * openflow in_port, and 'ipfix', 'sflow', and 'netflow' with the appropriate
- * handles for those protocols if they're enabled.  Caller is responsible for
- * unrefing them.
+ * handles for those protocols if they're enabled.  Caller may use the returned
+ * pointers until quiescing, for longer term use additional references must
+ * be taken.
  *
  * '*fp_in_port' is set to OFPP_NONE if 'flow''s in_port does not exist.
  *
@@ -999,15 +1000,15 @@ xlate_receive(const struct dpif_backer *backer, const 
struct flow *flow,
     }
 
     if (ipfix) {
-        *ipfix = dpif_ipfix_ref(xport->xbridge->ipfix);
+        *ipfix = xport->xbridge->ipfix;
     }
 
     if (sflow) {
-        *sflow = dpif_sflow_ref(xport->xbridge->sflow);
+        *sflow = xport->xbridge->sflow;
     }
 
     if (netflow) {
-        *netflow = netflow_ref(xport->xbridge->netflow);
+        *netflow = xport->xbridge->netflow;
     }
     return 0;
 }
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to