diff options
author | Joe Stringer <joestringer@nicira.com> | 2015-05-29 17:08:45 -0700 |
---|---|---|
committer | Joe Stringer <joestringer@nicira.com> | 2015-06-09 18:20:02 -0700 |
commit | 10e92b4f7a1db4bd88452cdc3aaec5fd46c4f7fe (patch) | |
tree | 0f80cc87dfec8c6ceb734efcc4fa9906cdb8e107 | |
parent | 78145f6edb62f6d6ec3a99f506dff3d617456f9a (diff) | |
download | openvswitch-10e92b4f7a1db4bd88452cdc3aaec5fd46c4f7fe.tar.gz |
odp-util: Reuse UUID marshalling for UFID.
Unique flow identifiers are really a UUID of sorts, so it makes sense to
reuse the UUID string representations for UFID.
Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r-- | lib/odp-util.c | 36 | ||||
-rw-r--r-- | tests/dpif-netdev.at | 2 | ||||
-rw-r--r-- | tests/ofproto-dpif.at | 2 | ||||
-rw-r--r-- | tests/ofproto-macros.at | 2 |
4 files changed, 13 insertions, 29 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c index dee85c850..f99683a24 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -37,6 +37,7 @@ #include "timeval.h" #include "unaligned.h" #include "util.h" +#include "uuid.h" #include "openvswitch/vlog.h" VLOG_DEFINE_THIS_MODULE(odp_util); @@ -51,8 +52,6 @@ VLOG_DEFINE_THIS_MODULE(odp_util); * from another. */ static const char *delimiters = ", \t\r\n"; -static const char *hex_chars = "0123456789abcdefABCDEF"; - struct attr_len_tbl { int len; const struct attr_len_tbl *next; @@ -2354,24 +2353,12 @@ odp_ufid_from_string(const char *s_, ovs_u128 *ufid) const char *s = s_; if (ovs_scan(s, "ufid:")) { - size_t n; - s += 5; - if (ovs_scan(s, "0x")) { - s += 2; - } - - n = strspn(s, hex_chars); - if (n != 32) { - return -EINVAL; - } - if (!ovs_scan(s, "%16"SCNx64"%16"SCNx64, &ufid->u64.hi, - &ufid->u64.lo)) { + if (!uuid_from_string_prefix((struct uuid *)ufid, s)) { return -EINVAL; } - s += n; - s += strspn(s, delimiters); + s += UUID_LEN; return s - s_; } @@ -2382,8 +2369,7 @@ odp_ufid_from_string(const char *s_, ovs_u128 *ufid) void odp_format_ufid(const ovs_u128 *ufid, struct ds *ds) { - ds_put_format(ds, "ufid:%016"PRIx64"%016"PRIx64, ufid->u64.hi, - ufid->u64.lo); + ds_put_format(ds, "ufid:"UUID_FMT, UUID_ARGS((struct uuid *)ufid)); } /* Appends to 'ds' a string representation of the 'key_len' bytes of @@ -3214,15 +3200,13 @@ static int parse_odp_key_mask_attr(const char *s, const struct simap *port_names, struct ofpbuf *key, struct ofpbuf *mask) { - if (!strncmp(s, "ufid:", 5)) { - const char *start = s; - - /* Skip UFID. */ - s += 5; - s += strspn(s, hex_chars); - s += strspn(s, delimiters); + ovs_u128 ufid; + int len; - return s - start; + /* Skip UFID. */ + len = odp_ufid_from_string(s, &ufid); + if (len) { + return len; } SCAN_SINGLE("skb_priority(", uint32_t, u32, OVS_KEY_ATTR_PRIORITY); diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index 067f9000c..e9af63f05 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -3,7 +3,7 @@ AT_BANNER([dpif-netdev]) # Strips out uninteresting parts of flow output, as well as parts # that vary from one run to another (e.g., timing and bond actions). m4_define([STRIP_XOUT], [[sed ' - s/ufid:[0-9a-f]* // + s/ufid:[-0-9a-f]* // s/used:[0-9]*\.[0-9]*/used:0.0/ s/actions:.*/actions: <del>/ s/packets:[0-9]*/packets:0/ diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index fbc6fd9d8..bd1b21c8e 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -5460,7 +5460,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00: ovs-appctl revalidator/wait AT_CHECK([ovs-appctl dpif/dump-flows -m br0], [0], [stdout]) -UFID=`sed -n 's/\(ufid:[[0-9a-fA-F]]*\).*/\1/p' stdout` +UFID=`sed -n 's/\(ufid:[[-0-9a-fA-F]]*\).*/\1/p' stdout` AT_CHECK([ovs-appctl dpctl/get-flow $UFID], [0], [dnl recirc_id(0),in_port(1),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:drop ]) diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index fd915ef28..a69719be0 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -36,7 +36,7 @@ m4_divert_pop([PREPARE_TESTS]) m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']]) m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']]) m4_define([STRIP_USED], [[sed 's/used:[0-9]\.[0-9]*/used:0.0/']]) -m4_define([STRIP_UFID], [[sed 's/ufid:[0-9a-f]* //']]) +m4_define([STRIP_UFID], [[sed 's/ufid:[-0-9a-f]* //']]) m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m']) # _OVS_VSWITCHD_START([vswitchd-aux-args]) |