aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2019-02-13 01:42:59 -0800
committerDamjan Marion <dmarion@me.com>2019-02-18 16:46:50 +0000
commite69e423743630b52e13db58c3f0229df8a46c07f (patch)
tree5471b64b7fe38031f47791c987f9791fc8207fa7
parent7dcb80a202f1ce075434a17ace3334a7a311e84e (diff)
NAT: VPP-1552 code migration from old multiarch scheme
Change-Id: I88f3df8aaa521e7707ef3335acdbf1ab41e7ee28 Signed-off-by: Filip Varga <fivarga@cisco.com>
-rw-r--r--src/plugins/nat/CMakeLists.txt19
-rw-r--r--src/plugins/nat/dslite.c10
-rw-r--r--src/plugins/nat/dslite.h5
-rw-r--r--src/plugins/nat/dslite_ce_decap.c11
-rw-r--r--src/plugins/nat/dslite_ce_encap.c11
-rw-r--r--src/plugins/nat/dslite_in2out.c26
-rw-r--r--src/plugins/nat/dslite_out2in.c13
-rwxr-xr-xsrc/plugins/nat/in2out.c87
-rw-r--r--src/plugins/nat/in2out_ed.c85
-rwxr-xr-xsrc/plugins/nat/nat.c61
-rw-r--r--src/plugins/nat/nat.h27
-rw-r--r--src/plugins/nat/nat44_classify.c43
-rw-r--r--src/plugins/nat/nat44_hairpinning.c86
-rw-r--r--src/plugins/nat/nat44_handoff.c38
-rw-r--r--src/plugins/nat/nat64.c25
-rw-r--r--src/plugins/nat/nat64.h12
-rw-r--r--src/plugins/nat/nat64_in2out.c51
-rw-r--r--src/plugins/nat/nat64_out2in.c48
-rw-r--r--src/plugins/nat/nat66.c9
-rw-r--r--src/plugins/nat/nat66.h5
-rw-r--r--src/plugins/nat/nat66_in2out.c13
-rw-r--r--src/plugins/nat/nat66_out2in.c13
-rw-r--r--src/plugins/nat/nat_det_in2out.c15
-rw-r--r--src/plugins/nat/nat_det_out2in.c15
-rwxr-xr-xsrc/plugins/nat/out2in.c60
-rw-r--r--src/plugins/nat/out2in_ed.c47
26 files changed, 387 insertions, 448 deletions
diff --git a/src/plugins/nat/CMakeLists.txt b/src/plugins/nat/CMakeLists.txt
index 134aafed509..f4a9919a329 100644
--- a/src/plugins/nat/CMakeLists.txt
+++ b/src/plugins/nat/CMakeLists.txt
@@ -49,6 +49,25 @@ add_vpp_plugin(nat
nat_format.c
nat_syslog.c
+ MULTIARCH_SOURCES
+ dslite_ce_decap.c
+ dslite_ce_encap.c
+ dslite_in2out.c
+ dslite_out2in.c
+ in2out.c
+ in2out_ed.c
+ nat44_classify.c
+ nat44_hairpinning.c
+ nat44_handoff.c
+ nat64_in2out.c
+ nat64_out2in.c
+ nat66_in2out.c
+ nat66_out2in.c
+ nat_det_in2out.c
+ nat_det_out2in.c
+ out2in.c
+ out2in_ed.c
+
API_FILES
nat.api
diff --git a/src/plugins/nat/dslite.c b/src/plugins/nat/dslite.c
index 883acecb052..339c12c5656 100644
--- a/src/plugins/nat/dslite.c
+++ b/src/plugins/nat/dslite.c
@@ -25,12 +25,22 @@ dslite_init (vlib_main_t * vm)
vlib_thread_registration_t *tr;
vlib_thread_main_t *tm = vlib_get_thread_main ();
uword *p;
+ vlib_node_t *node;
dslite_per_thread_data_t *td;
u32 translation_buckets = 1024;
u32 translation_memory_size = 128 << 20;
u32 b4_buckets = 128;
u32 b4_memory_size = 64 << 20;
+ node = vlib_get_node_by_name (vm, (u8 *) "dslite-in2out");
+ dm->dslite_in2out_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "dslite-in2out-slowpath");
+ dm->dslite_in2out_slowpath_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "dslite-out2in");
+ dm->dslite_out2in_node_index = node->index;
+
dm->first_worker_index = 0;
dm->num_workers = 0;
diff --git a/src/plugins/nat/dslite.h b/src/plugins/nat/dslite.h
index 066bfcf1379..65498eebd9d 100644
--- a/src/plugins/nat/dslite.h
+++ b/src/plugins/nat/dslite.h
@@ -91,6 +91,11 @@ typedef struct
vlib_simple_counter_main_t total_b4s;
vlib_simple_counter_main_t total_sessions;
+ /* node index */
+ u32 dslite_in2out_node_index;
+ u32 dslite_in2out_slowpath_node_index;
+ u32 dslite_out2in_node_index;
+
/* If set then the DSLite component behaves as CPE/B4
* otherwise it behaves as AFTR */
u8 is_ce;
diff --git a/src/plugins/nat/dslite_ce_decap.c b/src/plugins/nat/dslite_ce_decap.c
index c16ac17c2a6..77b80ea0f45 100644
--- a/src/plugins/nat/dslite_ce_decap.c
+++ b/src/plugins/nat/dslite_ce_decap.c
@@ -15,8 +15,6 @@
#include <nat/dslite.h>
#include <nat/nat_inlines.h>
-vlib_node_registration_t dslite_ce_decap_node;
-
typedef enum
{
DSLITE_CE_DECAP_NEXT_IP4_LOOKUP,
@@ -31,9 +29,9 @@ static char *dslite_ce_decap_error_strings[] = {
#undef _
};
-static uword
-dslite_ce_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (dslite_ce_decap_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
dslite_ce_decap_next_t next_index;
@@ -119,7 +117,6 @@ dslite_ce_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dslite_ce_decap_node) = {
- .function = dslite_ce_decap_node_fn,
.name = "dslite-ce-decap",
.vector_size = sizeof (u32),
.format_trace = format_dslite_ce_trace,
@@ -136,8 +133,6 @@ VLIB_REGISTER_NODE (dslite_ce_decap_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (dslite_ce_decap_node, dslite_ce_decap_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/dslite_ce_encap.c b/src/plugins/nat/dslite_ce_encap.c
index d83ca9c8046..39ff7975c3a 100644
--- a/src/plugins/nat/dslite_ce_encap.c
+++ b/src/plugins/nat/dslite_ce_encap.c
@@ -15,8 +15,6 @@
#include <nat/dslite.h>
#include <nat/nat_inlines.h>
-vlib_node_registration_t dslite_ce_encap_node;
-
typedef enum
{
DSLITE_CE_ENCAP_NEXT_IP6_LOOKUP,
@@ -30,9 +28,9 @@ static char *dslite_ce_encap_error_strings[] = {
#undef _
};
-static uword
-dslite_ce_encap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (dslite_ce_encap_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
dslite_ce_encap_next_t next_index;
@@ -112,7 +110,6 @@ dslite_ce_encap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dslite_ce_encap_node) = {
- .function = dslite_ce_encap_node_fn,
.name = "dslite-ce-encap",
.vector_size = sizeof (u32),
.format_trace = format_dslite_ce_trace,
@@ -128,8 +125,6 @@ VLIB_REGISTER_NODE (dslite_ce_encap_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (dslite_ce_encap_node, dslite_ce_encap_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/dslite_in2out.c b/src/plugins/nat/dslite_in2out.c
index cbb5d987d01..2a8b548c15f 100644
--- a/src/plugins/nat/dslite_in2out.c
+++ b/src/plugins/nat/dslite_in2out.c
@@ -16,9 +16,6 @@
#include <nat/nat_inlines.h>
#include <nat/nat_syslog.h>
-vlib_node_registration_t dslite_in2out_node;
-vlib_node_registration_t dslite_in2out_slowpath_node;
-
typedef enum
{
DSLITE_IN2OUT_NEXT_IP4_LOOKUP,
@@ -249,8 +246,8 @@ dslite_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
dslite_main_t *dm = &dslite_main;
node_index =
- is_slow_path ? dslite_in2out_slowpath_node.
- index : dslite_in2out_node.index;
+ is_slow_path ? dm->dslite_in2out_slowpath_node_index :
+ dm->dslite_in2out_node_index;
error_node = vlib_node_get_runtime (vm, node_index);
@@ -445,16 +442,15 @@ dslite_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
return frame->n_vectors;
}
-static uword
-dslite_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (dslite_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return dslite_in2out_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dslite_in2out_node) = {
- .function = dslite_in2out_node_fn,
.name = "dslite-in2out",
.vector_size = sizeof (u32),
.format_trace = format_dslite_trace,
@@ -472,18 +468,15 @@ VLIB_REGISTER_NODE (dslite_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (dslite_in2out_node, dslite_in2out_node_fn);
-
-static uword
-dslite_in2out_slowpath_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (dslite_in2out_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return dslite_in2out_node_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dslite_in2out_slowpath_node) = {
- .function = dslite_in2out_slowpath_node_fn,
.name = "dslite-in2out-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_dslite_trace,
@@ -501,9 +494,6 @@ VLIB_REGISTER_NODE (dslite_in2out_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (dslite_in2out_slowpath_node,
- dslite_in2out_slowpath_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/dslite_out2in.c b/src/plugins/nat/dslite_out2in.c
index 798367db6b1..18f9a577923 100644
--- a/src/plugins/nat/dslite_out2in.c
+++ b/src/plugins/nat/dslite_out2in.c
@@ -15,8 +15,6 @@
#include <nat/dslite.h>
#include <nat/nat_inlines.h>
-vlib_node_registration_t dslite_out2in_node;
-
typedef enum
{
DSLITE_OUT2IN_NEXT_IP4_LOOKUP,
@@ -94,9 +92,9 @@ done:
return n;
}
-static uword
-dslite_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (dslite_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
dslite_out2in_next_t next_index;
@@ -105,7 +103,7 @@ dslite_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
f64 now = vlib_time_now (vm);
dslite_main_t *dm = &dslite_main;
- error_node = vlib_node_get_runtime (vm, dslite_out2in_node.index);
+ error_node = vlib_node_get_runtime (vm, dm->dslite_out2in_node_index);
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -270,7 +268,6 @@ dslite_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dslite_out2in_node) = {
- .function = dslite_out2in_node_fn,
.name = "dslite-out2in",
.vector_size = sizeof (u32),
.format_trace = format_dslite_trace,
@@ -287,8 +284,6 @@ VLIB_REGISTER_NODE (dslite_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (dslite_out2in_node, dslite_out2in_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c
index abb916060f1..403d23c3565 100755
--- a/src/plugins/nat/in2out.c
+++ b/src/plugins/nat/in2out.c
@@ -72,13 +72,6 @@ format_snat_in2out_fast_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t snat_in2out_node;
-vlib_node_registration_t snat_in2out_slowpath_node;
-vlib_node_registration_t snat_in2out_fast_node;
-vlib_node_registration_t snat_in2out_output_node;
-vlib_node_registration_t snat_in2out_output_slowpath_node;
-vlib_node_registration_t nat44_in2out_reass_node;
-
#define foreach_snat_in2out_error \
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(IN2OUT_PACKETS, "good in2out packets processed") \
@@ -198,6 +191,7 @@ nat_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip0,
return 0;
}
+#ifndef CLIB_MARCH_VARIANT
int
nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
{
@@ -240,6 +234,7 @@ nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
return 0;
}
+#endif
static u32
slow_path (snat_main_t * sm, vlib_buffer_t * b0,
@@ -433,6 +428,7 @@ static_always_inline
return -1; /* success */
}
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
* and create session if needed
@@ -550,7 +546,9 @@ out:
*(snat_session_t **) d = s0;
return next0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
*
@@ -632,7 +630,9 @@ out2:
*p_dont_translate = dont_translate;
return next0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
u32
icmp_in2out (snat_main_t * sm,
vlib_buffer_t * b0,
@@ -782,6 +782,7 @@ icmp_in2out (snat_main_t * sm,
out:
return next0;
}
+#endif
static inline u32
icmp_in2out_slow_path (snat_main_t * sm,
@@ -863,8 +864,8 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
0, fragments = 0;
- stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index :
- snat_in2out_node.index;
+ stats_node_index = is_slow_path ? sm->in2out_slowpath_node_index :
+ sm->in2out_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1552,9 +1553,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-snat_in2out_fast_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_in2out_node_fn_inline (vm, node, frame, 0 /* is_slow_path */ ,
0);
@@ -1562,7 +1563,6 @@ snat_in2out_fast_path_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_node) = {
- .function = snat_in2out_fast_path_fn,
.name = "nat44-in2out",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
@@ -1586,12 +1586,9 @@ VLIB_REGISTER_NODE (snat_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_node, snat_in2out_fast_path_fn);
-
-static uword
-snat_in2out_output_fast_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_output_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_in2out_node_fn_inline (vm, node, frame, 0 /* is_slow_path */ ,
1);
@@ -1599,7 +1596,6 @@ snat_in2out_output_fast_path_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_output_node) = {
- .function = snat_in2out_output_fast_path_fn,
.name = "nat44-in2out-output",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
@@ -1623,12 +1619,9 @@ VLIB_REGISTER_NODE (snat_in2out_output_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_output_node,
- snat_in2out_output_fast_path_fn);
-
-static uword
-snat_in2out_slow_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_in2out_node_fn_inline (vm, node, frame, 1 /* is_slow_path */ ,
0);
@@ -1636,7 +1629,6 @@ snat_in2out_slow_path_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_slowpath_node) = {
- .function = snat_in2out_slow_path_fn,
.name = "nat44-in2out-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
@@ -1660,13 +1652,9 @@ VLIB_REGISTER_NODE (snat_in2out_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_slowpath_node,
- snat_in2out_slow_path_fn);
-
-static uword
-snat_in2out_output_slow_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_output_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_in2out_node_fn_inline (vm, node, frame, 1 /* is_slow_path */ ,
1);
@@ -1674,7 +1662,6 @@ snat_in2out_output_slow_path_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_output_slowpath_node) = {
- .function = snat_in2out_output_slow_path_fn,
.name = "nat44-in2out-output-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
@@ -1698,12 +1685,9 @@ VLIB_REGISTER_NODE (snat_in2out_output_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_output_slowpath_node,
- snat_in2out_output_slow_path_fn);
-
-static uword
-nat44_in2out_reass_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_in2out_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
snat_in2out_next_t next_index;
@@ -1960,10 +1944,10 @@ nat44_in2out_reass_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat44_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, sm->in2out_reass_node_index,
SNAT_IN2OUT_ERROR_PROCESSED_FRAGMENTS,
pkts_processed);
- vlib_node_increment_counter (vm, nat44_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, sm->in2out_reass_node_index,
SNAT_IN2OUT_ERROR_CACHED_FRAGMENTS,
cached_fragments);
@@ -1978,7 +1962,6 @@ nat44_in2out_reass_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_in2out_reass_node) = {
- .function = nat44_in2out_reass_node_fn,
.name = "nat44-in2out-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
@@ -1998,13 +1981,9 @@ VLIB_REGISTER_NODE (nat44_in2out_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_in2out_reass_node,
- nat44_in2out_reass_node_fn);
-
-static uword
-snat_in2out_fast_static_map_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_fast_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
snat_in2out_next_t next_index;
@@ -2012,7 +1991,7 @@ snat_in2out_fast_static_map_fn (vlib_main_t * vm,
snat_main_t *sm = &snat_main;
u32 stats_node_index;
- stats_node_index = snat_in2out_fast_node.index;
+ stats_node_index = sm->in2out_fast_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -2177,7 +2156,6 @@ snat_in2out_fast_static_map_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_fast_node) = {
- .function = snat_in2out_fast_static_map_fn,
.name = "nat44-in2out-fast",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_fast_trace,
@@ -2201,9 +2179,6 @@ VLIB_REGISTER_NODE (snat_in2out_fast_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_fast_node,
- snat_in2out_fast_static_map_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c
index 2cde378e801..8479d276261 100644
--- a/src/plugins/nat/in2out_ed.c
+++ b/src/plugins/nat/in2out_ed.c
@@ -81,12 +81,6 @@ typedef struct
u32 is_slow_path;
} nat_in2out_ed_trace_t;
-vlib_node_registration_t nat44_ed_in2out_node;
-vlib_node_registration_t nat44_ed_in2out_slowpath_node;
-vlib_node_registration_t nat44_ed_in2out_output_node;
-vlib_node_registration_t nat44_ed_in2out_output_slowpath_node;
-vlib_node_registration_t nat44_ed_in2out_reass_node;
-
static u8 *
format_nat_in2out_ed_trace (u8 * s, va_list * args)
{
@@ -154,6 +148,7 @@ icmp_get_ed_key (ip4_header_t * ip0, nat_ed_ses_key_t * p_key0)
return 0;
}
+#ifndef CLIB_MARCH_VARIANT
int
nat44_i2o_ed_is_idle_session_cb (clib_bihash_kv_16_8_t * kv, void *arg)
{
@@ -243,6 +238,7 @@ nat44_i2o_ed_is_idle_session_cb (clib_bihash_kv_16_8_t * kv, void *arg)
return 0;
}
+#endif
static inline u32
icmp_in2out_ed_slow_path (snat_main_t * sm, vlib_buffer_t * b0,
@@ -587,6 +583,7 @@ nat44_ed_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip,
return 0;
}
+#ifndef CLIB_MARCH_VARIANT
u32
icmp_match_in2out_ed (snat_main_t * sm, vlib_node_runtime_t * node,
u32 thread_index, vlib_buffer_t * b, ip4_header_t * ip,
@@ -696,6 +693,7 @@ out:
*(snat_session_t **) d = s;
return next;
}
+#endif
static snat_session_t *
nat44_ed_in2out_unknown_proto (snat_main_t * sm,
@@ -912,8 +910,8 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm,
u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
0, fragments = 0;
- stats_node_index = is_slow_path ? nat44_ed_in2out_slowpath_node.index :
- nat44_ed_in2out_node.index;
+ stats_node_index = is_slow_path ? sm->ed_in2out_slowpath_node_index :
+ sm->ed_in2out_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1650,17 +1648,15 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-nat44_ed_in2out_fast_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_node_fn_inline (vm, node, frame, 0, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_node) = {
- .function = nat44_ed_in2out_fast_path_fn,
.name = "nat44-ed-in2out",
.vector_size = sizeof (u32),
.format_trace = format_nat_in2out_ed_trace,
@@ -1679,20 +1675,15 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_node,
- nat44_ed_in2out_fast_path_fn);
-
-static uword
-nat44_ed_in2out_output_fast_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_output_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_node_fn_inline (vm, node, frame, 0, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_output_node) = {
- .function = nat44_ed_in2out_output_fast_path_fn,
.name = "nat44-ed-in2out-output",
.vector_size = sizeof (u32),
.format_trace = format_nat_in2out_ed_trace,
@@ -1711,20 +1702,15 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_output_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_output_node,
- nat44_ed_in2out_output_fast_path_fn);
-
-static uword
-nat44_ed_in2out_slow_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_node_fn_inline (vm, node, frame, 1, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node) = {
- .function = nat44_ed_in2out_slow_path_fn,
.name = "nat44-ed-in2out-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_nat_in2out_ed_trace,
@@ -1743,20 +1729,16 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_slowpath_node,
- nat44_ed_in2out_slow_path_fn);
-
-static uword
-nat44_ed_in2out_output_slow_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_output_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t *
+ node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_node_fn_inline (vm, node, frame, 1, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node) = {
- .function = nat44_ed_in2out_output_slow_path_fn,
.name = "nat44-ed-in2out-output-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_nat_in2out_ed_trace,
@@ -1775,9 +1757,6 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_output_slowpath_node,
- nat44_ed_in2out_output_slow_path_fn);
-
static inline uword
nat44_ed_in2out_reass_node_fn_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -2102,10 +2081,10 @@ nat44_ed_in2out_reass_node_fn_inline (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat44_ed_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, sm->ed_in2out_reass_node_index,
NAT_IN2OUT_ED_ERROR_PROCESSED_FRAGMENTS,
pkts_processed);
- vlib_node_increment_counter (vm, nat44_ed_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, sm->ed_in2out_reass_node_index,
NAT_IN2OUT_ED_ERROR_CACHED_FRAGMENTS,
cached_fragments);
@@ -2118,17 +2097,15 @@ nat44_ed_in2out_reass_node_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-nat44_ed_in2out_reass_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_reass_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_reass_node) = {
- .function = nat44_ed_in2out_reass_node_fn,
.name = "nat44-ed-in2out-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
@@ -2146,20 +2123,15 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_reass_node,
- nat44_ed_in2out_reass_node_fn);
-
-static uword
-nat44_ed_in2out_reass_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_in2out_reass_output_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_in2out_reass_node_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_in2out_reass_output_node) = {
- .function = nat44_ed_in2out_reass_output_node_fn,
.name = "nat44-ed-in2out-reass-output",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
@@ -2177,9 +2149,6 @@ VLIB_REGISTER_NODE (nat44_ed_in2out_reass_output_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_in2out_reass_output_node,
- nat44_ed_in2out_reass_output_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index 4e9d5023b3f..79c1eaa2c10 100755
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -2240,7 +2240,7 @@ snat_init (vlib_main_t * vm)
uword *bitmap = 0;
u32 i;
ip4_add_del_interface_address_callback_t cb4;
- vlib_node_t *error_drop_node;
+ vlib_node_t *node;
sm->vlib_main = vm;
sm->vnet_main = vnet_get_main ();
@@ -2262,10 +2262,63 @@ snat_init (vlib_main_t * vm)
sm->addr_and_port_alloc_alg = NAT_ADDR_AND_PORT_ALLOC_ALG_DEFAULT;
sm->forwarding_enabled = 0;
sm->log_class = vlib_log_register_class ("nat", 0);
- error_drop_node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
- sm->error_node_index = error_drop_node->index;
sm->mss_clamping = 0;
+ node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
+ sm->error_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out");
+ sm->in2out_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out-output");
+ sm->in2out_output_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out-fast");
+ sm->in2out_fast_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out-slowpath");
+ sm->in2out_slowpath_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out-output-slowpath");
+ sm->in2out_slowpath_output_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-in2out-reass");
+ sm->in2out_reass_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-in2out");
+ sm->ed_in2out_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-in2out-slowpath");
+ sm->ed_in2out_slowpath_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-in2out-reass");
+ sm->ed_in2out_reass_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-out2in");
+ sm->out2in_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-out2in-fast");
+ sm->out2in_fast_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-out2in-reass");
+ sm->out2in_reass_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-out2in");
+ sm->ed_out2in_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-out2in-slowpath");
+ sm->ed_out2in_slowpath_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-out2in-reass");
+ sm->ed_out2in_reass_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-det-in2out");
+ sm->det_in2out_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-det-out2in");
+ sm->det_out2in_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-hairpinning");
+ sm->hairpinning_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-hairpin-dst");
+ sm->hairpin_dst_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-hairpin-src");
+ sm->hairpin_src_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-hairpinning");
+ sm->ed_hairpinning_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-hairpin-dst");
+ sm->ed_hairpin_dst_node_index = node->index;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat44-ed-hairpin-src");
+ sm->ed_hairpin_src_node_index = node->index;
+
p = hash_get_mem (tm->thread_registrations_by_name, "workers");
if (p)
{
@@ -2329,7 +2382,7 @@ snat_init (vlib_main_t * vm)
dslite_init (vm);
- nat66_init ();
+ nat66_init (vm);
ip4_table_bind_callback_t cbt4 = {
.function = snat_ip4_table_bind,
diff --git a/src/plugins/nat/nat.h b/src/plugins/nat/nat.h
index 06d0decc9ab..c9139b35200 100644
--- a/src/plugins/nat/nat.h
+++ b/src/plugins/nat/nat.h
@@ -493,11 +493,34 @@ typedef struct snat_main_s
u32 fq_in2out_output_index;
u32 fq_out2in_index;
- /* in2out and out2in node index */
+ /* node indexes */
+ u32 error_node_index;
+
u32 in2out_node_index;
u32 in2out_output_node_index;
+ u32 in2out_fast_node_index;
+ u32 in2out_slowpath_node_index;
+ u32 in2out_slowpath_output_node_index;
+ u32 in2out_reass_node_index;
+ u32 ed_in2out_node_index;
+ u32 ed_in2out_slowpath_node_index;
+ u32 ed_in2out_reass_node_index;
u32 out2in_node_index;
- u32 error_node_index;
+ u32 out2in_fast_node_index;
+ u32 out2in_reass_node_index;
+ u32 ed_out2in_node_index;
+ u32 ed_out2in_slowpath_node_index;
+ u32 ed_out2in_reass_node_index;
+ u32 det_in2out_node_index;
+ u32 det_out2in_node_index;
+
+ u32 hairpinning_node_index;
+ u32 hairpin_dst_node_index;
+ u32 hairpin_src_node_index;
+ u32 ed_hairpinning_node_index;
+ u32 ed_hairpin_dst_node_index;
+ u32 ed_hairpin_src_node_index;
+
/* Deterministic NAT mappings */
snat_det_map_t *det_maps;
diff --git a/src/plugins/nat/nat44_classify.c b/src/plugins/nat/nat44_classify.c
index ed0c37ea21a..5401b5b70ee 100644
--- a/src/plugins/nat/nat44_classify.c
+++ b/src/plugins/nat/nat44_classify.c
@@ -24,11 +24,6 @@
#include <nat/nat_reass.h>
#include <nat/nat_inlines.h>
-vlib_node_registration_t nat44_classify_node;
-vlib_node_registration_t nat44_ed_classify_node;
-vlib_node_registration_t nat44_det_classify_node;
-vlib_node_registration_t nat44_handoff_classify_node;
-
#define foreach_nat44_classify_error \
_(MAX_REASS, "Maximum reassemblies exceeded") \
_(MAX_FRAG, "Maximum fragments per reassembly exceeded") \
@@ -418,16 +413,15 @@ nat44_classify_node_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-nat44_classify_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_classify_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_classify_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_classify_node) = {
- .function = nat44_classify_node_fn,
.name = "nat44-classify",
.vector_size = sizeof (u32),
.format_trace = format_nat44_classify_trace,
@@ -443,17 +437,15 @@ VLIB_REGISTER_NODE (nat44_classify_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_classify_node, nat44_classify_node_fn);
-static uword
-nat44_ed_classify_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_classify_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_classify_node_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_classify_node) = {
- .function = nat44_ed_classify_node_fn,
.name = "nat44-ed-classify",
.vector_size = sizeof (u32),
.format_trace = format_nat44_classify_trace,
@@ -467,19 +459,15 @@ VLIB_REGISTER_NODE (nat44_ed_classify_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_classify_node,
- nat44_ed_classify_node_fn);
-
-static uword
-nat44_det_classify_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_det_classify_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_classify_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_det_classify_node) = {
- .function = nat44_det_classify_node_fn,
.name = "nat44-det-classify",
.vector_size = sizeof (u32),
.format_trace = format_nat44_classify_trace,
@@ -493,20 +481,15 @@ VLIB_REGISTER_NODE (nat44_det_classify_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_det_classify_node,
- nat44_det_classify_node_fn);
-
-static uword
-nat44_handoff_classify_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_handoff_classify_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_classify_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_handoff_classify_node) = {
- .function = nat44_handoff_classify_node_fn,
.name = "nat44-handoff-classify",
.vector_size = sizeof (u32),
.format_trace = format_nat44_classify_trace,
@@ -519,8 +502,6 @@ VLIB_REGISTER_NODE (nat44_handoff_classify_node) = {
},
};
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_handoff_classify_node,
- nat44_handoff_classify_node_fn);
/* *INDENT-ON* */
/*
diff --git a/src/plugins/nat/nat44_hairpinning.c b/src/plugins/nat/nat44_hairpinning.c
index 09ea419e637..daa96ffe714 100644
--- a/src/plugins/nat/nat44_hairpinning.c
+++ b/src/plugins/nat/nat44_hairpinning.c
@@ -57,13 +57,6 @@ static char *nat44_hairpin_error_strings[] = {
#undef _
};
-vlib_node_registration_t snat_hairpin_dst_node;
-vlib_node_registration_t snat_hairpin_src_node;
-vlib_node_registration_t nat44_hairpinning_node;
-vlib_node_registration_t nat44_ed_hairpin_dst_node;
-vlib_node_registration_t nat44_ed_hairpin_src_node;
-vlib_node_registration_t nat44_ed_hairpinning_node;
-
extern vnet_feature_arc_registration_t vnet_feat_arc_ip4_local;
static_always_inline int
@@ -92,6 +85,7 @@ is_hairpinning (snat_main_t * sm, ip4_address_t * dst_addr)
return 0;
}
+#ifndef CLIB_MARCH_VARIANT
int
snat_hairpinning (snat_main_t * sm,
vlib_buffer_t * b0,
@@ -198,7 +192,9 @@ snat_hairpinning (snat_main_t * sm,
}
return 0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
u32
snat_icmp_hairpinning (snat_main_t * sm,
vlib_buffer_t * b0,
@@ -352,7 +348,9 @@ change_addr:
}
return 0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
void
nat_hairpinning_sm_unknown_proto (snat_main_t * sm,
vlib_buffer_t * b, ip4_header_t * ip)
@@ -377,7 +375,9 @@ nat_hairpinning_sm_unknown_proto (snat_main_t * sm,
if (vnet_buffer (b)->sw_if_index[VLIB_TX] == ~0)
vnet_buffer (b)->sw_if_index[VLIB_TX] = m->fib_index;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
void
nat44_ed_hairpinning_unknown_proto (snat_main_t * sm,
vlib_buffer_t * b, ip4_header_t * ip)
@@ -422,7 +422,9 @@ nat44_ed_hairpinning_unknown_proto (snat_main_t * sm,
sum = ip_csum_update (sum, old_addr, new_addr, ip4_header_t, dst_address);
ip->checksum = ip_csum_fold (sum);
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
void
nat44_reass_hairpinning (snat_main_t * sm,
vlib_buffer_t * b0,
@@ -533,6 +535,7 @@ nat44_reass_hairpinning (snat_main_t * sm,
}
}
}
+#endif
static inline uword
nat44_hairpinning_fn_inline (vlib_main_t * vm,
@@ -547,8 +550,8 @@ nat44_hairpinning_fn_inline (vlib_main_t * vm,
u8 arc_index = vnet_feat_arc_ip4_local.feature_arc_index;
vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc_index];
- stats_node_index = is_ed ? nat44_ed_hairpinning_node.index :
- nat44_hairpinning_node.index;
+ stats_node_index = is_ed ? sm->ed_hairpinning_node_index :
+ sm->hairpinning_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
@@ -606,16 +609,15 @@ nat44_hairpinning_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-nat44_hairpinning_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_hairpinning_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_hairpinning_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_hairpinning_node) = {
- .function = nat44_hairpinning_fn,
.name = "nat44-hairpinning",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -629,18 +631,15 @@ VLIB_REGISTER_NODE (nat44_hairpinning_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_hairpinning_node, nat44_hairpinning_fn);
-
-static uword
-nat44_ed_hairpinning_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_hairpinning_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_hairpinning_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_hairpinning_node) = {
- .function = nat44_ed_hairpinning_fn,
.name = "nat44-ed-hairpinning",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -654,9 +653,6 @@ VLIB_REGISTER_NODE (nat44_ed_hairpinning_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_hairpinning_node,
- nat44_ed_hairpinning_fn);
-
static inline uword
snat_hairpin_dst_fn_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -667,8 +663,8 @@ snat_hairpin_dst_fn_inline (vlib_main_t * vm,
u32 pkts_processed = 0;
snat_main_t *sm = &snat_main;
- stats_node_index = is_ed ? nat44_ed_hairpin_dst_node.index :
- snat_hairpin_dst_node.index;
+ stats_node_index = is_ed ? sm->ed_hairpin_dst_node_index :
+ sm->hairpin_dst_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -745,16 +741,15 @@ snat_hairpin_dst_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-snat_hairpin_dst_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_hairpin_dst_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_hairpin_dst_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_hairpin_dst_node) = {
- .function = snat_hairpin_dst_fn,
.name = "nat44-hairpin-dst",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -768,18 +763,15 @@ VLIB_REGISTER_NODE (snat_hairpin_dst_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_hairpin_dst_node, snat_hairpin_dst_fn);
-
-static uword
-nat44_ed_hairpin_dst_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_hairpin_dst_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_hairpin_dst_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node) = {
- .function = nat44_ed_hairpin_dst_fn,
.name = "nat44-ed-hairpin-dst",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -793,9 +785,6 @@ VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_hairpin_dst_node,
- nat44_ed_hairpin_dst_fn);
-
static inline uword
snat_hairpin_src_fn_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -806,8 +795,8 @@ snat_hairpin_src_fn_inline (vlib_main_t * vm,
u32 pkts_processed = 0;
snat_main_t *sm = &snat_main;
- stats_node_index = is_ed ? nat44_ed_hairpin_src_node.index :
- snat_hairpin_src_node.index;
+ stats_node_index = is_ed ? sm->ed_hairpin_src_node_index :
+ sm->hairpin_src_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -874,16 +863,15 @@ snat_hairpin_src_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-snat_hairpin_src_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_hairpin_src_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_hairpin_src_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_hairpin_src_node) = {
- .function = snat_hairpin_src_fn,
.name = "nat44-hairpin-src",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -899,18 +887,15 @@ VLIB_REGISTER_NODE (snat_hairpin_src_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_hairpin_src_node, snat_hairpin_src_fn);
-
-static uword
-nat44_ed_hairpin_src_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_hairpin_src_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return snat_hairpin_src_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node) = {
- .function = nat44_ed_hairpin_src_fn,
.name = "nat44-ed-hairpin-src",
.vector_size = sizeof (u32),
.type = VLIB_NODE_TYPE_INTERNAL,
@@ -926,9 +911,6 @@ VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_hairpin_src_node,
- nat44_ed_hairpin_src_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat44_handoff.c b/src/plugins/nat/nat44_handoff.c
index d7ab650a665..2a8404d141f 100644
--- a/src/plugins/nat/nat44_handoff.c
+++ b/src/plugins/nat/nat44_handoff.c
@@ -50,10 +50,6 @@ static char *nat44_handoff_error_strings[] = {
};
-vlib_node_registration_t snat_in2out_worker_handoff_node;
-vlib_node_registration_t snat_in2out_output_worker_handoff_node;
-vlib_node_registration_t snat_out2in_worker_handoff_node;
-
static u8 *
format_nat44_handoff_trace (u8 * s, va_list * args)
{
@@ -152,17 +148,15 @@ nat44_worker_handoff_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
return frame->n_vectors;
}
-static uword
-snat_in2out_worker_handoff_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_worker_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_worker_handoff_fn_inline (vm, node, frame, 0, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node) = {
- .function = snat_in2out_worker_handoff_fn,
.name = "nat44-in2out-worker-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat44_handoff_trace,
@@ -176,20 +170,16 @@ VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_worker_handoff_node,
- snat_in2out_worker_handoff_fn);
-
-static uword
-snat_in2out_output_worker_handoff_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_in2out_output_worker_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t *
+ node,
+ vlib_frame_t * frame)
{
return nat44_worker_handoff_fn_inline (vm, node, frame, 1, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node) = {
- .function = snat_in2out_output_worker_handoff_fn,
.name = "nat44-in2out-output-worker-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat44_handoff_trace,
@@ -203,20 +193,15 @@ VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_output_worker_handoff_node,
- snat_in2out_output_worker_handoff_fn);
-
-static uword
-snat_out2in_worker_handoff_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (snat_out2in_worker_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_worker_handoff_fn_inline (vm, node, frame, 0, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node) = {
- .function = snat_out2in_worker_handoff_fn,
.name = "nat44-out2in-worker-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat44_handoff_trace,
@@ -230,9 +215,6 @@ VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_out2in_worker_handoff_node,
- snat_out2in_worker_handoff_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat64.c b/src/plugins/nat/nat64.c
index 126cb3cdf79..9c7300462d9 100644
--- a/src/plugins/nat/nat64.c
+++ b/src/plugins/nat/nat64.c
@@ -232,16 +232,31 @@ nat64_init (vlib_main_t * vm)
vlib_thread_main_t *tm = vlib_get_thread_main ();
ip4_add_del_interface_address_callback_t cb4;
ip4_main_t *im = &ip4_main;
- vlib_node_t *error_drop_node =
- vlib_get_node_by_name (vm, (u8 *) "error-drop");
+ nm->sm = &snat_main;
+ vlib_node_t *node;
vec_validate (nm->db, tm->n_vlib_mains - 1);
- nm->sm = &snat_main;
-
nm->fq_in2out_index = ~0;
nm->fq_out2in_index = ~0;
- nm->error_node_index = error_drop_node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
+ nm->error_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat64-in2out");
+ nm->in2out_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat64-in2out-slowpath");
+ nm->in2out_slowpath_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat64-in2out-reass");
+ nm->in2out_reass_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat64-out2in");
+ nm->out2in_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat64-out2in-reass");
+ nm->out2in_reass_node_index = node->index;
/* set session timeouts to default values */
nm->udp_timeout = SNAT_UDP_TIMEOUT;
diff --git a/src/plugins/nat/nat64.h b/src/plugins/nat/nat64.h
index b9251402a0c..e805a10f29b 100644
--- a/src/plugins/nat/nat64.h
+++ b/src/plugins/nat/nat64.h
@@ -89,8 +89,6 @@ typedef struct
/** Pool of static BIB entries to be added/deleted in worker threads */
nat64_static_bib_to_update_t *static_bibs;
- u32 error_node_index;
-
/** config parameters */
u32 bib_buckets;
u32 bib_memory_size;
@@ -112,6 +110,16 @@ typedef struct
vlib_simple_counter_main_t total_bibs;
vlib_simple_counter_main_t total_sessions;
+ /** node index **/
+ u32 error_node_index;
+
+ u32 in2out_node_index;
+ u32 in2out_slowpath_node_index;
+ u32 in2out_reass_node_index;
+
+ u32 out2in_node_index;
+ u32 out2in_reass_node_index;
+
ip4_main_t *ip4_main;
snat_main_t *sm;
} nat64_main_t;
diff --git a/src/plugins/nat/nat64_in2out.c b/src/plugins/nat/nat64_in2out.c
index d30a9cbe519..11551f45741 100644
--- a/src/plugins/nat/nat64_in2out.c
+++ b/src/plugins/nat/nat64_in2out.c
@@ -70,10 +70,6 @@ format_nat64_in2out_reass_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t nat64_in2out_node;
-vlib_node_registration_t nat64_in2out_slowpath_node;
-vlib_node_registration_t nat64_in2out_reass_node;
-vlib_node_registration_t nat64_in2out_handoff_node;
#define foreach_nat64_in2out_error \
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
@@ -970,11 +966,13 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 pkts_processed = 0;
u32 stats_node_index;
u32 thread_index = vm->thread_index;
+ nat64_main_t *nm = &nat64_main;
+
u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
0, fragments = 0;
stats_node_index =
- is_slow_path ? nat64_in2out_slowpath_node.index : nat64_in2out_node.index;
+ is_slow_path ? nm->in2out_slowpath_node_index : nm->in2out_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1171,16 +1169,15 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
return frame->n_vectors;
}
-static uword
-nat64_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat64_in2out_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_in2out_node) = {
- .function = nat64_in2out_node_fn,
.name = "nat64-in2out",
.vector_size = sizeof (u32),
.format_trace = format_nat64_in2out_trace,
@@ -1199,18 +1196,15 @@ VLIB_REGISTER_NODE (nat64_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_in2out_node, nat64_in2out_node_fn);
-
-static uword
-nat64_in2out_slowpath_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_in2out_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat64_in2out_node_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_in2out_slowpath_node) = {
- .function = nat64_in2out_slowpath_node_fn,
.name = "nat64-in2out-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_nat64_in2out_trace,
@@ -1229,9 +1223,6 @@ VLIB_REGISTER_NODE (nat64_in2out_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_in2out_slowpath_node,
- nat64_in2out_slowpath_node_fn);
-
typedef struct nat64_in2out_frag_set_ctx_t_
{
vlib_main_t *vm;
@@ -1379,9 +1370,9 @@ nat64_in2out_frag_hairpinning (vlib_buffer_t * b, ip6_header_t * ip6,
return 0;
}
-static uword
-nat64_in2out_reass_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_in2out_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat64_in2out_next_t next_index;
@@ -1648,10 +1639,10 @@ nat64_in2out_reass_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat64_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, nm->in2out_reass_node_index,
NAT64_IN2OUT_ERROR_PROCESSED_FRAGMENTS,
pkts_processed);
- vlib_node_increment_counter (vm, nat64_in2out_reass_node.index,
+ vlib_node_increment_counter (vm, nm->in2out_reass_node_index,
NAT64_IN2OUT_ERROR_CACHED_FRAGMENTS,
cached_fragments);
@@ -1666,7 +1657,6 @@ nat64_in2out_reass_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_in2out_reass_node) = {
- .function = nat64_in2out_reass_node_fn,
.name = "nat64-in2out-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat64_in2out_reass_trace,
@@ -1685,9 +1675,6 @@ VLIB_REGISTER_NODE (nat64_in2out_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_in2out_reass_node,
- nat64_in2out_reass_node_fn);
-
#define foreach_nat64_in2out_handoff_error \
_(CONGESTION_DROP, "congestion drop") \
_(SAME_WORKER, "same worker") \
@@ -1726,9 +1713,9 @@ format_nat64_in2out_handoff_trace (u8 * s, va_list * args)
return s;
}
-static inline uword
-nat64_in2out_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_in2out_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
nat64_main_t *nm = &nat64_main;
vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
@@ -1793,7 +1780,6 @@ nat64_in2out_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_in2out_handoff_node) = {
- .function = nat64_in2out_handoff_node_fn,
.name = "nat64-in2out-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat64_in2out_handoff_trace,
@@ -1809,9 +1795,6 @@ VLIB_REGISTER_NODE (nat64_in2out_handoff_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_in2out_handoff_node,
- nat64_in2out_handoff_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat64_out2in.c b/src/plugins/nat/nat64_out2in.c
index 6c9e216d96e..b62bbee6f49 100644
--- a/src/plugins/nat/nat64_out2in.c
+++ b/src/plugins/nat/nat64_out2in.c
@@ -67,9 +67,6 @@ format_nat64_out2in_reass_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t nat64_out2in_node;
-vlib_node_registration_t nat64_out2in_reass_node;
-vlib_node_registration_t nat64_out2in_handoff_node;
#define foreach_nat64_out2in_error \
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
@@ -433,12 +430,13 @@ nat64_out2in_unk_proto_set_cb (ip4_header_t * ip4, ip6_header_t * ip6,
return 0;
}
-static uword
-nat64_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat64_out2in_next_t next_index;
+ nat64_main_t *nm = &nat64_main;
u32 pkts_processed = 0;
u32 thread_index = vm->thread_index;
u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
@@ -557,19 +555,19 @@ nat64_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_OUT2IN_PACKETS,
pkts_processed);
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_TCP_PACKETS, tcp_packets);
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_UDP_PACKETS, tcp_packets);
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_ICMP_PACKETS, icmp_packets);
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_OTHER_PACKETS,
other_packets);
- vlib_node_increment_counter (vm, nat64_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT64_OUT2IN_ERROR_FRAGMENTS, fragments);
return frame->n_vectors;
@@ -577,7 +575,6 @@ nat64_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_out2in_node) = {
- .function = nat64_out2in_node_fn,
.name = "nat64-out2in",
.vector_size = sizeof (u32),
.format_trace = format_nat64_out2in_trace,
@@ -595,8 +592,6 @@ VLIB_REGISTER_NODE (nat64_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_out2in_node, nat64_out2in_node_fn);
-
typedef struct nat64_out2in_frag_set_ctx_t_
{
vlib_main_t *vm;
@@ -695,9 +690,9 @@ nat64_out2in_frag_set_cb (ip4_header_t * ip4, ip6_header_t * ip6, void *arg)
return 0;
}
-static uword
-nat64_out2in_reass_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_out2in_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat64_out2in_next_t next_index;
@@ -916,10 +911,10 @@ nat64_out2in_reass_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat64_out2in_reass_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_reass_node_index,
NAT64_OUT2IN_ERROR_PROCESSED_FRAGMENTS,
pkts_processed);
- vlib_node_increment_counter (vm, nat64_out2in_reass_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_reass_node_index,
NAT64_OUT2IN_ERROR_CACHED_FRAGMENTS,
cached_fragments);
@@ -934,7 +929,6 @@ nat64_out2in_reass_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_out2in_reass_node) = {
- .function = nat64_out2in_reass_node_fn,
.name = "nat64-out2in-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat64_out2in_reass_trace,
@@ -952,9 +946,6 @@ VLIB_REGISTER_NODE (nat64_out2in_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_out2in_reass_node,
- nat64_out2in_reass_node_fn);
-
#define foreach_nat64_out2in_handoff_error \
_(CONGESTION_DROP, "congestion drop") \
_(SAME_WORKER, "same worker") \
@@ -993,9 +984,9 @@ format_nat64_out2in_handoff_trace (u8 * s, va_list * args)
return s;
}
-static inline uword
-nat64_out2in_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat64_out2in_handoff_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
nat64_main_t *nm = &nat64_main;
vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
@@ -1060,7 +1051,6 @@ nat64_out2in_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat64_out2in_handoff_node) = {
- .function = nat64_out2in_handoff_node_fn,
.name = "nat64-out2in-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat64_out2in_handoff_trace,
@@ -1076,8 +1066,6 @@ VLIB_REGISTER_NODE (nat64_out2in_handoff_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat64_out2in_handoff_node,
- nat64_out2in_handoff_node_fn);
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat66.c b/src/plugins/nat/nat66.c
index a0f6ec7929a..a6606a458a7 100644
--- a/src/plugins/nat/nat66.c
+++ b/src/plugins/nat/nat66.c
@@ -40,12 +40,19 @@ VNET_FEATURE_INIT (nat66_out2in, static) = {
void
-nat66_init (void)
+nat66_init (vlib_main_t * vm)
{
nat66_main_t *nm = &nat66_main;
+ vlib_node_t *node;
u32 static_mapping_buckets = 1024;
uword static_mapping_memory_size = 64 << 20;
+ node = vlib_get_node_by_name (vm, (u8 *) "nat66-in2out");
+ nm->in2out_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "nat66-out2in");
+ nm->out2in_node_index = node->index;
+
clib_bihash_init_24_8 (&nm->sm_l, "nat66-static-map-by-local",
static_mapping_buckets, static_mapping_memory_size);
clib_bihash_init_24_8 (&nm->sm_e, "nat66-static-map-by-external",
diff --git a/src/plugins/nat/nat66.h b/src/plugins/nat/nat66.h
index 52befd5c166..7b0ffed6dfc 100644
--- a/src/plugins/nat/nat66.h
+++ b/src/plugins/nat/nat66.h
@@ -55,6 +55,9 @@ typedef struct
clib_bihash_24_8_t sm_e;
/** Session counters */
vlib_combined_counter_main_t session_counters;
+ /** node index **/
+ u32 in2out_node_index;
+ u32 out2in_node_index;
u32 outside_vrf_id;
u32 outside_fib_index;
@@ -64,7 +67,7 @@ extern nat66_main_t nat66_main;
extern vlib_node_registration_t nat66_in2out_node;
extern vlib_node_registration_t nat66_out2in_node;
-void nat66_init (void);
+void nat66_init (vlib_main_t * vm);
typedef int (*nat66_interface_walk_fn_t) (snat_interface_t * i, void *ctx);
void nat66_interfaces_walk (nat66_interface_walk_fn_t fn, void *ctx);
int nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add);
diff --git a/src/plugins/nat/nat66_in2out.c b/src/plugins/nat/nat66_in2out.c
index 6bcf6ec667c..ac1f3298415 100644
--- a/src/plugins/nat/nat66_in2out.c
+++ b/src/plugins/nat/nat66_in2out.c
@@ -41,8 +41,6 @@ format_nat66_in2out_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t nat66_in2out_node;
-
#define foreach_nat66_in2out_error \
_(IN2OUT_PACKETS, "good in2out packets processed") \
_(NO_TRANSLATION, "no translation") \
@@ -109,9 +107,9 @@ nat66_not_translate (u32 rx_fib_index, ip6_address_t ip6_addr)
return 1;
}
-static inline uword
-nat66_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat66_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat66_in2out_next_t next_index;
@@ -232,7 +230,7 @@ nat66_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat66_in2out_node.index,
+ vlib_node_increment_counter (vm, nm->in2out_node_index,
NAT66_IN2OUT_ERROR_IN2OUT_PACKETS,
pkts_processed);
return frame->n_vectors;
@@ -240,7 +238,6 @@ nat66_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat66_in2out_node) = {
- .function = nat66_in2out_node_fn,
.name = "nat66-in2out",
.vector_size = sizeof (u32),
.format_trace = format_nat66_in2out_trace,
@@ -256,8 +253,6 @@ VLIB_REGISTER_NODE (nat66_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat66_in2out_node, nat66_in2out_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat66_out2in.c b/src/plugins/nat/nat66_out2in.c
index f264765448c..d404d9f71eb 100644
--- a/src/plugins/nat/nat66_out2in.c
+++ b/src/plugins/nat/nat66_out2in.c
@@ -41,8 +41,6 @@ format_nat66_out2in_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t nat66_out2in_node;
-
#define foreach_nat66_out2in_error \
_(OUT2IN_PACKETS, "good out2in packets processed") \
_(NO_TRANSLATION, "no translation") \
@@ -69,9 +67,9 @@ typedef enum
NAT66_OUT2IN_N_NEXT,
} nat66_out2in_next_t;
-static inline uword
-nat66_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat66_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat66_out2in_next_t next_index;
@@ -190,7 +188,7 @@ nat66_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat66_out2in_node.index,
+ vlib_node_increment_counter (vm, nm->out2in_node_index,
NAT66_OUT2IN_ERROR_OUT2IN_PACKETS,
pkts_processed);
return frame->n_vectors;
@@ -198,7 +196,6 @@ nat66_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat66_out2in_node) = {
- .function = nat66_out2in_node_fn,
.name = "nat66-out2in",
.vector_size = sizeof (u32),
.format_trace = format_nat66_out2in_trace,
@@ -214,8 +211,6 @@ VLIB_REGISTER_NODE (nat66_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat66_out2in_node, nat66_out2in_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat_det_in2out.c b/src/plugins/nat/nat_det_in2out.c
index e4aa0463a06..918e1f5f9c0 100644
--- a/src/plugins/nat/nat_det_in2out.c
+++ b/src/plugins/nat/nat_det_in2out.c
@@ -63,8 +63,6 @@ static char *nat_det_in2out_error_strings[] = {
#undef _
};
-vlib_node_registration_t snat_det_in2out_node;
-
static u8 *
format_nat_det_in2out_trace (u8 * s, va_list * args)
{
@@ -78,6 +76,7 @@ format_nat_det_in2out_trace (u8 * s, va_list * args)
return s;
}
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
* and create session if needed
@@ -242,10 +241,11 @@ out:
*(snat_det_map_t **) e = dm0;
return next0;
}
+#endif
-static uword
-snat_det_in2out_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat_det_in2out_next_t next_index;
@@ -849,7 +849,7 @@ snat_det_in2out_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, snat_det_in2out_node.index,
+ vlib_node_increment_counter (vm, sm->det_in2out_node_index,
NAT_DET_IN2OUT_ERROR_IN2OUT_PACKETS,
pkts_processed);
return frame->n_vectors;
@@ -857,7 +857,6 @@ snat_det_in2out_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_det_in2out_node) = {
- .function = snat_det_in2out_node_fn,
.name = "nat44-det-in2out",
.vector_size = sizeof (u32),
.format_trace = format_nat_det_in2out_trace,
@@ -874,8 +873,6 @@ VLIB_REGISTER_NODE (snat_det_in2out_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_det_in2out_node, snat_det_in2out_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/nat_det_out2in.c b/src/plugins/nat/nat_det_out2in.c
index 9e8ba27285b..45fba18b248 100644
--- a/src/plugins/nat/nat_det_out2in.c
+++ b/src/plugins/nat/nat_det_out2in.c
@@ -62,8 +62,6 @@ static char *nat_det_out2in_error_strings[] = {
#undef _
};
-vlib_node_registration_t snat_det_out2in_node;
-
static u8 *
format_nat_det_out2in_trace (u8 * s, va_list * args)
{
@@ -78,6 +76,7 @@ format_nat_det_out2in_trace (u8 * s, va_list * args)
return s;
}
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
* and create session if needed
@@ -217,10 +216,11 @@ out:
*(snat_det_map_t **) e = dm0;
return next0;
}
+#endif
-static uword
-snat_det_out2in_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_det_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat_det_out2in_next_t next_index;
@@ -680,7 +680,7 @@ snat_det_out2in_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, snat_det_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->det_out2in_node_index,
NAT_DET_OUT2IN_ERROR_OUT2IN_PACKETS,
pkts_processed);
return frame->n_vectors;
@@ -688,7 +688,6 @@ snat_det_out2in_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_det_out2in_node) = {
- .function = snat_det_out2in_node_fn,
.name = "nat44-det-out2in",
.vector_size = sizeof (u32),
.format_trace = format_nat_det_out2in_trace,
@@ -706,8 +705,6 @@ VLIB_REGISTER_NODE (snat_det_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_det_out2in_node, snat_det_out2in_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/out2in.c b/src/plugins/nat/out2in.c
index c687a06f498..347d41a2d46 100755
--- a/src/plugins/nat/out2in.c
+++ b/src/plugins/nat/out2in.c
@@ -69,10 +69,6 @@ format_snat_out2in_fast_trace (u8 * s, va_list * args)
return s;
}
-vlib_node_registration_t snat_out2in_node;
-vlib_node_registration_t snat_out2in_fast_node;
-vlib_node_registration_t nat44_out2in_reass_node;
-
#define foreach_snat_out2in_error \
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(OUT2IN_PACKETS, "good out2in packets processed") \
@@ -114,6 +110,7 @@ typedef enum
SNAT_OUT2IN_N_NEXT,
} snat_out2in_next_t;
+#ifndef CLIB_MARCH_VARIANT
int
nat44_o2i_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
{
@@ -156,6 +153,7 @@ nat44_o2i_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
return 0;
}
+#endif
/**
* @brief Create session for static mapping.
@@ -297,6 +295,7 @@ static_always_inline
return -1; /* success */
}
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
* and create session if needed
@@ -425,7 +424,9 @@ out:
*(snat_session_t **) d = s0;
return next0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
/**
* Get address and port values to be used for ICMP packet translation
*
@@ -499,7 +500,9 @@ out2:
*p_dont_translate = dont_translate;
return next0;
}
+#endif
+#ifndef CLIB_MARCH_VARIANT
u32
icmp_out2in (snat_main_t * sm,
vlib_buffer_t * b0,
@@ -629,7 +632,7 @@ icmp_out2in (snat_main_t * sm,
out:
return next0;
}
-
+#endif
static inline u32
icmp_out2in_slow_path (snat_main_t * sm,
@@ -688,9 +691,9 @@ nat_out2in_sm_unknown_proto (snat_main_t * sm,
return 0;
}
-static uword
-snat_out2in_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
snat_out2in_next_t next_index;
@@ -1305,19 +1308,19 @@ snat_out2in_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
pkts_processed);
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_TCP_PACKETS, tcp_packets);
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_UDP_PACKETS, udp_packets);
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_ICMP_PACKETS, icmp_packets);
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_OTHER_PACKETS,
other_packets);
- vlib_node_increment_counter (vm, snat_out2in_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_node_index,
SNAT_OUT2IN_ERROR_FRAGMENTS, fragments);
return frame->n_vectors;
@@ -1325,7 +1328,6 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_out2in_node) = {
- .function = snat_out2in_node_fn,
.name = "nat44-out2in",
.vector_size = sizeof (u32),
.format_trace = format_snat_out2in_trace,
@@ -1348,11 +1350,9 @@ VLIB_REGISTER_NODE (snat_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_out2in_node, snat_out2in_node_fn);
-
-static uword
-nat44_out2in_reass_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_out2in_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
snat_out2in_next_t next_index;
@@ -1645,10 +1645,10 @@ nat44_out2in_reass_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat44_out2in_reass_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_reass_node_index,
SNAT_OUT2IN_ERROR_PROCESSED_FRAGMENTS,
pkts_processed);
- vlib_node_increment_counter (vm, nat44_out2in_reass_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_reass_node_index,
SNAT_OUT2IN_ERROR_CACHED_FRAGMENTS,
cached_fragments);
@@ -1663,7 +1663,6 @@ nat44_out2in_reass_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_out2in_reass_node) = {
- .function = nat44_out2in_reass_node_fn,
.name = "nat44-out2in-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
@@ -1684,12 +1683,9 @@ VLIB_REGISTER_NODE (nat44_out2in_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_out2in_reass_node,
- nat44_out2in_reass_node_fn);
-
-static uword
-snat_out2in_fast_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (snat_out2in_fast_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
snat_out2in_next_t next_index;
@@ -1847,7 +1843,7 @@ snat_out2in_fast_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, snat_out2in_fast_node.index,
+ vlib_node_increment_counter (vm, sm->out2in_fast_node_index,
SNAT_OUT2IN_ERROR_OUT2IN_PACKETS,
pkts_processed);
return frame->n_vectors;
@@ -1855,7 +1851,6 @@ snat_out2in_fast_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (snat_out2in_fast_node) = {
- .function = snat_out2in_fast_node_fn,
.name = "nat44-out2in-fast",
.vector_size = sizeof (u32),
.format_trace = format_snat_out2in_fast_trace,
@@ -1878,9 +1873,6 @@ VLIB_REGISTER_NODE (snat_out2in_fast_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (snat_out2in_fast_node,
- snat_out2in_fast_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/nat/out2in_ed.c b/src/plugins/nat/out2in_ed.c
index c53d6d0066c..88b248fdbcf 100644
--- a/src/plugins/nat/out2in_ed.c
+++ b/src/plugins/nat/out2in_ed.c
@@ -83,10 +83,6 @@ typedef struct
u32 is_slow_path;
} nat44_ed_out2in_trace_t;
-vlib_node_registration_t nat44_ed_out2in_node;
-vlib_node_registration_t nat44_ed_out2in_slowpath_node;
-vlib_node_registration_t nat44_ed_out2in_reass_node;
-
static u8 *
format_nat44_ed_out2in_trace (u8 * s, va_list * args)
{
@@ -127,6 +123,7 @@ icmp_out2in_ed_slow_path (snat_main_t * sm, vlib_buffer_t * b0,
return next0;
}
+#ifndef CLIB_MARCH_VARIANT
int
nat44_o2i_ed_is_idle_session_cb (clib_bihash_kv_16_8_t * kv, void *arg)
{
@@ -218,6 +215,7 @@ nat44_o2i_ed_is_idle_session_cb (clib_bihash_kv_16_8_t * kv, void *arg)
return 0;
}
+#endif
static snat_session_t *
create_session_for_static_mapping_ed (snat_main_t * sm,
@@ -490,6 +488,7 @@ create_bypass_for_fwd (snat_main_t * sm, ip4_header_t * ip, u32 rx_fib_index,
nat44_session_update_lru (sm, s, thread_index);
}
+#ifndef CLIB_MARCH_VARIANT
u32
icmp_match_out2in_ed (snat_main_t * sm, vlib_node_runtime_t * node,
u32 thread_index, vlib_buffer_t * b, ip4_header_t * ip,
@@ -605,6 +604,7 @@ out:
*(snat_session_t **) d = s;
return next;
}
+#endif
static snat_session_t *
nat44_ed_out2in_unknown_proto (snat_main_t * sm,
@@ -724,8 +724,8 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm,
u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
0, fragments = 0;
- stats_node_index = is_slow_path ? nat44_ed_out2in_slowpath_node.index :
- nat44_ed_out2in_node.index;
+ stats_node_index = is_slow_path ? sm->ed_out2in_slowpath_node_index :
+ sm->ed_out2in_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1545,17 +1545,15 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm,
return frame->n_vectors;
}
-static uword
-nat44_ed_out2in_fast_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_out2in_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_out2in_node_fn_inline (vm, node, frame, 0);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_out2in_node) = {
- .function = nat44_ed_out2in_fast_path_fn,
.name = "nat44-ed-out2in",
.vector_size = sizeof (u32),
.format_trace = format_nat44_ed_out2in_trace,
@@ -1575,20 +1573,15 @@ VLIB_REGISTER_NODE (nat44_ed_out2in_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_out2in_node,
- nat44_ed_out2in_fast_path_fn);
-
-static uword
-nat44_ed_out2in_slow_path_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_out2in_slowpath_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
return nat44_ed_out2in_node_fn_inline (vm, node, frame, 1);
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node) = {
- .function = nat44_ed_out2in_slow_path_fn,
.name = "nat44-ed-out2in-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_nat44_ed_out2in_trace,
@@ -1608,13 +1601,9 @@ VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_out2in_slowpath_node,
- nat44_ed_out2in_slow_path_fn);
-
-static uword
-nat44_ed_out2in_reass_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+VLIB_NODE_FN (nat44_ed_out2in_reass_node) (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame)
{
u32 n_left_from, *from, *to_next;
nat44_ed_out2in_next_t next_index;
@@ -1951,7 +1940,7 @@ nat44_ed_out2in_reass_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, nat44_ed_out2in_reass_node.index,
+ vlib_node_increment_counter (vm, sm->ed_out2in_reass_node_index,
NAT_OUT2IN_ED_ERROR_OUT2IN_PACKETS,
pkts_processed);
@@ -1966,7 +1955,6 @@ nat44_ed_out2in_reass_node_fn (vlib_main_t * vm,
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (nat44_ed_out2in_reass_node) = {
- .function = nat44_ed_out2in_reass_node_fn,
.name = "nat44-ed-out2in-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
@@ -1985,9 +1973,6 @@ VLIB_REGISTER_NODE (nat44_ed_out2in_reass_node) = {
};
/* *INDENT-ON* */
-VLIB_NODE_FUNCTION_MULTIARCH (nat44_ed_out2in_reass_node,
- nat44_ed_out2in_reass_node_fn);
-
/*
* fd.io coding-style-patch-verification: ON
*