datapath: Use TCP flags in the flow key for stats.
[sliver-openvswitch.git] / datapath / flow.c
index c3e3fcb..30e0ab8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2013 Nicira, Inc.
+ * Copyright (c) 2007-2014 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -70,14 +70,12 @@ void ovs_flow_stats_update(struct sw_flow *flow, struct sk_buff *skb)
 
        stats = rcu_dereference(flow->stats[node]);
 
-       if ((flow->key.eth.type == htons(ETH_P_IP) ||
-            flow->key.eth.type == htons(ETH_P_IPV6)) &&
-           flow->key.ip.frag != OVS_FRAG_TYPE_LATER &&
-           flow->key.ip.proto == IPPROTO_TCP &&
-           likely(skb->len >= skb_transport_offset(skb) + sizeof(struct tcphdr))) {
-               tcp_flags = TCP_FLAGS_BE16(tcp_hdr(skb));
+       if (likely(flow->key.ip.proto == IPPROTO_TCP)) {
+               if (likely(flow->key.eth.type == htons(ETH_P_IP)))
+                       tcp_flags = flow->key.ipv4.tp.flags;
+               else if (likely(flow->key.eth.type == htons(ETH_P_IPV6)))
+                       tcp_flags = flow->key.ipv6.tp.flags;
        }
-
        /* Check if already have node-specific stats. */
        if (likely(stats)) {
                spin_lock(&stats->lock);
@@ -148,7 +146,7 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
                         * block bottom-halves here.
                         */
                        spin_lock_bh(&stats->lock);
-                       if (time_after(stats->used, *used))
+                       if (!*used || time_after(stats->used, *used))
                                *used = stats->used;
                        *tcp_flags |= stats->tcp_flags;
                        ovs_stats->n_packets += stats->packet_count;