From d1b6e6838f0b69088122c125dd435899dbb1ec28 Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@ovn.org>
Date: Fri, 6 Dec 2019 15:11:44 -0500
Subject: [PATCH ovn 1/4] nbctl: Log the source of duplicate IP addresses
When doing an lsp-add, ovn-nbctl will ensure that there is not another
port on the same logical switch with the same IP address. I'm seeing
this error occur with ovn-kubernetes, and I would find it helpful to
see which port it thinks had the duplicate address, because it's not
obvious what's happening.
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Han Zhou <hzhou@ovn.org>
(cherry picked from upstream commit e34cd53a66dac5a371744459ca51b8df9eeea3c4)
---
ovn/utilities/ovn-nbctl.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 1a1d83e..3d2df13 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1497,13 +1497,16 @@ nbctl_lsp_get_tag(struct ctl_context *ctx)
static char *
lsp_contains_duplicate_ip(struct lport_addresses *laddrs1,
- struct lport_addresses *laddrs2)
+ struct lport_addresses *laddrs2,
+ const struct nbrec_logical_switch_port *lsp_test)
{
for (size_t i = 0; i < laddrs1->n_ipv4_addrs; i++) {
for (size_t j = 0; j < laddrs2->n_ipv4_addrs; j++) {
if (laddrs1->ipv4_addrs[i].addr == laddrs2->ipv4_addrs[j].addr) {
- return xasprintf("duplicate IPv4 address %s",
- laddrs1->ipv4_addrs[i].addr_s);
+ return xasprintf("duplicate IPv4 address '%s' found on "
+ "logical switch port '%s'",
+ laddrs1->ipv4_addrs[i].addr_s,
+ lsp_test->name);
}
}
}
@@ -1512,8 +1515,10 @@ lsp_contains_duplicate_ip(struct lport_addresses *laddrs1,
for (size_t j = 0; j < laddrs2->n_ipv6_addrs; j++) {
if (IN6_ARE_ADDR_EQUAL(&laddrs1->ipv6_addrs[i].addr,
&laddrs2->ipv6_addrs[j].addr)) {
- return xasprintf("duplicate IPv6 address %s",
- laddrs1->ipv6_addrs[i].addr_s);
+ return xasprintf("duplicate IPv6 address '%s' found on "
+ "logical switch port '%s'",
+ laddrs1->ipv6_addrs[i].addr_s,
+ lsp_test->name);
}
}
}
@@ -1544,7 +1549,8 @@ lsp_contains_duplicates(const struct nbrec_logical_switch *ls,
addr = lsp_test->dynamic_addresses;
}
if (extract_lsp_addresses(addr, &laddrs_test)) {
- sub_error = lsp_contains_duplicate_ip(&laddrs, &laddrs_test);
+ sub_error = lsp_contains_duplicate_ip(&laddrs, &laddrs_test,
+ lsp_test);
destroy_lport_addresses(&laddrs_test);
if (sub_error) {
goto err_out;
--
1.8.3.1