Signed-off-by: nickcooper-zhangtonghao <[email protected]>
---
ovn/utilities/ovn-nbctl.c | 11 ++++++++++-
tests/ovn-nbctl.at | 16 ++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 7de8057..179c9eb 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1574,17 +1574,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]);
}
}
@@ -1607,8 +1612,12 @@ nbctl_lr_route_add(struct ctl_context *ctx)
}
if (!may_exist) {
+ char errm[60];
+ snprintf(errm, sizeof errm, "duplicate prefix: %s", prefix);
+ free(prefix);
+ free(next_hop);
free(rt_prefix);
- ctl_fatal("duplicate prefix: %s", prefix);
+ ctl_fatal("%s", errm);
}
/* Update the next hop for an existing route. */
diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at
index 3f459a8..1a10194 100644
--- a/tests/ovn-nbctl.at
+++ b/tests/ovn-nbctl.at
@@ -411,6 +411,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
[email protected]
http://openvswitch.org/mailman/listinfo/dev