openflow: Delete icmp_type and icmp_code macros.
authorBen Pfaff <blp@nicira.com>
Wed, 5 Oct 2011 18:06:12 +0000 (11:06 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 11 Oct 2011 17:37:25 +0000 (10:37 -0700)
These macros caused trouble if datapath-protocol.h was included before
openflow.h.  Later references to the icmp_type and icmp_code members of
struct ovs_key_icmp caused compiler errors, because the macros caused them
to try to refer to nonexistent tp_src and tp_dst members in those
structures.

include/openflow/openflow.h
lib/classifier.c
lib/flow.c
lib/meta-flow.c
lib/odp-util.c
lib/ofp-print.c

index 0dad50d..fd8fbeb 100644 (file)
@@ -536,11 +536,6 @@ struct ofp_match {
 };
 OFP_ASSERT(sizeof(struct ofp_match) == 40);
 
-/* The match fields for ICMP type and code use the transport source and
- * destination port fields, respectively. */
-#define icmp_type tp_src
-#define icmp_code tp_dst
-
 /* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
  * is permanent. */
 #define OFP_FLOW_PERMANENT 0
index 1f58860..9f4c42b 100644 (file)
@@ -327,7 +327,7 @@ void
 cls_rule_set_icmp_type(struct cls_rule *rule, uint8_t icmp_type)
 {
     rule->wc.wildcards &= ~FWW_TP_SRC;
-    rule->flow.icmp_type = htons(icmp_type);
+    rule->flow.tp_src = htons(icmp_type);
 
 }
 
@@ -335,7 +335,7 @@ void
 cls_rule_set_icmp_code(struct cls_rule *rule, uint8_t icmp_code)
 {
     rule->wc.wildcards &= ~FWW_TP_DST;
-    rule->flow.icmp_code = htons(icmp_code);
+    rule->flow.tp_dst = htons(icmp_code);
 }
 
 void
index 1e5f2e5..ded98b2 100644 (file)
@@ -245,8 +245,8 @@ parse_icmpv6(struct ofpbuf *b, struct flow *flow)
 
     /* The ICMPv6 type and code fields use the 16-bit transport port
      * fields, so we need to store them in 16-bit network byte order. */
-    flow->icmp_type = htons(icmp->icmp6_type);
-    flow->icmp_code = htons(icmp->icmp6_code);
+    flow->tp_src = htons(icmp->icmp6_type);
+    flow->tp_dst = htons(icmp->icmp6_code);
 
     if (icmp->icmp6_code == 0 &&
         (icmp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
@@ -373,8 +373,8 @@ flow_extract(struct ofpbuf *packet, ovs_be64 tun_id, uint16_t ofp_in_port,
                 } else if (flow->nw_proto == IPPROTO_ICMP) {
                     const struct icmp_header *icmp = pull_icmp(&b);
                     if (icmp) {
-                        flow->icmp_type = htons(icmp->icmp_type);
-                        flow->icmp_code = htons(icmp->icmp_code);
+                        flow->tp_src = htons(icmp->icmp_type);
+                        flow->tp_dst = htons(icmp->icmp_code);
                         packet->l7 = b.data;
                     }
                 }
index 7154426..f2f1348 100644 (file)
@@ -591,17 +591,17 @@ mf_are_prereqs_ok(const struct mf_field *mf, const struct flow *flow)
 
     case MFP_ND:
         return (is_icmpv6(flow)
-                && flow->icmp_code == htons(0)
-                && (flow->icmp_type == htons(ND_NEIGHBOR_SOLICIT) ||
-                    flow->icmp_type == htons(ND_NEIGHBOR_ADVERT)));
+                && flow->tp_dst == htons(0)
+                && (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT) ||
+                    flow->tp_src == htons(ND_NEIGHBOR_ADVERT)));
     case MFP_ND_SOLICIT:
         return (is_icmpv6(flow)
-                && flow->icmp_code == htons(0)
-                && (flow->icmp_type == htons(ND_NEIGHBOR_SOLICIT)));
+                && flow->tp_dst == htons(0)
+                && (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT)));
     case MFP_ND_ADVERT:
         return (is_icmpv6(flow)
-                && flow->icmp_code == htons(0)
-                && (flow->icmp_type == htons(ND_NEIGHBOR_ADVERT)));
+                && flow->tp_dst == htons(0)
+                && (flow->tp_src == htons(ND_NEIGHBOR_ADVERT)));
     }
 
     NOT_REACHED();
index 7f5158f..c67e14a 100644 (file)
@@ -1087,8 +1087,8 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len,
         return 0;
 
     case OVS_KEY_ATTR_ICMPV6:
-        if (flow->icmp_type == htons(ND_NEIGHBOR_SOLICIT)
-            || flow->icmp_type == htons(ND_NEIGHBOR_ADVERT)) {
+        if (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT)
+            || flow->tp_src == htons(ND_NEIGHBOR_ADVERT)) {
             return EINVAL;
         }
         return 0;
index a9f90df..64712b5 100644 (file)
@@ -739,9 +739,9 @@ ofp_match_to_string(const struct ofp_match *om, int verbosity)
                "%u", om->nw_tos);
     if (om->nw_proto == IPPROTO_ICMP) {
         print_wild(&f, "icmp_type=", w & OFPFW_ICMP_TYPE, verbosity,
-                   "%d", ntohs(om->icmp_type));
+                   "%d", ntohs(om->tp_src));
         print_wild(&f, "icmp_code=", w & OFPFW_ICMP_CODE, verbosity,
-                   "%d", ntohs(om->icmp_code));
+                   "%d", ntohs(om->tp_dst));
     } else {
         print_wild(&f, "tp_src=", w & OFPFW_TP_SRC, verbosity,
                    "%d", ntohs(om->tp_src));