summaryrefslogtreecommitdiffstats
path: root/src/vpp
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-05-01 05:17:55 -0700
committerOle Trøan <otroan@employees.org>2019-06-18 13:31:39 +0000
commit097fa66b986f06281f603767d321ab13ab6c88c3 (patch)
treeed052819615d08ee4bd0afbc34de7e64e4598105 /src/vpp
parent39baa32186fd3e4b20d9f58afbbfe7b8daebed62 (diff)
fib: fib api updates
Enhance the route add/del APIs to take a set of paths rather than just one. Most unicast routing protocols calcualte all the available paths in one run of the algorithm so updating all the paths at once is beneficial for the client. two knobs control the behaviour: is_multipath - if set the the set of paths passed will be added to those that already exist, otherwise the set will replace them. is_add - add or remove the set is_add=0, is_multipath=1 and an empty set, results in deleting the route. It is also considerably faster to add multiple paths at once, than one at a time: vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.11 100000 routes in .572240 secs, 174751.80 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.12 100000 routes in .528383 secs, 189256.54 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.13 100000 routes in .757131 secs, 132077.52 routes/sec vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.14 100000 routes in .878317 secs, 113854.12 routes/sec vat# ip_route_add_del 1.1.1.1/32 count 100000 multipath via 10.10.10.11 via 10.10.10.12 via 10.10.10.13 via 10.10.10.14 100000 routes in .900212 secs, 111084.93 routes/sec Change-Id: I416b93f7684745099c1adb0b33edac58c9339c1a Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp')
-rw-r--r--src/vpp/api/api.c2
-rw-r--r--src/vpp/api/custom_dump.c202
-rw-r--r--src/vpp/api/types.c47
-rw-r--r--src/vpp/api/types.h1
4 files changed, 106 insertions, 146 deletions
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index b6e7c848764..9c2381189a2 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -540,7 +540,7 @@ vpe_api_hookup (vlib_main_t * vm)
*/
am->is_mp_safe[VL_API_CONTROL_PING] = 1;
am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
- am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
+ am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
/*
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 4d764d40d16..d754c3ade1c 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -21,6 +21,7 @@
#include <vnet/ip/ip.h>
#include <vnet/ip/ip_neighbor.h>
#include <vnet/ip/ip_types_api.h>
+#include <vnet/fib/fib_api.h>
#include <vnet/unix/tuntap.h>
#include <vnet/mpls/mpls.h>
#include <vnet/dhcp/dhcp_proxy.h>
@@ -728,62 +729,19 @@ __clib_unused
FINISH;
}
-static void *vl_api_ip_add_del_route_t_print
- (vl_api_ip_add_del_route_t * mp, void *handle)
+static void *vl_api_ip_route_add_del_t_print
+ (vl_api_ip_route_add_del_t * mp, void *handle)
{
- u8 *s;
+ u8 *s, p;
- s = format (0, "SCRIPT: ip_add_del_route ");
+ s = format (0, "SCRIPT: ip_route_add_del ");
if (mp->is_add == 0)
s = format (s, "del ");
- if (mp->is_ipv6)
- s = format (s, "%U/%d ", format_ip6_address, mp->dst_address,
- mp->dst_address_length);
- 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)
- s = format (s, "via %U ", format_ip6_address, mp->next_hop_address);
- else
- s = format (s, "via %U ", format_ip4_address, mp->next_hop_address);
- if (mp->next_hop_sw_if_index != ~0)
- s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
+ s = format (s, "%U", format_vl_api_prefix, &mp->route.prefix);
- }
-
- if (mp->next_hop_weight != 1)
- s = format (s, "weight %d ", (u32) mp->next_hop_weight);
-
- if (mp->is_multipath)
- s = format (s, "multipath ");
-
- 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)
- {
- u8 i;
- for (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));
- }
- }
+ for (p = 0; p < mp->route.n_paths; p++)
+ s = format (s, " [%U]", format_vl_api_fib_path, &mp->route.paths[p]);
FINISH;
}
@@ -791,7 +749,7 @@ static void *vl_api_ip_add_del_route_t_print
static void *vl_api_mpls_route_add_del_t_print
(vl_api_mpls_route_add_del_t * mp, void *handle)
{
- u8 *s;
+ u8 *s, p;
s = format (0, "SCRIPT: mpls_route_add_del ");
@@ -800,67 +758,21 @@ static void *vl_api_mpls_route_add_del_t_print
else
s = format (s, "del ");
- s = format (s, "%d ", ntohl (mp->mr_label));
+ s = format (s, "table %d ", ntohl (mp->mr_route.mr_table_id));
+ s = format (s, "%d ", ntohl (mp->mr_route.mr_label));
- if (mp->mr_eos)
+ if (mp->mr_route.mr_eos)
s = format (s, "eos ");
else
s = format (s, "non-eos ");
+ if (mp->mr_route.mr_is_multicast)
+ s = format (s, "multicast ");
- 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);
+ for (p = 0; p < mp->mr_route.mr_n_paths; p++)
+ s =
+ format (s, " [%U]", format_vl_api_fib_path, &mp->mr_route.mr_paths[p]);
- 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)
- {
- u8 i;
- for (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;
}
@@ -875,9 +787,10 @@ static void *vl_api_ip_table_add_del_t_print
s = format (s, "add ");
else
s = format (s, "del ");
- if (mp->is_ipv6)
+ if (mp->table.is_ip6)
s = format (s, "ip6 ");
- s = format (s, "table %d ", ntohl (mp->table_id));
+ s = format (s, "table %d ", ntohl (mp->table.table_id));
+ s = format (s, "%s ", mp->table.name);
FINISH;
}
@@ -892,7 +805,7 @@ static void *vl_api_mpls_table_add_del_t_print
s = format (s, "add ");
else
s = format (s, "del ");
- s = format (s, "table %d ", ntohl (mp->mt_table_id));
+ s = format (s, "table %d ", ntohl (mp->mt_table.mt_table_id));
FINISH;
}
@@ -933,38 +846,27 @@ static void *vl_api_proxy_arp_intfc_enable_disable_t_print
static void *vl_api_mpls_tunnel_add_del_t_print
(vl_api_mpls_tunnel_add_del_t * mp, void *handle)
{
- u8 *s;
+ u8 *s, p;
s = format (0, "SCRIPT: mpls_tunnel_add_del ");
if (mp->mt_is_add == 0)
- s = format (s, "del sw_if_index %d ", ntohl (mp->mt_sw_if_index));
-
- 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, "del sw_if_index %d ", ntohl (mp->mt_tunnel.mt_sw_if_index));
else
- s = format (s, "via %U ", format_ip6_address, mp->mt_next_hop);
+ s = format (s, "sw_if_index %d ", ntohl (mp->mt_tunnel.mt_sw_if_index));
- 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)
+ if (mp->mt_tunnel.mt_l2_only)
s = format (s, "l2-only ");
+ if (mp->mt_tunnel.mt_is_multicast)
+ s = format (s, "multicast ");
+ if (mp->mt_tunnel.mt_tunnel_index)
+ s = format (s, "tunnel-index ");
- 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));
- }
- }
+ for (p = 0; p < mp->mt_tunnel.mt_n_paths; p++)
+ s = format (s, " [%U]", format_vl_api_fib_path,
+ &mp->mt_tunnel.mt_paths[p]);
FINISH;
}
@@ -2624,38 +2526,47 @@ static void *vl_api_mpls_tunnel_dump_t_print
u8 *s;
s = format (0, "SCRIPT: mpls_tunnel_dump ");
-
s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index));
FINISH;
}
-static void *vl_api_mpls_fib_dump_t_print
- (vl_api_mpls_fib_dump_t * mp, void *handle)
+static void *vl_api_mpls_table_dump_t_print
+ (vl_api_mpls_table_dump_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: mpls_table_decap_dump ");
+
+ FINISH;
+}
+
+static void *vl_api_mpls_route_dump_t_print
+ (vl_api_mpls_route_dump_t * mp, void *handle)
{
u8 *s;
- s = format (0, "SCRIPT: mpls_fib_decap_dump ");
+ s = format (0, "SCRIPT: mpls_route_decap_dump ");
FINISH;
}
-static void *vl_api_ip_fib_dump_t_print
- (vl_api_ip_fib_dump_t * mp, void *handle)
+static void *vl_api_ip_table_dump_t_print
+ (vl_api_ip_table_dump_t * mp, void *handle)
{
u8 *s;
- s = format (0, "SCRIPT: ip_fib_dump ");
+ s = format (0, "SCRIPT: ip_table_dump ");
FINISH;
}
-static void *vl_api_ip6_fib_dump_t_print
- (vl_api_ip6_fib_dump_t * mp, void *handle)
+static void *vl_api_ip_route_dump_t_print
+ (vl_api_ip_route_dump_t * mp, void *handle)
{
u8 *s;
- s = format (0, "SCRIPT: ip6_fib_dump ");
+ s = format (0, "SCRIPT: ip_route_dump ");
FINISH;
}
@@ -3782,10 +3693,10 @@ _(BOND_DETACH_SLAVE, bond_detach_slave) \
_(TAP_CREATE_V2, tap_create_v2) \
_(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) \
+_(IP_ROUTE_ADD_DEL, ip_route_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) \
@@ -3876,7 +3787,8 @@ _(AF_PACKET_CREATE, af_packet_create) \
_(AF_PACKET_DELETE, af_packet_delete) \
_(AF_PACKET_DUMP, af_packet_dump) \
_(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
-_(MPLS_FIB_DUMP, mpls_fib_dump) \
+_(MPLS_TABLE_DUMP, mpls_table_dump) \
+_(MPLS_ROUTE_DUMP, mpls_route_dump) \
_(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \
_(CLASSIFY_TABLE_IDS,classify_table_ids) \
_(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \
@@ -3941,8 +3853,8 @@ _(FLOW_CLASSIFY_DUMP, flow_classify_dump) \
_(GET_FIRST_MSG_ID, get_first_msg_id) \
_(IOAM_ENABLE, ioam_enable) \
_(IOAM_DISABLE, ioam_disable) \
-_(IP_FIB_DUMP, ip_fib_dump) \
-_(IP6_FIB_DUMP, ip6_fib_dump) \
+_(IP_TABLE_DUMP, ip_table_dump) \
+_(IP_ROUTE_DUMP, ip_route_dump) \
_(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \
_(HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \
diff --git a/src/vpp/api/types.c b/src/vpp/api/types.c
index a4766c298c2..3d556b72bfd 100644
--- a/src/vpp/api/types.c
+++ b/src/vpp/api/types.c
@@ -172,3 +172,50 @@ unformat_vl_api_prefix (unformat_input_t * input, va_list * args)
return (0);
}
+uword
+unformat_vl_api_mprefix (unformat_input_t * input, va_list * args)
+{
+ vl_api_mprefix_t *pfx = va_arg (*args, vl_api_mprefix_t *);
+
+ if (unformat (input, "%U/%d",
+ unformat_vl_api_ip4_address, &pfx->grp_address.ip4,
+ &pfx->grp_address_length))
+ pfx->af = ADDRESS_IP4;
+ else if (unformat (input, "%U/%d",
+ unformat_vl_api_ip6_address, &pfx->grp_address.ip6,
+ &pfx->grp_address_length))
+ pfx->af = ADDRESS_IP6;
+ else if (unformat (input, "%U %U",
+ unformat_vl_api_ip4_address, &pfx->src_address.ip4,
+ unformat_vl_api_ip4_address, &pfx->grp_address.ip4))
+ {
+ pfx->af = ADDRESS_IP4;
+ pfx->grp_address_length = 64;
+ }
+ else if (unformat (input, "%U %U",
+ unformat_vl_api_ip6_address, &pfx->src_address.ip6,
+ unformat_vl_api_ip6_address, &pfx->grp_address.ip6))
+ {
+ pfx->af = ADDRESS_IP6;
+ pfx->grp_address_length = 256;
+ }
+ else if (unformat (input, "%U",
+ unformat_vl_api_ip4_address, &pfx->grp_address.ip4))
+ {
+ pfx->af = ADDRESS_IP4;
+ pfx->grp_address_length = 32;
+ clib_memset(&pfx->src_address, 0, sizeof(pfx->src_address));
+ }
+ else if (unformat (input, "%U",
+ unformat_vl_api_ip6_address, &pfx->grp_address.ip6))
+ {
+ pfx->af = ADDRESS_IP6;
+ pfx->grp_address_length = 128;
+ clib_memset(&pfx->src_address, 0, sizeof(pfx->src_address));
+ }
+ else
+ return (0);
+
+ return (1);
+}
+
diff --git a/src/vpp/api/types.h b/src/vpp/api/types.h
index 40d80a09546..95797b4da2e 100644
--- a/src/vpp/api/types.h
+++ b/src/vpp/api/types.h
@@ -32,6 +32,7 @@ extern uword unformat_vl_api_address (unformat_input_t * input, va_list * args);
extern uword unformat_vl_api_ip4_address (unformat_input_t * input, va_list * args);
extern uword unformat_vl_api_ip6_address (unformat_input_t * input, va_list * args);
extern uword unformat_vl_api_prefix (unformat_input_t * input, va_list * args);
+extern uword unformat_vl_api_mprefix (unformat_input_t * input, va_list * args);
extern u8 *format_vl_api_address (u8 * s, va_list * args);
extern u8 *format_vl_api_address_family (u8 * s, va_list * args);