From: Jesse Gross Date: Wed, 28 Oct 2009 21:36:52 +0000 (-0700) Subject: datapath: Allow TCP flags to be cleared. X-Git-Tag: v0.99.0~49 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=18fdbe16de40062c63f9119a6beef17602f4b233;p=sliver-openvswitch.git datapath: Allow TCP flags to be cleared. When querying flow stats allow the TCP flags to be reset. Since the datapath ORs together all flags that have previously been seen it is otherwise impossible to determine the set of flags from after a particular time. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 1ae1d771a..6e97c345b 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -975,13 +975,18 @@ static int put_actions(const struct sw_flow *flow, struct odp_flow __user *ufp) return 0; } -static int answer_query(struct sw_flow *flow, struct odp_flow __user *ufp) +static int answer_query(struct sw_flow *flow, u32 query_flags, + struct odp_flow __user *ufp) { struct odp_flow_stats stats; unsigned long int flags; spin_lock_irqsave(&flow->lock, flags); get_stats(flow, &stats); + + if (query_flags & ODPFF_ZERO_TCP_FLAGS) { + flow->tcp_flags = 0; + } spin_unlock_irqrestore(&flow->lock, flags); if (__copy_to_user(&ufp->stats, &stats, sizeof(struct odp_flow_stats))) @@ -1016,7 +1021,7 @@ static int del_flow(struct datapath *dp, struct odp_flow __user *ufp) * we get completely accurate stats, but that blows our performance, * badly. */ dp->n_flows--; - error = answer_query(flow, ufp); + error = answer_query(flow, uf.flags, ufp); flow_deferred_free(flow); error: @@ -1041,7 +1046,7 @@ static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec) if (!flow) error = __put_user(ENOENT, &ufp->stats.error); else - error = answer_query(flow, ufp); + error = answer_query(flow, 0, ufp); if (error) return -EFAULT; } @@ -1062,7 +1067,7 @@ static int list_flow(struct sw_flow *flow, void *cbdata_) if (__copy_to_user(&ufp->key, &flow->key, sizeof flow->key)) return -EFAULT; - error = answer_query(flow, ufp); + error = answer_query(flow, 0, ufp); if (error) return error; diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 04423d941..ab7eb9e39 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -165,11 +165,15 @@ struct odp_flow_key { __u8 reserved; /* Pad to 64 bits. */ }; +/* Flags for ODP_FLOW. */ +#define ODPFF_ZERO_TCP_FLAGS (1 << 0) /* Zero the TCP flags. */ + struct odp_flow { struct odp_flow_stats stats; struct odp_flow_key key; union odp_action *actions; __u32 n_actions; + __u32 flags; }; /* Flags for ODP_FLOW_PUT. */