summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_test.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-10-03 08:20:21 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-05 09:50:26 +0000
commit6f6311560380d0e992f710558e213df1b098ef94 (patch)
tree237e34a2165ed5d2fc0848a1daec457ce57acc3e /src/vnet/fib/fib_test.c
parentd3c008d108aa2187d1a2afe2833b4de25ca2c2ab (diff)
Distributed Virtual Router Support
A distributed virtual router works by attmpeting to switch a packet, but on failing to find a local consumer (i.e. the packet is destined to a locally attached host) then the packet is sent unmodified 'upstream' to where the rest of the 'distributed' router is present. When L3 switching a packet this means the L2 header must not be modifed. This patch adds a 'l2-bridge' object to the L3 FIB which re-injects packets from the L3 path back into the L2 path - use with extreme caution. Change-Id: I069724eb45956647d7980cbe40a80a788ee6ee82 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_test.c')
-rw-r--r--src/vnet/fib/fib_test.c130
1 files changed, 53 insertions, 77 deletions
diff --git a/src/vnet/fib/fib_test.c b/src/vnet/fib/fib_test.c
index 64d9047163b..03c9ee75f48 100644
--- a/src/vnet/fib/fib_test.c
+++ b/src/vnet/fib/fib_test.c
@@ -27,9 +27,11 @@
#include <vnet/bfd/bfd_main.h>
#include <vnet/dpo/interface_rx_dpo.h>
#include <vnet/dpo/replicate_dpo.h>
+#include <vnet/dpo/l2_bridge_dpo.h>
#include <vnet/mpls/mpls.h>
+#include <vnet/fib/fib_test.h>
#include <vnet/fib/fib_path_list.h>
#include <vnet/fib/fib_entry_src.h>
#include <vnet/fib/fib_walk.h>
@@ -266,83 +268,6 @@ fib_test_build_rewrite (u8 *eth_addr)
return (rewrite);
}
-typedef enum fib_test_lb_bucket_type_t_ {
- FT_LB_LABEL_O_ADJ,
- FT_LB_LABEL_STACK_O_ADJ,
- FT_LB_LABEL_O_LB,
- FT_LB_O_LB,
- FT_LB_SPECIAL,
- FT_LB_ADJ,
- FT_LB_INTF,
-} fib_test_lb_bucket_type_t;
-
-typedef struct fib_test_lb_bucket_t_ {
- fib_test_lb_bucket_type_t type;
-
- union
- {
- struct
- {
- mpls_eos_bit_t eos;
- mpls_label_t label;
- u8 ttl;
- adj_index_t adj;
- } label_o_adj;
- struct
- {
- mpls_eos_bit_t eos;
- mpls_label_t label_stack[8];
- u8 label_stack_size;
- u8 ttl;
- adj_index_t adj;
- } label_stack_o_adj;
- struct
- {
- mpls_eos_bit_t eos;
- mpls_label_t label;
- u8 ttl;
- index_t lb;
- } label_o_lb;
- struct
- {
- index_t adj;
- } adj;
- struct
- {
- index_t lb;
- } lb;
- struct
- {
- index_t adj;
- } special;
- };
-} fib_test_lb_bucket_t;
-
-typedef enum fib_test_rep_bucket_type_t_ {
- FT_REP_LABEL_O_ADJ,
- FT_REP_DISP_MFIB_LOOKUP,
- FT_REP_INTF,
-} fib_test_rep_bucket_type_t;
-
-typedef struct fib_test_rep_bucket_t_ {
- fib_test_rep_bucket_type_t type;
-
- union
- {
- struct
- {
- mpls_eos_bit_t eos;
- mpls_label_t label;
- u8 ttl;
- adj_index_t adj;
- } label_o_adj;
- struct
- {
- adj_index_t adj;
- } adj;
- };
-} fib_test_rep_bucket_t;
-
#define FIB_TEST_LB(_cond, _comment, _args...) \
{ \
if (!FIB_TEST_I(_cond, _comment, ##_args)) { \
@@ -598,6 +523,16 @@ fib_test_validate_lb_v (const load_balance_t *lb,
bucket,
exp->adj.adj);
break;
+ case FT_LB_L2:
+ FIB_TEST_I((DPO_L2_BRIDGE == dpo->dpoi_type),
+ "bucket %d stacks on %U",
+ bucket,
+ format_dpo_type, dpo->dpoi_type);
+ FIB_TEST_LB((exp->adj.adj == dpo->dpoi_index),
+ "bucket %d stacks on adj %d",
+ bucket,
+ exp->adj.adj);
+ break;
case FT_LB_O_LB:
FIB_TEST_I((DPO_LOAD_BALANCE == dpo->dpoi_type),
"bucket %d stacks on %U",
@@ -4067,6 +4002,45 @@ fib_test_v4 (void)
format_ip_flow_hash_config, lb->lb_hash_config);
/*
+ * A route via an L2 Bridge
+ */
+ fei = fib_table_entry_path_add(fib_index,
+ &pfx_10_10_10_3_s_32,
+ FIB_SOURCE_API,
+ FIB_ENTRY_FLAG_NONE,
+ DPO_PROTO_ETHERNET,
+ &zero_addr,
+ tm->hw[0]->sw_if_index,
+ ~0,
+ 1,
+ NULL,
+ FIB_ROUTE_PATH_FLAG_NONE);
+ dpo_id_t l2_dpo = DPO_INVALID;
+ l2_bridge_dpo_add_or_lock(tm->hw[0]->sw_if_index, &l2_dpo);
+ fib_test_lb_bucket_t ip_o_l2 = {
+ .type = FT_LB_L2,
+ .adj = {
+ .adj = l2_dpo.dpoi_index,
+ },
+ };
+
+ FIB_TEST(fib_test_validate_entry(fei,
+ FIB_FORW_CHAIN_TYPE_UNICAST_IP4,
+ 1,
+ &ip_o_l2),
+ "10.10.10.3 via L2 on Eth0");
+ fib_table_entry_path_remove(fib_index,
+ &pfx_10_10_10_3_s_32,
+ FIB_SOURCE_API,
+ DPO_PROTO_ETHERNET,
+ &zero_addr,
+ tm->hw[0]->sw_if_index,
+ fib_index,
+ 1,
+ FIB_ROUTE_PATH_FLAG_NONE);
+ dpo_reset(&l2_dpo);
+
+ /*
* CLEANUP
* remove adj-fibs:
*/
@@ -4165,6 +4139,8 @@ fib_test_v4 (void)
pool_elts(load_balance_map_pool));
FIB_TEST((lb_count == pool_elts(load_balance_pool)), "LB pool size is %d",
pool_elts(load_balance_pool));
+ FIB_TEST((0 == pool_elts(l2_bridge_dpo_pool)), "L2 DPO pool size is %d",
+ pool_elts(l2_bridge_dpo_pool));
return 0;
}