aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/l2tp/l2tp.c
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-06-22 12:54:48 +0100
committerChris Luke <chris_luke@comcast.com>2016-06-24 12:55:22 +0000
commit80ee21386cea217d0e9292d2a8b15ea88bf99d30 (patch)
tree69938e625f969b7d9c8352cdceb7430fa6ac2367 /vnet/vnet/l2tp/l2tp.c
parentde393bb76d8c221e1145f62070f51a9ca4191f9f (diff)
Add admin-up flag to L2TP tunnels and start tunnels set to down
L2TP tunnels use virtual interfaces but directly send packets to l2-input node (not ethernet-input). This node requires a bridge-domain to be associated with the interface. Past code was immediatly turning the interface up, but some packets could be sent to l2-input without bridge domain between interface creation and association with a bridge domain. The tunnel is now created as down and has to be set up later (typically after being associated with a bridge-domain). Another option would have been to change the api and enforce a bridge-domain to be specified before the tunnel, but this is less flexible for the user. Change-Id: I26d1f36bb4f327d9fa1c8044023f2210c4117904 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'vnet/vnet/l2tp/l2tp.c')
-rw-r--r--vnet/vnet/l2tp/l2tp.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/vnet/vnet/l2tp/l2tp.c b/vnet/vnet/l2tp/l2tp.c
index 4380137704b..85f9c30ed11 100644
--- a/vnet/vnet/l2tp/l2tp.c
+++ b/vnet/vnet/l2tp/l2tp.c
@@ -345,6 +345,7 @@ int create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
s->l2tp_hdr_size = l2_sublayer_present ?
sizeof (l2tpv3_header_t) :
sizeof (l2tpv3_header_t) - sizeof(l2tp_hdr.l2_specific_sublayer);
+ s->admin_up = 0;
/* Setup hash table entries */
switch (lm->lookup_type) {
@@ -402,9 +403,6 @@ int create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
if (sw_if_index)
*sw_if_index = hi->sw_if_index;
- vnet_sw_interface_set_flags (vnm, hi->sw_if_index,
- VNET_SW_INTERFACE_FLAG_ADMIN_UP);
-
return 0;
}
@@ -665,6 +663,25 @@ l2tp_config (vlib_main_t * vm, unformat_input_t * input)
VLIB_CONFIG_FUNCTION (l2tp_config, "l2tp");
+
+clib_error_t *
+l2tp_sw_interface_up_down (vnet_main_t * vnm,
+ u32 sw_if_index,
+ u32 flags)
+{
+ l2t_main_t *lm = &l2t_main;
+ vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ if (hi->hw_class_index != l2tpv3_hw_class.index)
+ return 0;
+
+ u32 session_index = hi->dev_instance;
+ l2t_session_t *s = pool_elt_at_index (lm->sessions, session_index);
+ s->admin_up = !! (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP);
+ return 0;
+}
+
+VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (l2tp_sw_interface_up_down);
+
clib_error_t *l2tp_init (vlib_main_t *vm)
{
l2t_main_t *lm = &l2t_main;