X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=lib%2Fodp-util.c;fp=lib%2Fodp-util.c;h=f16e113af6d0f86da77e41bbf69293bc9a196fc6;hb=9d4e54c6ff743941bd0b6abc19e55b065c4a4186;hp=aa5bd6b554a4140e76236b663288e3f19178b5e5;hpb=74cb32e3c25732aff687b31f97f4816f3bc79919;p=cascardo%2Fovs.git diff --git a/lib/odp-util.c b/lib/odp-util.c index aa5bd6b55..f16e113af 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -909,11 +909,14 @@ parse_odp_userspace_action(const char *s, struct ofpbuf *actions) void *user_data = NULL; size_t user_data_size = 0; bool include_actions = false; + int res; if (!ovs_scan(s, "userspace(pid=%"SCNi32"%n", &pid, &n)) { return -EINVAL; } + ofpbuf_init(&buf, 16); + { uint32_t output; uint32_t probability; @@ -940,8 +943,6 @@ parse_odp_userspace_action(const char *s, struct ofpbuf *actions) user_data_size = sizeof cookie.sflow; } else if (ovs_scan(&s[n], ",slow_path(%n", &n1)) { - int res; - n += n1; cookie.type = USER_ACTION_COOKIE_SLOW_PATH; cookie.slow_path.unused = 0; @@ -951,7 +952,7 @@ parse_odp_userspace_action(const char *s, struct ofpbuf *actions) &cookie.slow_path.reason, SLOW_PATH_REASON_MASK, NULL); if (res < 0 || s[n + res] != ')') { - return res; + goto out; } n += res + 1; @@ -984,10 +985,10 @@ parse_odp_userspace_action(const char *s, struct ofpbuf *actions) char *end; n += n1; - ofpbuf_init(&buf, 16); end = ofpbuf_put_hex(&buf, &s[n], NULL); if (end[0] != ')') { - return -EINVAL; + res = -EINVAL; + goto out; } user_data = buf.data; user_data_size = buf.size; @@ -1009,15 +1010,18 @@ parse_odp_userspace_action(const char *s, struct ofpbuf *actions) &tunnel_out_port, &n1)) { odp_put_userspace_action(pid, user_data, user_data_size, tunnel_out_port, include_actions, actions); - return n + n1; + res = n + n1; } else if (s[n] == ')') { odp_put_userspace_action(pid, user_data, user_data_size, ODPP_NONE, include_actions, actions); - return n + 1; + res = n + 1; + } else { + res = -EINVAL; } } - - return -EINVAL; +out: + ofpbuf_uninit(&buf); + return res; } static int