Collect TCP flags in stats only if needed for netflow or NXAST_FIN_TIMEOUT.

Signed-off-by: Jarno Rajahalme <jarno.rajaha...@nsn.com>
---
 ofproto/ofproto-dpif.c |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 4584987..594f3f3 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3380,8 +3380,7 @@ init_flow_miss_execute_op(struct flow_miss *miss, struct 
ofpbuf *packet,
     op->dpif_op.u.execute.packet = packet;
 }
 
-/* Helper for handle_flow_miss_without_facet() and
- * handle_flow_miss_with_facet(). */
+/* Helper for handle_flow_miss_with_facet(). */
 static void
 handle_flow_miss_common(struct rule_dpif *rule,
                         struct ofpbuf *packet, const struct flow *flow)
@@ -3430,6 +3429,17 @@ flow_miss_should_make_facet(struct ofproto_dpif *ofproto,
                                         list_size(&miss->packets));
 }
 
+/* Initializes 'stats' with stats from a packet. */
+static inline void
+packet_stats_extract(const struct ofpbuf *packet,
+                     long long int used, struct dpif_flow_stats *stats)
+{
+    stats->tcp_flags = 0;
+    stats->n_bytes = packet->size;
+    stats->n_packets = 1;
+    stats->used = used;
+}
+
 /* Handles 'miss', which matches 'rule', without creating a facet or subfacet
  * or creating any datapath flow.  May add an "execute" operation to 'ops' and
  * increment '*n_ops'. */
@@ -3452,7 +3462,7 @@ handle_flow_miss_without_facet(struct flow_miss *miss,
 
         ofpbuf_use_stub(&odp_actions, op->stub, sizeof op->stub);
 
-        dpif_flow_stats_extract(&miss->flow, packet, now, &stats);
+        packet_stats_extract(packet, now, &stats);
         rule_credit_stats(rule, &stats);
 
         action_xlate_ctx_init(&ctx, ofproto, &miss->flow, miss->initial_tci,
@@ -3509,7 +3519,10 @@ handle_flow_miss_with_facet(struct flow_miss *miss, 
struct facet *facet,
             subfacet_make_actions(subfacet, packet, &odp_actions);
         }
 
-        dpif_flow_stats_extract(&facet->flow, packet, now, &stats);
+        packet_stats_extract(packet, now, &stats);
+        if (facet->has_fin_timeout || ofproto->netflow) {
+            stats.tcp_flags = packet_get_tcp_flags(packet, &facet->flow);
+        }
         subfacet_update_stats(subfacet, &stats);
 
         if (subfacet->actions_len) {
-- 
1.7.10.4

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

Reply via email to