aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-11-09 18:29:03 -0800
committerOle Tr�an <otroan@employees.org>2022-02-03 20:38:18 +0000
commitf840880c2fd8fbd6acfa79948224aafe6e4a62d1 (patch)
tree6ffe2362c468c4eace54767f86889d4e70a64b6e /src/plugins
parent7285be2aabf4ba9915a23085e63efb896c5a8896 (diff)
ip nat: use ip rx sw_if_index in ip-local arc start
This also changes the behavior of the nat44-ei hairpinning feature. Rather then enabling the feature on every nat interface, it is enabled only on local0. Type: improvement Signed-off-by: Filip Varga <fivarga@cisco.com> Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I4e16a83c9e328aa75fc61df508b620ef743ca775
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/nat/nat44-ei/nat44_ei.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/plugins/nat/nat44-ei/nat44_ei.c b/src/plugins/nat/nat44-ei/nat44_ei.c
index 10b04ce6d71..7692816a2ee 100644
--- a/src/plugins/nat/nat44-ei/nat44_ei.c
+++ b/src/plugins/nat/nat44-ei/nat44_ei.c
@@ -576,10 +576,34 @@ nat44_ei_get_interface (nat44_ei_interface_t *interfaces, u32 sw_if_index)
}
static_always_inline int
-nat44_ei_hairpinning_enable (u32 sw_if_index, u8 is_enable)
+nat44_ei_hairpinning_enable (u8 is_enable)
{
- return vnet_feature_enable_disable ("ip4-local", "nat44-ei-hairpinning",
- sw_if_index, is_enable, 0, 0);
+ nat44_ei_main_t *nm = &nat44_ei_main;
+ u32 sw_if_index = 0; // local0
+
+ if (is_enable)
+ {
+ nm->hairpin_reg += 1;
+ if (1 == nm->hairpin_reg)
+ {
+ return vnet_feature_enable_disable (
+ "ip4-local", "nat44-ei-hairpinning", sw_if_index, is_enable, 0, 0);
+ }
+ }
+ else
+ {
+ if (0 == nm->hairpin_reg)
+ return 1;
+
+ nm->hairpin_reg -= 1;
+ if (0 == nm->hairpin_reg)
+ {
+ return vnet_feature_enable_disable (
+ "ip4-local", "nat44-ei-hairpinning", sw_if_index, is_enable, 0, 0);
+ }
+ }
+
+ return 0;
}
int
@@ -648,7 +672,7 @@ nat44_ei_add_interface (u32 sw_if_index, u8 is_inside)
}
if (!is_inside)
{
- rv = nat44_ei_hairpinning_enable (sw_if_index, 0);
+ rv = nat44_ei_hairpinning_enable (0);
if (rv)
{
return rv;
@@ -681,7 +705,7 @@ nat44_ei_add_interface (u32 sw_if_index, u8 is_inside)
}
if (is_inside && !nm->out2in_dpo)
{
- rv = nat44_ei_hairpinning_enable (sw_if_index, 1);
+ rv = nat44_ei_hairpinning_enable (1);
if (rv)
{
return rv;
@@ -786,7 +810,7 @@ nat44_ei_del_interface (u32 sw_if_index, u8 is_inside)
}
else
{
- rv = nat44_ei_hairpinning_enable (sw_if_index, 1);
+ rv = nat44_ei_hairpinning_enable (1);
if (rv)
{
return rv;
@@ -819,7 +843,7 @@ nat44_ei_del_interface (u32 sw_if_index, u8 is_inside)
}
if (is_inside)
{
- rv = nat44_ei_hairpinning_enable (sw_if_index, 0);
+ rv = nat44_ei_hairpinning_enable (0);
if (rv)
{
return rv;