5f9769
From 19fc17eee44cb899e62292a8f6ff4cfe98815ea6 Mon Sep 17 00:00:00 2001
5f9769
Message-Id: <19fc17eee44cb899e62292a8f6ff4cfe98815ea6.1610114400.git.lorenzo.bianconi@redhat.com>
5f9769
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5f9769
Date: Tue, 5 Jan 2021 15:37:37 +0100
5f9769
Subject: [PATCH] ovn-trace: fix trigger_event warning.
5f9769
5f9769
Fix the following ovn-trace warning triggered by controller_event:
5f9769
5f9769
00001|ovntrace|WARN|trigger_event(event = "empty_lb_backends", meter = "",
5f9769
				  vip = "192.168.0.100:80", protocol = "tcp",
5f9769
				  load_balancer = "2c5462a7-b6ca-4b02-86c9-b9aa98a570e8");
5f9769
parsing actions failed (Syntax error a t `vip' expecting empty_lb_backends option name.)
5f9769
5f9769
The issue can be triggered running the following reproducer in ovn-sanbox:
5f9769
5f9769
$./ovn-setup.sh
5f9769
$ovn-nbctl lb-add lb0 192.168.0.100:80 ""
5f9769
$ovn-nbctl ls-lb-add sw0 lb0
5f9769
$ovn-nbctl --wait=hv set NB_Global . options:controller_event=true
5f9769
$ovn-trace sw0 'inport == "sw0-port1" && eth.src == 50:54:00:00:00:01 && ip4.src==192.168.0.2 && eth.dst == 00:00:00:00:ff:01 && ip4.dst==192.168.0.100 && tcp && tcp.dst==80'
5f9769
5f9769
Acked-by: Dumitru Ceara <dceara@redhat.com>
5f9769
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5f9769
Signed-off-by: Numan Siddique <numans@ovn.org>
5f9769
---
5f9769
 tests/ovn.at          | 2 ++
5f9769
 utilities/ovn-trace.c | 4 ++++
5f9769
 2 files changed, 6 insertions(+)
5f9769
5f9769
--- a/tests/ovn.at
5f9769
+++ b/tests/ovn.at
5f9769
@@ -16889,6 +16889,8 @@ AT_CHECK_UNQUOTED([ovn-sbctl get control
5f9769
 "$uuid_lb2"
5f9769
 ])
5f9769
 
5f9769
+AT_CHECK_UNQUOTED([ovn-trace sw0 'inport == "sw0-p11" && eth.src == 00:00:00:00:00:11 && ip4.dst == 192.168.1.100 && tcp && tcp.dst == 80' | grep -q 'event = "empty_lb_backends"'], [0])
5f9769
+
5f9769
 OVN_CLEANUP([hv1], [hv2])
5f9769
 AT_CLEANUP
5f9769
 
5f9769
--- a/utilities/ovn-trace.c
5f9769
+++ b/utilities/ovn-trace.c
5f9769
@@ -478,6 +478,7 @@ static struct shash port_groups;
5f9769
 static struct hmap dhcp_opts;   /* Contains "struct gen_opts_map"s. */
5f9769
 static struct hmap dhcpv6_opts; /* Contains "struct gen_opts_map"s. */
5f9769
 static struct hmap nd_ra_opts; /* Contains "struct gen_opts_map"s. */
5f9769
+static struct controller_event_options event_opts;
5f9769
 
5f9769
 static struct ovntrace_datapath *
5f9769
 ovntrace_datapath_find_by_sb_uuid(const struct uuid *sb_uuid)
5f9769
@@ -901,6 +902,7 @@ parse_lflow_for_datapath(const struct sb
5f9769
             .dhcp_opts = &dhcp_opts,
5f9769
             .dhcpv6_opts = &dhcpv6_opts,
5f9769
             .nd_ra_opts = &nd_ra_opts,
5f9769
+            .controller_event_opts = &event_opts,
5f9769
             .pipeline = (!strcmp(sblf->pipeline, "ingress")
5f9769
                          ? OVNACT_P_INGRESS
5f9769
                          : OVNACT_P_EGRESS),
5f9769
@@ -1006,6 +1008,8 @@ read_gen_opts(void)
5f9769
 
5f9769
     hmap_init(&nd_ra_opts);
5f9769
     nd_ra_opts_init(&nd_ra_opts);
5f9769
+
5f9769
+    controller_event_opts_init(&event_opts);
5f9769
 }
5f9769
 
5f9769
 static void