Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtong...@opencloud.tech> --- ovn/utilities/ovn-nbctl.c | 6 ++++++ tests/ovn-nbctl.at | 16 ++++++++++++++++ 2 files changed, 22 insertions(+)
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 453ff72..572370f 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2039,17 +2039,22 @@ nbctl_lr_route_add(struct ctl_context *ctx) next_hop = normalize_prefix_str(ctx->argv[3]); if (!next_hop) { + free(prefix); ctl_fatal("bad next hop argument: %s", ctx->argv[3]); } if (strchr(prefix, '.')) { ovs_be32 hop_ipv4; if (!ip_parse(ctx->argv[3], &hop_ipv4)) { + free(prefix); + free(next_hop); ctl_fatal("bad IPv4 nexthop argument: %s", ctx->argv[3]); } } else { struct in6_addr hop_ipv6; if (!ipv6_parse(ctx->argv[3], &hop_ipv6)) { + free(prefix); + free(next_hop); ctl_fatal("bad IPv6 nexthop argument: %s", ctx->argv[3]); } } @@ -2072,6 +2077,7 @@ nbctl_lr_route_add(struct ctl_context *ctx) } if (!may_exist) { + free(next_hop); free(rt_prefix); ctl_fatal("duplicate prefix: %s", prefix); } diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 115d781..af00dad 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -640,6 +640,22 @@ dnl Add overlapping route with 10.0.0.1/24 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [], [ovn-nbctl: duplicate prefix: 10.0.0.0/24 ]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111a/24 11.0.0.1], [1], [], + [ovn-nbctl: bad prefix argument: 10.0.0.111a/24 +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24a 11.0.0.1], [1], [], + [ovn-nbctl: bad prefix argument: 10.0.0.111/24a +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1a], [1], [], + [ovn-nbctl: bad next hop argument: 11.0.0.1a +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1/24], [1], [], + [ovn-nbctl: bad IPv4 nexthop argument: 11.0.0.1/24 +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1/64], [1], [], + [ovn-nbctl: bad IPv6 nexthop argument: 2001:0db8:0:f103::1/64 +]) + AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1]) AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev