aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
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
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')
-rw-r--r--src/vnet/fib/fib_api.h1
-rw-r--r--src/vnet/fib/fib_path.c64
-rw-r--r--src/vnet/fib/fib_table.c3
-rw-r--r--src/vnet/fib/fib_test.c130
-rw-r--r--src/vnet/fib/fib_test.h2
5 files changed, 100 insertions, 100 deletions
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h
index f5a107ca352..c369e8f8588 100644
--- a/src/vnet/fib/fib_api.h
+++ b/src/vnet/fib/fib_api.h
@@ -40,6 +40,7 @@ add_del_route_t_handler (u8 is_multipath,
u8 is_resolve_attached,
u8 is_interface_rx,
u8 is_rpf_id,
+ u8 is_l2_bridged,
u32 fib_index,
const fib_prefix_t * prefix,
dpo_proto_t next_hop_proto,
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index f126333425a..889d17def9c 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -23,6 +23,7 @@
#include <vnet/dpo/lookup_dpo.h>
#include <vnet/dpo/interface_rx_dpo.h>
#include <vnet/dpo/mpls_disposition.h>
+#include <vnet/dpo/l2_bridge_dpo.h>
#include <vnet/adj/adj.h>
#include <vnet/adj/adj_mcast.h>
@@ -771,11 +772,18 @@ fib_path_unresolve (fib_path_t *path)
}
break;
case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
- case FIB_PATH_TYPE_ATTACHED:
adj_child_remove(path->fp_dpo.dpoi_index,
path->fp_sibling);
adj_unlock(path->fp_dpo.dpoi_index);
break;
+ case FIB_PATH_TYPE_ATTACHED:
+ if (DPO_PROTO_ETHERNET != path->fp_nh_proto)
+ {
+ adj_child_remove(path->fp_dpo.dpoi_index,
+ path->fp_sibling);
+ adj_unlock(path->fp_dpo.dpoi_index);
+ }
+ break;
case FIB_PATH_TYPE_EXCLUSIVE:
dpo_reset(&path->exclusive.fp_ex_dpo);
break;
@@ -1594,28 +1602,35 @@ fib_path_resolve (fib_node_index_t path_index)
fib_path_attached_next_hop_set(path);
break;
case FIB_PATH_TYPE_ATTACHED:
- /*
- * path->attached.fp_interface
- */
- if (!vnet_sw_interface_is_admin_up(vnet_get_main(),
- path->attached.fp_interface))
- {
- path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED;
- }
- dpo_set(&path->fp_dpo,
- DPO_ADJACENCY,
- path->fp_nh_proto,
- fib_path_attached_get_adj(path,
- dpo_proto_to_link(path->fp_nh_proto)));
-
- /*
- * become a child of the adjacency so we receive updates
- * when the interface state changes
- */
- path->fp_sibling = adj_child_add(path->fp_dpo.dpoi_index,
- FIB_NODE_TYPE_PATH,
- fib_path_get_index(path));
+ if (DPO_PROTO_ETHERNET == path->fp_nh_proto)
+ {
+ l2_bridge_dpo_add_or_lock(path->attached.fp_interface,
+ &path->fp_dpo);
+ }
+ else
+ {
+ /*
+ * path->attached.fp_interface
+ */
+ if (!vnet_sw_interface_is_admin_up(vnet_get_main(),
+ path->attached.fp_interface))
+ {
+ path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED;
+ }
+ dpo_set(&path->fp_dpo,
+ DPO_ADJACENCY,
+ path->fp_nh_proto,
+ fib_path_attached_get_adj(path,
+ dpo_proto_to_link(path->fp_nh_proto)));
+ /*
+ * become a child of the adjacency so we receive updates
+ * when the interface state changes
+ */
+ path->fp_sibling = adj_child_add(path->fp_dpo.dpoi_index,
+ FIB_NODE_TYPE_PATH,
+ fib_path_get_index(path));
+ }
break;
case FIB_PATH_TYPE_RECURSIVE:
{
@@ -1996,6 +2011,11 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
dpo_copy(dpo, &path->exclusive.fp_ex_dpo);
break;
case FIB_PATH_TYPE_ATTACHED:
+ if (DPO_PROTO_ETHERNET == path->fp_nh_proto)
+ {
+ dpo_copy(dpo, &path->fp_dpo);
+ break;
+ }
switch (fct)
{
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index 6daa61c2612..d5625d83673 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -481,7 +481,8 @@ fib_table_route_path_fixup (const fib_prefix_t *prefix,
}
if (fib_prefix_is_host(prefix) &&
ip46_address_is_zero(&path->frp_addr) &&
- path->frp_sw_if_index != ~0)
+ path->frp_sw_if_index != ~0 &&
+ path->frp_proto != DPO_PROTO_ETHERNET)
{
path->frp_addr = prefix->fp_addr;
path->frp_flags |= FIB_ROUTE_PATH_ATTACHED;
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;
}
diff --git a/src/vnet/fib/fib_test.h b/src/vnet/fib/fib_test.h
index 3692f57386d..5adc52ec658 100644
--- a/src/vnet/fib/fib_test.h
+++ b/src/vnet/fib/fib_test.h
@@ -26,6 +26,7 @@ typedef enum fib_test_lb_bucket_type_t_ {
FT_LB_SPECIAL,
FT_LB_ADJ,
FT_LB_INTF,
+ FT_LB_L2,
} fib_test_lb_bucket_type_t;
typedef struct fib_test_lb_bucket_t_ {
@@ -72,6 +73,7 @@ typedef struct 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;