summaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-04-01 09:45:23 +0000
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2020-05-05 18:36:33 +0000
commitabc5660c61698fa29252dc202358002a97f2608c (patch)
tree969edc7dc2145e40e3fb96c470df917f2053abfe /src/vnet/ipsec/ipsec.c
parent6fdd7a5f77301a3398c4445bfef202b123ce90d8 (diff)
ipsec: User can choose the UDP source port
Type: feature thus allowing NAT traversal, Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Ie8650ceeb5074f98c68d2d90f6adc2f18afeba08 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec.c')
-rw-r--r--src/vnet/ipsec/ipsec.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/vnet/ipsec/ipsec.c b/src/vnet/ipsec/ipsec.c
index 95e322e87a6..0ef90673596 100644
--- a/src/vnet/ipsec/ipsec.c
+++ b/src/vnet/ipsec/ipsec.c
@@ -124,6 +124,61 @@ ipsec_add_node (vlib_main_t * vm, const char *node_name,
*out_next_index = vlib_node_add_next (vm, prev_node->index, node->index);
}
+void
+ipsec_add_feature (const char *arc_name,
+ const char *node_name, u32 * out_feature_index)
+{
+ u8 arc;
+
+ arc = vnet_get_feature_arc_index (arc_name);
+ ASSERT (arc != (u8) ~ 0);
+ *out_feature_index = vnet_get_feature_index (arc, node_name);
+}
+
+void
+ipsec_unregister_udp_port (u16 port)
+{
+ ipsec_main_t *im = &ipsec_main;
+ u32 n_regs;
+ uword *p;
+
+ p = hash_get (im->udp_port_registrations, port);
+
+ ASSERT (p);
+
+ n_regs = p[0];
+
+ if (0 == --n_regs)
+ {
+ udp_unregister_dst_port (vlib_get_main (), port, 1);
+ hash_unset (im->udp_port_registrations, port);
+ }
+ else
+ {
+ hash_unset (im->udp_port_registrations, port);
+ hash_set (im->udp_port_registrations, port, n_regs);
+ }
+}
+
+void
+ipsec_register_udp_port (u16 port)
+{
+ ipsec_main_t *im = &ipsec_main;
+ u32 n_regs;
+ uword *p;
+
+ p = hash_get (im->udp_port_registrations, port);
+
+ n_regs = (p ? p[0] : 0);
+
+ if (0 == n_regs++)
+ udp_register_dst_port (vlib_get_main (), port,
+ ipsec4_tun_input_node.index, 1);
+
+ hash_unset (im->udp_port_registrations, port);
+ hash_set (im->udp_port_registrations, port, n_regs);
+}
+
u32
ipsec_register_ah_backend (vlib_main_t * vm, ipsec_main_t * im,
const char *name,