aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c201
-rw-r--r--src/vpp/api/custom_dump.c160
2 files changed, 328 insertions, 33 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index bb070ed7b1d..0dde721aa1e 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -5387,6 +5387,9 @@ _(sw_interface_ip6nd_ra_prefix_reply) \
_(sw_interface_ip6nd_ra_config_reply) \
_(set_arp_neighbor_limit_reply) \
_(l2_patch_add_del_reply) \
+_(sr_mpls_policy_add_reply) \
+_(sr_mpls_policy_mod_reply) \
+_(sr_mpls_policy_del_reply) \
_(sr_policy_add_reply) \
_(sr_policy_mod_reply) \
_(sr_policy_del_reply) \
@@ -5613,6 +5616,9 @@ _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
sw_interface_ip6nd_ra_config_reply) \
_(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
+_(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
+_(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
+_(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
_(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
_(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
_(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
@@ -8476,7 +8482,7 @@ api_ip_add_del_route (vat_main_t * vam)
u32 classify_table_index = ~0;
u8 is_classify = 0;
u8 resolve_host = 0, resolve_attached = 0;
- mpls_label_t *next_hop_out_label_stack = NULL;
+ vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
@@ -8555,8 +8561,15 @@ api_ip_add_del_route (vat_main_t * vam)
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 (next_hop_out_label_stack, ntohl (next_hop_out_label));
- else if (unformat (i, "via-label %d", &next_hop_via_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 if (unformat (i, "via via-label %d", &next_hop_via_label))
;
else if (unformat (i, "random"))
random_add_del = 1;
@@ -8629,8 +8642,8 @@ api_ip_add_del_route (vat_main_t * vam)
for (j = 0; j < count; j++)
{
/* Construct the API message */
- M2 (IP_ADD_DEL_ROUTE, mp,
- sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
+ M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
+ vec_len (next_hop_out_label_stack));
mp->next_hop_sw_if_index = ntohl (sw_if_index);
mp->table_id = ntohl (vrf_id);
@@ -8655,7 +8668,8 @@ api_ip_add_del_route (vat_main_t * vam)
{
memcpy (mp->next_hop_out_label_stack,
next_hop_out_label_stack,
- vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
+ (vec_len (next_hop_out_label_stack) *
+ sizeof (vl_api_fib_mpls_label_t)));
vec_free (next_hop_out_label_stack);
}
@@ -8919,12 +8933,13 @@ api_mpls_route_add_del (vat_main_t * vam)
u32 classify_table_index = ~0;
u8 is_classify = 0;
u8 resolve_host = 0, resolve_attached = 0;
+ u8 is_interface_rx = 0;
mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
- mpls_label_t *next_hop_out_label_stack = NULL;
+ vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
mpls_label_t local_label = MPLS_LABEL_INVALID;
u8 is_eos = 0;
- dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
+ dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
@@ -8969,22 +8984,44 @@ api_mpls_route_add_del (vat_main_t * vam)
is_multipath = 1;
else if (unformat (i, "count %d", &count))
;
- else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
+ else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
{
next_hop_set = 1;
next_hop_proto = DPO_PROTO_IP4;
}
- else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
+ else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
{
next_hop_set = 1;
next_hop_proto = DPO_PROTO_IP6;
}
- else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
- ;
- else if (unformat (i, "via-label %d", &next_hop_via_label))
- ;
+ else
+ if (unformat
+ (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
+ &sw_if_index))
+ {
+ next_hop_set = 1;
+ next_hop_proto = DPO_PROTO_ETHERNET;
+ is_interface_rx = 1;
+ }
+ else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
+ {
+ next_hop_set = 1;
+ next_hop_proto = DPO_PROTO_ETHERNET;
+ is_interface_rx = 1;
+ }
+ else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
+ next_hop_set = 1;
+ else if (unformat (i, "via via-label %d", &next_hop_via_label))
+ next_hop_set = 1;
else if (unformat (i, "out-label %d", &next_hop_out_label))
- vec_add1 (next_hop_out_label_stack, 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);
@@ -9015,8 +9052,8 @@ api_mpls_route_add_del (vat_main_t * vam)
for (j = 0; j < count; j++)
{
/* Construct the API message */
- M2 (MPLS_ROUTE_ADD_DEL, mp,
- sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
+ M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
+ vec_len (next_hop_out_label_stack));
mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
mp->mr_table_id = ntohl (table_id);
@@ -9027,6 +9064,7 @@ api_mpls_route_add_del (vat_main_t * vam)
mp->mr_is_multipath = is_multipath;
mp->mr_is_resolve_host = resolve_host;
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_table_id = ntohl (next_hop_table_id);
mp->mr_classify_table_index = ntohl (classify_table_index);
@@ -9039,7 +9077,8 @@ api_mpls_route_add_del (vat_main_t * vam)
{
memcpy (mp->mr_next_hop_out_label_stack,
next_hop_out_label_stack,
- vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
+ vec_len (next_hop_out_label_stack) *
+ sizeof (vl_api_fib_mpls_label_t));
vec_free (next_hop_out_label_stack);
}
@@ -9200,6 +9239,109 @@ api_mpls_ip_bind_unbind (vat_main_t * vam)
}
static int
+api_sr_mpls_policy_add (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sr_mpls_policy_add_t *mp;
+ u32 bsid = 0;
+ u32 weight = 1;
+ u8 type = 0;
+ u8 n_segments = 0;
+ u32 sid;
+ u32 *segments = NULL;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "bsid %d", &bsid))
+ ;
+ else if (unformat (i, "weight %d", &weight))
+ ;
+ else if (unformat (i, "spray"))
+ type = 1;
+ else if (unformat (i, "next %d", &sid))
+ {
+ n_segments += 1;
+ vec_add1 (segments, htonl (sid));
+ }
+ else
+ {
+ clib_warning ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (bsid == 0)
+ {
+ errmsg ("bsid not set");
+ return -99;
+ }
+
+ if (n_segments == 0)
+ {
+ errmsg ("no sid in segment stack");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
+
+ mp->bsid = htonl (bsid);
+ mp->weight = htonl (weight);
+ mp->type = type;
+ mp->n_segments = n_segments;
+ memcpy (mp->segments, segments, sizeof (u32) * n_segments);
+ vec_free (segments);
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
+api_sr_mpls_policy_del (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sr_mpls_policy_del_t *mp;
+ u32 bsid = 0;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "bsid %d", &bsid))
+ ;
+ else
+ {
+ clib_warning ("parse error '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (bsid == 0)
+ {
+ errmsg ("bsid not set");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M (SR_MPLS_POLICY_DEL, mp);
+
+ mp->bsid = htonl (bsid);
+
+ /* send it... */
+ S (mp);
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
+
+static int
api_bier_table_add_del (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
@@ -9452,6 +9594,7 @@ api_mpls_tunnel_add_del (vat_main_t * vam)
.as_u32 = 0,
};
ip6_address_t v6_next_hop_address = { {0} };
+ mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
int ret;
@@ -9473,6 +9616,8 @@ api_mpls_tunnel_add_del (vat_main_t * vam)
{
next_hop_proto_is_ip4 = 0;
}
+ else if (unformat (i, "via-label %d", &next_hop_via_label))
+ ;
else if (unformat (i, "l2-only"))
l2_only = 1;
else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
@@ -9494,6 +9639,7 @@ api_mpls_tunnel_add_del (vat_main_t * vam)
mp->mt_l2_only = l2_only;
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_n_out_labels = vec_len (labels);
@@ -23352,9 +23498,9 @@ _(sw_interface_bond_dump, "") \
_(sw_interface_slave_dump, \
"<vpp-if-name> | sw_if_index <id>") \
_(ip_table_add_del, \
- "table-id <n> [ipv6]\n") \
+ "table <n> [ipv6] [add | del]\n") \
_(ip_add_del_route, \
- "<addr>/<mask> via <addr> [table-id <n>]\n" \
+ "<addr>/<mask> via <addr | via-label <n>> [table-id <n>]\n" \
"[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
"[weight <n>] [drop] [local] [classify <n>] [del]\n" \
"[multipath] [count <n>]") \
@@ -23362,17 +23508,22 @@ _(ip_mroute_add_del, \
"<src> <grp>/<mask> [table-id <n>]\n" \
"[<intfc> | sw_if_index <id>] [local] [del]") \
_(mpls_table_add_del, \
- "table-id <n>\n") \
+ "table <n> [add | del]\n") \
_(mpls_route_add_del, \
- "<label> <eos> via <addr> [table-id <n>]\n" \
- "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
- "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
- "[multipath] [count <n>]") \
+ "<label> <eos> via <addr | next-hop-table <n> | via-label <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]") \
_(mpls_ip_bind_unbind, \
"<label> <addr/len>") \
_(mpls_tunnel_add_del, \
" via <addr> [table-id <n>]\n" \
"sw_if_index <id>] [l2] [del]") \
+_(sr_mpls_policy_add, \
+ "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
+_(sr_mpls_policy_del, \
+ "bsid <id>") \
_(bier_table_add_del, \
"<label> <sub-domain> <set> <bsl> [del]") \
_(bier_route_add_del, \
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 57268a9692c..85296bb2953 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -726,7 +726,7 @@ static void *vl_api_ip_add_del_route_t_print
if (mp->is_add == 0)
s = format (s, "del ");
- if (mp->next_hop_sw_if_index)
+ if (mp->next_hop_sw_if_index != ~0)
s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
if (mp->is_ipv6)
@@ -735,12 +735,18 @@ static void *vl_api_ip_add_del_route_t_print
else
s = format (s, "%U/%d ", format_ip4_address, mp->dst_address,
mp->dst_address_length);
+
+ if (mp->table_id != 0)
+ s = format (s, "vrf %d ", ntohl (mp->table_id));
+
if (mp->is_local)
s = format (s, "local ");
else if (mp->is_drop)
s = format (s, "drop ");
else if (mp->is_classify)
s = format (s, "classify %d", ntohl (mp->classify_table_index));
+ else if (mp->next_hop_via_label != htonl (MPLS_LABEL_INVALID))
+ s = format (s, "via via_label %d ", ntohl (mp->next_hop_via_label));
else
{
if (mp->is_ipv6)
@@ -749,11 +755,8 @@ static void *vl_api_ip_add_del_route_t_print
s = format (s, "via %U ", format_ip4_address, mp->next_hop_address);
}
- if (mp->table_id != 0)
- s = format (s, "vrf %d ", ntohl (mp->table_id));
-
if (mp->next_hop_weight != 1)
- s = format (s, "weight %d ", mp->next_hop_weight);
+ s = format (s, "weight %d ", (u32) mp->next_hop_weight);
if (mp->is_multipath)
s = format (s, "multipath ");
@@ -761,6 +764,91 @@ static void *vl_api_ip_add_del_route_t_print
if (mp->next_hop_table_id)
s = format (s, "lookup-in-vrf %d ", ntohl (mp->next_hop_table_id));
+ if (mp->next_hop_n_out_labels)
+ {
+ for (u8 i = 0; i < mp->next_hop_n_out_labels; i++)
+ {
+ s = format (s, "out-label %d ",
+ ntohl (mp->next_hop_out_label_stack[i].label));
+ }
+ }
+
+ FINISH;
+}
+
+static void *vl_api_mpls_route_add_del_t_print
+ (vl_api_mpls_route_add_del_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: mpls_route_add_del ");
+
+ if (mp->mr_is_add)
+ s = format (s, "add ");
+ else
+ s = format (s, "del ");
+
+ s = format (s, "%d ", ntohl (mp->mr_label));
+
+ if (mp->mr_eos)
+ s = format (s, "eos ");
+ else
+ s = format (s, "non-eos ");
+
+
+ if (mp->mr_next_hop_proto == DPO_PROTO_IP4)
+ {
+ ip4_address_t ip4_null = {.as_u32 = 0, };
+ if (memcmp (mp->mr_next_hop, &ip4_null, sizeof (ip4_null)))
+ s = format (s, "via %U ", format_ip4_address, mp->mr_next_hop);
+ else
+ s = format (s, "via lookup-in-ip4-table %d ",
+ ntohl (mp->mr_next_hop_table_id));
+ }
+ else if (mp->mr_next_hop_proto == DPO_PROTO_IP6)
+ {
+ ip6_address_t ip6_null = { {0}
+ };
+ if (memcmp (mp->mr_next_hop, &ip6_null, sizeof (ip6_null)))
+ s = format (s, "via %U ", format_ip6_address, mp->mr_next_hop);
+ else
+ s = format (s, "via lookup-in-ip6-table %d ",
+ ntohl (mp->mr_next_hop_table_id));
+ }
+ else if (mp->mr_next_hop_proto == DPO_PROTO_ETHERNET)
+ {
+ s = format (s, "via l2-input-on ");
+ }
+ else if (mp->mr_next_hop_proto == DPO_PROTO_MPLS)
+ {
+ if (mp->mr_next_hop_via_label != htonl (MPLS_LABEL_INVALID))
+ s =
+ format (s, "via via-label %d ", ntohl (mp->mr_next_hop_via_label));
+ else
+ s = format (s, "via next-hop-table %d ",
+ ntohl (mp->mr_next_hop_table_id));
+ }
+ if (mp->mr_next_hop_sw_if_index != ~0)
+ s = format (s, "sw_if_index %d ", ntohl (mp->mr_next_hop_sw_if_index));
+
+ if (mp->mr_next_hop_weight != 1)
+ s = format (s, "weight %d ", (u32) mp->mr_next_hop_weight);
+
+ if (mp->mr_is_multipath)
+ s = format (s, "multipath ");
+
+ if (mp->mr_is_classify)
+ s = format (s, "classify %d", ntohl (mp->mr_classify_table_index));
+
+ if (mp->mr_next_hop_n_out_labels)
+ {
+ for (u8 i = 0; i < mp->mr_next_hop_n_out_labels; i++)
+ {
+ s = format (s, "out-label %d ",
+ ntohl (mp->mr_next_hop_out_label_stack[i].label));
+ }
+ }
+
FINISH;
}
@@ -770,12 +858,28 @@ static void *vl_api_ip_table_add_del_t_print
u8 *s;
s = format (0, "SCRIPT: ip_table_add_del ");
- if (!mp->is_add)
+ if (mp->is_add)
+ s = format (s, "add ");
+ else
s = format (s, "del ");
if (mp->is_ipv6)
s = format (s, "ip6 ");
- if (mp->table_id != 0)
- s = format (s, "vrf %d ", ntohl (mp->table_id));
+ s = format (s, "table %d ", ntohl (mp->table_id));
+
+ FINISH;
+}
+
+static void *vl_api_mpls_table_add_del_t_print
+ (vl_api_mpls_table_add_del_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: mpls_table_add_del ");
+ if (mp->mt_is_add)
+ s = format (s, "add ");
+ else
+ s = format (s, "del ");
+ s = format (s, "table %d ", ntohl (mp->mt_table_id));
FINISH;
}
@@ -838,6 +942,42 @@ static void *vl_api_mpls_tunnel_add_del_t_print
FINISH;
}
+static void *vl_api_sr_mpls_policy_add_t_print
+ (vl_api_sr_mpls_policy_add_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sr_mpls_policy_add ");
+
+ s = format (s, "bsid %d ", ntohl (mp->bsid));
+
+ if (mp->weight != htonl ((u32) 1))
+ s = format (s, "%d ", ntohl (mp->weight));
+
+ if (mp->type)
+ s = format (s, "spray ");
+
+ if (mp->n_segments)
+ {
+ for (int i = 0; i < mp->n_segments; i++)
+ s = format (s, "next %d ", ntohl (mp->segments[i]));
+ }
+
+ FINISH;
+}
+
+static void *vl_api_sr_mpls_policy_del_t_print
+ (vl_api_sr_mpls_policy_del_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sr_mpls_policy_del ");
+
+ s = format (s, "bsid %d ", ntohl (mp->bsid));
+
+ FINISH;
+}
+
static void *vl_api_sw_interface_set_unnumbered_t_print
(vl_api_sw_interface_set_unnumbered_t * mp, void *handle)
{
@@ -3574,9 +3714,13 @@ _(TAP_DELETE_V2, tap_delete_v2) \
_(SW_INTERFACE_TAP_V2_DUMP, sw_interface_tap_v2_dump) \
_(IP_ADD_DEL_ROUTE, ip_add_del_route) \
_(IP_TABLE_ADD_DEL, ip_table_add_del) \
+_(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \
+_(MPLS_TABLE_ADD_DEL, mpls_table_add_del) \
_(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
_(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
_(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \
+_(SR_MPLS_POLICY_ADD, sr_mpls_policy_add) \
+_(SR_MPLS_POLICY_DEL, sr_mpls_policy_del) \
_(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
_(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
_(CREATE_VLAN_SUBIF, create_vlan_subif) \