datapath: Don't track IP TOS value two different ways.
[openvswitch] / lib / flow.c
index 38ad72abcb5906f20383fa23af4bf17a06df5f70..72ee14f2a087f33dc66b718116a8af4e621f843c 100644 (file)
 #include "openvswitch/datapath-protocol.h"
 #include "packets.h"
 #include "unaligned.h"
+#include "vlog.h"
 #include "xtoxll.h"
 
-#include "vlog.h"
-#define THIS_MODULE VLM_flow
+VLOG_DEFINE_THIS_MODULE(flow)
 
 static struct arp_eth_header *
 pull_arp(struct ofpbuf *packet)
@@ -231,8 +231,6 @@ flow_extract_stats(const flow_t *flow, struct ofpbuf *packet,
     memset(stats, '\0', sizeof(*stats));
 
     if ((flow->dl_type == htons(ETH_TYPE_IP)) && packet->l4) {
-        struct ip_header *ip = packet->l3;
-        stats->ip_tos = ip->ip_tos;
         if ((flow->nw_proto == IP_TYPE_TCP) && packet->l7) {
             struct tcp_header *tcp = packet->l4;
             stats->tcp_flags = TCP_FLAGS(tcp->tcp_ctl);
@@ -273,20 +271,16 @@ flow_to_match(const flow_t *flow, uint32_t wildcards, bool tun_id_from_cookie,
 
 void
 flow_from_match(const struct ofp_match *match, bool tun_id_from_cookie,
-                uint64_t cookie, flow_t *flow, uint32_t *wildcards)
+                uint64_t cookie, flow_t *flow, uint32_t *flow_wildcards)
 {
-    if (wildcards) {
-        *wildcards = ntohl(match->wildcards);
+       uint32_t wildcards = ntohl(match->wildcards);
 
-        if (!tun_id_from_cookie) {
-            *wildcards |= NXFW_TUN_ID;
-        }
-    }
     flow->nw_src = match->nw_src;
     flow->nw_dst = match->nw_dst;
-    if (tun_id_from_cookie) {
+    if (tun_id_from_cookie && !(wildcards & NXFW_TUN_ID)) {
         flow->tun_id = htonl(ntohll(cookie) >> 32);
     } else {
+        wildcards |= NXFW_TUN_ID;
         flow->tun_id = 0;
     }
     flow->in_port = (match->in_port == htons(OFPP_LOCAL) ? ODPP_LOCAL
@@ -301,6 +295,10 @@ flow_from_match(const struct ofp_match *match, bool tun_id_from_cookie,
     flow->nw_tos = match->nw_tos;
     flow->nw_proto = match->nw_proto;
     memset(flow->reserved, 0, sizeof flow->reserved);
+
+    if (flow_wildcards) {
+        *flow_wildcards = wildcards;
+    }
 }
 
 char *