packet: Add additional TCP flags extraction on IPv6.
authorJesse Gross <jesse@nicira.com>
Mon, 26 Mar 2012 19:56:14 +0000 (12:56 -0700)
committerJesse Gross <jesse@nicira.com>
Mon, 26 Mar 2012 22:54:56 +0000 (15:54 -0700)
Commit 11460e2316b88f0bd0ea0005d94338d800ea16bd
(flow: Enable retrieval of TCP flags from IPv6 traffic.) updated
one of the TCP flags extraction functions in userspace but missed
the other.  This updates that function and converts the other to
use it to reduce duplication.

Bug #10194

Signed-off-by: Jesse Gross <jesse@nicira.com>
lib/dpif-netdev.c
lib/packets.c

index a38e56b..8381a89 100644 (file)
@@ -113,7 +113,7 @@ struct dp_netdev_flow {
     long long int used;         /* Last used time, in monotonic msecs. */
     long long int packet_count; /* Number of packets matched. */
     long long int byte_count;   /* Number of bytes matched. */
-    ovs_be16 tcp_ctl;           /* Bitwise-OR of seen tcp_ctl values. */
+    ovs_be16 tcp_flags;         /* Bitwise-OR of seen tcp_flags values. */
 
     /* Actions. */
     struct nlattr *actions;
@@ -627,7 +627,7 @@ get_dpif_flow_stats(struct dp_netdev_flow *flow, struct dpif_flow_stats *stats)
     stats->n_packets = flow->packet_count;
     stats->n_bytes = flow->byte_count;
     stats->used = flow->used;
-    stats->tcp_flags = TCP_FLAGS(flow->tcp_ctl);
+    stats->tcp_flags = flow->tcp_flags;
 }
 
 static int
@@ -728,7 +728,7 @@ clear_stats(struct dp_netdev_flow *flow)
     flow->used = 0;
     flow->packet_count = 0;
     flow->byte_count = 0;
-    flow->tcp_ctl = 0;
+    flow->tcp_flags = 0;
 }
 
 static int
@@ -976,12 +976,7 @@ dp_netdev_flow_used(struct dp_netdev_flow *flow, struct flow *key,
     flow->used = time_msec();
     flow->packet_count++;
     flow->byte_count += packet->size;
-    if ((key->dl_type == htons(ETH_TYPE_IP) ||
-         key->dl_type == htons(ETH_TYPE_IPV6)) &&
-        key->nw_proto == IPPROTO_TCP && packet->l7) {
-        struct tcp_header *th = packet->l4;
-        flow->tcp_ctl |= th->tcp_ctl;
-    }
+    flow->tcp_flags |= packet_get_tcp_flags(packet, key);
 }
 
 static void
index 9d861da..8fb7f6b 100644 (file)
@@ -487,9 +487,9 @@ packet_set_udp_port(struct ofpbuf *packet, ovs_be16 src, ovs_be16 dst)
 uint8_t
 packet_get_tcp_flags(const struct ofpbuf *packet, const struct flow *flow)
 {
-    /* XXX IPv6? */
-    if (flow->dl_type == htons(ETH_TYPE_IP) && packet->l4
-        && flow->nw_proto == IPPROTO_TCP && packet->l7) {
+    if ((flow->dl_type == htons(ETH_TYPE_IP) ||
+         flow->dl_type == htons(ETH_TYPE_IPV6)) &&
+        flow->nw_proto == IPPROTO_TCP && packet->l7) {
         const struct tcp_header *tcp = packet->l4;
         return TCP_FLAGS(tcp->tcp_ctl);
     } else {