odp-util: Fix UFID string parsing.
authorJoe Stringer <joestringer@nicira.com>
Wed, 17 Dec 2014 02:40:50 +0000 (18:40 -0800)
committerJoe Stringer <joestringer@nicira.com>
Fri, 19 Dec 2014 20:57:40 +0000 (12:57 -0800)
Commit 534a19b (dpctl: Add support for using UFID to add/del flows.)
introduced string parsing functions for UFIDs, but provided a broken
implementation where the upper 64 bits would be ignored, then the lower
64 bits would be read into both the lower and upper UFID positions. Fix
the implementation to read the upper bits properly.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
lib/odp-util.c

index e626bf0..d52c172 100644 (file)
@@ -2017,15 +2017,11 @@ odp_ufid_from_string(const char *s_, ovs_u128 *ufid)
             return -EINVAL;
         }
 
-        if (!ovs_scan(s, "%"SCNx64, &ufid->u64.hi)) {
+        if (!ovs_scan(s, "%16"SCNx64"%16"SCNx64, &ufid->u64.hi,
+                      &ufid->u64.lo)) {
             return -EINVAL;
         }
-        s += 16;
-
-        if (!ovs_scan(s, "%"SCNx64, &ufid->u64.lo)) {
-            return -EINVAL;
-        }
-        s += 16;
+        s += n;
         s += strspn(s, delimiters);
 
         return s - s_;