datapath: net: make skb_gso_segment error handling more robust
[cascardo/ovs.git] / lib / ofp-util.c
index 2b9b5c0..1b4b29e 100644 (file)
@@ -50,6 +50,53 @@ VLOG_DEFINE_THIS_MODULE(ofp_util);
  * in the peer and so there's not much point in showing a lot of them. */
 static struct vlog_rate_limit bad_ofmsg_rl = VLOG_RATE_LIMIT_INIT(1, 5);
 
+struct ofp_prop_header {
+    ovs_be16 type;
+    ovs_be16 len;
+};
+
+/* Pulls a property, beginning with struct ofp_prop_header, from the beginning
+ * of 'msg'.  Stores the type of the property in '*typep' and, if 'property' is
+ * nonnull, the entire property, including the header, in '*property'.  Returns
+ * 0 if successful, otherwise an error code. */
+static enum ofperr
+ofputil_pull_property(struct ofpbuf *msg, struct ofpbuf *property,
+                      uint16_t *typep)
+{
+    struct ofp_prop_header *oph;
+    unsigned int len;
+
+    if (ofpbuf_size(msg) < sizeof *oph) {
+        return OFPERR_OFPBPC_BAD_LEN;
+    }
+
+    oph = ofpbuf_data(msg);
+    len = ntohs(oph->len);
+    if (len < sizeof *oph || ROUND_UP(len, 8) > ofpbuf_size(msg)) {
+        return OFPERR_OFPBPC_BAD_LEN;
+    }
+
+    *typep = ntohs(oph->type);
+    if (property) {
+        ofpbuf_use_const(property, ofpbuf_data(msg), len);
+    }
+    ofpbuf_pull(msg, ROUND_UP(len, 8));
+    return 0;
+}
+
+static void PRINTF_FORMAT(2, 3)
+log_property(bool loose, const char *message, ...)
+{
+    enum vlog_level level = loose ? VLL_DBG : VLL_WARN;
+    if (!vlog_should_drop(THIS_MODULE, level, &bad_ofmsg_rl)) {
+        va_list args;
+
+        va_start(args, message);
+        vlog_valist(THIS_MODULE, level, message, args);
+        va_end(args);
+    }
+}
+
 /* Given the wildcard bit count in the least-significant 6 of 'wcbits', returns
  * an IP netmask with a 1 in each bit that must match and a 0 in each bit that
  * is wildcarded.
@@ -85,7 +132,7 @@ ofputil_netmask_to_wcbits(ovs_be32 netmask)
 void
 ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 25);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 26);
 
     /* Initialize most of wc. */
     flow_wildcards_init_catchall(wc);
@@ -575,6 +622,7 @@ ofputil_match_typical_len(enum ofputil_protocol protocol)
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
     case OFPUTIL_P_OF14_OXM:
+    case OFPUTIL_P_OF15_OXM:
         return NXM_TYPICAL_LEN;
 
     default:
@@ -616,7 +664,9 @@ ofputil_put_ofp11_match(struct ofpbuf *b, const struct match *match,
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
     case OFPUTIL_P_OF14_OXM:
-        return oxm_put_match(b, match);
+    case OFPUTIL_P_OF15_OXM:
+        return oxm_put_match(b, match,
+                             ofputil_protocol_to_ofp_version(protocol));
     }
 
     OVS_NOT_REACHED();
@@ -652,20 +702,17 @@ struct proto_abbrev {
 };
 
 /* Most users really don't care about some of the differences between
- * protocols.  These abbreviations help with that.
- *
- * Until it is safe to use the OpenFlow 1.4 protocol (which currently can
- * cause aborts due to unimplemented features), we omit OpenFlow 1.4 from all
- * abbrevations. */
+ * protocols.  These abbreviations help with that. */
 static const struct proto_abbrev proto_abbrevs[] = {
-    { OFPUTIL_P_ANY          & ~OFPUTIL_P_OF14_OXM, "any" },
-    { OFPUTIL_P_OF10_STD_ANY & ~OFPUTIL_P_OF14_OXM, "OpenFlow10" },
-    { OFPUTIL_P_OF10_NXM_ANY & ~OFPUTIL_P_OF14_OXM, "NXM" },
-    { OFPUTIL_P_ANY_OXM      & ~OFPUTIL_P_OF14_OXM, "OXM" },
+    { OFPUTIL_P_ANY,          "any" },
+    { OFPUTIL_P_OF10_STD_ANY, "OpenFlow10" },
+    { OFPUTIL_P_OF10_NXM_ANY, "NXM" },
+    { OFPUTIL_P_ANY_OXM,      "OXM" },
 };
 #define N_PROTO_ABBREVS ARRAY_SIZE(proto_abbrevs)
 
 enum ofputil_protocol ofputil_flow_dump_protocols[] = {
+    OFPUTIL_P_OF15_OXM,
     OFPUTIL_P_OF14_OXM,
     OFPUTIL_P_OF13_OXM,
     OFPUTIL_P_OF12_OXM,
@@ -693,6 +740,8 @@ ofputil_protocols_from_ofp_version(enum ofp_version version)
         return OFPUTIL_P_OF13_OXM;
     case OFP14_VERSION:
         return OFPUTIL_P_OF14_OXM;
+    case OFP15_VERSION:
+        return OFPUTIL_P_OF15_OXM;
     default:
         return 0;
     }
@@ -728,6 +777,8 @@ ofputil_protocol_to_ofp_version(enum ofputil_protocol protocol)
         return OFP13_VERSION;
     case OFPUTIL_P_OF14_OXM:
         return OFP14_VERSION;
+    case OFPUTIL_P_OF15_OXM:
+        return OFP15_VERSION;
     }
 
     OVS_NOT_REACHED();
@@ -807,6 +858,9 @@ ofputil_protocol_set_tid(enum ofputil_protocol protocol, bool enable)
     case OFPUTIL_P_OF14_OXM:
         return OFPUTIL_P_OF14_OXM;
 
+    case OFPUTIL_P_OF15_OXM:
+        return OFPUTIL_P_OF15_OXM;
+
     default:
         OVS_NOT_REACHED();
     }
@@ -850,6 +904,9 @@ ofputil_protocol_set_base(enum ofputil_protocol cur,
     case OFPUTIL_P_OF14_OXM:
         return ofputil_protocol_set_tid(OFPUTIL_P_OF14_OXM, tid);
 
+    case OFPUTIL_P_OF15_OXM:
+        return ofputil_protocol_set_tid(OFPUTIL_P_OF15_OXM, tid);
+
     default:
         OVS_NOT_REACHED();
     }
@@ -889,6 +946,9 @@ ofputil_protocol_to_string(enum ofputil_protocol protocol)
 
     case OFPUTIL_P_OF14_OXM:
         return "OXM-OpenFlow14";
+
+    case OFPUTIL_P_OF15_OXM:
+        return "OXM-OpenFlow15";
     }
 
     /* Check abbreviations. */
@@ -1009,7 +1069,7 @@ ofputil_protocols_from_string(const char *s)
     return protocols;
 }
 
-static int
+enum ofp_version
 ofputil_version_from_string(const char *s)
 {
     if (!strcasecmp(s, "OpenFlow10")) {
@@ -1027,6 +1087,9 @@ ofputil_version_from_string(const char *s)
     if (!strcasecmp(s, "OpenFlow14")) {
         return OFP14_VERSION;
     }
+    if (!strcasecmp(s, "OpenFlow15")) {
+        return OFP15_VERSION;
+    }
     return 0;
 }
 
@@ -1099,6 +1162,8 @@ ofputil_version_to_string(enum ofp_version ofp_version)
         return "OpenFlow13";
     case OFP14_VERSION:
         return "OpenFlow14";
+    case OFP15_VERSION:
+        return "OpenFlow15";
     default:
         OVS_NOT_REACHED();
     }
@@ -1333,6 +1398,7 @@ ofputil_encode_set_protocol(enum ofputil_protocol current,
         case OFPUTIL_P_OF12_OXM:
         case OFPUTIL_P_OF13_OXM:
         case OFPUTIL_P_OF14_OXM:
+        case OFPUTIL_P_OF15_OXM:
             /* There is only one variant of each OpenFlow 1.1+ protocol, and we
              * verified above that we're not trying to change versions. */
             OVS_NOT_REACHED();
@@ -1918,7 +1984,7 @@ ofputil_decode_meter_config(struct ofpbuf *msg,
     enum ofperr err;
 
     /* Pull OpenFlow headers for the first call. */
-    if (!msg->l2) {
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -1994,7 +2060,7 @@ ofputil_decode_meter_stats(struct ofpbuf *msg,
     enum ofperr err;
 
     /* Pull OpenFlow headers for the first call. */
-    if (!msg->l2) {
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -2105,7 +2171,8 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
     case OFPUTIL_P_OF11_STD:
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
-    case OFPUTIL_P_OF14_OXM: {
+    case OFPUTIL_P_OF14_OXM:
+    case OFPUTIL_P_OF15_OXM: {
         struct ofp11_flow_mod *ofm;
         int tailroom;
 
@@ -2176,7 +2243,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
         nfm->command = ofputil_tid_command(fm, protocol);
         nfm->cookie = fm->new_cookie;
         match_len = nx_put_match(msg, &fm->match, fm->cookie, fm->cookie_mask);
-        nfm = ofpbuf_get_l3(msg);
+        nfm = ofpbuf_l3(msg);
         nfm->idle_timeout = htons(fm->idle_timeout);
         nfm->hard_timeout = htons(fm->hard_timeout);
         nfm->priority = htons(fm->priority);
@@ -2396,7 +2463,7 @@ ofputil_append_queue_get_config_reply(struct ofpbuf *reply,
         struct ofp12_packet_queue *opq12;
         ovs_be32 port;
 
-        qgcr11 = ofpbuf_get_l3(reply);
+        qgcr11 = ofpbuf_l3(reply);
         port = qgcr11->port;
 
         opq12 = ofpbuf_put_zeros(reply, sizeof *opq12);
@@ -2475,7 +2542,7 @@ ofputil_pull_queue_get_config_reply(struct ofpbuf *reply,
     queue->min_rate = UINT16_MAX;
     queue->max_rate = UINT16_MAX;
 
-    oh = reply->l2;
+    oh = reply->frame;
     if (oh->version < OFP12_VERSION) {
         const struct ofp10_packet_queue *opq10;
 
@@ -2590,7 +2657,8 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
     case OFPUTIL_P_OF11_STD:
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
-    case OFPUTIL_P_OF14_OXM: {
+    case OFPUTIL_P_OF14_OXM:
+    case OFPUTIL_P_OF15_OXM: {
         struct ofp11_flow_stats_request *ofsr;
 
         raw = (fsr->aggregate
@@ -2636,7 +2704,7 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
         match_len = nx_put_match(msg, &fsr->match,
                                  fsr->cookie, fsr->cookie_mask);
 
-        nfsr = ofpbuf_get_l3(msg);
+        nfsr = ofpbuf_l3(msg);
         nfsr->out_port = htons(ofp_to_u16(fsr->out_port));
         nfsr->match_len = htons(match_len);
         nfsr->table_id = fsr->table_id;
@@ -2680,13 +2748,13 @@ ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *fs,
     enum ofperr error;
     enum ofpraw raw;
 
-    error = (msg->l2
-             ? ofpraw_decode(&raw, msg->l2)
+    error = (msg->frame
+             ? ofpraw_decode(&raw, msg->frame)
              : ofpraw_pull(&raw, msg));
     if (error) {
         return error;
     }
-    oh = msg->l2;
+    oh = msg->frame;
 
     if (!ofpbuf_size(msg)) {
         return EOF;
@@ -2855,15 +2923,14 @@ ofputil_append_flow_stats_reply(const struct ofputil_flow_stats *fs,
 {
     struct ofpbuf *reply = ofpbuf_from_list(list_back(replies));
     size_t start_ofs = ofpbuf_size(reply);
-    enum ofpraw raw;
-    enum ofp_version version = ((struct ofp_header *)ofpbuf_data(reply))->version;
+    enum ofp_version version = ofpmp_version(replies);
+    enum ofpraw raw = ofpmp_decode_raw(replies);
 
-    ofpraw_decode_partial(&raw, ofpbuf_data(reply), ofpbuf_size(reply));
     if (raw == OFPRAW_OFPST11_FLOW_REPLY || raw == OFPRAW_OFPST13_FLOW_REPLY) {
         struct ofp11_flow_stats *ofs;
 
         ofpbuf_put_uninit(reply, sizeof *ofs);
-        oxm_put_match(reply, &fs->match);
+        oxm_put_match(reply, &fs->match, version);
         ofpacts_put_openflow_instructions(fs->ofpacts, fs->ofpacts_len, reply,
                                           version);
 
@@ -2982,7 +3049,7 @@ ofputil_decode_aggregate_stats_reply(struct ofputil_aggregate_stats *stats,
     ofpbuf_use_const(&msg, reply, ntohs(reply->length));
     ofpraw_pull_assert(&msg);
 
-    asr = ofpbuf_get_l3(&msg);
+    asr = ofpbuf_l3(&msg);
     stats->packet_count = ntohll(get_32aligned_be64(&asr->packet_count));
     stats->byte_count = ntohll(get_32aligned_be64(&asr->byte_count));
     stats->flow_count = ntohl(asr->flow_count);
@@ -3083,7 +3150,8 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
     case OFPUTIL_P_OF11_STD:
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
-    case OFPUTIL_P_OF14_OXM: {
+    case OFPUTIL_P_OF14_OXM:
+    case OFPUTIL_P_OF15_OXM: {
         struct ofp12_flow_removed *ofr;
 
         msg = ofpraw_alloc_xid(OFPRAW_OFPT11_FLOW_REMOVED,
@@ -3134,7 +3202,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         nfr = ofpbuf_put_zeros(msg, sizeof *nfr);
         match_len = nx_put_match(msg, &fr->match, 0, 0);
 
-        nfr = ofpbuf_get_l3(msg);
+        nfr = ofpbuf_l3(msg);
         nfr->cookie = fr->cookie;
         nfr->priority = htons(fr->priority);
         nfr->reason = fr->reason;
@@ -3346,7 +3414,7 @@ ofputil_encode_nx_packet_in(const struct ofputil_packet_in *pin)
     ofpbuf_put_zeros(packet, 2);
     ofpbuf_put(packet, pin->packet, pin->packet_len);
 
-    npi = ofpbuf_get_l3(packet);
+    npi = ofpbuf_l3(packet);
     npi->buffer_id = htonl(pin->buffer_id);
     npi->total_len = htons(pin->total_len);
     npi->reason = pin->reason;
@@ -3406,11 +3474,11 @@ ofputil_encode_ofp12_packet_in(const struct ofputil_packet_in *pin,
                               htonl(0), (sizeof(struct flow_metadata) * 2
                                          + 2 + pin->packet_len));
     ofpbuf_put_zeros(packet, packet_in_size);
-    oxm_put_match(packet, &match);
+    oxm_put_match(packet, &match, ofputil_protocol_to_ofp_version(protocol));
     ofpbuf_put_zeros(packet, 2);
     ofpbuf_put(packet, pin->packet, pin->packet_len);
 
-    opi = ofpbuf_get_l3(packet);
+    opi = ofpbuf_l3(packet);
     opi->pi.buffer_id = htonl(pin->buffer_id);
     opi->pi.total_len = htons(pin->total_len);
     opi->pi.reason = pin->reason;
@@ -3448,6 +3516,7 @@ ofputil_encode_packet_in(const struct ofputil_packet_in *pin,
     case OFPUTIL_P_OF12_OXM:
     case OFPUTIL_P_OF13_OXM:
     case OFPUTIL_P_OF14_OXM:
+    case OFPUTIL_P_OF15_OXM:
         packet = ofputil_encode_ofp12_packet_in(pin, protocol);
         break;
 
@@ -3637,8 +3706,6 @@ static enum ofperr
 ofputil_decode_ofp10_phy_port(struct ofputil_phy_port *pp,
                               const struct ofp10_phy_port *opp)
 {
-    memset(pp, 0, sizeof *pp);
-
     pp->port_no = u16_to_ofp(ntohs(opp->port_no));
     memcpy(pp->hw_addr, opp->hw_addr, OFP_ETH_ALEN);
     ovs_strlcpy(pp->name, opp->name, OFP_MAX_PORT_NAME_LEN);
@@ -3663,8 +3730,6 @@ ofputil_decode_ofp11_port(struct ofputil_phy_port *pp,
 {
     enum ofperr error;
 
-    memset(pp, 0, sizeof *pp);
-
     error = ofputil_port_from_ofp11(op->port_no, &pp->port_no);
     if (error) {
         return error;
@@ -3686,20 +3751,84 @@ ofputil_decode_ofp11_port(struct ofputil_phy_port *pp,
     return 0;
 }
 
-static size_t
-ofputil_get_phy_port_size(enum ofp_version ofp_version)
+static enum ofperr
+parse_ofp14_port_ethernet_property(const struct ofpbuf *payload,
+                                   struct ofputil_phy_port *pp)
 {
-    switch (ofp_version) {
-    case OFP10_VERSION:
-        return sizeof(struct ofp10_phy_port);
-    case OFP11_VERSION:
-    case OFP12_VERSION:
-    case OFP13_VERSION:
-    case OFP14_VERSION:
-        return sizeof(struct ofp11_port);
-    default:
-        OVS_NOT_REACHED();
+    struct ofp14_port_desc_prop_ethernet *eth = ofpbuf_data(payload);
+
+    if (ofpbuf_size(payload) != sizeof *eth) {
+        return OFPERR_OFPBPC_BAD_LEN;
     }
+
+    pp->curr = netdev_port_features_from_ofp11(eth->curr);
+    pp->advertised = netdev_port_features_from_ofp11(eth->advertised);
+    pp->supported = netdev_port_features_from_ofp11(eth->supported);
+    pp->peer = netdev_port_features_from_ofp11(eth->peer);
+
+    pp->curr_speed = ntohl(eth->curr_speed);
+    pp->max_speed = ntohl(eth->max_speed);
+
+    return 0;
+}
+
+static enum ofperr
+ofputil_pull_ofp14_port(struct ofputil_phy_port *pp, struct ofpbuf *msg)
+{
+    struct ofpbuf properties;
+    struct ofp14_port *op;
+    enum ofperr error;
+    size_t len;
+
+    op = ofpbuf_try_pull(msg, sizeof *op);
+    if (!op) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+
+    len = ntohs(op->length);
+    if (len < sizeof *op || len - sizeof *op > ofpbuf_size(msg)) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+    len -= sizeof *op;
+    ofpbuf_use_const(&properties, ofpbuf_pull(msg, len), len);
+
+    error = ofputil_port_from_ofp11(op->port_no, &pp->port_no);
+    if (error) {
+        return error;
+    }
+    memcpy(pp->hw_addr, op->hw_addr, OFP_ETH_ALEN);
+    ovs_strlcpy(pp->name, op->name, OFP_MAX_PORT_NAME_LEN);
+
+    pp->config = ntohl(op->config) & OFPPC11_ALL;
+    pp->state = ntohl(op->state) & OFPPS11_ALL;
+
+    while (ofpbuf_size(&properties) > 0) {
+        struct ofpbuf payload;
+        enum ofperr error;
+        uint16_t type;
+
+        error = ofputil_pull_property(&properties, &payload, &type);
+        if (error) {
+            return error;
+        }
+
+        switch (type) {
+        case OFPPDPT14_ETHERNET:
+            error = parse_ofp14_port_ethernet_property(&payload, pp);
+            break;
+
+        default:
+            log_property(true, "unknown port property %"PRIu16, type);
+            error = 0;
+            break;
+        }
+
+        if (error) {
+            return error;
+        }
+    }
+
+    return 0;
 }
 
 static void
@@ -3743,33 +3872,56 @@ ofputil_encode_ofp11_port(const struct ofputil_phy_port *pp,
     op->max_speed = htonl(pp->max_speed);
 }
 
+static void
+ofputil_put_ofp14_port(const struct ofputil_phy_port *pp,
+                       struct ofpbuf *b)
+{
+    struct ofp14_port *op;
+    struct ofp14_port_desc_prop_ethernet *eth;
+
+    ofpbuf_prealloc_tailroom(b, sizeof *op + sizeof *eth);
+
+    op = ofpbuf_put_zeros(b, sizeof *op);
+    op->port_no = ofputil_port_to_ofp11(pp->port_no);
+    op->length = htons(sizeof *op + sizeof *eth);
+    memcpy(op->hw_addr, pp->hw_addr, ETH_ADDR_LEN);
+    ovs_strlcpy(op->name, pp->name, sizeof op->name);
+    op->config = htonl(pp->config & OFPPC11_ALL);
+    op->state = htonl(pp->state & OFPPS11_ALL);
+
+    eth = ofpbuf_put_zeros(b, sizeof *eth);
+    eth->type = htons(OFPPDPT14_ETHERNET);
+    eth->length = htons(sizeof *eth);
+    eth->curr = netdev_port_features_to_ofp11(pp->curr);
+    eth->advertised = netdev_port_features_to_ofp11(pp->advertised);
+    eth->supported = netdev_port_features_to_ofp11(pp->supported);
+    eth->peer = netdev_port_features_to_ofp11(pp->peer);
+    eth->curr_speed = htonl(pp->curr_speed);
+    eth->max_speed = htonl(pp->max_speed);
+}
+
 static void
 ofputil_put_phy_port(enum ofp_version ofp_version,
                      const struct ofputil_phy_port *pp, struct ofpbuf *b)
 {
     switch (ofp_version) {
     case OFP10_VERSION: {
-        struct ofp10_phy_port *opp;
-        if (ofpbuf_size(b) + sizeof *opp <= UINT16_MAX) {
-            opp = ofpbuf_put_uninit(b, sizeof *opp);
-            ofputil_encode_ofp10_phy_port(pp, opp);
-        }
+        struct ofp10_phy_port *opp = ofpbuf_put_uninit(b, sizeof *opp);
+        ofputil_encode_ofp10_phy_port(pp, opp);
         break;
     }
 
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION: {
-        struct ofp11_port *op;
-        if (ofpbuf_size(b) + sizeof *op <= UINT16_MAX) {
-            op = ofpbuf_put_uninit(b, sizeof *op);
-            ofputil_encode_ofp11_port(pp, op);
-        }
+        struct ofp11_port *op = ofpbuf_put_uninit(b, sizeof *op);
+        ofputil_encode_ofp11_port(pp, op);
         break;
     }
 
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION:
+        ofputil_put_ofp14_port(pp, b);
         break;
 
     default:
@@ -3777,37 +3929,68 @@ ofputil_put_phy_port(enum ofp_version ofp_version,
     }
 }
 
-void
-ofputil_append_port_desc_stats_reply(enum ofp_version ofp_version,
-                                     const struct ofputil_phy_port *pp,
-                                     struct list *replies)
+enum ofperr
+ofputil_decode_port_desc_stats_request(const struct ofp_header *request,
+                                       ofp_port_t *port)
 {
-    switch (ofp_version) {
-    case OFP10_VERSION: {
-        struct ofp10_phy_port *opp;
+    struct ofpbuf b;
+    enum ofpraw raw;
 
-        opp = ofpmp_append(replies, sizeof *opp);
-        ofputil_encode_ofp10_phy_port(pp, opp);
-        break;
+    ofpbuf_use_const(&b, request, ntohs(request->length));
+    raw = ofpraw_pull_assert(&b);
+    if (raw == OFPRAW_OFPST10_PORT_DESC_REQUEST) {
+        *port = OFPP_ANY;
+        return 0;
+    } else if (raw == OFPRAW_OFPST15_PORT_DESC_REQUEST) {
+        ovs_be32 *ofp11_port;
+
+        ofp11_port = ofpbuf_pull(&b, sizeof *ofp11_port);
+        return ofputil_port_from_ofp11(*ofp11_port, port);
+    } else {
+        OVS_NOT_REACHED();
     }
+}
 
+struct ofpbuf *
+ofputil_encode_port_desc_stats_request(enum ofp_version ofp_version,
+                                       ofp_port_t port)
+{
+    struct ofpbuf *request;
+    ovs_be32 ofp11_port;
+
+    switch (ofp_version) {
+    case OFP10_VERSION:
     case OFP11_VERSION:
     case OFP12_VERSION:
-    case OFP13_VERSION: {
-        struct ofp11_port *op;
-
-        op = ofpmp_append(replies, sizeof *op);
-        ofputil_encode_ofp11_port(pp, op);
+    case OFP13_VERSION:
+    case OFP14_VERSION:
+        request = ofpraw_alloc(OFPRAW_OFPST10_PORT_DESC_REQUEST,
+                               ofp_version, 0);
         break;
-    }
 
-    case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION:
+        request = ofpraw_alloc(OFPRAW_OFPST15_PORT_DESC_REQUEST,
+                               ofp_version, 0);
+        ofp11_port = ofputil_port_to_ofp11(port);
+        ofpbuf_put(request, &ofp11_port, sizeof ofp11_port);
         break;
 
     default:
-      OVS_NOT_REACHED();
+        OVS_NOT_REACHED();
     }
+
+    return request;
+}
+
+void
+ofputil_append_port_desc_stats_reply(const struct ofputil_phy_port *pp,
+                                     struct list *replies)
+{
+    struct ofpbuf *reply = ofpbuf_from_list(list_back(replies));
+    size_t start_ofs = ofpbuf_size(reply);
+
+    ofputil_put_phy_port(ofpmp_version(replies), pp, reply);
+    ofpmp_postappend(replies, start_ofs);
 }
 \f
 /* ofputil_switch_features */
@@ -3867,10 +4050,9 @@ ofputil_capabilities_mask(enum ofp_version ofp_version)
         return OFPC_COMMON | OFPC_ARP_MATCH_IP;
     case OFP12_VERSION:
     case OFP13_VERSION:
-        return OFPC_COMMON | OFPC12_PORT_BLOCKED;
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        break;
+    case OFP15_VERSION:
+        return OFPC_COMMON | OFPC12_PORT_BLOCKED;
     default:
         /* Caller needs to check osf->header.version itself */
         return 0;
@@ -3902,10 +4084,6 @@ ofputil_decode_switch_features(const struct ofp_header *oh,
     features->capabilities = ntohl(osf->capabilities) &
         ofputil_capabilities_mask(oh->version);
 
-    if (ofpbuf_size(b) % ofputil_get_phy_port_size(oh->version)) {
-        return OFPERR_OFPBRC_BAD_LEN;
-    }
-
     if (raw == OFPRAW_OFPT10_FEATURES_REPLY) {
         if (osf->capabilities & htonl(OFPC10_STP)) {
             features->capabilities |= OFPUTIL_C_STP;
@@ -3927,35 +4105,43 @@ ofputil_decode_switch_features(const struct ofp_header *oh,
     return 0;
 }
 
-/* Returns true if the maximum number of ports are in 'oh'. */
-static bool
-max_ports_in_features(const struct ofp_header *oh)
-{
-    size_t pp_size = ofputil_get_phy_port_size(oh->version);
-    return ntohs(oh->length) + pp_size > UINT16_MAX;
-}
-
-/* Given a buffer 'b' that contains a Features Reply message, checks if
- * it contains the maximum number of ports that will fit.  If so, it
- * returns true and removes the ports from the message.  The caller
- * should then send an OFPST_PORT_DESC stats request to get the ports,
- * since the switch may have more ports than could be represented in the
- * Features Reply.  Otherwise, returns false.
- */
+/* In OpenFlow 1.0, 1.1, and 1.2, an OFPT_FEATURES_REPLY message lists all the
+ * switch's ports, unless there are too many to fit.  In OpenFlow 1.3 and
+ * later, an OFPT_FEATURES_REPLY does not list ports at all.
+ *
+ * Given a buffer 'b' that contains a Features Reply message, this message
+ * checks if it contains a complete list of the switch's ports.  Returns true,
+ * if so.  Returns false if the list is missing (OF1.3+) or incomplete
+ * (OF1.0/1.1/1.2), and in the latter case removes all of the ports from the
+ * message.
+ *
+ * When this function returns false, the caller should send an OFPST_PORT_DESC
+ * stats request to get the ports. */
 bool
-ofputil_switch_features_ports_trunc(struct ofpbuf *b)
+ofputil_switch_features_has_ports(struct ofpbuf *b)
 {
     struct ofp_header *oh = ofpbuf_data(b);
+    size_t phy_port_size;
 
-    if (max_ports_in_features(oh)) {
-        /* Remove all the ports. */
-        ofpbuf_set_size(b, (sizeof(struct ofp_header) +
-                            sizeof(struct ofp_switch_features)));
-        ofpmsg_update_length(b);
+    if (oh->version >= OFP13_VERSION) {
+        /* OpenFlow 1.3+ never has ports in the feature reply. */
+        return false;
+    }
 
+    phy_port_size = (oh->version == OFP10_VERSION
+                     ? sizeof(struct ofp10_phy_port)
+                     : sizeof(struct ofp11_port));
+    if (ntohs(oh->length) + phy_port_size <= UINT16_MAX) {
+        /* There's room for additional ports in the feature reply.
+         * Assume that the list is complete. */
         return true;
     }
 
+    /* The feature reply has no room for more ports.  Probably the list is
+     * truncated.  Drop the ports and tell the caller to retrieve them with
+     * OFPST_PORT_DESC. */
+    ofpbuf_set_size(b, sizeof *oh + sizeof(struct ofp_switch_features));
+    ofpmsg_update_length(b);
     return false;
 }
 
@@ -3998,6 +4184,7 @@ ofputil_encode_switch_features(const struct ofputil_switch_features *features,
         break;
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         raw = OFPRAW_OFPT13_FEATURES_REPLY;
         break;
     default:
@@ -4021,6 +4208,7 @@ ofputil_encode_switch_features(const struct ofputil_switch_features *features,
         break;
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         osf->auxiliary_id = features->auxiliary_id;
         /* fall through */
     case OFP11_VERSION:
@@ -4046,7 +4234,14 @@ ofputil_put_switch_features_port(const struct ofputil_phy_port *pp,
     const struct ofp_header *oh = ofpbuf_data(b);
 
     if (oh->version < OFP13_VERSION) {
+        /* Try adding a port description to the message, but drop it again if
+         * the buffer overflows.  (This possibility for overflow is why
+         * OpenFlow 1.3+ moved port descriptions into a multipart message.)  */
+        size_t start_ofs = ofpbuf_size(b);
         ofputil_put_phy_port(oh->version, pp, b);
+        if (ofpbuf_size(b) > UINT16_MAX) {
+            ofpbuf_set_size(b, start_ofs);
+        }
     }
 }
 \f
@@ -4099,10 +4294,14 @@ ofputil_encode_port_status(const struct ofputil_port_status *ps,
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION:
-    case OFP14_VERSION:
         raw = OFPRAW_OFPT11_PORT_STATUS;
         break;
 
+    case OFP14_VERSION:
+    case OFP15_VERSION:
+        raw = OFPRAW_OFPT14_PORT_STATUS;
+        break;
+
     default:
         OVS_NOT_REACHED();
     }
@@ -4117,11 +4316,25 @@ ofputil_encode_port_status(const struct ofputil_port_status *ps,
 
 /* ofputil_port_mod */
 
+static enum ofperr
+parse_port_mod_ethernet_property(struct ofpbuf *property,
+                                 struct ofputil_port_mod *pm)
+{
+    struct ofp14_port_mod_prop_ethernet *eth = ofpbuf_data(property);
+
+    if (ofpbuf_size(property) != sizeof *eth) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+
+    pm->advertise = netdev_port_features_from_ofp11(eth->advertise);
+    return 0;
+}
+
 /* Decodes the OpenFlow "port mod" message in '*oh' into an abstract form in
  * '*pm'.  Returns 0 if successful, otherwise an OFPERR_* value. */
 enum ofperr
 ofputil_decode_port_mod(const struct ofp_header *oh,
-                        struct ofputil_port_mod *pm)
+                        struct ofputil_port_mod *pm, bool loose)
 {
     enum ofpraw raw;
     struct ofpbuf b;
@@ -4150,6 +4363,52 @@ ofputil_decode_port_mod(const struct ofp_header *oh,
         pm->config = ntohl(opm->config) & OFPPC11_ALL;
         pm->mask = ntohl(opm->mask) & OFPPC11_ALL;
         pm->advertise = netdev_port_features_from_ofp11(opm->advertise);
+    } else if (raw == OFPRAW_OFPT14_PORT_MOD) {
+        const struct ofp14_port_mod *opm = ofpbuf_pull(&b, sizeof *opm);
+        enum ofperr error;
+
+        memset(pm, 0, sizeof *pm);
+
+        error = ofputil_port_from_ofp11(opm->port_no, &pm->port_no);
+        if (error) {
+            return error;
+        }
+
+        memcpy(pm->hw_addr, opm->hw_addr, ETH_ADDR_LEN);
+        pm->config = ntohl(opm->config) & OFPPC11_ALL;
+        pm->mask = ntohl(opm->mask) & OFPPC11_ALL;
+
+        while (ofpbuf_size(&b) > 0) {
+            struct ofpbuf property;
+            enum ofperr error;
+            uint16_t type;
+
+            error = ofputil_pull_property(&b, &property, &type);
+            if (error) {
+                return error;
+            }
+
+            switch (type) {
+            case OFPPMPT14_ETHERNET:
+                error = parse_port_mod_ethernet_property(&property, pm);
+                break;
+
+            default:
+                log_property(loose, "unknown port_mod property %"PRIu16, type);
+                if (loose) {
+                    error = 0;
+                } else if (type == OFPPMPT14_EXPERIMENTER) {
+                    error = OFPERR_OFPBPC_BAD_EXPERIMENTER;
+                } else {
+                    error = OFPERR_OFPBRC_BAD_TYPE;
+                }
+                break;
+            }
+
+            if (error) {
+                return error;
+            }
+        }
     } else {
         return OFPERR_OFPBRC_BAD_TYPE;
     }
@@ -4197,8 +4456,25 @@ ofputil_encode_port_mod(const struct ofputil_port_mod *pm,
         break;
     }
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION: {
+        struct ofp14_port_mod_prop_ethernet *eth;
+        struct ofp14_port_mod *opm;
+
+        b = ofpraw_alloc(OFPRAW_OFPT14_PORT_MOD, ofp_version, sizeof *eth);
+        opm = ofpbuf_put_zeros(b, sizeof *opm);
+        opm->port_no = ofputil_port_to_ofp11(pm->port_no);
+        memcpy(opm->hw_addr, pm->hw_addr, ETH_ADDR_LEN);
+        opm->config = htonl(pm->config & OFPPC11_ALL);
+        opm->mask = htonl(pm->mask & OFPPC11_ALL);
+
+        if (pm->advertise) {
+            eth = ofpbuf_put_zeros(b, sizeof *eth);
+            eth->type = htons(OFPPMPT14_ETHERNET);
+            eth->length = htons(sizeof *eth);
+            eth->advertise = netdev_port_features_to_ofp11(pm->advertise);
+        }
         break;
+    }
     default:
         OVS_NOT_REACHED();
     }
@@ -4206,48 +4482,17 @@ ofputil_encode_port_mod(const struct ofputil_port_mod *pm,
     return b;
 }
 
-struct ofp_prop_header {
-    ovs_be16 type;
-    ovs_be16 len;
-};
-
 static enum ofperr
-ofputil_pull_property(struct ofpbuf *msg, struct ofpbuf *payload,
-                      uint16_t *typep)
-{
-    struct ofp_prop_header *oph;
-    unsigned int len;
-
-    if (ofpbuf_size(msg) < sizeof *oph) {
-        return OFPERR_OFPTFFC_BAD_LEN;
-    }
-
-    oph = ofpbuf_data(msg);
-    len = ntohs(oph->len);
-    if (len < sizeof *oph || ROUND_UP(len, 8) > ofpbuf_size(msg)) {
-        return OFPERR_OFPTFFC_BAD_LEN;
-    }
-
-    *typep = ntohs(oph->type);
-    if (payload) {
-        ofpbuf_use_const(payload, ofpbuf_data(msg), len);
-        ofpbuf_pull(payload, sizeof *oph);
-    }
-    ofpbuf_pull(msg, ROUND_UP(len, 8));
-    return 0;
-}
-
-static void PRINTF_FORMAT(2, 3)
-log_property(bool loose, const char *message, ...)
+pull_table_feature_property(struct ofpbuf *msg, struct ofpbuf *payload,
+                        uint16_t *typep)
 {
-    enum vlog_level level = loose ? VLL_DBG : VLL_WARN;
-    if (!vlog_should_drop(THIS_MODULE, level, &bad_ofmsg_rl)) {
-        va_list args;
+    enum ofperr error;
 
-        va_start(args, message);
-        vlog_valist(THIS_MODULE, level, message, args);
-        va_end(args);
+    error = ofputil_pull_property(msg, payload, typep);
+    if (payload && !error) {
+        ofpbuf_pull(payload, sizeof(struct ofp_prop_header));
     }
+    return error;
 }
 
 static enum ofperr
@@ -4257,7 +4502,7 @@ parse_table_ids(struct ofpbuf *payload, uint32_t *ids)
 
     *ids = 0;
     while (ofpbuf_size(payload) > 0) {
-        enum ofperr error = ofputil_pull_property(payload, NULL, &type);
+        enum ofperr error = pull_table_feature_property(payload, NULL, &type);
         if (error) {
             return error;
         }
@@ -4277,7 +4522,7 @@ parse_instruction_ids(struct ofpbuf *payload, bool loose, uint32_t *insts)
         enum ofperr error;
         uint16_t ofpit;
 
-        error = ofputil_pull_property(payload, NULL, &ofpit);
+        error = pull_table_feature_property(payload, NULL, &ofpit);
         if (error) {
             return error;
         }
@@ -4302,7 +4547,7 @@ parse_table_features_next_table(struct ofpbuf *payload,
     for (i = 0; i < ofpbuf_size(payload); i++) {
         uint8_t id = ((const uint8_t *) ofpbuf_data(payload))[i];
         if (id >= 255) {
-            return OFPERR_OFPTFFC_BAD_ARGUMENT;
+            return OFPERR_OFPBPC_BAD_VALUE;
         }
         bitmap_set1(next_tables, id);
     }
@@ -4318,7 +4563,7 @@ parse_oxm(struct ofpbuf *b, bool loose,
 
     oxmp = ofpbuf_try_pull(b, sizeof *oxmp);
     if (!oxmp) {
-        return OFPERR_OFPTFFC_BAD_LEN;
+        return OFPERR_OFPBPC_BAD_LEN;
     }
     oxm = ntohl(*oxmp);
 
@@ -4329,7 +4574,7 @@ parse_oxm(struct ofpbuf *b, bool loose,
     *hasmask = NXM_HASMASK(oxm);
     if (*hasmask) {
         if (NXM_LENGTH(oxm) & 1) {
-            return OFPERR_OFPTFFC_BAD_ARGUMENT;
+            return OFPERR_OFPBPC_BAD_VALUE;
         }
         oxm = NXM_HEADER(NXM_VENDOR(oxm), NXM_FIELD(oxm), NXM_LENGTH(oxm) / 2);
     }
@@ -4400,8 +4645,7 @@ ofputil_decode_table_features(struct ofpbuf *msg,
     struct ofp13_table_features *otf;
     unsigned int len;
 
-    if (!msg->l2) {
-        msg->l2 = ofpbuf_data(msg);
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -4410,13 +4654,13 @@ ofputil_decode_table_features(struct ofpbuf *msg,
     }
 
     if (ofpbuf_size(msg) < sizeof *otf) {
-        return OFPERR_OFPTFFC_BAD_LEN;
+        return OFPERR_OFPBPC_BAD_LEN;
     }
 
     otf = ofpbuf_data(msg);
     len = ntohs(otf->length);
     if (len < sizeof *otf || len % 8 || len > ofpbuf_size(msg)) {
-        return OFPERR_OFPTFFC_BAD_LEN;
+        return OFPERR_OFPBPC_BAD_LEN;
     }
     ofpbuf_pull(msg, sizeof *otf);
 
@@ -4436,7 +4680,7 @@ ofputil_decode_table_features(struct ofpbuf *msg,
         enum ofperr error;
         uint16_t type;
 
-        error = ofputil_pull_property(msg, &payload, &type);
+        error = pull_table_feature_property(msg, &payload, &type);
         if (error) {
             return error;
         }
@@ -4499,9 +4743,10 @@ ofputil_decode_table_features(struct ofpbuf *msg,
 
         case OFPTFPT13_EXPERIMENTER:
         case OFPTFPT13_EXPERIMENTER_MISS:
-            log_property(loose,
-                         "unknown table features experimenter property");
-            error = loose ? 0 : OFPERR_OFPTFFC_BAD_TYPE;
+        default:
+            log_property(loose, "unknown table features property %"PRIu16,
+                         type);
+            error = loose ? 0 : OFPERR_OFPBPC_BAD_TYPE;
             break;
         }
         if (error) {
@@ -4539,6 +4784,7 @@ ofputil_encode_table_features_request(enum ofp_version ofp_version)
                      "(\'-O OpenFlow13\')");
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         request = ofpraw_alloc(OFPRAW_OFPST13_TABLE_FEATURES_REQUEST,
                                ofp_version, 0);
         break;
@@ -4568,6 +4814,13 @@ ofputil_decode_table_mod(const struct ofp_header *oh,
 
         pm->table_id = otm->table_id;
         pm->config = ntohl(otm->config);
+    } else if (raw == OFPRAW_OFPT14_TABLE_MOD) {
+        const struct ofp14_table_mod *otm = ofpbuf_pull(&b, sizeof *otm);
+
+        pm->table_id = otm->table_id;
+        pm->config = ntohl(otm->config);
+        /* We do not understand any properties yet, so we do not bother
+         * parsing them. */
     } else {
         return OFPERR_OFPBRC_BAD_TYPE;
     }
@@ -4603,8 +4856,15 @@ ofputil_encode_table_mod(const struct ofputil_table_mod *pm,
         break;
     }
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION: {
+        struct ofp14_table_mod *otm;
+
+        b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
+        otm = ofpbuf_put_zeros(b, sizeof *otm);
+        otm->table_id = pm->table_id;
+        otm->config = htonl(pm->config);
         break;
+    }
     default:
         OVS_NOT_REACHED();
     }
@@ -4629,7 +4889,7 @@ ofputil_decode_role_message(const struct ofp_header *oh,
 
     if (raw == OFPRAW_OFPT12_ROLE_REQUEST ||
         raw == OFPRAW_OFPT12_ROLE_REPLY) {
-        const struct ofp12_role_request *orr = ofpbuf_get_l3(&b);
+        const struct ofp12_role_request *orr = ofpbuf_l3(&b);
 
         if (orr->role != htonl(OFPCR12_ROLE_NOCHANGE) &&
             orr->role != htonl(OFPCR12_ROLE_EQUAL) &&
@@ -4650,7 +4910,7 @@ ofputil_decode_role_message(const struct ofp_header *oh,
         }
     } else if (raw == OFPRAW_NXT_ROLE_REQUEST ||
                raw == OFPRAW_NXT_ROLE_REPLY) {
-        const struct nx_role_request *nrr = ofpbuf_get_l3(&b);
+        const struct nx_role_request *nrr = ofpbuf_l3(&b);
 
         BUILD_ASSERT(NX_ROLE_OTHER + 1 == OFPCR12_ROLE_EQUAL);
         BUILD_ASSERT(NX_ROLE_MASTER + 1 == OFPCR12_ROLE_MASTER);
@@ -4709,22 +4969,31 @@ ofputil_encode_role_reply(const struct ofp_header *request,
     return buf;
 }
 \f
+/* Encodes "role status" message 'status' for sending in the given
+ * 'protocol'.  Returns the role status message, if 'protocol' supports them,
+ * otherwise a null pointer. */
 struct ofpbuf *
 ofputil_encode_role_status(const struct ofputil_role_status *status,
                            enum ofputil_protocol protocol)
 {
-    struct ofpbuf *buf;
     enum ofp_version version;
-    struct ofp14_role_status *rstatus;
 
     version = ofputil_protocol_to_ofp_version(protocol);
-    buf = ofpraw_alloc_xid(OFPRAW_OFPT14_ROLE_STATUS, version, htonl(0), 0);
-    rstatus = ofpbuf_put_zeros(buf, sizeof *rstatus);
-    rstatus->role = htonl(status->role);
-    rstatus->reason = status->reason;
-    rstatus->generation_id = htonll(status->generation_id);
-
-    return buf;
+    if (version >= OFP14_VERSION) {
+        struct ofp14_role_status *rstatus;
+        struct ofpbuf *buf;
+
+        buf = ofpraw_alloc_xid(OFPRAW_OFPT14_ROLE_STATUS, version, htonl(0),
+                               0);
+        rstatus = ofpbuf_put_zeros(buf, sizeof *rstatus);
+        rstatus->role = htonl(status->role);
+        rstatus->reason = status->reason;
+        rstatus->generation_id = htonll(status->generation_id);
+
+        return buf;
+    } else {
+        return NULL;
+    }
 }
 
 enum ofperr
@@ -4739,7 +5008,7 @@ ofputil_decode_role_status(const struct ofp_header *oh,
     raw = ofpraw_pull_assert(&b);
     ovs_assert(raw == OFPRAW_OFPT14_ROLE_STATUS);
 
-    r = ofpbuf_get_l3(&b);
+    r = ofpbuf_l3(&b);
     if (r->role != htonl(OFPCR12_ROLE_NOCHANGE) &&
         r->role != htonl(OFPCR12_ROLE_EQUAL) &&
         r->role != htonl(OFPCR12_ROLE_MASTER) &&
@@ -4912,6 +5181,7 @@ ofputil_encode_table_stats_reply(const struct ofp12_table_stats stats[], int n,
 
         case OFP13_VERSION:
         case OFP14_VERSION:
+        case OFP15_VERSION:
             ofputil_put_ofp13_table_stats(&stats[i], reply);
             break;
 
@@ -4942,8 +5212,7 @@ ofputil_decode_flow_monitor_request(struct ofputil_flow_monitor_request *rq,
     struct nx_flow_monitor_request *nfmr;
     uint16_t flags;
 
-    if (!msg->l2) {
-        msg->l2 = ofpbuf_data(msg);
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -5027,8 +5296,7 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
     unsigned int length;
     struct ofp_header *oh;
 
-    if (!msg->l2) {
-        msg->l2 = ofpbuf_data(msg);
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -5040,7 +5308,7 @@ ofputil_decode_flow_update(struct ofputil_flow_update *update,
         goto bad_len;
     }
 
-    oh = msg->l2;
+    oh = msg->frame;
 
     nfuh = ofpbuf_data(msg);
     update->event = ntohs(nfuh->event);
@@ -5148,14 +5416,13 @@ void
 ofputil_append_flow_update(const struct ofputil_flow_update *update,
                            struct list *replies)
 {
+    enum ofp_version version = ofpmp_version(replies);
     struct nx_flow_update_header *nfuh;
     struct ofpbuf *msg;
     size_t start_ofs;
-    enum ofp_version version;
 
     msg = ofpbuf_from_list(list_back(replies));
     start_ofs = ofpbuf_size(msg);
-    version = ((struct ofp_header *)msg->l2)->version;
 
     if (update->event == NXFME_ABBREV) {
         struct nx_flow_update_abbrev *nfua;
@@ -5211,7 +5478,7 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po,
         ofpacts_put_openflow_actions(po->ofpacts, po->ofpacts_len, msg,
                                      ofp_version);
 
-        opo = ofpbuf_get_l3(msg);
+        opo = ofpbuf_l3(msg);
         opo->buffer_id = htonl(po->buffer_id);
         opo->in_port = htons(ofp_to_u16(po->in_port));
         opo->actions_len = htons(ofpbuf_size(msg) - actions_ofs);
@@ -5221,7 +5488,8 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po,
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION:
-    case OFP14_VERSION:{
+    case OFP14_VERSION:
+    case OFP15_VERSION: {
         struct ofp11_packet_out *opo;
         size_t len;
 
@@ -5229,7 +5497,7 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po,
         ofpbuf_put_zeros(msg, sizeof *opo);
         len = ofpacts_put_openflow_actions(po->ofpacts, po->ofpacts_len, msg,
                                            ofp_version);
-        opo = ofpbuf_get_l3(msg);
+        opo = ofpbuf_l3(msg);
         opo->buffer_id = htonl(po->buffer_id);
         opo->in_port = ofputil_port_to_ofp11(po->in_port);
         opo->actions_len = htons(len);
@@ -5279,6 +5547,7 @@ ofputil_encode_barrier_request(enum ofp_version ofp_version)
     enum ofpraw type;
 
     switch (ofp_version) {
+    case OFP15_VERSION:
     case OFP14_VERSION:
     case OFP13_VERSION:
     case OFP12_VERSION:
@@ -5397,8 +5666,12 @@ ofputil_port_to_ofp11(ofp_port_t ofp10_port)
 bool
 ofputil_port_from_string(const char *s, ofp_port_t *portp)
 {
-    uint32_t port32;
+    unsigned int port32; /* int is at least 32 bits wide. */
 
+    if (*s == '-') {
+        VLOG_WARN("Negative value %s is not a valid port number.", s);
+        return false;
+    }
     *portp = 0;
     if (str_to_uint(s, 10, &port32)) {
         if (port32 < ofp_to_u16(OFPP_MAX)) {
@@ -5549,6 +5822,8 @@ int
 ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *b,
                       struct ofputil_phy_port *pp)
 {
+    memset(pp, 0, sizeof *pp);
+
     switch (ofp_version) {
     case OFP10_VERSION: {
         const struct ofp10_phy_port *opp = ofpbuf_try_pull(b, sizeof *opp);
@@ -5561,20 +5836,13 @@ ofputil_pull_phy_port(enum ofp_version ofp_version, struct ofpbuf *b,
         return op ? ofputil_decode_ofp11_port(pp, op) : EOF;
     }
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        break;
+    case OFP15_VERSION:
+        return ofpbuf_size(b) ? ofputil_pull_ofp14_port(pp, b) : EOF;
     default:
         OVS_NOT_REACHED();
     }
 }
 
-/* Given a buffer 'b' that contains an array of OpenFlow ports of type
- * 'ofp_version', returns the number of elements. */
-size_t ofputil_count_phy_ports(uint8_t ofp_version, struct ofpbuf *b)
-{
-    return ofpbuf_size(b) / ofputil_get_phy_port_size(ofp_version);
-}
-
 /* ofp-util.def lists the mapping from names to action. */
 static const char *const names[OFPUTIL_N_ACTIONS] = {
     NULL,
@@ -5912,7 +6180,8 @@ ofputil_encode_dump_ports_request(enum ofp_version ofp_version, ofp_port_t port)
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION:
-    case OFP14_VERSION:{
+    case OFP14_VERSION:
+    case OFP15_VERSION: {
         struct ofp11_port_stats_request *req;
         request = ofpraw_alloc(OFPRAW_OFPST11_PORT_REQUEST, ofp_version, 0);
         req = ofpbuf_put_zeros(request, sizeof *req);
@@ -5975,16 +6244,47 @@ ofputil_port_stats_to_ofp13(const struct ofputil_port_stats *ops,
     ps13->duration_nsec = htonl(ops->duration_nsec);
 }
 
+static void
+ofputil_append_ofp14_port_stats(const struct ofputil_port_stats *ops,
+                                struct list *replies)
+{
+    struct ofp14_port_stats_prop_ethernet *eth;
+    struct ofp14_port_stats *ps14;
+    struct ofpbuf *reply;
+
+    reply = ofpmp_reserve(replies, sizeof *ps14 + sizeof *eth);
+
+    ps14 = ofpbuf_put_uninit(reply, sizeof *ps14);
+    ps14->length = htons(sizeof *ps14 + sizeof *eth);
+    memset(ps14->pad, 0, sizeof ps14->pad);
+    ps14->port_no = ofputil_port_to_ofp11(ops->port_no);
+    ps14->duration_sec = htonl(ops->duration_sec);
+    ps14->duration_nsec = htonl(ops->duration_nsec);
+    ps14->rx_packets = htonll(ops->stats.rx_packets);
+    ps14->tx_packets = htonll(ops->stats.tx_packets);
+    ps14->rx_bytes = htonll(ops->stats.rx_bytes);
+    ps14->tx_bytes = htonll(ops->stats.tx_bytes);
+    ps14->rx_dropped = htonll(ops->stats.rx_dropped);
+    ps14->tx_dropped = htonll(ops->stats.tx_dropped);
+    ps14->rx_errors = htonll(ops->stats.rx_errors);
+    ps14->tx_errors = htonll(ops->stats.tx_errors);
+
+    eth = ofpbuf_put_uninit(reply, sizeof *eth);
+    eth->type = htons(OFPPSPT14_ETHERNET);
+    eth->length = htons(sizeof *eth);
+    memset(eth->pad, 0, sizeof eth->pad);
+    eth->rx_frame_err = htonll(ops->stats.rx_frame_errors);
+    eth->rx_over_err = htonll(ops->stats.rx_over_errors);
+    eth->rx_crc_err = htonll(ops->stats.rx_crc_errors);
+    eth->collisions = htonll(ops->stats.collisions);
+}
 
 /* Encode a ports stat for 'ops' and append it to 'replies'. */
 void
 ofputil_append_port_stat(struct list *replies,
                          const struct ofputil_port_stats *ops)
 {
-    struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = ofpbuf_data(msg);
-
-    switch ((enum ofp_version)oh->version) {
+    switch (ofpmp_version(replies)) {
     case OFP13_VERSION: {
         struct ofp13_port_stats *reply = ofpmp_append(replies, sizeof *reply);
         ofputil_port_stats_to_ofp13(ops, reply);
@@ -6004,7 +6304,8 @@ ofputil_append_port_stat(struct list *replies,
     }
 
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION:
+        ofputil_append_ofp14_port_stats(ops, replies);
         break;
 
     default:
@@ -6078,23 +6379,92 @@ ofputil_port_stats_from_ofp13(struct ofputil_port_stats *ops,
     return error;
 }
 
-static size_t
-ofputil_get_port_stats_size(enum ofp_version ofp_version)
+static enum ofperr
+parse_ofp14_port_stats_ethernet_property(const struct ofpbuf *payload,
+                                         struct ofputil_port_stats *ops)
 {
-    switch (ofp_version) {
-    case OFP10_VERSION:
-        return sizeof(struct ofp10_port_stats);
-    case OFP11_VERSION:
-    case OFP12_VERSION:
-        return sizeof(struct ofp11_port_stats);
-    case OFP13_VERSION:
-        return sizeof(struct ofp13_port_stats);
-    case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        return 0;
-    default:
-        OVS_NOT_REACHED();
+    const struct ofp14_port_stats_prop_ethernet *eth = ofpbuf_data(payload);
+
+    if (ofpbuf_size(payload) != sizeof *eth) {
+        return OFPERR_OFPBPC_BAD_LEN;
     }
+
+    ops->stats.rx_frame_errors = ntohll(eth->rx_frame_err);
+    ops->stats.rx_over_errors = ntohll(eth->rx_over_err);
+    ops->stats.rx_crc_errors = ntohll(eth->rx_crc_err);
+    ops->stats.collisions = ntohll(eth->collisions);
+
+    return 0;
+}
+
+static enum ofperr
+ofputil_pull_ofp14_port_stats(struct ofputil_port_stats *ops,
+                              struct ofpbuf *msg)
+{
+    const struct ofp14_port_stats *ps14;
+    struct ofpbuf properties;
+    enum ofperr error;
+    size_t len;
+
+    ps14 = ofpbuf_try_pull(msg, sizeof *ps14);
+    if (!ps14) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+
+    len = ntohs(ps14->length);
+    if (len < sizeof *ps14 || len - sizeof *ps14 > ofpbuf_size(msg)) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+    len -= sizeof *ps14;
+    ofpbuf_use_const(&properties, ofpbuf_pull(msg, len), len);
+
+    error = ofputil_port_from_ofp11(ps14->port_no, &ops->port_no);
+    if (error) {
+        return error;
+    }
+
+    ops->duration_sec = ntohl(ps14->duration_sec);
+    ops->duration_nsec = ntohl(ps14->duration_nsec);
+    ops->stats.rx_packets = ntohll(ps14->rx_packets);
+    ops->stats.tx_packets = ntohll(ps14->tx_packets);
+    ops->stats.rx_bytes = ntohll(ps14->rx_bytes);
+    ops->stats.tx_bytes = ntohll(ps14->tx_bytes);
+    ops->stats.rx_dropped = ntohll(ps14->rx_dropped);
+    ops->stats.tx_dropped = ntohll(ps14->tx_dropped);
+    ops->stats.rx_errors = ntohll(ps14->rx_errors);
+    ops->stats.tx_errors = ntohll(ps14->tx_errors);
+    ops->stats.rx_frame_errors = UINT64_MAX;
+    ops->stats.rx_over_errors = UINT64_MAX;
+    ops->stats.rx_crc_errors = UINT64_MAX;
+    ops->stats.collisions = UINT64_MAX;
+
+    while (ofpbuf_size(&properties) > 0) {
+        struct ofpbuf payload;
+        enum ofperr error;
+        uint16_t type;
+
+        error = ofputil_pull_property(&properties, &payload, &type);
+        if (error) {
+            return error;
+        }
+
+        switch (type) {
+        case OFPPSPT14_ETHERNET:
+            error = parse_ofp14_port_stats_ethernet_property(&payload, ops);
+            break;
+
+        default:
+            log_property(true, "unknown port stats property %"PRIu16, type);
+            error = 0;
+            break;
+        }
+
+        if (error) {
+            return error;
+        }
+    }
+
+    return 0;
 }
 
 /* Returns the number of port stats elements in OFPTYPE_PORT_STATS_REPLY
@@ -6102,12 +6472,16 @@ ofputil_get_port_stats_size(enum ofp_version ofp_version)
 size_t
 ofputil_count_port_stats(const struct ofp_header *oh)
 {
+    struct ofputil_port_stats ps;
     struct ofpbuf b;
+    size_t n = 0;
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
-
-    return ofpbuf_size(&b) / ofputil_get_port_stats_size(oh->version);
+    while (!ofputil_decode_port_stats(&ps, &b)) {
+        n++;
+    }
+    return n;
 }
 
 /* Converts an OFPST_PORT_STATS reply in 'msg' into an abstract
@@ -6126,8 +6500,8 @@ ofputil_decode_port_stats(struct ofputil_port_stats *ps, struct ofpbuf *msg)
     enum ofperr error;
     enum ofpraw raw;
 
-    error = (msg->l2
-             ? ofpraw_decode(&raw, msg->l2)
+    error = (msg->frame
+             ? ofpraw_decode(&raw, msg->frame)
              : ofpraw_pull(&raw, msg));
     if (error) {
         return error;
@@ -6135,6 +6509,8 @@ ofputil_decode_port_stats(struct ofputil_port_stats *ps, struct ofpbuf *msg)
 
     if (!ofpbuf_size(msg)) {
         return EOF;
+    } else if (raw == OFPRAW_OFPST14_PORT_REPLY) {
+        return ofputil_pull_ofp14_port_stats(ps, msg);
     } else if (raw == OFPRAW_OFPST13_PORT_REPLY) {
         const struct ofp13_port_stats *ps13;
 
@@ -6177,6 +6553,8 @@ ofputil_decode_port_stats_request(const struct ofp_header *request,
                                   ofp_port_t *ofp10_port)
 {
     switch ((enum ofp_version)request->version) {
+    case OFP15_VERSION:
+    case OFP14_VERSION:
     case OFP13_VERSION:
     case OFP12_VERSION:
     case OFP11_VERSION: {
@@ -6190,10 +6568,6 @@ ofputil_decode_port_stats_request(const struct ofp_header *request,
         return 0;
     }
 
-    case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        break;
-
     default:
         OVS_NOT_REACHED();
     }
@@ -6230,7 +6604,8 @@ ofputil_encode_group_stats_request(enum ofp_version ofp_version,
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION:
-    case OFP14_VERSION: {
+    case OFP14_VERSION:
+    case OFP15_VERSION: {
         struct ofp11_group_stats_request *req;
         request = ofpraw_alloc(OFPRAW_OFPST11_GROUP_REQUEST, ofp_version, 0);
         req = ofpbuf_put_zeros(request, sizeof *req);
@@ -6244,16 +6619,40 @@ ofputil_encode_group_stats_request(enum ofp_version ofp_version,
     return request;
 }
 
+/* Decodes the OpenFlow group description request in 'oh', returning the group
+ * whose description is requested, or OFPG_ALL if stats for all groups was
+ * requested. */
+uint32_t
+ofputil_decode_group_desc_request(const struct ofp_header *oh)
+{
+    struct ofpbuf request;
+    enum ofpraw raw;
+
+    ofpbuf_use_const(&request, oh, ntohs(oh->length));
+    raw = ofpraw_pull_assert(&request);
+    if (raw == OFPRAW_OFPST11_GROUP_DESC_REQUEST) {
+        return OFPG_ALL;
+    } else if (raw == OFPRAW_OFPST15_GROUP_DESC_REQUEST) {
+        ovs_be32 *group_id = ofpbuf_pull(&request, sizeof *group_id);
+        return ntohl(*group_id);
+    } else {
+        OVS_NOT_REACHED();
+    }
+}
+
 /* Returns an OpenFlow group description request for OpenFlow version
- * 'ofp_version', that requests stats for group 'group_id'.  (Use OFPG_ALL to
- * request stats for all groups.)
+ * 'ofp_version', that requests stats for group 'group_id'.  Use OFPG_ALL to
+ * request stats for all groups (OpenFlow 1.4 and earlier always request all
+ * groups).
  *
  * Group descriptions include the bucket and action configuration for each
  * group. */
 struct ofpbuf *
-ofputil_encode_group_desc_request(enum ofp_version ofp_version)
+ofputil_encode_group_desc_request(enum ofp_version ofp_version,
+                                  uint32_t group_id)
 {
     struct ofpbuf *request;
+    ovs_be32 gid;
 
     switch (ofp_version) {
     case OFP10_VERSION:
@@ -6263,7 +6662,14 @@ ofputil_encode_group_desc_request(enum ofp_version ofp_version)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
-        request = ofpraw_alloc(OFPRAW_OFPST11_GROUP_DESC_REQUEST, ofp_version, 0);
+        request = ofpraw_alloc(OFPRAW_OFPST11_GROUP_DESC_REQUEST,
+                               ofp_version, 0);
+        break;
+    case OFP15_VERSION:
+        request = ofpraw_alloc(OFPRAW_OFPST15_GROUP_DESC_REQUEST,
+                               ofp_version, 0);
+        gid = htonl(group_id);
+        ofpbuf_put(request, &gid, sizeof gid);
         break;
     default:
         OVS_NOT_REACHED();
@@ -6272,78 +6678,85 @@ ofputil_encode_group_desc_request(enum ofp_version ofp_version)
     return request;
 }
 
-static void *
-ofputil_group_stats_to_ofp11(const struct ofputil_group_stats *ogs,
-                             size_t base_len, struct list *replies)
+static void
+ofputil_group_bucket_counters_to_ofp11(const struct ofputil_group_stats *gs,
+                                    struct ofp11_bucket_counter bucket_cnts[])
 {
-    struct ofp11_bucket_counter *bc11;
-    struct ofp11_group_stats *gs11;
-    size_t length;
     int i;
 
-    length = base_len + sizeof(struct ofp11_bucket_counter) * ogs->n_buckets;
-
-    gs11 = ofpmp_append(replies, length);
-    memset(gs11, 0, base_len);
-    gs11->length = htons(length);
-    gs11->group_id = htonl(ogs->group_id);
-    gs11->ref_count = htonl(ogs->ref_count);
-    gs11->packet_count = htonll(ogs->packet_count);
-    gs11->byte_count = htonll(ogs->byte_count);
-
-    bc11 = (void *) (((uint8_t *) gs11) + base_len);
-    for (i = 0; i < ogs->n_buckets; i++) {
-        const struct bucket_counter *obc = &ogs->bucket_stats[i];
-
-        bc11[i].packet_count = htonll(obc->packet_count);
-        bc11[i].byte_count = htonll(obc->byte_count);
+    for (i = 0; i < gs->n_buckets; i++) {
+       bucket_cnts[i].packet_count = htonll(gs->bucket_stats[i].packet_count);
+       bucket_cnts[i].byte_count = htonll(gs->bucket_stats[i].byte_count);
     }
+}
 
-    return gs11;
+static void
+ofputil_group_stats_to_ofp11(const struct ofputil_group_stats *gs,
+                             struct ofp11_group_stats *gs11, size_t length,
+                             struct ofp11_bucket_counter bucket_cnts[])
+{
+    memset(gs11, 0, sizeof *gs11);
+    gs11->length = htons(length);
+    gs11->group_id = htonl(gs->group_id);
+    gs11->ref_count = htonl(gs->ref_count);
+    gs11->packet_count = htonll(gs->packet_count);
+    gs11->byte_count = htonll(gs->byte_count);
+    ofputil_group_bucket_counters_to_ofp11(gs, bucket_cnts);
 }
 
 static void
-ofputil_append_of13_group_stats(const struct ofputil_group_stats *ogs,
-                                struct list *replies)
+ofputil_group_stats_to_ofp13(const struct ofputil_group_stats *gs,
+                             struct ofp13_group_stats *gs13, size_t length,
+                             struct ofp11_bucket_counter bucket_cnts[])
 {
-    struct ofp13_group_stats *gs13;
+    ofputil_group_stats_to_ofp11(gs, &gs13->gs, length, bucket_cnts);
+    gs13->duration_sec = htonl(gs->duration_sec);
+    gs13->duration_nsec = htonl(gs->duration_nsec);
 
-    gs13 = ofputil_group_stats_to_ofp11(ogs, sizeof *gs13, replies);
-    gs13->duration_sec = htonl(ogs->duration_sec);
-    gs13->duration_nsec = htonl(ogs->duration_nsec);
 }
 
-/* Encodes 'ogs' properly for the format of the list of group statistics
+/* Encodes 'gs' properly for the format of the list of group statistics
  * replies already begun in 'replies' and appends it to the list.  'replies'
  * must have originally been initialized with ofpmp_init(). */
 void
 ofputil_append_group_stats(struct list *replies,
-                           const struct ofputil_group_stats *ogs)
+                           const struct ofputil_group_stats *gs)
 {
-    struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = ofpbuf_data(msg);
+    size_t bucket_counter_size;
+    struct ofp11_bucket_counter *bucket_counters;
+    size_t length;
+
+    bucket_counter_size = gs->n_buckets * sizeof(struct ofp11_bucket_counter);
 
-    switch ((enum ofp_version)oh->version) {
+    switch (ofpmp_version(replies)) {
     case OFP11_VERSION:
-    case OFP12_VERSION:
-        ofputil_group_stats_to_ofp11(ogs, sizeof(struct ofp11_group_stats),
-                                     replies);
-        break;
+    case OFP12_VERSION:{
+            struct ofp11_group_stats *gs11;
 
-    case OFP13_VERSION:
-        ofputil_append_of13_group_stats(ogs, replies);
-        break;
+            length = sizeof *gs11 + bucket_counter_size;
+            gs11 = ofpmp_append(replies, length);
+            bucket_counters = (struct ofp11_bucket_counter *)(gs11 + 1);
+            ofputil_group_stats_to_ofp11(gs, gs11, length, bucket_counters);
+            break;
+        }
 
+    case OFP13_VERSION:
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        break;
+    case OFP15_VERSION: {
+            struct ofp13_group_stats *gs13;
+
+            length = sizeof *gs13 + bucket_counter_size;
+            gs13 = ofpmp_append(replies, length);
+            bucket_counters = (struct ofp11_bucket_counter *)(gs13 + 1);
+            ofputil_group_stats_to_ofp13(gs, gs13, length, bucket_counters);
+            break;
+        }
 
     case OFP10_VERSION:
     default:
         OVS_NOT_REACHED();
     }
 }
-
 /* Returns an OpenFlow group features request for OpenFlow version
  * 'ofp_version'. */
 struct ofpbuf *
@@ -6359,6 +6772,7 @@ ofputil_encode_group_features_request(enum ofp_version ofp_version)
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         request = ofpraw_alloc(OFPRAW_OFPST12_GROUP_FEATURES_REQUEST,
                                ofp_version, 0);
         break;
@@ -6451,8 +6865,8 @@ ofputil_decode_group_stats_reply(struct ofpbuf *msg,
     size_t i;
 
     gs->bucket_stats = NULL;
-    error = (msg->l2
-             ? ofpraw_decode(&raw, msg->l2)
+    error = (msg->frame
+             ? ofpraw_decode(&raw, msg->frame)
              : ofpraw_pull(&raw, msg));
     if (error) {
         return error;
@@ -6525,10 +6939,10 @@ ofputil_append_group_desc_reply(const struct ofputil_group_desc *gds,
                                 struct list *replies)
 {
     struct ofpbuf *reply = ofpbuf_from_list(list_back(replies));
+    enum ofp_version version = ofpmp_version(replies);
     struct ofp11_group_desc_stats *ogds;
     struct ofputil_bucket *bucket;
     size_t start_ogds;
-    enum ofp_version version = ((struct ofp_header *)ofpbuf_data(reply))->version;
 
     start_ogds = ofpbuf_size(reply);
     ofpbuf_put_zeros(reply, sizeof *ogds);
@@ -6573,6 +6987,7 @@ ofputil_pull_buckets(struct ofpbuf *msg, size_t buckets_length,
         if (!ob) {
             VLOG_WARN_RL(&bad_ofmsg_rl, "buckets end with %"PRIuSIZE" leftover bytes",
                          buckets_length);
+            return OFPERR_OFPGMFC_BAD_BUCKET;
         }
 
         ob_len = ntohs(ob->len);
@@ -6631,7 +7046,7 @@ ofputil_decode_group_desc_reply(struct ofputil_group_desc *gd,
     struct ofp11_group_desc_stats *ogds;
     size_t length;
 
-    if (!msg->l2) {
+    if (!msg->frame) {
         ofpraw_pull_assert(msg);
     }
 
@@ -6690,6 +7105,7 @@ ofputil_encode_group_mod(enum ofp_version ofp_version,
     case OFP12_VERSION:
     case OFP13_VERSION:
     case OFP14_VERSION:
+    case OFP15_VERSION:
         b = ofpraw_alloc(OFPRAW_OFPT11_GROUP_MOD, ofp_version, 0);
         start_ogm = ofpbuf_size(b);
         ofpbuf_put_zeros(b, sizeof *ogm);
@@ -6776,6 +7192,7 @@ ofputil_decode_queue_stats_request(const struct ofp_header *request,
                                    struct ofputil_queue_stats_request *oqsr)
 {
     switch ((enum ofp_version)request->version) {
+    case OFP15_VERSION:
     case OFP14_VERSION:
     case OFP13_VERSION:
     case OFP12_VERSION:
@@ -6814,7 +7231,8 @@ ofputil_encode_queue_stats_request(enum ofp_version ofp_version,
     case OFP11_VERSION:
     case OFP12_VERSION:
     case OFP13_VERSION:
-    case OFP14_VERSION: {
+    case OFP14_VERSION:
+    case OFP15_VERSION: {
         struct ofp11_queue_stats_request *req;
         request = ofpraw_alloc(OFPRAW_OFPST11_QUEUE_REQUEST, ofp_version, 0);
         req = ofpbuf_put_zeros(request, sizeof *req);
@@ -6839,36 +7257,21 @@ ofputil_encode_queue_stats_request(enum ofp_version ofp_version,
     return request;
 }
 
-static size_t
-ofputil_get_queue_stats_size(enum ofp_version ofp_version)
-{
-    switch (ofp_version) {
-    case OFP10_VERSION:
-        return sizeof(struct ofp10_queue_stats);
-    case OFP11_VERSION:
-    case OFP12_VERSION:
-        return sizeof(struct ofp11_queue_stats);
-    case OFP13_VERSION:
-        return sizeof(struct ofp13_queue_stats);
-    case OFP14_VERSION:
-        OVS_NOT_REACHED();
-        return 0;
-    default:
-        OVS_NOT_REACHED();
-    }
-}
-
 /* Returns the number of queue stats elements in OFPTYPE_QUEUE_STATS_REPLY
  * message 'oh'. */
 size_t
 ofputil_count_queue_stats(const struct ofp_header *oh)
 {
+    struct ofputil_queue_stats qs;
     struct ofpbuf b;
+    size_t n = 0;
 
     ofpbuf_use_const(&b, oh, ntohs(oh->length));
     ofpraw_pull_assert(&b);
-
-    return ofpbuf_size(&b) / ofputil_get_queue_stats_size(oh->version);
+    while (!ofputil_decode_queue_stats(&qs, &b)) {
+        n++;
+    }
+    return n;
 }
 
 static enum ofperr
@@ -6918,6 +7321,29 @@ ofputil_queue_stats_from_ofp13(struct ofputil_queue_stats *oqs,
     return error;
 }
 
+static enum ofperr
+ofputil_pull_ofp14_queue_stats(struct ofputil_queue_stats *oqs,
+                               struct ofpbuf *msg)
+{
+    const struct ofp14_queue_stats *qs14;
+    size_t len;
+
+    qs14 = ofpbuf_try_pull(msg, sizeof *qs14);
+    if (!qs14) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+
+    len = ntohs(qs14->length);
+    if (len < sizeof *qs14 || len - sizeof *qs14 > ofpbuf_size(msg)) {
+        return OFPERR_OFPBRC_BAD_LEN;
+    }
+    ofpbuf_pull(msg, len - sizeof *qs14);
+
+    /* No properties yet defined, so ignore them for now. */
+
+    return ofputil_queue_stats_from_ofp13(oqs, &qs14->qs);
+}
+
 /* Converts an OFPST_QUEUE_STATS reply in 'msg' into an abstract
  * ofputil_queue_stats in 'qs'.
  *
@@ -6934,8 +7360,8 @@ ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg)
     enum ofperr error;
     enum ofpraw raw;
 
-    error = (msg->l2
-             ? ofpraw_decode(&raw, msg->l2)
+    error = (msg->frame
+             ? ofpraw_decode(&raw, msg->frame)
              : ofpraw_pull(&raw, msg));
     if (error) {
         return error;
@@ -6943,6 +7369,8 @@ ofputil_decode_queue_stats(struct ofputil_queue_stats *qs, struct ofpbuf *msg)
 
     if (!ofpbuf_size(msg)) {
         return EOF;
+    } else if (raw == OFPRAW_OFPST14_QUEUE_REPLY) {
+        return ofputil_pull_ofp14_queue_stats(qs, msg);
     } else if (raw == OFPRAW_OFPST13_QUEUE_REPLY) {
         const struct ofp13_queue_stats *qs13;
 
@@ -7014,15 +7442,22 @@ ofputil_queue_stats_to_ofp13(const struct ofputil_queue_stats *oqs,
     }
 }
 
+static void
+ofputil_queue_stats_to_ofp14(const struct ofputil_queue_stats *oqs,
+                             struct ofp14_queue_stats *qs14)
+{
+    qs14->length = htons(sizeof *qs14);
+    memset(qs14->pad, 0, sizeof qs14->pad);
+    ofputil_queue_stats_to_ofp13(oqs, &qs14->qs);
+}
+
+
 /* Encode a queue stat for 'oqs' and append it to 'replies'. */
 void
 ofputil_append_queue_stat(struct list *replies,
                           const struct ofputil_queue_stats *oqs)
 {
-    struct ofpbuf *msg = ofpbuf_from_list(list_back(replies));
-    struct ofp_header *oh = ofpbuf_data(msg);
-
-    switch ((enum ofp_version)oh->version) {
+    switch (ofpmp_version(replies)) {
     case OFP13_VERSION: {
         struct ofp13_queue_stats *reply = ofpmp_append(replies, sizeof *reply);
         ofputil_queue_stats_to_ofp13(oqs, reply);
@@ -7043,10 +7478,93 @@ ofputil_append_queue_stat(struct list *replies,
     }
 
     case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP15_VERSION: {
+        struct ofp14_queue_stats *reply = ofpmp_append(replies, sizeof *reply);
+        ofputil_queue_stats_to_ofp14(oqs, reply);
         break;
+    }
 
     default:
         OVS_NOT_REACHED();
     }
 }
+
+enum ofperr
+ofputil_decode_bundle_ctrl(const struct ofp_header *oh,
+                           struct ofputil_bundle_ctrl_msg *msg)
+{
+    struct ofpbuf b;
+    enum ofpraw raw;
+    const struct ofp14_bundle_ctrl_msg *m;
+
+    ofpbuf_use_const(&b, oh, ntohs(oh->length));
+    raw = ofpraw_pull_assert(&b);
+    ovs_assert(raw == OFPRAW_OFPT14_BUNDLE_CONTROL);
+
+    m = ofpbuf_l3(&b);
+    msg->bundle_id = ntohl(m->bundle_id);
+    msg->type = ntohs(m->type);
+    msg->flags = ntohs(m->flags);
+
+    return 0;
+}
+
+struct ofpbuf *
+ofputil_encode_bundle_ctrl_reply(const struct ofp_header *oh,
+                                 struct ofputil_bundle_ctrl_msg *msg)
+{
+    struct ofpbuf *buf;
+    struct ofp14_bundle_ctrl_msg *m;
+
+    buf = ofpraw_alloc_reply(OFPRAW_OFPT14_BUNDLE_CONTROL, oh, 0);
+    m = ofpbuf_put_zeros(buf, sizeof *m);
+
+    m->bundle_id = htonl(msg->bundle_id);
+    m->type = htons(msg->type);
+    m->flags = htons(msg->flags);
+
+    return buf;
+}
+
+enum ofperr
+ofputil_decode_bundle_add(const struct ofp_header *oh,
+                          struct ofputil_bundle_add_msg *msg)
+{
+    const struct ofp14_bundle_ctrl_msg *m;
+    struct ofpbuf b;
+    enum ofpraw raw;
+    size_t inner_len;
+
+    ofpbuf_use_const(&b, oh, ntohs(oh->length));
+    raw = ofpraw_pull_assert(&b);
+    ovs_assert(raw == OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE);
+
+    m = ofpbuf_pull(&b, sizeof *m);
+    msg->bundle_id = ntohl(m->bundle_id);
+    msg->flags = ntohs(m->flags);
+
+    msg->msg = ofpbuf_data(&b);
+    inner_len = ntohs(msg->msg->length);
+    if (inner_len < sizeof(struct ofp_header) || inner_len > ofpbuf_size(&b)) {
+        return OFPERR_OFPBFC_MSG_BAD_LEN;
+    }
+
+    return 0;
+}
+
+struct ofpbuf *
+ofputil_encode_bundle_add(enum ofp_version ofp_version,
+                          struct ofputil_bundle_add_msg *msg)
+{
+    struct ofpbuf *request;
+    struct ofp14_bundle_ctrl_msg *m;
+
+    request = ofpraw_alloc(OFPRAW_OFPT14_BUNDLE_ADD_MESSAGE, ofp_version, 0);
+    m = ofpbuf_put_zeros(request, sizeof *m);
+
+    m->bundle_id = htonl(msg->bundle_id);
+    m->flags = htons(msg->flags);
+    ofpbuf_put(request, msg->msg, ntohs(msg->msg->length));
+
+    return request;
+}