Skip to content

Commit

Permalink
ovn-sbctl: fix lflow-list when uuid has leading 0s.
Browse files Browse the repository at this point in the history
When uuid starts with 0s, lflow-list will fail if leading 0s are
not included in command argument. This leads to unexpected results
considering that leading 0s are usually not shown up in cookies
of OpenFlow outputs of tools such as ovs-ofctl dump-flows
and ovs-appctl ofproto/trace. E.g.

lflow uuid: 0c16ceb4-0409-484b-8297-a6e7f264ac2d
$ ovn-nbctl lflow-list 0c16ceb4 # works fine
$ ovn-nbctl lflow-list c16ceb4 # doesn't work

This patch fixes the problem.

Signed-off-by: Han Zhou <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
hzhou8 authored and blp committed Apr 21, 2017
1 parent f1dac51 commit 8b8d09d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ovn/utilities/ovn-sbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,13 +715,22 @@ parse_partial_uuid(char *s)
return NULL;
}

static const char *
strip_leading_zero(const char *s)
{
return s + strspn(s, "0");
}

static bool
is_partial_uuid_match(const struct uuid *uuid, const char *match)
{
char uuid_s[UUID_LEN + 1];
snprintf(uuid_s, sizeof uuid_s, UUID_FMT, UUID_ARGS(uuid));

return !strncmp(uuid_s, match, strlen(match));
const char *s1 = strip_leading_zero(uuid_s);
const char *s2 = strip_leading_zero(match);

return !strncmp(s1, s2, strlen(s2));
}

static const struct sbrec_datapath_binding *
Expand Down

0 comments on commit 8b8d09d

Please sign in to comment.