Despite of linux, 'strtoull' on FreeBSD sets errno to EINVAL in case
of no digits found. This causes odp_flow parsing failure if
there is no geneve data inside it. For example, ovs fails to parse
following flow on FreeBSD:

  tunnel(<...>,geneve({class=0xffff,type=1,len=0}),<...>)

Moving the parsing attempt under the if condition fixes the following
unit test failure:

  tunnel.at:780: testing tunnel - Geneve option present ...
  ./tunnel.at:810: ovs-appctl ofproto/trace ovs-dummy \
      'tunnel(<...>,geneve({class=0xffff,type=1,len=0}), ...'
  --- /dev/null 2018-12-18 13:24:55.001110000 +0000
  +++ /tmp/cirrus-ci-build/tests/testsuite.dir/at-groups/848/stderr
  @@ -0,0 +1,2 @@
  +ovs-dummy: unknown bridge
  +ovs-appctl: ovs-vswitchd: server returned an error

CC: Jesse Gross <[email protected]>
Fixes: 622a0a8e764d ("odp-util: Geneve netlink decoding.")
Signed-off-by: Ilya Maximets <[email protected]>
---
 lib/odp-util.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 1e8c5f194..9a0ca3ee5 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -5005,11 +5005,11 @@ scan_geneve(const char *s, struct geneve_scan *key, 
struct geneve_scan *mask)
 
         if (s[0] == ',') {
             s++;
+            if (parse_int_string(s, (uint8_t *)(opt + 1),
+                                 data_len, (char **)&s)) {
+                return 0;
+            }
         }
-        if (parse_int_string(s, (uint8_t *)(opt + 1), data_len, (char **)&s)) {
-            return 0;
-        }
-
         if (mask) {
             if (s[0] == '/') {
                 s++;
-- 
2.17.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to