From 693c4a01124ec5ad9253f8cfcfd99075a9d637f6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 17 Jan 2011 14:43:30 -0800 Subject: [PATCH] datapath: Eliminate 'flags' member from odp_flow. 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 Acked-by: Jesse Gross --- datapath/datapath.c | 37 ++++++++++--------------- 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(+), 46 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 0f59e9ae..04d8bbd9 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -927,7 +927,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) @@ -938,9 +937,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); if (copy_to_user(ustats, &stats, sizeof(struct odp_flow_stats)) || @@ -961,15 +957,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) @@ -1011,7 +1006,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; } @@ -1034,7 +1029,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) @@ -1069,10 +1064,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; @@ -1082,7 +1076,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) @@ -1778,8 +1772,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); @@ -1809,7 +1802,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; @@ -1817,7 +1809,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); } @@ -1834,7 +1826,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; } @@ -1857,7 +1849,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) @@ -1877,10 +1869,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; @@ -1890,7 +1881,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 9e74a26d..bccfaf9d 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 54c39d1f..0078874f 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 8d5c4896..d60950b6 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -470,7 +470,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) { @@ -486,7 +486,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) { @@ -519,7 +518,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; @@ -594,7 +592,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 7284e2f1..b1e54816 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -656,7 +656,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) { @@ -681,9 +681,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 0ab3c1f2..d7953823 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -221,7 +221,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 b7e2b389..b4a1d93c 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -731,7 +731,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) { @@ -739,8 +739,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 20fe0f77..e401168e 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 751dc0e7..08d80d89 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -3479,7 +3479,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; -- 2.30.2