ovs-ofctl: Bug fix in flow_format()
[sliver-openvswitch.git] / lib / match.c
index fc3c540..91c05a7 100644 (file)
@@ -111,21 +111,22 @@ match_wc_init(struct match *match, const struct flow *flow)
     if (is_ip_any(flow)) {
         memset(&wc->masks.nw_tos, 0xff, sizeof wc->masks.nw_tos);
         memset(&wc->masks.nw_ttl, 0xff, sizeof wc->masks.nw_ttl);
-    }
 
-    if (flow->nw_frag) {
-        memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag);
-    }
+        if (flow->nw_frag) {
+            memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag);
+        }
 
-    if (flow->nw_proto == IPPROTO_ICMP || flow->nw_proto == IPPROTO_ICMPV6 ||
-        (flow->tp_src || flow->tp_dst)) {
-        memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
-        memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
-    }
+        if (flow->nw_proto == IPPROTO_ICMP ||
+            flow->nw_proto == IPPROTO_ICMPV6 ||
+            (flow->tp_src || flow->tp_dst)) {
+            memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
+            memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+        }
 
-    if (flow->nw_proto == IPPROTO_ICMPV6) {
-        memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha);
-        memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha);
+        if (flow->nw_proto == IPPROTO_ICMPV6) {
+            memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha);
+            memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha);
+        }
     }
 
     return;
@@ -135,13 +136,9 @@ match_wc_init(struct match *match, const struct flow *flow)
 void
 match_init_exact(struct match *match, const struct flow *flow)
 {
-    ovs_be64 tun_id = flow->tunnel.tun_id;
-
     match->flow = *flow;
     match->flow.skb_priority = 0;
     match->flow.skb_mark = 0;
-    memset(&match->flow.tunnel, 0, sizeof match->flow.tunnel);
-    match->flow.tunnel.tun_id = tun_id;
     flow_wildcards_init_exact(&match->wc);
 }
 
@@ -275,10 +272,10 @@ match_set_tun_flags_masked(struct match *match, uint16_t flags, uint16_t mask)
 }
 
 void
-match_set_in_port(struct match *match, uint16_t ofp_port)
+match_set_in_port(struct match *match, ofp_port_t ofp_port)
 {
-    match->wc.masks.in_port = UINT16_MAX;
-    match->flow.in_port = ofp_port;
+    match->wc.masks.in_port.ofp_port = u16_to_ofp(UINT16_MAX);
+    match->flow.in_port.ofp_port = ofp_port;
 }
 
 void
@@ -920,9 +917,9 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
                       ntohll(f->metadata), ntohll(wc->masks.metadata));
         break;
     }
-    if (wc->masks.in_port) {
+    if (wc->masks.in_port.ofp_port) {
         ds_put_cstr(s, "in_port=");
-        ofputil_format_port(f->in_port, s);
+        ofputil_format_port(f->in_port.ofp_port, s);
         ds_put_char(s, ',');
     }
     if (wc->masks.vlan_tci) {