summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/l2tp/l2tp.c
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-07-15 09:19:39 +0100
committerChris Luke <chris_luke@comcast.com>2016-07-20 11:48:13 +0000
commit08e0312fe2ecb10e10acf334c71440df7be95cac (patch)
tree121f3aff1bfd7e5474fefd1226cbfbabd2ded6e4 /vnet/vnet/l2tp/l2tp.c
parent8c4072696d2805fc8d9d2f76d8955f710d192bdd (diff)
L2TP: Add option for custom fib id for outgoing encapsulated packets
If a custom fib ID is used (different from ~0), the associated fib is used to forward outgoing encapsulated packets. Otherwise, the fib used is the same as for any packet received on the original RX interface (L2TP does not modify RX interface index). Change-Id: I4533d5f7fa432c78c937d3acdd802d0d1c92a0c7 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'vnet/vnet/l2tp/l2tp.c')
-rw-r--r--vnet/vnet/l2tp/l2tp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/vnet/vnet/l2tp/l2tp.c b/vnet/vnet/l2tp/l2tp.c
index 85f9c30ed11..ebf317fe6db 100644
--- a/vnet/vnet/l2tp/l2tp.c
+++ b/vnet/vnet/l2tp/l2tp.c
@@ -296,7 +296,8 @@ int create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
u32 remote_session_id,
u64 local_cookie,
u64 remote_cookie,
- int l2_sublayer_present,
+ int l2_sublayer_present,
+ u32 encap_fib_index,
u32 * sw_if_index)
{
l2t_session_t *s = 0;
@@ -346,6 +347,7 @@ int create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
sizeof (l2tpv3_header_t) :
sizeof (l2tpv3_header_t) - sizeof(l2tp_hdr.l2_specific_sublayer);
s->admin_up = 0;
+ s->encap_fib_index = encap_fib_index;
/* Setup hash table entries */
switch (lm->lookup_type) {
@@ -420,6 +422,8 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
int l2_sublayer_present = 0;
int rv;
u32 sw_if_index;
+ u32 encap_fib_id = ~0;
+ u32 encap_fib_index = ~0;
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
@@ -442,6 +446,9 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "remote-session-id %d",
&remote_session_id))
;
+ else if (unformat (line_input, "fib-id %d",
+ &encap_fib_id))
+ ;
else if (unformat (line_input, "l2-sublayer-present"))
l2_sublayer_present = 1;
else
@@ -451,6 +458,16 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
unformat_free (line_input);
+ if (encap_fib_id != ~0) {
+ uword *p;
+ ip6_main_t *im = &ip6_main;
+ if (!(p = hash_get (im->fib_index_by_table_id, encap_fib_id)))
+ return clib_error_return (0, "No fib with id %d", encap_fib_id);
+ encap_fib_index = p[0];
+ } else {
+ encap_fib_index = ~0;
+ }
+
if (our_address_set == 0)
return clib_error_return (0, "our address not specified");
if (client_address_set == 0)
@@ -460,6 +477,7 @@ create_l2tpv3_tunnel_command_fn (vlib_main_t * vm,
local_session_id, remote_session_id,
local_cookie, remote_cookie,
l2_sublayer_present,
+ encap_fib_index,
&sw_if_index);
switch(rv)
{