bbaaef
From 3624362cb395b6bc90f6fd69e12988979db95b7e Mon Sep 17 00:00:00 2001
bbaaef
Message-Id: <3624362cb395b6bc90f6fd69e12988979db95b7e.1568637354.git.lorenzo.bianconi@redhat.com>
bbaaef
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
bbaaef
Date: Tue, 3 Sep 2019 16:22:51 +0200
bbaaef
Subject: [PATCH ovn 1/3] northd: introduce build_empty_lb_event_flow routine
bbaaef
bbaaef
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
bbaaef
Signed-off-by: Mark Michelson <mmichels@redhat.com>
bbaaef
Acked-by: Mark Michelson <mmichels@redhat.com>
bbaaef
---
bbaaef
 ovn/northd/ovn-northd.c | 63 ++++++++++++++++++++++++++-------------------
bbaaef
 1 file changed, 37 insertions(+), 26 deletions(-)
bbaaef
bbaaef
--- a/ovn/northd/ovn-northd.c
bbaaef
+++ b/ovn/northd/ovn-northd.c
bbaaef
@@ -3882,6 +3882,41 @@ ls_has_dns_records(const struct nbrec_lo
bbaaef
 }
bbaaef
 
bbaaef
 static void
bbaaef
+build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows,
bbaaef
+                          struct smap_node *node, char *ip_address,
bbaaef
+                          struct nbrec_load_balancer *lb, uint16_t port,
bbaaef
+                          int addr_family, int pl)
bbaaef
+{
bbaaef
+    if (!controller_event_en || node->value[0]) {
bbaaef
+        return;
bbaaef
+    }
bbaaef
+
bbaaef
+    struct ds match = DS_EMPTY_INITIALIZER;
bbaaef
+    char *action;
bbaaef
+
bbaaef
+    if (addr_family == AF_INET) {
bbaaef
+        ds_put_format(&match, "ip4.dst == %s && %s",
bbaaef
+                      ip_address, lb->protocol);
bbaaef
+    } else {
bbaaef
+        ds_put_format(&match, "ip6.dst == %s && %s",
bbaaef
+                      ip_address, lb->protocol);
bbaaef
+    }
bbaaef
+    if (port) {
bbaaef
+        ds_put_format(&match, " && %s.dst == %u", lb->protocol,
bbaaef
+                      port);
bbaaef
+    }
bbaaef
+    action = xasprintf("trigger_event(event = \"%s\", "
bbaaef
+                   "vip = \"%s\", protocol = \"%s\", "
bbaaef
+                   "load_balancer = \"" UUID_FMT "\");",
bbaaef
+                   event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS),
bbaaef
+                   node->key, lb->protocol,
bbaaef
+                   UUID_ARGS(&lb->header_.uuid));
bbaaef
+    ovn_lflow_add(lflows, od, pl, 130, ds_cstr(&match), action);
bbaaef
+    ds_destroy(&match);
bbaaef
+    free(action);
bbaaef
+}
bbaaef
+
bbaaef
+static void
bbaaef
 build_pre_lb(struct ovn_datapath *od, struct hmap *lflows)
bbaaef
 {
bbaaef
     /* Do not send ND packets to conntrack */
bbaaef
@@ -3918,32 +3953,8 @@ build_pre_lb(struct ovn_datapath *od, st
bbaaef
                 sset_add(&all_ips, ip_address);
bbaaef
             }
bbaaef
 
bbaaef
-            if (controller_event_en && !node->value[0]) {
bbaaef
-                struct ds match = DS_EMPTY_INITIALIZER;
bbaaef
-                char *action;
bbaaef
-
bbaaef
-                if (addr_family == AF_INET) {
bbaaef
-                    ds_put_format(&match, "ip4.dst == %s && %s",
bbaaef
-                                  ip_address, lb->protocol);
bbaaef
-                } else {
bbaaef
-                    ds_put_format(&match, "ip6.dst == %s && %s",
bbaaef
-                                  ip_address, lb->protocol);
bbaaef
-                }
bbaaef
-                if (port) {
bbaaef
-                    ds_put_format(&match, " && %s.dst == %u", lb->protocol,
bbaaef
-                                  port);
bbaaef
-                }
bbaaef
-                action = xasprintf("trigger_event(event = \"%s\", "
bbaaef
-                               "vip = \"%s\", protocol = \"%s\", "
bbaaef
-                               "load_balancer = \"" UUID_FMT "\");",
bbaaef
-                               event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS),
bbaaef
-                               node->key, lb->protocol,
bbaaef
-                               UUID_ARGS(&lb->header_.uuid));
bbaaef
-                ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, 120,
bbaaef
-                              ds_cstr(&match), action);
bbaaef
-                ds_destroy(&match);
bbaaef
-                free(action);
bbaaef
-            }
bbaaef
+            build_empty_lb_event_flow(od, lflows, node, ip_address, lb,
bbaaef
+                                      port, addr_family, S_SWITCH_IN_PRE_LB);
bbaaef
 
bbaaef
             free(ip_address);
bbaaef