diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vat/api_format.c | 55 | ||||
-rw-r--r-- | src/vnet/mpls/mpls_api.c | 18 | ||||
-rw-r--r-- | src/vpp/api/custom_dump.c | 29 |
3 files changed, 79 insertions, 23 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 96a79bf251b..0e53f56196a 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -2144,8 +2144,10 @@ static void vl_api_mpls_tunnel_add_del_reply_t_handler else { vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } + vam->regenerate_interface_table = 1; } static void vl_api_mpls_tunnel_add_del_reply_t_handler_json @@ -8828,6 +8830,7 @@ api_ip_add_del_route (vat_main_t * vam) 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); @@ -9235,6 +9238,7 @@ api_mpls_route_add_del (vat_main_t * vam) 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); @@ -9763,18 +9767,21 @@ api_mpls_tunnel_add_del (vat_main_t * vam) .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_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; + 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, "sw_if_index %d", &next_hop_sw_if_index)) - ; else if (unformat (i, "via %U", unformat_ip4_address, &v4_next_hop_address)) { @@ -9787,12 +9794,25 @@ api_mpls_tunnel_add_del (vat_main_t * vam) } 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)) - 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); @@ -9800,7 +9820,8 @@ api_mpls_tunnel_add_del (vat_main_t * vam) } } - 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); @@ -9809,14 +9830,18 @@ api_mpls_tunnel_add_del (vat_main_t * vam) 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) { - 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) @@ -23679,8 +23704,8 @@ _(ip_table_add_del, \ _(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]") \ @@ -23691,12 +23716,14 @@ _(mpls_route_add_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" \ - "[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, \ - " 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, \ diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c index 18eb748c423..84532bffbda 100644 --- a/src/vnet/mpls/mpls_api.c +++ b/src/vnet/mpls/mpls_api.c @@ -311,7 +311,7 @@ mpls_table_create (u32 table_id, u8 is_api, const u8 * name) 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; @@ -333,7 +333,8 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp) 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 = 1; + 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)) @@ -343,6 +344,18 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp) 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++) @@ -383,6 +396,7 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp) stats_dsunlock (); +out: /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY, ({ diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c index aa635668593..8fd4a8deeb1 100644 --- a/src/vpp/api/custom_dump.c +++ b/src/vpp/api/custom_dump.c @@ -944,19 +944,34 @@ static void *vl_api_mpls_tunnel_add_del_t_print 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); else - 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_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)); + } + } FINISH; } |