Handles next_hop_weight, next_hop_preference and next_hop_table_id
properly in vl_api_mpls_tunnel_add_del_t_handler(). Also updated
vpp_api_test and custom_dump handling of related APIs.
Change-Id: I89e211bfa3b9d8ead396b24b3c46b7c7f6511f44
Signed-off-by: John Lo <loj@cisco.com>
else
{
vam->retval = retval;
else
{
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
+ vam->regenerate_interface_table = 1;
}
static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
}
static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
mp->is_resolve_host = resolve_host;
mp->is_resolve_attached = resolve_attached;
mp->next_hop_weight = next_hop_weight;
mp->is_resolve_host = resolve_host;
mp->is_resolve_attached = resolve_attached;
mp->next_hop_weight = next_hop_weight;
+ mp->next_hop_preference = 0;
mp->dst_address_length = dst_address_length;
mp->next_hop_table_id = ntohl (next_hop_table_id);
mp->classify_table_index = ntohl (classify_table_index);
mp->dst_address_length = dst_address_length;
mp->next_hop_table_id = ntohl (next_hop_table_id);
mp->classify_table_index = ntohl (classify_table_index);
mp->mr_is_resolve_attached = resolve_attached;
mp->mr_is_interface_rx = is_interface_rx;
mp->mr_next_hop_weight = next_hop_weight;
mp->mr_is_resolve_attached = resolve_attached;
mp->mr_is_interface_rx = is_interface_rx;
mp->mr_next_hop_weight = next_hop_weight;
+ mp->mr_next_hop_preference = 0;
mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
mp->mr_classify_table_index = ntohl (classify_table_index);
mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
mp->mr_classify_table_index = ntohl (classify_table_index);
mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
.as_u32 = 0,
};
ip6_address_t v6_next_hop_address = { {0} };
.as_u32 = 0,
};
ip6_address_t v6_next_hop_address = { {0} };
+ vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
- mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
+ mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "add"))
is_add = 1;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "add"))
is_add = 1;
+ else
+ if (unformat
+ (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
+ is_add = 0;
else if (unformat (i, "del sw_if_index %d", &sw_if_index))
is_add = 0;
else if (unformat (i, "del sw_if_index %d", &sw_if_index))
is_add = 0;
- else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
- ;
else if (unformat (i, "via %U",
unformat_ip4_address, &v4_next_hop_address))
{
else if (unformat (i, "via %U",
unformat_ip4_address, &v4_next_hop_address))
{
}
else if (unformat (i, "via-label %d", &next_hop_via_label))
;
}
else if (unformat (i, "via-label %d", &next_hop_via_label))
;
+ else
+ if (unformat
+ (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
+ ;
+ else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
+ ;
else if (unformat (i, "l2-only"))
l2_only = 1;
else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
;
else if (unformat (i, "out-label %d", &next_hop_out_label))
else if (unformat (i, "l2-only"))
l2_only = 1;
else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
;
else if (unformat (i, "out-label %d", &next_hop_out_label))
- vec_add1 (labels, ntohl (next_hop_out_label));
+ {
+ vl_api_fib_mpls_label_t fib_label = {
+ .label = ntohl (next_hop_out_label),
+ .ttl = 64,
+ .exp = 0,
+ };
+ vec_add1 (next_hop_out_label_stack, fib_label);
+ }
else
{
clib_warning ("parse error '%U'", format_unformat_error, i);
else
{
clib_warning ("parse error '%U'", format_unformat_error, i);
- M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
+ M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
+ vec_len (next_hop_out_label_stack));
mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
mp->mt_sw_if_index = ntohl (sw_if_index);
mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
mp->mt_sw_if_index = ntohl (sw_if_index);
mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
+ mp->mt_next_hop_weight = 1;
+ mp->mt_next_hop_preference = 0;
- mp->mt_next_hop_n_out_labels = vec_len (labels);
+ mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
if (0 != mp->mt_next_hop_n_out_labels)
{
if (0 != mp->mt_next_hop_n_out_labels)
{
- clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
- sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
- vec_free (labels);
+ clib_memcpy (mp->mt_next_hop_out_label_stack,
+ next_hop_out_label_stack,
+ (vec_len (next_hop_out_label_stack) *
+ sizeof (vl_api_fib_mpls_label_t)));
+ vec_free (next_hop_out_label_stack);
}
if (next_hop_proto_is_ip4)
}
if (next_hop_proto_is_ip4)
_(ip_add_del_route, \
"<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
"[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
_(ip_add_del_route, \
"<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
"[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
- "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
- "[multipath] [count <n>]") \
+ "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
+ "[multipath] [count <n>] [del]") \
_(ip_mroute_add_del, \
"<src> <grp>/<mask> [table-id <n>]\n" \
"[<intfc> | sw_if_index <id>] [local] [del]") \
_(ip_mroute_add_del, \
"<src> <grp>/<mask> [table-id <n>]\n" \
"[<intfc> | sw_if_index <id>] [local] [del]") \
"lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
"l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
"[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
"lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
"l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
"[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
- "[drop] [local] [classify <n>] [multipath] [count <n>] [del]") \
+ "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
+ "[count <n>] [del]") \
_(mpls_ip_bind_unbind, \
"<label> <addr/len>") \
_(mpls_tunnel_add_del, \
_(mpls_ip_bind_unbind, \
"<label> <addr/len>") \
_(mpls_tunnel_add_del, \
- " via <addr> [table-id <n>]\n" \
- "sw_if_index <id>] [l2] [del]") \
+ "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
+ "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
+ "[l2-only] [out-label <n>]") \
_(sr_mpls_policy_add, \
"bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
_(sr_mpls_policy_del, \
_(sr_mpls_policy_add, \
"bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
_(sr_mpls_policy_del, \
static void
vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
{
static void
vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
{
- u32 tunnel_sw_if_index, tunnel_index, next_hop_via_label;
+ u32 tunnel_sw_if_index = ~0, tunnel_index = ~0, next_hop_via_label;
vl_api_mpls_tunnel_add_del_reply_t *rmp;
fib_route_path_t rpath, *rpaths = NULL;
int ii, rv = 0;
vl_api_mpls_tunnel_add_del_reply_t *rmp;
fib_route_path_t rpath, *rpaths = NULL;
int ii, rv = 0;
mp->mt_next_hop, sizeof (rpath.frp_addr.ip6));
}
rpath.frp_sw_if_index = ntohl (mp->mt_next_hop_sw_if_index);
mp->mt_next_hop, sizeof (rpath.frp_addr.ip6));
}
rpath.frp_sw_if_index = ntohl (mp->mt_next_hop_sw_if_index);
+ rpath.frp_weight = mp->mt_next_hop_weight;
+ rpath.frp_preference = mp->mt_next_hop_preference;
next_hop_via_label = ntohl (mp->mt_next_hop_via_label);
if ((MPLS_LABEL_INVALID != next_hop_via_label) && (0 != next_hop_via_label))
next_hop_via_label = ntohl (mp->mt_next_hop_via_label);
if ((MPLS_LABEL_INVALID != next_hop_via_label) && (0 != next_hop_via_label))
rpath.frp_eos = MPLS_NON_EOS;
}
rpath.frp_eos = MPLS_NON_EOS;
}
+ if (rpath.frp_sw_if_index == ~0)
+ { /* recursive path, set fib index */
+ rpath.frp_fib_index =
+ fib_table_find (dpo_proto_to_fib (rpath.frp_proto),
+ ntohl (mp->mt_next_hop_table_id));
+ if (rpath.frp_fib_index == ~0)
+ {
+ rv = VNET_API_ERROR_NO_SUCH_FIB;
+ goto out;
+ }
+ }
+
if (mp->mt_is_add)
{
for (ii = 0; ii < mp->mt_next_hop_n_out_labels; ii++)
if (mp->mt_is_add)
{
for (ii = 0; ii < mp->mt_next_hop_n_out_labels; ii++)
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY,
({
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY,
({
s = format (0, "SCRIPT: mpls_tunnel_add_del ");
s = format (0, "SCRIPT: mpls_tunnel_add_del ");
- if (mp->mt_next_hop_sw_if_index)
- s = format (s, "sw_if_index %d ", ntohl (mp->mt_next_hop_sw_if_index));
+ if (mp->mt_is_add == 0)
+ s = format (s, "del sw_if_index %d ", ntohl (mp->mt_sw_if_index));
- if (mp->mt_next_hop_proto_is_ip4)
- s = format (s, "%U ", format_ip4_address, mp->mt_next_hop);
+ mpls_label_t label = ntohl (mp->mt_next_hop_via_label);
+ if (label != MPLS_LABEL_INVALID)
+ s = format (s, "via-label %d ", label);
+ else if (mp->mt_next_hop_proto_is_ip4)
+ s = format (s, "via %U ", format_ip4_address, mp->mt_next_hop);
- s = format (s, "%U ", format_ip6_address, mp->mt_next_hop);
+ s = format (s, "via %U ", format_ip6_address, mp->mt_next_hop);
+
+ if (mp->mt_next_hop_sw_if_index != ~0)
+ s = format (s, "sw_if_index %d ", ntohl (mp->mt_next_hop_sw_if_index));
+ else if (mp->mt_next_hop_table_id)
+ s = format (s, "next-hop-table %d ", ntohl (mp->mt_next_hop_table_id));
if (mp->mt_l2_only)
s = format (s, "l2-only ");
if (mp->mt_l2_only)
s = format (s, "l2-only ");
- if (mp->mt_is_add == 0)
- s = format (s, "del ");
+ if (mp->mt_next_hop_n_out_labels)
+ {
+ u8 i;
+ for (i = 0; i < mp->mt_next_hop_n_out_labels; i++)
+ {
+ s = format (s, "out-label %d ",
+ ntohl (mp->mt_next_hop_out_label_stack[i].label));
+ }
+ }