aboutsummaryrefslogtreecommitdiff
path: root/lib/bundle.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-09-20 08:40:29 -0700
committerBen Pfaff <blp@nicira.com>2012-09-20 08:40:29 -0700
commitc6100d92142bc3dd325180cb4e10553eb4341731 (patch)
treed03b58dd371880d8fda4785f4cc1bb3100f412e5 /lib/bundle.c
parent2ac3c572267c550302eee88d4f584b3694d88f88 (diff)
ovs-ofctl: Accept port keywords, OF1.1 port numbers, reject port number 0.
OpenFlow 1.0 has special reserved ports in the range 0xfff8 to 0xffff. OpenFlow 1.1 and later has the same ports in the range 0xfffffff8 to 0xffffffff and allows the OF1.0 range to be used for ordinary ("physical") switch ports. This means that, naively, the meaning of a port number in the range 0xfff8 to 0xffff given on the ovs-ofctl command line depends on the protocol in use. This commit implements something a little smarter: - Accept keyword names (e.g. LOCAL) for special reserved ports everywhere that such a port can plausibly be used (previously they were only accepted in some places). - Translate 0xfff8...0xffff to 0xfffffff8...0xffffffff for now, since OF1.1+ isn't in widespread use and those particular ports aren't likely to be in use in OF1.1+ anyway. - Log warnings about those ports when they are specified by number, to allow users to fix their invocations. Also: - Accept the OF1.1+ port numbers for these ports, without warning, for compatibility with the upcoming OF1.1+ support. - Stop accepting port number 0, which has never been a valid port number in OpenFlow 1.0 and later. (This required fixing some tests that inadvertently used this port number). Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'lib/bundle.c')
-rw-r--r--lib/bundle.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/bundle.c b/lib/bundle.c
index e0f8e6b6..b68ebab8 100644
--- a/lib/bundle.c
+++ b/lib/bundle.c
@@ -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, ")");