aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/bier/bier_update.c15
-rw-r--r--src/vnet/fib/fib_types.c161
-rw-r--r--src/vnet/fib/fib_types.h10
-rw-r--r--src/vnet/ip/lookup.c153
-rw-r--r--src/vnet/mpls/mpls.c161
-rw-r--r--src/vnet/mpls/mpls_tunnel.c58
6 files changed, 198 insertions, 360 deletions
diff --git a/src/vnet/bier/bier_update.c b/src/vnet/bier/bier_update.c
index 170893d45b6..4d7509dd52e 100644
--- a/src/vnet/bier/bier_update.c
+++ b/src/vnet/bier/bier_update.c
@@ -79,13 +79,14 @@ vnet_bier_route_cmd (vlib_main_t * vm,
fib_route_path_t *brps = NULL, brp = {
.frp_flags = FIB_ROUTE_PATH_BIER_FMASK,
};
+ u32 hdr_len, payload_proto;
bier_table_id_t bti = {
};
- mpls_label_t out_label;
bier_bp_t bp;
- u32 hdr_len;
u32 add = 1;
+ payload_proto = DPO_PROTO_BIER;
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
if (unformat (input, "del")) {
add = 0;
@@ -93,11 +94,9 @@ vnet_bier_route_cmd (vlib_main_t * vm,
} else if (unformat (input, "set %d", &bti.bti_set)) {
} else if (unformat (input, "bsl %d", &hdr_len)) {
} else if (unformat (input, "bp %d", &bp)) {
- } else if (unformat (input, "v4-nh %U",
- unformat_ip46_address,
- &brp.frp_addr, 0)) {
- } else if (unformat (input, "mpls %d", &out_label)) {
- vec_add1(brp.frp_label_stack, out_label);
+ } else if (unformat (input, "via %U",
+ unformat_fib_route_path,
+ &brp, &payload_proto)) {
} else {
error = unformat_parse_error (input);
goto done;
@@ -124,7 +123,7 @@ done:
}
VLIB_CLI_COMMAND (bier_route_command) = {
- .path = "bier route",
+ .path = "bier route via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
.short_help = "Add/delete BIER Routes",
.function = vnet_bier_route_cmd,
};
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c
index 656966b2331..5c70d6c1729 100644
--- a/src/vnet/fib/fib_types.c
+++ b/src/vnet/fib/fib_types.c
@@ -330,3 +330,164 @@ fib_forw_chain_type_to_dpo_proto (fib_forward_chain_type_t fct)
}
return (DPO_PROTO_IP4);
}
+
+uword
+unformat_fib_route_path (unformat_input_t * input, va_list * args)
+{
+ fib_route_path_t *rpath = va_arg (*args, fib_route_path_t *);
+ u32 *payload_proto = va_arg (*args, u32*);
+ u32 weight, preference, udp_encap_id;
+ mpls_label_t out_label;
+ vnet_main_t *vnm;
+
+ vnm = vnet_get_main ();
+ memset(rpath, 0, sizeof(*rpath));
+ rpath->frp_weight = 1;
+ rpath->frp_sw_if_index = ~0;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "%U %U",
+ unformat_ip4_address,
+ &rpath->frp_addr.ip4,
+ unformat_vnet_sw_interface, vnm,
+ &rpath->frp_sw_if_index))
+ {
+ rpath->frp_proto = DPO_PROTO_IP4;
+ }
+ else if (unformat (input, "%U %U",
+ unformat_ip6_address,
+ &rpath->frp_addr.ip6,
+ unformat_vnet_sw_interface, vnm,
+ &rpath->frp_sw_if_index))
+ {
+ rpath->frp_proto = DPO_PROTO_IP6;
+ }
+ else if (unformat (input, "weight %u", &weight))
+ {
+ rpath->frp_weight = weight;
+ }
+ else if (unformat (input, "preference %u", &preference))
+ {
+ rpath->frp_preference = preference;
+ }
+ else if (unformat (input, "%U next-hop-table %d",
+ unformat_ip4_address,
+ &rpath->frp_addr.ip4,
+ &rpath->frp_fib_index))
+ {
+ rpath->frp_sw_if_index = ~0;
+ rpath->frp_proto = DPO_PROTO_IP4;
+ }
+ else if (unformat (input, "%U next-hop-table %d",
+ unformat_ip6_address,
+ &rpath->frp_addr.ip6,
+ &rpath->frp_fib_index))
+ {
+ rpath->frp_sw_if_index = ~0;
+ rpath->frp_proto = DPO_PROTO_IP6;
+ }
+ else if (unformat (input, "%U",
+ unformat_ip4_address,
+ &rpath->frp_addr.ip4))
+ {
+ /*
+ * the recursive next-hops are by default in the default table
+ */
+ rpath->frp_fib_index = 0;
+ rpath->frp_sw_if_index = ~0;
+ rpath->frp_proto = DPO_PROTO_IP4;
+ }
+ else if (unformat (input, "%U",
+ unformat_ip6_address,
+ &rpath->frp_addr.ip6))
+ {
+ rpath->frp_fib_index = 0;
+ rpath->frp_sw_if_index = ~0;
+ rpath->frp_proto = DPO_PROTO_IP6;
+ }
+ else if (unformat (input, "udp-encap %d", &udp_encap_id))
+ {
+ rpath->frp_udp_encap_id = udp_encap_id;
+ rpath->frp_flags |= FIB_ROUTE_PATH_UDP_ENCAP;
+ rpath->frp_proto = *payload_proto;
+ }
+ else if (unformat (input, "lookup in table %d", &rpath->frp_fib_index))
+ {
+ rpath->frp_proto = *payload_proto;
+ rpath->frp_sw_if_index = ~0;
+ }
+ else if (unformat (input, "via %U",
+ unformat_vnet_sw_interface, vnm,
+ &rpath->frp_sw_if_index))
+ {
+ rpath->frp_proto = *payload_proto;
+ }
+ else if (unformat (input, "resolve-via-host"))
+ {
+ rpath->frp_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
+ }
+ else if (unformat (input, "resolve-via-attached"))
+ {
+ rpath->frp_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
+ }
+ else if (unformat (input,
+ "ip4-lookup-in-table %d",
+ &rpath->frp_fib_index))
+ {
+ rpath->frp_proto = DPO_PROTO_IP4;
+ *payload_proto = DPO_PROTO_IP4;
+ }
+ else if (unformat (input,
+ "ip6-lookup-in-table %d",
+ &rpath->frp_fib_index))
+ {
+ rpath->frp_proto = DPO_PROTO_IP6;
+ *payload_proto = DPO_PROTO_IP6;
+ }
+ else if (unformat (input,
+ "mpls-lookup-in-table %d",
+ &rpath->frp_fib_index))
+ {
+ rpath->frp_proto = DPO_PROTO_MPLS;
+ *payload_proto = DPO_PROTO_MPLS;
+ }
+ else if (unformat (input,
+ "l2-input-on %U",
+ unformat_vnet_sw_interface, vnm,
+ &rpath->frp_sw_if_index))
+ {
+ rpath->frp_proto = DPO_PROTO_ETHERNET;
+ *payload_proto = DPO_PROTO_ETHERNET;
+ }
+ else if (unformat (input, "via-label %U",
+ unformat_mpls_unicast_label,
+ &rpath->frp_local_label))
+ {
+ rpath->frp_eos = MPLS_NON_EOS;
+ rpath->frp_proto = DPO_PROTO_MPLS;
+ rpath->frp_sw_if_index = ~0;
+ }
+ else if (unformat (input, "rx-ip4 %U",
+ unformat_vnet_sw_interface, vnm,
+ &rpath->frp_sw_if_index))
+ {
+ rpath->frp_proto = DPO_PROTO_IP4;
+ rpath->frp_flags = FIB_ROUTE_PATH_INTF_RX;
+ }
+ else if (unformat (input, "out-labels"))
+ {
+ while (unformat (input, "%U",
+ unformat_mpls_unicast_label, &out_label))
+ {
+ vec_add1(rpath->frp_label_stack, out_label);
+ }
+ }
+ else
+ {
+ return (0);
+ }
+ }
+
+ return (1);
+}
diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h
index 0a4b1699609..be6a24ee9cd 100644
--- a/src/vnet/fib/fib_types.h
+++ b/src/vnet/fib/fib_types.h
@@ -461,6 +461,16 @@ typedef struct fib_route_path_t_ {
} fib_route_path_t;
/**
+ * Unformat a fib_route_path_t from CLI input
+ */
+extern uword unformat_fib_route_path(unformat_input_t * input, va_list * args);
+
+/**
+ * A help string to list the FIB path options
+ */
+#define FIB_ROUTE_PATH_HELP "[next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]"
+
+/**
* @brief
* A representation of a fib path for fib_path_encode to convey the information to the caller
*/
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 9bb53f5e8c0..95039bdf116 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -366,24 +366,18 @@ vnet_ip_route_cmd (vlib_main_t * vm,
unformat_input_t * main_input, vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- fib_route_path_t *rpaths = NULL, rpath;
+ u32 table_id, is_del, fib_index, payload_proto;
dpo_id_t dpo = DPO_INVALID, *dpos = NULL;
- u32 table_id, is_del, udp_encap_id;
+ fib_route_path_t *rpaths = NULL, rpath;
fib_prefix_t *prefixs = NULL, pfx;
- mpls_label_t out_label, via_label;
clib_error_t *error = NULL;
- u32 weight, preference;
- vnet_main_t *vnm;
- u32 fib_index;
f64 count;
int i;
- vnm = vnet_get_main ();
is_del = 0;
table_id = 0;
count = 1;
memset (&pfx, 0, sizeof (pfx));
- out_label = via_label = MPLS_LABEL_INVALID;
/* Get a line of input. */
if (!unformat_user (main_input, unformat_line_input, line_input))
@@ -395,159 +389,24 @@ vnet_ip_route_cmd (vlib_main_t * vm,
if (unformat (line_input, "table %d", &table_id))
;
- else if (unformat (line_input, "resolve-via-host"))
- {
- if (vec_len (rpaths) == 0)
- {
- error = clib_error_return (0, "Paths then flags");
- goto done;
- }
- rpaths[vec_len (rpaths) - 1].frp_flags |=
- FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
- }
- else if (unformat (line_input, "resolve-via-attached"))
- {
- if (vec_len (rpaths) == 0)
- {
- error = clib_error_return (0, "Paths then flags");
- goto done;
- }
- rpaths[vec_len (rpaths) - 1].frp_flags |=
- FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
- }
- else if (unformat (line_input, "out-labels"))
- {
- if (vec_len (rpaths) == 0)
- {
- error = clib_error_return (0, "Paths then labels");
- goto done;
- }
- else
- {
- while (unformat (line_input, "%U",
- unformat_mpls_unicast_label, &out_label))
- {
- vec_add1 (rpaths[vec_len (rpaths) - 1].frp_label_stack,
- out_label);
- }
- }
- }
- else if (unformat (line_input, "via-label %U",
- unformat_mpls_unicast_label, &rpath.frp_local_label))
- {
- rpath.frp_weight = 1;
- rpath.frp_eos = MPLS_NON_EOS;
- rpath.frp_proto = DPO_PROTO_MPLS;
- rpath.frp_sw_if_index = ~0;
- vec_add1 (rpaths, rpath);
- }
else if (unformat (line_input, "count %f", &count))
;
else if (unformat (line_input, "%U/%d",
unformat_ip4_address, &pfx.fp_addr.ip4, &pfx.fp_len))
{
- pfx.fp_proto = FIB_PROTOCOL_IP4;
+ payload_proto = pfx.fp_proto = FIB_PROTOCOL_IP4;
vec_add1 (prefixs, pfx);
}
else if (unformat (line_input, "%U/%d",
unformat_ip6_address, &pfx.fp_addr.ip6, &pfx.fp_len))
{
- pfx.fp_proto = FIB_PROTOCOL_IP6;
+ payload_proto = pfx.fp_proto = FIB_PROTOCOL_IP6;
vec_add1 (prefixs, pfx);
}
- else if (unformat (line_input, "via %U %U",
- unformat_ip4_address,
- &rpath.frp_addr.ip4,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1 (rpaths, rpath);
- }
-
- else if (unformat (line_input, "via %U %U",
- unformat_ip6_address,
- &rpath.frp_addr.ip6,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1 (rpaths, rpath);
- }
- else if (unformat (line_input, "weight %u", &weight))
- {
- ASSERT (vec_len (rpaths));
- rpaths[vec_len (rpaths) - 1].frp_weight = weight;
- }
- else if (unformat (line_input, "preference %u", &preference))
- {
- ASSERT (vec_len (rpaths));
- rpaths[vec_len (rpaths) - 1].frp_preference = preference;
- }
- else if (unformat (line_input, "via %U next-hop-table %d",
- unformat_ip4_address,
- &rpath.frp_addr.ip4, &rpath.frp_fib_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1 (rpaths, rpath);
- }
- else if (unformat (line_input, "via %U next-hop-table %d",
- unformat_ip6_address,
- &rpath.frp_addr.ip6, &rpath.frp_fib_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1 (rpaths, rpath);
- }
else if (unformat (line_input, "via %U",
- unformat_ip4_address, &rpath.frp_addr.ip4))
+ unformat_fib_route_path, &rpath, &payload_proto))
{
- /*
- * the recursive next-hops are by default in the same table
- * as the prefix
- */
- rpath.frp_fib_index = table_id;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1 (rpaths, rpath);
- }
- else if (unformat (line_input, "via %U",
- unformat_ip6_address, &rpath.frp_addr.ip6))
- {
- rpath.frp_fib_index = table_id;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1 (rpaths, rpath);
- }
- else if (unformat (line_input, "via udp-encap %d", &udp_encap_id))
- {
- rpath.frp_udp_encap_id = udp_encap_id;
- rpath.frp_flags |= FIB_ROUTE_PATH_UDP_ENCAP;
- rpath.frp_proto = fib_proto_to_dpo (pfx.fp_proto);
- vec_add1 (rpaths, rpath);
- }
- else if (unformat (line_input,
- "lookup in table %d", &rpath.frp_fib_index))
- {
- rpath.frp_proto = fib_proto_to_dpo (pfx.fp_proto);
- rpath.frp_sw_if_index = ~0;
- vec_add1 (rpaths, rpath);
- }
- else if (vec_len (prefixs) > 0 &&
- unformat (line_input, "via %U",
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = fib_proto_to_dpo (prefixs[0].fp_proto);
vec_add1 (rpaths, rpath);
}
else if (vec_len (prefixs) > 0 &&
@@ -838,7 +697,7 @@ VLIB_CLI_COMMAND (vlib_cli_show_ip6_command, static) = {
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (ip_route_command, static) = {
.path = "ip route",
- .short_help = "ip route [add|del] [count <n>] <dst-ip-addr>/<width> [table <table-id>] [via <next-hop-ip-addr> [<interface>] [weight <weight>]] | [via arp <interface> <adj-hop-ip-addr>] | [via drop|punt|local<id>|arp|classify <classify-idx>] [lookup in table <out-table-id>]",
+ .short_help = "ip route [add|del] [count <n>] <dst-ip-addr>/<width> [table <table-id>] via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
.function = vnet_ip_route_cmd,
.is_mp_safe = 1,
};
diff --git a/src/vnet/mpls/mpls.c b/src/vnet/mpls/mpls.c
index ed24f75fbde..173771477de 100644
--- a/src/vnet/mpls/mpls.c
+++ b/src/vnet/mpls/mpls.c
@@ -212,16 +212,13 @@ vnet_mpls_local_label (vlib_main_t * vm,
vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, * line_input = &_line_input;
+ u32 table_id, is_del, is_ip, payload_proto;
fib_route_path_t *rpaths = NULL, rpath;
- u32 table_id, is_del, is_ip;
mpls_label_t local_label;
- mpls_label_t out_label;
clib_error_t * error;
mpls_eos_bit_t eos;
- vnet_main_t * vnm;
fib_prefix_t pfx;
- vnm = vnet_get_main();
error = NULL;
is_ip = 0;
table_id = 0;
@@ -229,6 +226,7 @@ vnet_mpls_local_label (vlib_main_t * vm,
is_del = 0;
local_label = MPLS_LABEL_INVALID;
memset(&pfx, 0, sizeof(pfx));
+ payload_proto = DPO_PROTO_MPLS;
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
@@ -236,8 +234,6 @@ vnet_mpls_local_label (vlib_main_t * vm,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- memset(&rpath, 0, sizeof(rpath));
-
if (unformat (line_input, "table %d", &table_id))
;
else if (unformat (line_input, "del"))
@@ -264,158 +260,15 @@ vnet_mpls_local_label (vlib_main_t * vm,
pfx.fp_proto = FIB_PROTOCOL_IP6;
is_ip = 1;
}
- else if (unformat (line_input, "via %U %U weight %u",
- unformat_ip4_address,
- &rpath.frp_addr.ip4,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index,
- &rpath.frp_weight))
- {
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1(rpaths, rpath);
- }
-
- else if (unformat (line_input, "via %U %U weight %u",
- unformat_ip6_address,
- &rpath.frp_addr.ip6,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index,
- &rpath.frp_weight))
- {
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1(rpaths, rpath);
- }
-
- else if (unformat (line_input, "via %U %U",
- unformat_ip4_address,
- &rpath.frp_addr.ip4,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1(rpaths, rpath);
- }
- else if (unformat (line_input, "rx-ip4 %U",
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP4;
- rpath.frp_flags = FIB_ROUTE_PATH_INTF_RX;
- vec_add1(rpaths, rpath);
- }
- else if (unformat (line_input, "via %U %U",
- unformat_ip6_address,
- &rpath.frp_addr.ip6,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1(rpaths, rpath);
- }
- else if (unformat (line_input, "via %U next-hop-table %d",
- unformat_ip4_address,
- &rpath.frp_addr.ip4,
- &rpath.frp_fib_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1(rpaths, rpath);
- }
- else if (unformat (line_input, "via %U next-hop-table %d",
- unformat_ip6_address,
- &rpath.frp_addr.ip6,
- &rpath.frp_fib_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP6;
- vec_add1(rpaths, rpath);
- }
- else if (unformat (line_input, "via %U",
- unformat_ip4_address,
- &rpath.frp_addr.ip4))
- {
- /*
- * the recursive next-hops are by default in the same table
- * as the prefix
- */
- rpath.frp_fib_index = table_id;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP4;
- vec_add1(rpaths, rpath);
- }
else if (unformat (line_input, "via %U",
- unformat_ip6_address,
- &rpath.frp_addr.ip6))
+ unformat_fib_route_path,
+ &rpath, &payload_proto))
{
- rpath.frp_fib_index = table_id;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP6;
+ pfx.fp_payload_proto = payload_proto;
vec_add1(rpaths, rpath);
}
else if (unformat (line_input, "%d", &local_label))
;
- else if (unformat (line_input,
- "ip4-lookup-in-table %d",
- &rpath.frp_fib_index))
- {
- 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);
- }
- else if (unformat (line_input,
- "ip6-lookup-in-table %d",
- &rpath.frp_fib_index))
- {
- 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;
- }
- else if (unformat (line_input,
- "mpls-lookup-in-table %d",
- &rpath.frp_fib_index))
- {
- 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-labels"))
- {
- if (vec_len (rpaths) == 0)
- {
- error = clib_error_return (0, "Paths then labels");
- goto done;
- }
- else
- {
- while (unformat (line_input, "%U",
- unformat_mpls_unicast_label,
- &out_label))
- {
- vec_add1 (rpaths[vec_len (rpaths) - 1].frp_label_stack,
- out_label);
- }
- }
- }
else
{
error = clib_error_return (0, "unkown input: %U",
@@ -531,9 +384,9 @@ done:
}
VLIB_CLI_COMMAND (mpls_local_label_command, static) = {
- .path = "mpls local-label",
+ .path = "mpls local-label <label-value> [eos|non-eos] via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
.function = vnet_mpls_local_label,
- .short_help = "Create/Delete MPL local labels",
+ .short_help = "Create/Delete MPLS local labels",
};
clib_error_t *
diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c
index 2d5521f447a..a9f32d4e48f 100644
--- a/src/vnet/mpls/mpls_tunnel.c
+++ b/src/vnet/mpls/mpls_tunnel.c
@@ -778,11 +778,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
vnet_main_t * vnm = vnet_get_main();
u8 is_del = 0, l2_only = 0, is_multicast =0;
fib_route_path_t rpath, *rpaths = NULL;
- mpls_label_t out_label = MPLS_LABEL_INVALID;
- u32 sw_if_index = ~0;
+ u32 sw_if_index = ~0, payload_proto;
clib_error_t *error = NULL;
memset(&rpath, 0, sizeof(rpath));
+ payload_proto = DPO_PROTO_MPLS;
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
@@ -800,56 +800,14 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
is_del = 0;
else if (unformat (line_input, "add"))
is_del = 0;
- else if (unformat (line_input, "out-labels"))
- {
- while (unformat (line_input, "%U",
- unformat_mpls_unicast_label,
- &out_label))
- {
- vec_add1 (rpath.frp_label_stack, out_label);
- }
- }
- else if (unformat (line_input, "via %U %U",
- unformat_ip4_address,
- &rpath.frp_addr.ip4,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP4;
- }
-
- else if (unformat (line_input, "via %U %U",
- unformat_ip6_address,
- &rpath.frp_addr.ip6,
- unformat_vnet_sw_interface, vnm,
- &rpath.frp_sw_if_index))
- {
- rpath.frp_weight = 1;
- rpath.frp_proto = DPO_PROTO_IP6;
- }
- else if (unformat (line_input, "via %U",
- unformat_ip6_address,
- &rpath.frp_addr.ip6))
- {
- rpath.frp_fib_index = 0;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP6;
- }
- else if (unformat (line_input, "via %U",
- unformat_ip4_address,
- &rpath.frp_addr.ip4))
- {
- rpath.frp_fib_index = 0;
- rpath.frp_weight = 1;
- rpath.frp_sw_if_index = ~0;
- rpath.frp_proto = DPO_PROTO_IP4;
- }
else if (unformat (line_input, "l2-only"))
l2_only = 1;
else if (unformat (line_input, "multicast"))
is_multicast = 1;
+ else if (unformat (line_input, "via %U",
+ unformat_fib_route_path,
+ &rpath, &payload_proto))
+ vec_add1(rpaths, rpath);
else
{
error = clib_error_return (0, "unknown input '%U'",
@@ -858,8 +816,6 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
}
}
- vec_add1(rpaths, rpath);
-
if (is_del)
{
if (!vnet_mpls_tunnel_path_remove(sw_if_index, rpaths))
@@ -901,7 +857,7 @@ done:
VLIB_CLI_COMMAND (create_mpls_tunnel_command, static) = {
.path = "mpls tunnel",
.short_help =
- "mpls tunnel via [addr] [interface] [out-labels]",
+ "mpls tunnel [multicast] [l2-only] via [next-hop-address] [next-hop-interface] [next-hop-table <value>] [weight <value>] [preference <value>] [udp-encap-id <value>] [ip4-lookup-in-table <value>] [ip6-lookup-in-table <value>] [mpls-lookup-in-table <value>] [resolve-via-host] [resolve-via-connected] [rx-ip4 <interface>] [out-labels <value value value>]",
.function = vnet_create_mpls_tunnel_command_fn,
};