aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cnat/cnat_node_feature.c
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-02-25 17:39:03 +0100
committerDave Barach <openvpp@barachs.net>2021-03-04 12:35:15 +0000
commit3fd77f7dea1ac91c5b4c9ede69b992a4e2243153 (patch)
tree21550f5d6e28f55f4e64ee1ddb7697c9e261dd85 /src/plugins/cnat/cnat_node_feature.c
parent8786a4cd4a62f2817da7060afd8523857f504912 (diff)
cnat: Prepare extended snat policies
Type: refactor Change-Id: I9ca3333274d6f32b6aff57f0fb3d2049c066337a Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/plugins/cnat/cnat_node_feature.c')
-rw-r--r--src/plugins/cnat/cnat_node_feature.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/plugins/cnat/cnat_node_feature.c b/src/plugins/cnat/cnat_node_feature.c
index c99160cb33e..4585fcb5dd6 100644
--- a/src/plugins/cnat/cnat_node_feature.c
+++ b/src/plugins/cnat/cnat_node_feature.c
@@ -18,7 +18,7 @@
#include <cnat/cnat_translation.h>
#include <cnat/cnat_inline.h>
#include <cnat/cnat_src_policy.h>
-#include <cnat/cnat_snat.h>
+#include <cnat/cnat_snat_policy.h>
#include <vnet/dpo/load_balance.h>
#include <vnet/dpo/load_balance_map.h>
@@ -217,10 +217,8 @@ VLIB_REGISTER_NODE (cnat_input_feature_ip6_node) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = CNAT_N_ERROR,
.error_strings = cnat_error_strings,
- .n_next_nodes = CNAT_FEATURE_N_NEXT,
- .next_nodes = {
- [CNAT_FEATURE_NEXT_DROP] = "error-drop",
- },
+ .n_next_nodes = IP6_LOOKUP_N_NEXT,
+ .next_nodes = IP6_LOOKUP_NEXT_NODES,
};
VNET_FEATURE_INIT (cnat_in_ip6_feature, static) = {
@@ -236,8 +234,7 @@ cnat_output_feature_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
vlib_buffer_t *b, cnat_node_ctx_t *ctx,
int session_not_found, cnat_session_t *session)
{
- cnat_main_t *cm = &cnat_main;
- cnat_snat_policy_main_t *cms = &cnat_snat_policy_main;
+ cnat_snat_policy_main_t *cpm = &cnat_snat_policy_main;
ip4_header_t *ip4 = NULL;
ip_protocol_t iproto;
ip6_header_t *ip6 = NULL;
@@ -275,32 +272,31 @@ cnat_output_feature_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
/* session table hit */
cnat_timestamp_update (session->value.cs_ts_index, ctx->now);
}
- else if (!cms->snat_policy)
+ else if (!cpm->snat_policy)
goto trace;
else
{
- /* TODO: handle errors? */
- cms->snat_policy (vm, b, session, ctx, &do_snat);
+ do_snat = cpm->snat_policy (b, session);
if (do_snat != 1)
goto trace;
if (AF_IP4 == ctx->af)
{
- if (ip_address_is_zero (&cm->snat_ip4.ce_ip))
+ if (ip_address_is_zero (&cpm->snat_ip4.ce_ip))
goto trace;
ip46_address_set_ip4 (&session->value.cs_ip[VLIB_RX],
- &ip_addr_v4 (&cm->snat_ip4.ce_ip));
+ &ip_addr_v4 (&cpm->snat_ip4.ce_ip));
ip46_address_set_ip4 (&session->value.cs_ip[VLIB_TX],
&ip4->dst_address);
}
else
{
- if (ip_address_is_zero (&cm->snat_ip6.ce_ip))
+ if (ip_address_is_zero (&cpm->snat_ip6.ce_ip))
goto trace;
ip46_address_set_ip6 (&session->value.cs_ip[VLIB_RX],
- &ip_addr_v6 (&cm->snat_ip6.ce_ip));
+ &ip_addr_v6 (&cpm->snat_ip6.ce_ip));
ip46_address_set_ip6 (&session->value.cs_ip[VLIB_TX],
&ip6->dst_address);
}