aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_if.c
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2018-12-10 11:19:08 +0100
committerNeale Ranns <nranns@cisco.com>2018-12-11 12:42:09 +0000
commit4c422f9a3c9d5a4ecae3f4ef6bee16bb8ce35bb2 (patch)
tree4e144869c29d93d2df240058a4b871f60c96b654 /src/vnet/ipsec/ipsec_if.c
parent240f69aed757720cfb78a140aaa84eb31db198f4 (diff)
Add IPSec interface FIB index for TX packet
This patch adds a configuration parameter to IPSec tunnels, enabling custom FIB selection for encapsulated packets. Although this option could also be used for policy-based IPSec, this change only enables it for virtual-tunnel-interface mode. Note that this patch does change the API default behavior regarding TX fib selection for encapsulated packets. Previous behavior was to use the same FIB after and before encap. The new default behavior consists in using the FIB 0 as default. Change-Id: I5c212af909940a8cf6c7e3971bdc7623a2296452 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec_if.c')
-rw-r--r--src/vnet/ipsec/ipsec_if.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vnet/ipsec/ipsec_if.c b/src/vnet/ipsec/ipsec_if.c
index 2e0dae0a35d..3054af16765 100644
--- a/src/vnet/ipsec/ipsec_if.c
+++ b/src/vnet/ipsec/ipsec_if.c
@@ -18,6 +18,7 @@
#include <vnet/vnet.h>
#include <vnet/api_errno.h>
#include <vnet/ip/ip.h>
+#include <vnet/fib/fib.h>
#include <vnet/ipsec/ipsec.h>
#include <vnet/ipsec/esp.h>
@@ -262,6 +263,7 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
ipsec_sa_t *sa;
u32 dev_instance;
u32 slot;
+ u32 tx_fib_index = ~0;
u64 key = (u64) args->remote_ip.as_u32 << 32 | (u64) args->remote_spi;
p = hash_get (im->ipsec_if_pool_index_by_key, key);
@@ -272,6 +274,10 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
if (p)
return VNET_API_ERROR_INVALID_VALUE;
+ tx_fib_index = fib_table_find (FIB_PROTOCOL_IP4, args->tx_table_id);
+ if (tx_fib_index == ~((u32) 0))
+ return VNET_API_ERROR_NO_SUCH_FIB;
+
pool_get_aligned (im->tunnel_interfaces, t, CLIB_CACHE_LINE_BYTES);
clib_memset (t, 0, sizeof (*t));
@@ -301,6 +307,7 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
sa->use_anti_replay = args->anti_replay;
sa->integ_alg = args->integ_alg;
sa->udp_encap = args->udp_encap;
+ sa->tx_fib_index = ~((u32) 0); /* Not used, but set for troubleshooting */
if (args->remote_integ_key_len <= sizeof (args->remote_integ_key))
{
sa->integ_key_len = args->remote_integ_key_len;
@@ -326,6 +333,7 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
sa->use_anti_replay = args->anti_replay;
sa->integ_alg = args->integ_alg;
sa->udp_encap = args->udp_encap;
+ sa->tx_fib_index = tx_fib_index;
if (args->local_integ_key_len <= sizeof (args->local_integ_key))
{
sa->integ_key_len = args->local_integ_key_len;