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