Blob Blame History Raw
From 1ba92ed2f401b8288481134279d7843908621c86 Mon Sep 17 00:00:00 2001
From: Numan Siddique <numans@ovn.org>
Date: Fri, 17 Apr 2020 11:45:56 +0530
Subject: [PATCH] pinctrl: Handle service monitors even if the lport doesn't
 have IPv4 addresses set.

If a logical port is only configured with MAC address(es) in the
Logical_Switch_Port.addresses, pinctrl is ignoring the service monitors
configured for that logical port. This patch allows that.

Change-Id: I0351395a88cd0d27ee3e18e1b2af7d9e0f0483b3
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1801058
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>

(cherry-picked from upstream ovn commit 71c6157575f4ac52484fa8703395301bd2189903)
---
 ovn/controller/pinctrl.c |  5 +++++
 tests/ovn.at             | 31 +++++++++++++++++++++++++++++++
 tests/system-ovn.at      |  4 ++--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 1824347c2..8bc99df4e 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -4935,6 +4935,11 @@ sync_svc_monitors(struct ovsdb_idl_txn *ovnsb_idl_txn,
 
             if (mac_found) {
                 break;
+            } else if (!laddrs.n_ipv4_addrs) {
+                /* IPv4 address(es) are not configured. Use the first mac. */
+                ea = laddrs.ea;
+                mac_found = true;
+                break;
             }
         }
 
diff --git a/tests/ovn.at b/tests/ovn.at
index d6e9b6581..c06337147 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -17345,5 +17345,36 @@ AT_CHECK([cat lflows.txt], [0], [dnl
   table=6 (lr_in_dnat         ), priority=120  , match=(ct.new && ip && ip4.dst == 10.0.0.10 && tcp && tcp.dst == 80 && is_chassis_resident("cr-lr0-public")), action=(drop;)
 ])
 
+# Delete sw0-p1
+ovn-nbctl lsp-del sw0-p1
+
+OVS_WAIT_UNTIL([test 1 = $(ovn-sbctl --bare --columns _uuid find \
+service_monitor | sed '/^$/d' | wc -l)])
+
+# Add back sw0-p1 but without any IP address.
+ovn-nbctl lsp-add sw0 sw0-p1
+ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03" -- \
+lsp-set-port-security sw0-p1 "50:54:00:00:00:03"
+
+OVS_WAIT_UNTIL([test 2 = $(ovn-sbctl --bare --columns status find \
+service_monitor | grep offline | wc -l)])
+
+ovn-nbctl lsp-del sw0-p1
+ovn-nbctl lsp-del sw1-p1
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns _uuid find \
+service_monitor | sed '/^$/d' | wc -l)])
+
+# Add back sw0-p1 but without any address set.
+ovn-nbctl lsp-add sw0 sw0-p1
+
+OVS_WAIT_UNTIL([test 1 = $(ovn-sbctl --bare --columns _uuid find \
+service_monitor | sed '/^$/d' | wc -l)])
+
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns status find \
+service_monitor | grep offline | wc -l)])
+
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns status find \
+service_monitor | grep online | wc -l)])
+
 OVN_CLEANUP([hv1], [hv2])
 AT_CLEANUP
diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 22e9a5926..d863c828d 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -2545,8 +2545,8 @@ start_daemon ovn-controller
 ovn-nbctl ls-add sw0
 
 ovn-nbctl lsp-add sw0 sw0-p1
-ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03 10.0.0.3"
-ovn-nbctl lsp-set-port-security sw0-p1 "50:54:00:00:00:03 10.0.0.3"
+ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03"
+ovn-nbctl lsp-set-port-security sw0-p1 "50:54:00:00:00:03"
 
 ovn-nbctl lsp-add sw0 sw0-p2
 ovn-nbctl lsp-set-addresses sw0-p2 "50:54:00:00:00:04 10.0.0.4"
-- 
2.25.1