ovs-ofctl: Accept port keywords, OF1.1 port numbers, reject port number 0.
[sliver-openvswitch.git] / lib / bundle.c
index c6b1f75..b68ebab 100644 (file)
@@ -217,7 +217,7 @@ bundle_check(const struct ofpact_bundle *bundle, int max_ports,
 void
 bundle_to_nxast(const struct ofpact_bundle *bundle, struct ofpbuf *openflow)
 {
-    int slaves_len = ROUND_UP(bundle->n_slaves, OFP_ACTION_ALIGN);
+    int slaves_len = ROUND_UP(2 * bundle->n_slaves, OFP_ACTION_ALIGN);
     struct nx_action_bundle *nab;
     ovs_be16 *slaves;
     size_t i;
@@ -267,12 +267,15 @@ bundle_parse__(const char *s, char **save_ptr,
         uint16_t slave_port;
         char *slave;
 
-        slave = strtok_r(NULL, ", [", save_ptr);
+        slave = strtok_r(NULL, ", []", save_ptr);
         if (!slave || bundle->n_slaves >= BUNDLE_MAX_SLAVES) {
             break;
         }
 
-        slave_port = atoi(slave);
+        slave_port = ofputil_port_from_string(slave);
+        if (!slave_port) {
+            ovs_fatal(0, "%s: bad port number", slave);
+        }
         ofpbuf_put(ofpacts, &slave_port, sizeof slave_port);
 
         bundle = ofpacts->l2;
@@ -387,7 +390,7 @@ bundle_format(const struct ofpact_bundle *bundle, struct ds *s)
             ds_put_cstr(s, ",");
         }
 
-        ds_put_format(s, "%"PRIu16, bundle->slaves[i]);
+        ofputil_format_port(bundle->slaves[i], s);
     }
 
     ds_put_cstr(s, ")");