summaryrefslogtreecommitdiffstats
path: root/src/vnet/mpls
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-05-24 09:15:43 -0700
committerFlorin Coras <florin.coras@gmail.com>2017-08-08 17:25:00 +0000
commitda78f957e46c686434149d332a477d7ea055d76a (patch)
tree4499475fa0904c4b7660dd29576857def77a29ba /src/vnet/mpls
parentb60f4965bf6f51eb746e18fa0307af8e3444bf96 (diff)
L2 over MPLS
[support for VPWS/VPLS] - switch to using dpo_proto_t rather than fib_protocol_t in fib_paths so that we can describe L2 paths - VLIB nodes to handle pop/push of MPLS labels to L2 Change-Id: Id050d06a11fd2c9c1c81ce5a0654e6c5ae6afa6e Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/mpls')
-rw-r--r--src/vnet/mpls/mpls.api4
-rw-r--r--src/vnet/mpls/mpls.c36
-rw-r--r--src/vnet/mpls/mpls_api.c21
-rw-r--r--src/vnet/mpls/mpls_tunnel.c75
-rw-r--r--src/vnet/mpls/mpls_tunnel.h38
5 files changed, 94 insertions, 80 deletions
diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api
index 67f1045d57a..5973a0a6cbd 100644
--- a/src/vnet/mpls/mpls.api
+++ b/src/vnet/mpls/mpls.api
@@ -156,7 +156,7 @@ manual_endian manual_print define mpls_tunnel_details
@param mr_is_interface_rx - Interface Receive path
@param mr_is_interface_rx - RPF-ID Receive path. The next-hop interface
is used as the RPF-ID
- @param mr_next_hop_proto_is_ip4 - The next-hop is IPV4
+ @param mr_next_hop_proto - The next-hop protocol, of type dpo_proto_t
@param mr_next_hop_weight - The weight, for UCMP
@param mr_next_hop[16] - the nextop address
@param mr_next_hop_sw_if_index - the next-hop SW interface
@@ -182,7 +182,7 @@ autoreply define mpls_route_add_del
u8 mr_is_resolve_attached;
u8 mr_is_interface_rx;
u8 mr_is_rpf_id;
- u8 mr_next_hop_proto_is_ip4;
+ u8 mr_next_hop_proto;
u8 mr_next_hop_weight;
u8 mr_next_hop_preference;
u8 mr_next_hop[16];
diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c
index 068d31f4c8e..266ba42c94f 100644
--- a/src/vnet/mpls/mpls.c
+++ b/src/vnet/mpls/mpls.c
@@ -261,7 +261,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
&rpath.frp_sw_if_index,
&rpath.frp_weight))
{
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
vec_add1(rpaths, rpath);
}
@@ -272,7 +272,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
&rpath.frp_sw_if_index,
&rpath.frp_weight))
{
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
vec_add1(rpaths, rpath);
}
@@ -283,7 +283,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
&rpath.frp_sw_if_index))
{
rpath.frp_weight = 1;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "rx-ip4 %U",
@@ -291,7 +291,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
&rpath.frp_sw_if_index))
{
rpath.frp_weight = 1;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
rpath.frp_flags = FIB_ROUTE_PATH_INTF_RX;
vec_add1(rpaths, rpath);
}
@@ -302,7 +302,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
&rpath.frp_sw_if_index))
{
rpath.frp_weight = 1;
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "via %U next-hop-table %d",
@@ -312,7 +312,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
{
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "via %U next-hop-table %d",
@@ -322,7 +322,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
{
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "via %U",
@@ -336,7 +336,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
rpath.frp_fib_index = table_id;
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "via %U",
@@ -346,7 +346,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
rpath.frp_fib_index = table_id;
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "%d", &local_label))
@@ -355,7 +355,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
"ip4-lookup-in-table %d",
&rpath.frp_fib_index))
{
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
rpath.frp_sw_if_index = FIB_NODE_INDEX_INVALID;
pfx.fp_payload_proto = DPO_PROTO_IP4;
vec_add1(rpaths, rpath);
@@ -364,7 +364,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
"ip6-lookup-in-table %d",
&rpath.frp_fib_index))
{
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
rpath.frp_sw_if_index = FIB_NODE_INDEX_INVALID;
vec_add1(rpaths, rpath);
pfx.fp_payload_proto = DPO_PROTO_IP6;
@@ -373,11 +373,21 @@ vnet_mpls_local_label (vlib_main_t * vm,
"mpls-lookup-in-table %d",
&rpath.frp_fib_index))
{
- rpath.frp_proto = FIB_PROTOCOL_MPLS;
+ rpath.frp_proto = DPO_PROTO_MPLS;
rpath.frp_sw_if_index = FIB_NODE_INDEX_INVALID;
pfx.fp_payload_proto = DPO_PROTO_MPLS;
vec_add1(rpaths, rpath);
}
+ else if (unformat (line_input,
+ "l2-input-on %U",
+ unformat_vnet_sw_interface, vnm,
+ &rpath.frp_sw_if_index))
+ {
+ rpath.frp_proto = DPO_PROTO_ETHERNET;
+ pfx.fp_payload_proto = DPO_PROTO_ETHERNET;
+ rpath.frp_flags = FIB_ROUTE_PATH_INTF_RX;
+ vec_add1(rpaths, rpath);
+ }
else if (unformat (line_input, "out-label %U",
unformat_mpls_unicast_label,
&out_label))
@@ -440,7 +450,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
pfx.fp_proto = FIB_PROTOCOL_MPLS;
pfx.fp_len = 21;
pfx.fp_label = local_label;
- pfx.fp_payload_proto = fib_proto_to_dpo(rpaths[0].frp_proto);
+ pfx.fp_payload_proto = rpaths[0].frp_proto;
/*
* the CLI parsing stored table Ids, swap to FIB indicies
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index 92fb24a6e88..737299e6a2b 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -144,14 +144,7 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
};
if (pfx.fp_eos)
{
- if (mp->mr_next_hop_proto_is_ip4)
- {
- pfx.fp_payload_proto = DPO_PROTO_IP4;
- }
- else
- {
- pfx.fp_payload_proto = DPO_PROTO_IP6;
- }
+ pfx.fp_payload_proto = mp->mr_next_hop_proto;
}
else
{
@@ -161,7 +154,7 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
rv = add_del_route_check (FIB_PROTOCOL_MPLS,
mp->mr_table_id,
mp->mr_next_hop_sw_if_index,
- dpo_proto_to_fib (pfx.fp_payload_proto),
+ pfx.fp_payload_proto,
mp->mr_next_hop_table_id,
mp->mr_create_table_if_needed,
mp->mr_is_rpf_id,
@@ -173,9 +166,9 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
ip46_address_t nh;
memset (&nh, 0, sizeof (nh));
- if (mp->mr_next_hop_proto_is_ip4)
+ if (DPO_PROTO_IP4 == mp->mr_next_hop_proto)
memcpy (&nh.ip4, mp->mr_next_hop, sizeof (nh.ip4));
- else
+ else if (DPO_PROTO_IP6 == mp->mr_next_hop_proto)
memcpy (&nh.ip6, mp->mr_next_hop, sizeof (nh.ip6));
n_labels = mp->mr_next_hop_n_out_labels;
@@ -202,7 +195,7 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
mp->mr_is_interface_rx,
mp->mr_is_rpf_id,
fib_index, &pfx,
- mp->mr_next_hop_proto_is_ip4,
+ mp->mr_next_hop_proto,
&nh, ntohl (mp->mr_next_hop_sw_if_index),
next_hop_fib_index,
mp->mr_next_hop_weight,
@@ -243,13 +236,13 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
if (mp->mt_next_hop_proto_is_ip4)
{
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
clib_memcpy (&rpath.frp_addr.ip4,
mp->mt_next_hop, sizeof (rpath.frp_addr.ip4));
}
else
{
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
clib_memcpy (&rpath.frp_addr.ip6,
mp->mt_next_hop, sizeof (rpath.frp_addr.ip6));
}
diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c
index c025cc58033..6452a60bfe2 100644
--- a/src/vnet/mpls/mpls_tunnel.c
+++ b/src/vnet/mpls/mpls_tunnel.c
@@ -171,7 +171,7 @@ mpls_tunnel_mk_lb (mpls_tunnel_t *mt,
vec_validate(ctx.next_hops, fib_path_list_get_n_paths(mt->mt_path_list));
vec_reset_length(ctx.next_hops);
- lb_proto = vnet_link_to_dpo_proto(linkt);
+ lb_proto = fib_forw_chain_type_to_dpo_proto(fct);
fib_path_list_walk(mt->mt_path_list,
mpls_tunnel_collect_forwarding,
@@ -313,12 +313,34 @@ mpls_tunnel_restack (mpls_tunnel_t *mt)
/*
* walk all the adjacencies on the MPLS interface and restack them
*/
- FOR_EACH_FIB_PROTOCOL(proto)
+ if (mt->mt_flags & MPLS_TUNNEL_FLAG_L2)
{
- adj_nbr_walk(mt->mt_sw_if_index,
- proto,
- mpls_adj_walk_cb,
- NULL);
+ /*
+ * Stack a load-balance that drops, whilst we have no paths
+ */
+ vnet_hw_interface_t * hi;
+ dpo_id_t dpo = DPO_INVALID;
+
+ mpls_tunnel_mk_lb(mt,
+ VNET_LINK_MPLS,
+ FIB_FORW_CHAIN_TYPE_ETHERNET,
+ &dpo);
+
+ hi = vnet_get_hw_interface(vnet_get_main(), mt->mt_hw_if_index);
+ dpo_stack_from_node(hi->tx_node_index,
+ &mt->mt_l2_lb,
+ &dpo);
+ dpo_reset(&dpo);
+ }
+ else
+ {
+ FOR_EACH_FIB_PROTOCOL(proto)
+ {
+ adj_nbr_walk(mt->mt_sw_if_index,
+ proto,
+ mpls_adj_walk_cb,
+ NULL);
+ }
}
}
@@ -495,7 +517,7 @@ mpls_tunnel_tx (vlib_main_t * vm,
b0 = vlib_get_buffer(vm, bi0);
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = mt->mt_l2_adj;
+ vnet_buffer(b0)->ip.adj_index[VLIB_TX] = mt->mt_l2_lb.dpoi_index;
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
{
@@ -506,7 +528,7 @@ mpls_tunnel_tx (vlib_main_t * vm,
vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
to_next, n_left_to_next,
- bi0, mt->mt_l2_tx_arc);
+ bi0, mt->mt_l2_lb.dpoi_next_node);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -565,8 +587,7 @@ vnet_mpls_tunnel_del (u32 sw_if_index)
if (FIB_NODE_INDEX_INVALID != mt->mt_path_list)
fib_path_list_child_remove(mt->mt_path_list,
mt->mt_sibling_index);
- if (ADJ_INDEX_INVALID != mt->mt_l2_adj)
- adj_unlock(mt->mt_l2_adj);
+ dpo_reset(&mt->mt_l2_lb);
vec_add1 (mpls_tunnel_free_hw_if_indices, mt->mt_hw_if_index);
pool_put(mpls_tunnel_pool, mt);
@@ -587,12 +608,13 @@ vnet_mpls_tunnel_create (u8 l2_only,
memset (mt, 0, sizeof (*mt));
mti = mt - mpls_tunnel_pool;
fib_node_init(&mt->mt_node, FIB_NODE_TYPE_MPLS_TUNNEL);
- mt->mt_l2_adj = ADJ_INDEX_INVALID;
mt->mt_path_list = FIB_NODE_INDEX_INVALID;
mt->mt_sibling_index = FIB_NODE_INDEX_INVALID;
if (is_multicast)
mt->mt_flags |= MPLS_TUNNEL_FLAG_MCAST;
+ if (l2_only)
+ mt->mt_flags |= MPLS_TUNNEL_FLAG_L2;
/*
* Create a new, or re=use and old, tunnel HW interface
@@ -614,7 +636,7 @@ vnet_mpls_tunnel_create (u8 l2_only,
mti,
mpls_tunnel_hw_interface_class.index,
mti);
- hi = vnet_get_hw_interface(vnm, mt->mt_hw_if_index);
+ hi = vnet_get_hw_interface (vnm, mt->mt_hw_if_index);
}
/*
@@ -624,19 +646,6 @@ vnet_mpls_tunnel_create (u8 l2_only,
vec_validate_init_empty(mpls_tunnel_db, mt->mt_sw_if_index, ~0);
mpls_tunnel_db[mt->mt_sw_if_index] = mti;
- if (l2_only)
- {
- mt->mt_l2_adj =
- adj_nbr_add_or_lock(fib_path_list_get_proto(mt->mt_path_list),
- VNET_LINK_ETHERNET,
- &zero_addr,
- mt->mt_sw_if_index);
-
- mt->mt_l2_tx_arc = vlib_node_add_named_next(vlib_get_main(),
- hi->tx_node_index,
- "adj-l2-midchain");
- }
-
return (mt->mt_sw_if_index);
}
@@ -803,7 +812,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
&rpath.frp_sw_if_index))
{
rpath.frp_weight = 1;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
}
else if (unformat (line_input, "via %U %U",
@@ -813,7 +822,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
&rpath.frp_sw_if_index))
{
rpath.frp_weight = 1;
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
}
else if (unformat (line_input, "via %U",
unformat_ip6_address,
@@ -822,7 +831,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
rpath.frp_fib_index = 0;
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP6;
+ rpath.frp_proto = DPO_PROTO_IP6;
}
else if (unformat (line_input, "via %U",
unformat_ip4_address,
@@ -831,7 +840,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
rpath.frp_fib_index = 0;
rpath.frp_weight = 1;
rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = FIB_PROTOCOL_IP4;
+ rpath.frp_proto = DPO_PROTO_IP4;
}
else if (unformat (line_input, "l2-only"))
l2_only = 1;
@@ -915,6 +924,14 @@ format_mpls_tunnel (u8 * s, va_list * args)
s = format(s, "%U", format_fib_path_ext_list, &mt->mt_path_exts);
s = format(s, "\n");
+ if (mt->mt_flags & MPLS_TUNNEL_FLAG_L2)
+ {
+ s = format(s, " forwarding: %U\n",
+ format_fib_forw_chain_type,
+ FIB_FORW_CHAIN_TYPE_ETHERNET);
+ s = format(s, " %U\n", format_dpo_id, &mt->mt_l2_lb, 2);
+ }
+
return (s);
}
diff --git a/src/vnet/mpls/mpls_tunnel.h b/src/vnet/mpls/mpls_tunnel.h
index 4cb0a860802..285817c33c4 100644
--- a/src/vnet/mpls/mpls_tunnel.h
+++ b/src/vnet/mpls/mpls_tunnel.h
@@ -23,14 +23,19 @@ typedef enum mpls_tunnel_attribute_t_
{
MPLS_TUNNEL_ATTRIBUTE_FIRST = 0,
/**
+ * @brief The tunnel is L2 only
+ */
+ MPLS_TUNNEL_ATTRIBUTE_L2 = MPLS_TUNNEL_ATTRIBUTE_FIRST,
+ /**
* @brief The tunnel has an underlying multicast LSP
*/
- MPLS_TUNNEL_ATTRIBUTE_MCAST = MPLS_TUNNEL_ATTRIBUTE_FIRST,
+ MPLS_TUNNEL_ATTRIBUTE_MCAST,
MPLS_TUNNEL_ATTRIBUTE_LAST = MPLS_TUNNEL_ATTRIBUTE_MCAST,
} mpls_tunnel_attribute_t;
#define MPLS_TUNNEL_ATTRIBUTES { \
[MPLS_TUNNEL_ATTRIBUTE_MCAST] = "multicast", \
+ [MPLS_TUNNEL_ATTRIBUTE_L2] = "L2", \
}
#define FOR_EACH_MPLS_TUNNEL_ATTRIBUTE(_item) \
for (_item = MPLS_TUNNEL_ATTRIBUTE_FIRST; \
@@ -39,6 +44,7 @@ typedef enum mpls_tunnel_attribute_t_
typedef enum mpls_tunnel_flag_t_ {
MPLS_TUNNEL_FLAG_NONE = 0,
+ MPLS_TUNNEL_FLAG_L2 = (1 << MPLS_TUNNEL_ATTRIBUTE_L2),
MPLS_TUNNEL_FLAG_MCAST = (1 << MPLS_TUNNEL_ATTRIBUTE_MCAST),
} __attribute__ ((packed)) mpls_tunnel_flags_t;
@@ -60,14 +66,19 @@ typedef struct mpls_tunnel_t_
/**
* @brief If the tunnel is an L2 tunnel, this is the link type ETHERNET
- * adjacency
+ * load-balance
+ */
+ dpo_id_t mt_l2_lb;
+
+ /**
+ * @brief The HW interface index of the tunnel interfaces
*/
- adj_index_t mt_l2_adj;
+ u32 mt_hw_if_index;
/**
- * @brief on a L2 tunnel this is the VLIB arc from the L2-tx to the l2-midchain
+ * @brief The SW interface index of the tunnel interfaces
*/
- u32 mt_l2_tx_arc;
+ u32 mt_sw_if_index;
/**
* @brief The path-list over which the tunnel's destination is reachable
@@ -83,23 +94,6 @@ typedef struct mpls_tunnel_t_
* A vector of path extensions o hold the label stack for each path
*/
fib_path_ext_list_t mt_path_exts;
-
- /**
- * @brief Flag to indicate the tunnel is only for L2 traffic, that is
- * this tunnel belongs in a bridge domain.
- */
- u8 mt_l2_only;
-
- /**
- * @brief The HW interface index of the tunnel interfaces
- */
- u32 mt_hw_if_index;
-
- /**
- * @brief The SW interface index of the tunnel interfaces
- */
- u32 mt_sw_if_index;
-
} mpls_tunnel_t;
/**