summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-02-15 00:38:27 -0800
committerFlorin Coras <florin.coras@gmail.com>2017-02-20 10:03:31 +0000
commit52456fca3d922d71098d4c1aef8dcee6c5459f8c (patch)
tree40a47c5510a991a399dfc4c5bc51987fc02cba37
parent5a8123bda0261158457e38bfb4922aa5961389ff (diff)
CLI extension to add multiple (S,G)s at once and time it
Change-Id: Id17060fd0e8ac80c8cf1999b0b82d0241b3b969a Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r--src/vnet/ip/lookup.c86
1 files changed, 76 insertions, 10 deletions
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 6c5611d3955..0ef0e7a6deb 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -784,7 +784,10 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
u32 fib_index;
mfib_itf_flags_t iflags = 0;
mfib_entry_flags_t eflags = 0;
+ u32 gcount, scount, ss, gg, incr;
+ f64 timet[2];
+ gcount = scount = 1;
vnm = vnet_get_main ();
is_del = 0;
table_id = 0;
@@ -804,6 +807,10 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
is_del = 1;
else if (unformat (line_input, "add"))
is_del = 0;
+ else if (unformat (line_input, "scount %d", &scount))
+ ;
+ else if (unformat (line_input, "gcount %d", &gcount))
+ ;
else if (unformat (line_input, "%U %U",
unformat_ip4_address,
&pfx.fp_src_addr.ip4,
@@ -885,24 +892,83 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
}
}
- if (is_del && 0 == rpath.frp_weight)
+ timet[0] = vlib_time_now (vm);
+
+ if (FIB_PROTOCOL_IP4 == pfx.fp_proto)
{
- mfib_table_entry_delete (fib_index, &pfx, MFIB_SOURCE_CLI);
+ incr = 1 << (32 - (pfx.fp_len % 32));
}
- else if (eflags)
+ else
{
- mfib_table_entry_update (fib_index, &pfx, MFIB_SOURCE_CLI, eflags);
+ incr = 1 << (128 - (pfx.fp_len % 128));
}
- else
+
+ for (ss = 0; ss < scount; ss++)
{
- if (is_del)
- mfib_table_entry_path_remove (fib_index,
- &pfx, MFIB_SOURCE_CLI, &rpath);
+ for (gg = 0; gg < gcount; gg++)
+ {
+ if (is_del && 0 == rpath.frp_weight)
+ {
+ /* no path provided => route delete */
+ mfib_table_entry_delete (fib_index, &pfx, MFIB_SOURCE_CLI);
+ }
+ else if (eflags)
+ {
+ mfib_table_entry_update (fib_index, &pfx, MFIB_SOURCE_CLI,
+ eflags);
+ }
+ else
+ {
+ if (is_del)
+ mfib_table_entry_path_remove (fib_index,
+ &pfx, MFIB_SOURCE_CLI, &rpath);
+ else
+ mfib_table_entry_path_update (fib_index,
+ &pfx, MFIB_SOURCE_CLI, &rpath,
+ iflags);
+ }
+
+ if (FIB_PROTOCOL_IP4 == pfx.fp_proto)
+ {
+ pfx.fp_grp_addr.ip4.as_u32 =
+ clib_host_to_net_u32 (incr +
+ clib_net_to_host_u32 (pfx.
+ fp_grp_addr.ip4.
+ as_u32));
+ }
+ else
+ {
+ int bucket = (incr < 64 ? 0 : 1);
+ pfx.fp_grp_addr.ip6.as_u64[bucket] =
+ clib_host_to_net_u64 (incr +
+ clib_net_to_host_u64 (pfx.
+ fp_grp_addr.ip6.as_u64
+ [bucket]));
+
+ }
+ }
+ if (FIB_PROTOCOL_IP4 == pfx.fp_proto)
+ {
+ pfx.fp_src_addr.ip4.as_u32 =
+ clib_host_to_net_u32 (1 +
+ clib_net_to_host_u32 (pfx.fp_src_addr.
+ ip4.as_u32));
+ }
else
- mfib_table_entry_path_update (fib_index,
- &pfx, MFIB_SOURCE_CLI, &rpath, iflags);
+ {
+ pfx.fp_src_addr.ip6.as_u64[1] =
+ clib_host_to_net_u64 (1 +
+ clib_net_to_host_u64 (pfx.fp_src_addr.
+ ip6.as_u64[1]));
+ }
}
+ timet[1] = vlib_time_now (vm);
+
+ if (scount > 1 || gcount > 1)
+ vlib_cli_output (vm, "%.6e routes/sec",
+ (scount * gcount) / (timet[1] - timet[0]));
+
done:
return error;
}