From 6bf3dfd2cab5fc907c4698a35801e027eb01ab17 Mon Sep 17 00:00:00 2001 From: Filip Varga Date: Thu, 19 Nov 2020 10:58:42 +0100 Subject: nat: fix tests Fixed nat_ha and ipfix tests. Removed obsolete tests and moved extended tests to standard tests. Type: fix Change-Id: I2d7f4c4fa4c52a4aa10d70c956e085a0fe00b911 Signed-off-by: Filip Varga --- src/plugins/nat/nat_ha.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/plugins/nat/nat_ha.c') diff --git a/src/plugins/nat/nat_ha.c b/src/plugins/nat/nat_ha.c index 93f762f61ae..3ae572ba930 100644 --- a/src/plugins/nat/nat_ha.c +++ b/src/plugins/nat/nat_ha.c @@ -124,6 +124,7 @@ typedef struct /* NAT HA settings */ typedef struct nat_ha_main_s { + u8 enabled; /* local IP address and UDP port */ ip4_address_t src_ip_address; u16 src_port; @@ -318,6 +319,16 @@ nat_ha_enable (nat_ha_sadd_cb_t sadd_cb, ha->sadd_cb = sadd_cb; ha->sdel_cb = sdel_cb; ha->sref_cb = sref_cb; + + ha->enabled = 1; +} + +void +nat_ha_disable () +{ + nat_ha_main_t *ha = &nat_ha_main; + ha->dst_port = 0; + ha->enabled = 0; } void @@ -749,12 +760,23 @@ nat_ha_sref (ip4_address_t * out_addr, u16 out_port, ip4_address_t * eh_addr, nat_ha_event_add (&event, 0, thread_index, 0); } +static_always_inline u8 +plugin_enabled () +{ + nat_ha_main_t *ha = &nat_ha_main; + return ha->enabled; +} + /* per thread process waiting for interrupt */ static uword nat_ha_worker_fn (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) { u32 thread_index = vm->thread_index; + + if (plugin_enabled () == 0) + return 0; + /* flush HA NAT data under construction */ nat_ha_event_add (0, 1, thread_index, 0); /* scan if we need to resend some non-ACKed data */ -- cgit 1.2.3-korg