bbaaef
From 1ba92ed2f401b8288481134279d7843908621c86 Mon Sep 17 00:00:00 2001
bbaaef
From: Numan Siddique <numans@ovn.org>
bbaaef
Date: Fri, 17 Apr 2020 11:45:56 +0530
bbaaef
Subject: [PATCH] pinctrl: Handle service monitors even if the lport doesn't
bbaaef
 have IPv4 addresses set.
bbaaef
bbaaef
If a logical port is only configured with MAC address(es) in the
bbaaef
Logical_Switch_Port.addresses, pinctrl is ignoring the service monitors
bbaaef
configured for that logical port. This patch allows that.
bbaaef
bbaaef
Change-Id: I0351395a88cd0d27ee3e18e1b2af7d9e0f0483b3
bbaaef
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1801058
bbaaef
Acked-by: Mark Michelson <mmichels@redhat.com>
bbaaef
Signed-off-by: Numan Siddique <numans@ovn.org>
bbaaef
bbaaef
(cherry-picked from upstream ovn commit 71c6157575f4ac52484fa8703395301bd2189903)
bbaaef
---
bbaaef
 ovn/controller/pinctrl.c |  5 +++++
bbaaef
 tests/ovn.at             | 31 +++++++++++++++++++++++++++++++
bbaaef
 tests/system-ovn.at      |  4 ++--
bbaaef
 3 files changed, 38 insertions(+), 2 deletions(-)
bbaaef
bbaaef
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
bbaaef
index 1824347c2..8bc99df4e 100644
bbaaef
--- a/ovn/controller/pinctrl.c
bbaaef
+++ b/ovn/controller/pinctrl.c
bbaaef
@@ -4935,6 +4935,11 @@ sync_svc_monitors(struct ovsdb_idl_txn *ovnsb_idl_txn,
bbaaef
 
bbaaef
             if (mac_found) {
bbaaef
                 break;
bbaaef
+            } else if (!laddrs.n_ipv4_addrs) {
bbaaef
+                /* IPv4 address(es) are not configured. Use the first mac. */
bbaaef
+                ea = laddrs.ea;
bbaaef
+                mac_found = true;
bbaaef
+                break;
bbaaef
             }
bbaaef
         }
bbaaef
 
bbaaef
diff --git a/tests/ovn.at b/tests/ovn.at
bbaaef
index d6e9b6581..c06337147 100644
bbaaef
--- a/tests/ovn.at
bbaaef
+++ b/tests/ovn.at
bbaaef
@@ -17345,5 +17345,36 @@ AT_CHECK([cat lflows.txt], [0], [dnl
bbaaef
   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;)
bbaaef
 ])
bbaaef
 
bbaaef
+# Delete sw0-p1
bbaaef
+ovn-nbctl lsp-del sw0-p1
bbaaef
+
bbaaef
+OVS_WAIT_UNTIL([test 1 = $(ovn-sbctl --bare --columns _uuid find \
bbaaef
+service_monitor | sed '/^$/d' | wc -l)])
bbaaef
+
bbaaef
+# Add back sw0-p1 but without any IP address.
bbaaef
+ovn-nbctl lsp-add sw0 sw0-p1
bbaaef
+ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03" -- \
bbaaef
+lsp-set-port-security sw0-p1 "50:54:00:00:00:03"
bbaaef
+
bbaaef
+OVS_WAIT_UNTIL([test 2 = $(ovn-sbctl --bare --columns status find \
bbaaef
+service_monitor | grep offline | wc -l)])
bbaaef
+
bbaaef
+ovn-nbctl lsp-del sw0-p1
bbaaef
+ovn-nbctl lsp-del sw1-p1
bbaaef
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns _uuid find \
bbaaef
+service_monitor | sed '/^$/d' | wc -l)])
bbaaef
+
bbaaef
+# Add back sw0-p1 but without any address set.
bbaaef
+ovn-nbctl lsp-add sw0 sw0-p1
bbaaef
+
bbaaef
+OVS_WAIT_UNTIL([test 1 = $(ovn-sbctl --bare --columns _uuid find \
bbaaef
+service_monitor | sed '/^$/d' | wc -l)])
bbaaef
+
bbaaef
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns status find \
bbaaef
+service_monitor | grep offline | wc -l)])
bbaaef
+
bbaaef
+OVS_WAIT_UNTIL([test 0 = $(ovn-sbctl --bare --columns status find \
bbaaef
+service_monitor | grep online | wc -l)])
bbaaef
+
bbaaef
 OVN_CLEANUP([hv1], [hv2])
bbaaef
 AT_CLEANUP
bbaaef
diff --git a/tests/system-ovn.at b/tests/system-ovn.at
bbaaef
index 22e9a5926..d863c828d 100644
bbaaef
--- a/tests/system-ovn.at
bbaaef
+++ b/tests/system-ovn.at
bbaaef
@@ -2545,8 +2545,8 @@ start_daemon ovn-controller
bbaaef
 ovn-nbctl ls-add sw0
bbaaef
 
bbaaef
 ovn-nbctl lsp-add sw0 sw0-p1
bbaaef
-ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03 10.0.0.3"
bbaaef
-ovn-nbctl lsp-set-port-security sw0-p1 "50:54:00:00:00:03 10.0.0.3"
bbaaef
+ovn-nbctl lsp-set-addresses sw0-p1 "50:54:00:00:00:03"
bbaaef
+ovn-nbctl lsp-set-port-security sw0-p1 "50:54:00:00:00:03"
bbaaef
 
bbaaef
 ovn-nbctl lsp-add sw0 sw0-p2
bbaaef
 ovn-nbctl lsp-set-addresses sw0-p2 "50:54:00:00:00:04 10.0.0.4"
bbaaef
-- 
bbaaef
2.25.1
bbaaef