ofproto: Maintain ofp_phy_port for each ofport in network byte order.
[openvswitch] / lib / ofp-util.c
index cc448bcd6b9ce8efe1dba00f61ca33108355115e..4ee09ebe4048fbefb09d12be1e3dfa81ac01e1c6 100644 (file)
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include "autopath.h"
 #include "byte-order.h"
 #include "classifier.h"
 #include "dynamic-string.h"
@@ -136,7 +137,7 @@ ofputil_cls_rule_from_match(const struct ofp_match *match,
     wc->nw_dst_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_DST_SHIFT);
 
     if (flow_format == NXFF_TUN_ID_FROM_COOKIE && !(ofpfw & NXFW_TUN_ID)) {
-        rule->flow.tun_id = htonll(ntohll(cookie) >> 32);
+        cls_rule_set_tun_id(rule, htonll(ntohll(cookie) >> 32));
     }
 
     if (ofpfw & OFPFW_DL_DST) {
@@ -1863,19 +1864,6 @@ make_echo_reply(const struct ofp_header *rq)
     return out;
 }
 
-/* Converts the members of 'opp' from host to network byte order. */
-void
-hton_ofp_phy_port(struct ofp_phy_port *opp)
-{
-    opp->port_no = htons(opp->port_no);
-    opp->config = htonl(opp->config);
-    opp->state = htonl(opp->state);
-    opp->curr = htonl(opp->curr);
-    opp->advertised = htonl(opp->advertised);
-    opp->supported = htonl(opp->supported);
-    opp->peer = htonl(opp->peer);
-}
-
 static int
 check_action_exact_len(const union ofp_action *a, unsigned int len,
                        unsigned int required_len)
@@ -1958,7 +1946,7 @@ check_nicira_action(const union ofp_action *a, unsigned int len,
                     const struct flow *flow)
 {
     const struct nx_action_header *nah;
-    uint16_t subtype;
+    int subtype;
     int error;
 
     if (len < 16) {
@@ -1970,7 +1958,7 @@ check_nicira_action(const union ofp_action *a, unsigned int len,
 
     subtype = ntohs(nah->subtype);
     if (subtype > TYPE_MAXIMUM(enum nx_action_subtype)) {
-        /* This is necessary because enum nx_action_subtype is probably an
+        /* This is necessary because enum nx_action_subtype may be an
          * 8-bit type, so the cast below throws away the top 8 bits. */
         return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_VENDOR_TYPE);
     }
@@ -2014,11 +2002,18 @@ check_nicira_action(const union ofp_action *a, unsigned int len,
         }
         return multipath_check((const struct nx_action_multipath *) a);
 
+    case NXAST_AUTOPATH:
+        error = check_nx_action_exact_len(
+            nah, len, sizeof(struct nx_action_autopath));
+        if (error) {
+            return error;
+        }
+        return autopath_check((const struct nx_action_autopath *) a);
+
     case NXAST_SNAT__OBSOLETE:
     default:
         VLOG_WARN_RL(&bad_ofmsg_rl,
-                     "unknown Nicira vendor action subtype %"PRIu16,
-                     ntohs(nah->subtype));
+                     "unknown Nicira vendor action subtype %d", subtype);
         return ofp_mkerr(OFPET_BAD_ACTION, OFPBAC_BAD_VENDOR_TYPE);
     }
 }