diff options
author | Matus Fabian <matfabia@cisco.com> | 2017-07-21 03:46:03 -0700 |
---|---|---|
committer | Matus Fabian <matfabia@cisco.com> | 2017-07-21 03:46:47 -0700 |
commit | 161c59c75c667ce7a3c1d6173723831dc30e994c (patch) | |
tree | 8e7ed4f26a2e9120fde75401f3d738b546a037fe /src/plugins/snat/snat.c | |
parent | faee17e8b866fe16ce706af31d1e9cbc6d06b961 (diff) |
SNAT: in2out translation as an output feature hairpinning (VPP-913)
Change-Id: I3790739683c6090ffb2aefb4758bd4275856c09a
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/snat/snat.c')
-rw-r--r-- | src/plugins/snat/snat.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index bce7d210767..1820aef8829 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -72,6 +72,11 @@ VNET_FEATURE_INIT (ip4_snat_out2in_fast, static) = { .node_name = "snat-out2in-fast", .runs_before = VNET_FEATURES ("ip4-lookup"), }; +VNET_FEATURE_INIT (ip4_snat_hairpin_dst, static) = { + .arc_name = "ip4-unicast", + .node_name = "snat-hairpin-dst", + .runs_before = VNET_FEATURES ("ip4-lookup"), +}; /* Hook up output features */ VNET_FEATURE_INIT (ip4_snat_in2out_output, static) = { @@ -79,12 +84,16 @@ VNET_FEATURE_INIT (ip4_snat_in2out_output, static) = { .node_name = "snat-in2out-output", .runs_before = VNET_FEATURES ("interface-output"), }; - VNET_FEATURE_INIT (ip4_snat_in2out_output_worker_handoff, static) = { .arc_name = "ip4-output", .node_name = "snat-in2out-output-worker-handoff", .runs_before = VNET_FEATURES ("interface-output"), }; +VNET_FEATURE_INIT (ip4_snat_hairpin_src, static) = { + .arc_name = "ip4-output", + .node_name = "snat-hairpin-src", + .runs_before = VNET_FEATURES ("interface-output"), +}; /* *INDENT-OFF* */ @@ -798,7 +807,13 @@ int snat_interface_add_del_output_feature (u32 sw_if_index, return VNET_API_ERROR_UNSUPPORTED; if (is_inside) - goto find; + { + vnet_feature_enable_disable ("ip4-unicast", "snat-hairpin-dst", + sw_if_index, !is_del, 0, 0); + vnet_feature_enable_disable ("ip4-output", "snat-hairpin-src", + sw_if_index, !is_del, 0, 0); + goto fq; + } if (sm->num_workers > 1) { @@ -816,6 +831,7 @@ int snat_interface_add_del_output_feature (u32 sw_if_index, sw_if_index, !is_del, 0, 0); } +fq: if (sm->fq_in2out_output_index == ~0 && sm->num_workers > 1) sm->fq_in2out_output_index = vlib_frame_queue_main_init (sm->in2out_output_node_index, 0); @@ -823,7 +839,6 @@ int snat_interface_add_del_output_feature (u32 sw_if_index, if (sm->fq_out2in_index == ~0 && sm->num_workers > 1) sm->fq_out2in_index = vlib_frame_queue_main_init (sm->out2in_node_index, 0); -find: pool_foreach (i, sm->output_feature_interfaces, ({ if (i->sw_if_index == sw_if_index) |