[ovs-dev] [netlink v4 39/52] datapath: Eliminate 'flags' member from odp_flow.

Ben Pfaff blp at nicira.com
Wed Jan 12 05:49:51 UTC 2011


Nothing was productively using the 'flags' member of odp_flow, so this
commit removes it.

ODPFF_ZERO_TCP_FLAGS isn't used at all (as of the previous commit).

ODPFF_EOF has been replaced by a special case of the 'key_len' member.
This will go away, too, once AF_NETLINK starts being used.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 datapath/datapath.c                     |   36 ++++++++++++-------------------
 datapath/odp-compat.h                   |    1 -
 include/openvswitch/datapath-protocol.h |   11 ++-------
 lib/dpif-linux.c                        |    6 +---
 lib/dpif-netdev.c                       |    5 +---
 lib/dpif-provider.h                     |    2 +-
 lib/dpif.c                              |    5 +--
 lib/dpif.h                              |    2 +-
 ofproto/ofproto.c                       |    2 +-
 9 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 38e0445..4456ec8 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -925,7 +925,6 @@ static int put_flow(struct datapath *dp, struct odp_flow_put __user *ufp)
 }
 
 static int do_answer_query(struct datapath *dp, struct sw_flow *flow,
-			   u32 query_flags,
 			   struct odp_flow_stats __user *ustats,
 			   struct nlattr __user *actions,
 			   u32 __user *actions_lenp)
@@ -936,8 +935,6 @@ static int do_answer_query(struct datapath *dp, struct sw_flow *flow,
 
 	spin_lock_bh(&flow->lock);
 	get_stats(flow, &stats);
-	if (query_flags & ODPFF_ZERO_TCP_FLAGS)
-		flow->tcp_flags = 0;
 
 	spin_unlock_bh(&flow->lock);
 
@@ -959,15 +956,14 @@ static int do_answer_query(struct datapath *dp, struct sw_flow *flow,
 }
 
 static int answer_query(struct datapath *dp, struct sw_flow *flow,
-			u32 query_flags, struct odp_flow __user *ufp)
+			struct odp_flow __user *ufp)
 {
 	struct nlattr __user *actions;
 
 	if (get_user(actions, (struct nlattr __user * __user *)&ufp->actions))
 		return -EFAULT;
 
-	return do_answer_query(dp, flow, query_flags, 
-			       &ufp->stats, actions, &ufp->actions_len);
+	return do_answer_query(dp, flow, &ufp->stats, actions, &ufp->actions_len);
 }
 
 static struct sw_flow *do_del_flow(struct datapath *dp, const struct nlattr __user *key, u32 key_len)
@@ -1009,7 +1005,7 @@ static int del_flow(struct datapath *dp, struct odp_flow __user *ufp)
 	if (IS_ERR(flow))
 		return PTR_ERR(flow);
 
-	error = answer_query(dp, flow, 0, ufp);
+	error = answer_query(dp, flow, ufp);
 	flow_deferred_free(flow);
 	return error;
 }
@@ -1032,7 +1028,7 @@ static int query_flow(struct datapath *dp, struct odp_flow __user *uflow)
 	flow_node = tbl_lookup(table, &flow.key, flow_hash(&key), flow_cmp);
 	if (!flow_node)
 		return -ENOENT;
-	return answer_query(dp, flow_cast(flow_node), flow.flags, uflow);
+	return answer_query(dp, flow_cast(flow_node), uflow);
 }
 
 static struct sw_flow *do_dump_flow(struct datapath *dp, u32 __user *state)
@@ -1067,10 +1063,9 @@ static int dump_flow(struct datapath *dp, struct odp_flow_dump __user *udumpp)
 		return -EFAULT;
 
 	if (!flow)
-		return put_user(ODPFF_EOF, &uflowp->flags);
+		return put_user(0, &uflowp->key_len);
 
-	if (put_user(0, &uflowp->flags) ||
-	    get_user(ukey, (struct nlattr __user * __user*)&uflowp->key) ||
+	if (get_user(ukey, (struct nlattr __user * __user*)&uflowp->key) ||
 	    get_user(key_len, &uflowp->key_len))
 		return -EFAULT;
 
@@ -1080,7 +1075,7 @@ static int dump_flow(struct datapath *dp, struct odp_flow_dump __user *udumpp)
 	if (put_user(key_len, &uflowp->key_len))
 		return -EFAULT;
 
-	return answer_query(dp, flow, 0, uflowp);
+	return answer_query(dp, flow, uflowp);
 }
 
 static int do_execute(struct datapath *dp, const struct odp_execute *execute)
@@ -1729,8 +1724,7 @@ static int compat_get_flow(struct odp_flow *flow, const struct compat_odp_flow _
 	    __get_user(key, &compat->key) ||
 	    __get_user(flow->key_len, &compat->key_len) ||
 	    __get_user(actions, &compat->actions) ||
-	    __get_user(flow->actions_len, &compat->actions_len) ||
-	    __get_user(flow->flags, &compat->flags))
+	    __get_user(flow->actions_len, &compat->actions_len))
 		return -EFAULT;
 
 	flow->key = (struct nlattr __force *)compat_ptr(key);
@@ -1760,7 +1754,6 @@ static int compat_put_flow(struct datapath *dp, struct compat_odp_flow_put __use
 }
 
 static int compat_answer_query(struct datapath *dp, struct sw_flow *flow,
-			       u32 query_flags,
 			       struct compat_odp_flow __user *ufp)
 {
 	compat_uptr_t actions;
@@ -1768,7 +1761,7 @@ static int compat_answer_query(struct datapath *dp, struct sw_flow *flow,
 	if (get_user(actions, &ufp->actions))
 		return -EFAULT;
 
-	return do_answer_query(dp, flow, query_flags, &ufp->stats,
+	return do_answer_query(dp, flow, &ufp->stats,
 			       compat_ptr(actions), &ufp->actions_len);
 }
 
@@ -1785,7 +1778,7 @@ static int compat_del_flow(struct datapath *dp, struct compat_odp_flow __user *u
 	if (IS_ERR(flow))
 		return PTR_ERR(flow);
 
-	error = compat_answer_query(dp, flow, 0, ufp);
+	error = compat_answer_query(dp, flow, ufp);
 	flow_deferred_free(flow);
 	return error;
 }
@@ -1808,7 +1801,7 @@ static int compat_query_flow(struct datapath *dp, struct compat_odp_flow __user
 	flow_node = tbl_lookup(table, &key, flow_hash(&key), flow_cmp);
 	if (!flow_node)
 		return -ENOENT;
-	return compat_answer_query(dp, flow_cast(flow_node), flow.flags, uflow);
+	return compat_answer_query(dp, flow_cast(flow_node), uflow);
 }
 
 static int compat_dump_flow(struct datapath *dp, struct compat_odp_flow_dump __user *udumpp)
@@ -1828,10 +1821,9 @@ static int compat_dump_flow(struct datapath *dp, struct compat_odp_flow_dump __u
 	uflowp = compat_ptr(compat_ufp);
 
 	if (!flow)
-		return put_user(ODPFF_EOF, &uflowp->flags);
+		return put_user(0, &uflowp->key_len);
 
-	if (put_user(0, &uflowp->flags) ||
-	    get_user(ukey, &uflowp->key) ||
+	if (get_user(ukey, &uflowp->key) ||
 	    get_user(key_len, &uflowp->key_len))
 		return -EFAULT;
 
@@ -1841,7 +1833,7 @@ static int compat_dump_flow(struct datapath *dp, struct compat_odp_flow_dump __u
 	if (put_user(key_len, &uflowp->key_len))
 		return -EFAULT;
 
-	return compat_answer_query(dp, flow, 0, uflowp);
+	return compat_answer_query(dp, flow, uflowp);
 }
 
 static int compat_execute(struct datapath *dp, const struct compat_odp_execute __user *uexecute)
diff --git a/datapath/odp-compat.h b/datapath/odp-compat.h
index 9e74a26..bccfaf9 100644
--- a/datapath/odp-compat.h
+++ b/datapath/odp-compat.h
@@ -28,7 +28,6 @@ struct compat_odp_flow {
 	u32 key_len;
 	compat_uptr_t actions;
 	u32 actions_len;
-	u32 flags;
 };
 
 struct compat_odp_flow_put {
diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h
index ea425fe..f852345 100644
--- a/include/openvswitch/datapath-protocol.h
+++ b/include/openvswitch/datapath-protocol.h
@@ -271,17 +271,12 @@ struct odp_key_arp {
 	ovs_be16 arp_op;
 };
 
-/* Flags for ODP_FLOW. */
-#define ODPFF_ZERO_TCP_FLAGS (1 << 0) /* Zero the TCP flags. */
-#define ODPFF_EOF            (1 << 1) /* ODP_FLOW_DUMP: end of flow table. */
-
 struct odp_flow {
     struct odp_flow_stats stats;
     struct nlattr *key;
     uint32_t key_len;
     struct nlattr *actions;
     uint32_t actions_len;
-    uint32_t flags;
 };
 
 /* Flags for ODP_FLOW_PUT. */
@@ -298,9 +293,9 @@ struct odp_flow_put {
 /* ODP_FLOW_DUMP argument.
  *
  * This is used to iterate through the flow table flow-by-flow.  Each
- * ODP_FLOW_DUMP call either stores a new odp_flow into 'flow' or stores
- * ODPFF_EOF into flow->flags to indicate that the end of the table has been
- * reaches, and updates 'state' in-place.
+ * ODP_FLOW_DUMP call either stores a new odp_flow into 'flow' or stores 0 into
+ * flow->key_len to indicate that the end of the table has been reached, and
+ * updates 'state' in-place.
  *
  * Before the first call, zero 'state'.  The format of 'state' is otherwise
  * unspecified.
diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index ba35991..13967b3 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -469,7 +469,7 @@ odp_flow_stats_to_dpif_flow_stats(const struct odp_flow_stats *ofs,
 }
 
 static int
-dpif_linux_flow_get(const struct dpif *dpif_, int flags,
+dpif_linux_flow_get(const struct dpif *dpif_,
                     const struct nlattr *key, size_t key_len,
                     struct ofpbuf **actionsp, struct dpif_flow_stats *stats)
 {
@@ -485,7 +485,6 @@ dpif_linux_flow_get(const struct dpif *dpif_, int flags,
         odp_flow.actions = actions->base;
         odp_flow.actions_len = actions->allocated;
     }
-    odp_flow.flags = flags;
 
     error = do_ioctl(dpif_, ODP_FLOW_GET, &odp_flow);
     if (!error) {
@@ -518,7 +517,6 @@ dpif_linux_flow_put(struct dpif *dpif_, enum dpif_flow_put_flags flags,
     put.flow.key_len = key_len;
     put.flow.actions = (struct nlattr *) actions;
     put.flow.actions_len = actions_len;
-    put.flow.flags = 0;
     put.flags = 0;
     if (flags & DPIF_FP_CREATE) {
         put.flags |= ODPPF_CREATE;
@@ -593,7 +591,7 @@ dpif_linux_flow_dump_next(const struct dpif *dpif, void *state_,
 
     error = do_ioctl(dpif, ODP_FLOW_DUMP, &state->dump);
     if (!error) {
-        if (state->flow.flags & ODPFF_EOF) {
+        if (!state->flow.key_len) {
             return EOF;
         }
         if (key) {
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 8e0404c..8f86e6f 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -655,7 +655,7 @@ dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len,
 }
 
 static int
-dpif_netdev_flow_get(const struct dpif *dpif, int flags,
+dpif_netdev_flow_get(const struct dpif *dpif,
                      const struct nlattr *nl_key, size_t nl_key_len,
                      struct ofpbuf **actionsp, struct dpif_flow_stats *stats)
 {
@@ -680,9 +680,6 @@ dpif_netdev_flow_get(const struct dpif *dpif, int flags,
     if (actionsp) {
         *actionsp = ofpbuf_clone_data(flow->actions, flow->actions_len);
     }
-    if (flags & ODPFF_ZERO_TCP_FLAGS) {
-        flow->tcp_ctl = 0;
-    }
     return 0;
 }
 
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index 1f9adf7..6018ac2 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -220,7 +220,7 @@ struct dpif_class {
      *
      * If 'stats' is nonnull, then on success it must be updated with the
      * flow's statistics. */
-    int (*flow_get)(const struct dpif *dpif, int flags,
+    int (*flow_get)(const struct dpif *dpif,
                     const struct nlattr *key, size_t key_len,
                     struct ofpbuf **actionsp, struct dpif_flow_stats *stats);
 
diff --git a/lib/dpif.c b/lib/dpif.c
index b5a990a..fc994ab 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -730,7 +730,7 @@ dpif_flow_flush(struct dpif *dpif)
  * If 'stats' is nonnull, then on success it will be updated with the flow's
  * statistics. */
 int
-dpif_flow_get(const struct dpif *dpif, int flags,
+dpif_flow_get(const struct dpif *dpif,
               const struct nlattr *key, size_t key_len,
               struct ofpbuf **actionsp, struct dpif_flow_stats *stats)
 {
@@ -738,8 +738,7 @@ dpif_flow_get(const struct dpif *dpif, int flags,
 
     COVERAGE_INC(dpif_flow_get);
 
-    error = dpif->dpif_class->flow_get(dpif, flags, key, key_len, actionsp,
-                                       stats);
+    error = dpif->dpif_class->flow_get(dpif, key, key_len, actionsp, stats);
     if (error) {
         if (actionsp) {
             *actionsp = NULL;
diff --git a/lib/dpif.h b/lib/dpif.h
index 20fe0f7..e401168 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -131,7 +131,7 @@ int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
 int dpif_flow_del(struct dpif *,
                   const struct nlattr *key, size_t key_len,
                   struct dpif_flow_stats *);
-int dpif_flow_get(const struct dpif *, int flags,
+int dpif_flow_get(const struct dpif *,
                   const struct nlattr *key, size_t key_len,
                   struct ofpbuf **actionsp, struct dpif_flow_stats *);
 
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 6169ec7..657d901 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3416,7 +3416,7 @@ query_stats(struct ofproto *p, struct rule *rule,
 
         ofpbuf_clear(&key);
         odp_flow_key_from_flow(&key, &facet->flow);
-        dpif_flow_get(p->dpif, 0, key.data, key.size, NULL, &stats);
+        dpif_flow_get(p->dpif, key.data, key.size, NULL, &stats);
 
         packet_count += stats.n_packets + facet->packet_count;
         byte_count += stats.n_bytes + facet->byte_count;
-- 
1.7.1





More information about the dev mailing list