aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_entry.c1
-rw-r--r--src/vnet/fib/fib_entry.h5
-rw-r--r--src/vnet/fib/fib_entry_delegate.c1
-rw-r--r--src/vnet/fib/fib_entry_src.c14
-rw-r--r--src/vnet/fib/fib_entry_src_special.c1
-rw-r--r--src/vnet/fib/fib_node.h4
-rw-r--r--src/vnet/fib/fib_path.c385
-rw-r--r--src/vnet/fib/fib_path.h3
-rw-r--r--src/vnet/fib/fib_path_list.c5
-rw-r--r--src/vnet/fib/fib_table.c1
-rw-r--r--src/vnet/fib/fib_table.h2
-rw-r--r--src/vnet/fib/fib_test.c67
-rw-r--r--src/vnet/fib/fib_test.h24
-rw-r--r--src/vnet/fib/fib_types.c5
-rw-r--r--src/vnet/fib/fib_types.h113
15 files changed, 561 insertions, 70 deletions
diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c
index 4c9b1abd881..74c6a4a587b 100644
--- a/src/vnet/fib/fib_entry.c
+++ b/src/vnet/fib/fib_entry.c
@@ -394,6 +394,7 @@ fib_entry_chain_type_mcast_to_ucast (fib_forward_chain_type_t fct)
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
case FIB_FORW_CHAIN_TYPE_ETHERNET:
case FIB_FORW_CHAIN_TYPE_NSH:
+ case FIB_FORW_CHAIN_TYPE_BIER:
break;
}
diff --git a/src/vnet/fib/fib_entry.h b/src/vnet/fib/fib_entry.h
index 7e4b52acffd..cd2a685b765 100644
--- a/src/vnet/fib/fib_entry.h
+++ b/src/vnet/fib/fib_entry.h
@@ -61,6 +61,10 @@ typedef enum fib_source_t_ {
*/
FIB_SOURCE_PLUGIN_HI,
/**
+ * From the BIER subsystem
+ */
+ FIB_SOURCE_BIER,
+ /**
* From the control plane API
*/
FIB_SOURCE_API,
@@ -141,6 +145,7 @@ STATIC_ASSERT (sizeof(fib_source_t) == 1,
[FIB_SOURCE_SPECIAL] = "special", \
[FIB_SOURCE_INTERFACE] = "interface", \
[FIB_SOURCE_PROXY] = "proxy", \
+ [FIB_SOURCE_BIER] = "BIER", \
[FIB_SOURCE_API] = "API", \
[FIB_SOURCE_CLI] = "CLI", \
[FIB_SOURCE_ADJ] = "adjacency", \
diff --git a/src/vnet/fib/fib_entry_delegate.c b/src/vnet/fib/fib_entry_delegate.c
index 41af14f2245..4bf37df0a7e 100644
--- a/src/vnet/fib/fib_entry_delegate.c
+++ b/src/vnet/fib/fib_entry_delegate.c
@@ -122,6 +122,7 @@ fib_entry_chain_type_to_delegate_type (fib_forward_chain_type_t fct)
return (FIB_ENTRY_DELEGATE_CHAIN_ETHERNET);
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_BIER:
break;
case FIB_FORW_CHAIN_TYPE_NSH:
return (FIB_ENTRY_DELEGATE_CHAIN_NSH);
diff --git a/src/vnet/fib/fib_entry_src.c b/src/vnet/fib/fib_entry_src.c
index 173df74f0a4..667aa485f7c 100644
--- a/src/vnet/fib/fib_entry_src.c
+++ b/src/vnet/fib/fib_entry_src.c
@@ -275,6 +275,7 @@ fib_entry_src_get_path_forwarding (fib_node_index_t path_index,
case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_BIER:
/*
* EOS traffic with no label to stack, we need the IP Adj
*/
@@ -480,8 +481,8 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
}
else
{
+ fib_protocol_t flow_hash_proto;
flow_hash_config_t fhc;
- fib_protocol_t fp;
/*
* if the protocol for the LB we are building does not match that
@@ -489,16 +490,17 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
* then the fib_index is not an index that relates to the table
* type we need. So get the default flow-hash config instead.
*/
- fp = dpo_proto_to_fib(lb_proto);
-
- if (fib_entry->fe_prefix.fp_proto != fp)
+ flow_hash_proto = dpo_proto_to_fib(lb_proto);
+ if (fib_entry->fe_prefix.fp_proto != flow_hash_proto)
{
- fhc = fib_table_get_default_flow_hash_config(fp);
+ fhc = fib_table_get_default_flow_hash_config(flow_hash_proto);
}
else
{
- fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index, fp);
+ fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index,
+ flow_hash_proto);
}
+
dpo_set(dpo_lb,
DPO_LOAD_BALANCE,
lb_proto,
diff --git a/src/vnet/fib/fib_entry_src_special.c b/src/vnet/fib/fib_entry_src_special.c
index c3e4fe5eba7..a2493bb5be9 100644
--- a/src/vnet/fib/fib_entry_src_special.c
+++ b/src/vnet/fib/fib_entry_src_special.c
@@ -68,4 +68,5 @@ fib_entry_src_special_register (void)
fib_entry_src_register(FIB_SOURCE_CLASSIFY, &special_src_vft);
fib_entry_src_register(FIB_SOURCE_AE, &special_src_vft);
fib_entry_src_register(FIB_SOURCE_PROXY, &special_src_vft);
+ fib_entry_src_register(FIB_SOURCE_BIER, &special_src_vft);
}
diff --git a/src/vnet/fib/fib_node.h b/src/vnet/fib/fib_node.h
index 6d26bdd3671..d4c96c90b77 100644
--- a/src/vnet/fib/fib_node.h
+++ b/src/vnet/fib/fib_node.h
@@ -45,6 +45,8 @@ typedef enum fib_node_type_t_ {
FIB_NODE_TYPE_VXLAN_GPE_TUNNEL,
FIB_NODE_TYPE_GENEVE_TUNNEL,
FIB_NODE_TYPE_UDP_ENCAP,
+ FIB_NODE_TYPE_BIER_FMASK,
+ FIB_NODE_TYPE_BIER_ENTRY,
/**
* Marker. New types before this one. leave the test last.
*/
@@ -70,6 +72,8 @@ typedef enum fib_node_type_t_ {
[FIB_NODE_TYPE_MAP_E] = "map-e", \
[FIB_NODE_TYPE_VXLAN_GPE_TUNNEL] = "vxlan-gpe-tunnel", \
[FIB_NODE_TYPE_UDP_ENCAP] = "udp-encap", \
+ [FIB_NODE_TYPE_BIER_FMASK] = "bier-fmask", \
+ [FIB_NODE_TYPE_BIER_ENTRY] = "bier-entry", \
}
/**
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index 4fccca80672..3e031929419 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -24,6 +24,7 @@
#include <vnet/dpo/interface_rx_dpo.h>
#include <vnet/dpo/mpls_disposition.h>
#include <vnet/dpo/l2_bridge_dpo.h>
+#include <vnet/dpo/drop_dpo.h>
#include <vnet/adj/adj.h>
#include <vnet/adj/adj_mcast.h>
@@ -37,6 +38,9 @@
#include <vnet/fib/fib_urpf_list.h>
#include <vnet/fib/mpls_fib.h>
#include <vnet/udp/udp_encap.h>
+#include <vnet/bier/bier_fmask.h>
+#include <vnet/bier/bier_table.h>
+#include <vnet/bier/bier_imp.h>
/**
* Enurmeration of path types
@@ -83,9 +87,21 @@ typedef enum fib_path_type_t_ {
*/
FIB_PATH_TYPE_RECEIVE,
/**
+ * bier-imp. it's via a BIER imposition.
+ */
+ FIB_PATH_TYPE_BIER_IMP,
+ /**
+ * bier-fmask. it's via a BIER ECMP-table.
+ */
+ FIB_PATH_TYPE_BIER_TABLE,
+ /**
+ * bier-fmask. it's via a BIER f-mask.
+ */
+ FIB_PATH_TYPE_BIER_FMASK,
+ /**
* Marker. Add new types before this one, then update it.
*/
- FIB_PATH_TYPE_LAST = FIB_PATH_TYPE_RECEIVE,
+ FIB_PATH_TYPE_LAST = FIB_PATH_TYPE_BIER_FMASK,
} __attribute__ ((packed)) fib_path_type_t;
/**
@@ -103,10 +119,15 @@ typedef enum fib_path_type_t_ {
[FIB_PATH_TYPE_INTF_RX] = "intf-rx", \
[FIB_PATH_TYPE_UDP_ENCAP] = "udp-encap", \
[FIB_PATH_TYPE_RECEIVE] = "receive", \
+ [FIB_PATH_TYPE_BIER_IMP] = "bier-imp", \
+ [FIB_PATH_TYPE_BIER_TABLE] = "bier-table", \
+ [FIB_PATH_TYPE_BIER_FMASK] = "bier-fmask", \
}
-#define FOR_EACH_FIB_PATH_TYPE(_item) \
- for (_item = FIB_PATH_TYPE_FIRST; _item <= FIB_PATH_TYPE_LAST; _item++)
+#define FOR_EACH_FIB_PATH_TYPE(_item) \
+ for (_item = FIB_PATH_TYPE_FIRST; \
+ _item <= FIB_PATH_TYPE_LAST; \
+ _item++)
/**
* Enurmeration of path operational (i.e. derived) attributes
@@ -252,12 +273,42 @@ typedef struct fib_path_t_ {
mpls_eos_bit_t fp_eos;
};
} fp_nh;
- /**
- * The FIB table index in which to find the next-hop.
- */
- fib_node_index_t fp_tbl_id;
+ union {
+ /**
+ * The FIB table index in which to find the next-hop.
+ */
+ fib_node_index_t fp_tbl_id;
+ /**
+ * The BIER FIB the fmask is in
+ */
+ index_t fp_bier_fib;
+ };
} recursive;
struct {
+ /**
+ * The next-hop
+ */
+ ip46_address_t fp_nh;
+ /**
+ * The BIER FIB the fmask is in
+ */
+ index_t fp_bier_fib;
+ } bier_fmask;
+ struct {
+ /**
+ * The BIER table's ID
+ */
+ bier_table_id_t fp_bier_tbl;
+ } bier_table;
+ struct {
+ /**
+ * The BIER imposition object
+ * this is part of the path's key, since the index_t
+ * of an imposition object is the object's key.
+ */
+ index_t fp_bier_imp;
+ } bier_imp;
+ struct {
/**
* The FIB index in which to perfom the next lookup
*/
@@ -311,11 +362,21 @@ typedef struct fib_path_t_ {
*/
fib_path_oper_flags_t fp_oper_flags;
- /**
- * the resolving via fib. not part of the union, since it it not part
- * of the path's hash.
- */
- fib_node_index_t fp_via_fib;
+ union {
+ /**
+ * the resolving via fib. not part of the union, since it it not part
+ * of the path's hash.
+ */
+ fib_node_index_t fp_via_fib;
+ /**
+ * the resolving bier-fmask
+ */
+ index_t fp_via_bier_fmask;
+ /**
+ * the resolving bier-table
+ */
+ index_t fp_via_bier_tbl;
+ };
/**
* The Data-path objects through which this path resolves for IP.
@@ -494,6 +555,31 @@ format_fib_path (u8 * s, va_list * args)
case FIB_PATH_TYPE_UDP_ENCAP:
s = format (s, " UDP-encap ID:%d", path->udp_encap.fp_udp_encap_id);
break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ s = format (s, "via bier-table:[%U}",
+ format_bier_table_id,
+ &path->bier_table.fp_bier_tbl);
+ s = format (s, " via-dpo:[%U:%d]",
+ format_dpo_type, path->fp_dpo.dpoi_type,
+ path->fp_dpo.dpoi_index);
+ break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ s = format (s, "via %U",
+ format_ip46_address,
+ &path->bier_fmask.fp_nh,
+ IP46_TYPE_ANY);
+ s = format (s, " in BIER-fib:%d",
+ path->bier_fmask.fp_bier_fib,
+ path->fp_via_fib);
+ s = format (s, " via-fmask:%d", path->fp_via_bier_fmask);
+ s = format (s, " via-dpo:[%U:%d]",
+ format_dpo_type, path->fp_dpo.dpoi_type,
+ path->fp_dpo.dpoi_index);
+ break;
+ case FIB_PATH_TYPE_BIER_IMP:
+ s = format (s, "via %U", format_bier_imp,
+ path->bier_imp.fp_bier_imp, 0, BIER_SHOW_BRIEF);
+ break;
case FIB_PATH_TYPE_RECEIVE:
case FIB_PATH_TYPE_INTF_RX:
case FIB_PATH_TYPE_SPECIAL:
@@ -742,6 +828,28 @@ fib_path_recursive_adj_update (fib_path_t *path,
}
/*
+ * re-evaulate the forwarding state for a via fmask path
+ */
+static void
+fib_path_bier_fmask_update (fib_path_t *path,
+ dpo_id_t *dpo)
+{
+ bier_fmask_contribute_forwarding(path->fp_via_bier_fmask, dpo);
+
+ /*
+ * if we are stakcing on the drop, then the path is not resolved
+ */
+ if (dpo_is_drop(dpo))
+ {
+ path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED;
+ }
+ else
+ {
+ path->fp_oper_flags |= FIB_PATH_OPER_FLAG_RESOLVED;
+ }
+}
+
+/*
* fib_path_is_permanent_drop
*
* Return !0 if the path is configured to permanently drop,
@@ -786,6 +894,20 @@ fib_path_unresolve (fib_path_t *path)
path->fp_via_fib = FIB_NODE_INDEX_INVALID;
}
break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ if (FIB_NODE_INDEX_INVALID != path->fp_via_bier_fmask)
+ {
+ bier_fmask_child_remove(path->fp_via_bier_fmask,
+ path->fp_sibling);
+ path->fp_via_bier_fmask = FIB_NODE_INDEX_INVALID;
+ }
+ break;
+ case FIB_PATH_TYPE_BIER_IMP:
+ bier_imp_unlock(path->fp_dpo.dpoi_index);
+ break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ bier_table_ecmp_unlock(path->fp_via_bier_tbl);
+ break;
case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
adj_child_remove(path->fp_dpo.dpoi_index,
path->fp_sibling);
@@ -890,6 +1012,30 @@ fib_path_back_walk_notify (fib_node_t *node,
return (FIB_NODE_BACK_WALK_CONTINUE);
}
break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ if (FIB_NODE_BW_REASON_FLAG_EVALUATE & ctx->fnbw_reason)
+ {
+ /*
+ * update to use the BIER fmask's new forwading
+ */
+ fib_path_bier_fmask_update(path, &path->fp_dpo);
+ }
+ if ((FIB_NODE_BW_REASON_FLAG_ADJ_UPDATE & ctx->fnbw_reason) ||
+ (FIB_NODE_BW_REASON_FLAG_ADJ_DOWN & ctx->fnbw_reason))
+ {
+ /*
+ * ADJ updates (complete<->incomplete) do not need to propagate to
+ * recursive entries.
+ * The only reason its needed as far back as here, is that the adj
+ * and the incomplete adj are a different DPO type, so the LBs need
+ * to re-stack.
+ * If this walk was quashed in the fib_entry, then any non-fib_path
+ * children (like tunnels that collapse out the LB when they stack)
+ * would not see the update.
+ */
+ return (FIB_NODE_BACK_WALK_CONTINUE);
+ }
+ break;
case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
/*
FIXME comment
@@ -1043,6 +1189,8 @@ FIXME comment
case FIB_PATH_TYPE_SPECIAL:
case FIB_PATH_TYPE_RECEIVE:
case FIB_PATH_TYPE_EXCLUSIVE:
+ case FIB_PATH_TYPE_BIER_TABLE:
+ case FIB_PATH_TYPE_BIER_IMP:
/*
* these path types have no parents. so to be
* walked from one is unexpected.
@@ -1164,6 +1312,22 @@ fib_path_create (fib_node_index_t pl_index,
path->deag.fp_tbl_id = rpath->frp_fib_index;
path->deag.fp_rpf_id = rpath->frp_rpf_id;
}
+ else if (rpath->frp_flags & FIB_ROUTE_PATH_BIER_FMASK)
+ {
+ path->fp_type = FIB_PATH_TYPE_BIER_FMASK;
+ path->bier_fmask.fp_nh = rpath->frp_addr;
+ path->bier_fmask.fp_bier_fib = rpath->frp_bier_fib_index;
+ }
+ else if (rpath->frp_flags & FIB_ROUTE_PATH_BIER_IMP)
+ {
+ path->fp_type = FIB_PATH_TYPE_BIER_IMP;
+ path->bier_imp.fp_bier_imp = rpath->frp_bier_imp;
+ }
+ else if (rpath->frp_flags & FIB_ROUTE_PATH_BIER_TABLE)
+ {
+ path->fp_type = FIB_PATH_TYPE_BIER_TABLE;
+ path->bier_table.fp_bier_tbl = rpath->frp_bier_tbl;
+ }
else if (~0 != rpath->frp_sw_if_index)
{
if (ip46_address_is_zero(&rpath->frp_addr))
@@ -1204,7 +1368,7 @@ fib_path_create (fib_node_index_t pl_index,
{
path->recursive.fp_nh.fp_ip = rpath->frp_addr;
}
- path->recursive.fp_tbl_id = rpath->frp_fib_index;
+ path->recursive.fp_tbl_id = rpath->frp_fib_index;
}
}
@@ -1386,6 +1550,24 @@ fib_path_cmp_i (const fib_path_t *path1,
res = (path1->recursive.fp_tbl_id - path2->recursive.fp_tbl_id);
}
break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ res = ip46_address_cmp(&path1->bier_fmask.fp_nh,
+ &path2->bier_fmask.fp_nh);
+
+ if (0 == res)
+ {
+ res = (path1->bier_fmask.fp_bier_fib -
+ path2->bier_fmask.fp_bier_fib);
+ }
+ break;
+ case FIB_PATH_TYPE_BIER_IMP:
+ res = (path1->bier_imp.fp_bier_imp -
+ path2->bier_imp.fp_bier_imp);
+ break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ res = bier_table_id_cmp(&path1->bier_table.fp_bier_tbl,
+ &path2->bier_table.fp_bier_tbl);
+ break;
case FIB_PATH_TYPE_DEAG:
res = (path1->deag.fp_tbl_id - path2->deag.fp_tbl_id);
if (0 == res)
@@ -1510,6 +1692,22 @@ fib_path_cmp_w_route_path (fib_node_index_t path_index,
res = (path->recursive.fp_tbl_id - rpath->frp_fib_index);
}
break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ res = ip46_address_cmp(&path->bier_fmask.fp_nh,
+ &rpath->frp_addr);
+
+ if (0 == res)
+ {
+ res = (path->bier_fmask.fp_bier_fib - rpath->frp_bier_fib_index);
+ }
+ break;
+ case FIB_PATH_TYPE_BIER_IMP:
+ res = (path->bier_imp.fp_bier_imp - rpath->frp_bier_imp);
+ break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ res = bier_table_id_cmp(&path->bier_table.fp_bier_tbl,
+ &rpath->frp_bier_tbl);
+ break;
case FIB_PATH_TYPE_INTF_RX:
res = (path->intf_rx.fp_interface - rpath->frp_sw_if_index);
break;
@@ -1623,6 +1821,9 @@ fib_path_recursive_loop_detect (fib_node_index_t path_index,
case FIB_PATH_TYPE_INTF_RX:
case FIB_PATH_TYPE_UDP_ENCAP:
case FIB_PATH_TYPE_EXCLUSIVE:
+ case FIB_PATH_TYPE_BIER_FMASK:
+ case FIB_PATH_TYPE_BIER_TABLE:
+ case FIB_PATH_TYPE_BIER_IMP:
/*
* these path types cannot be part of a loop, since they are the leaves
* of the graph.
@@ -1742,6 +1943,53 @@ fib_path_resolve (fib_node_index_t path_index)
break;
}
+ case FIB_PATH_TYPE_BIER_FMASK:
+ {
+ /*
+ * Find the BIER f-mask to link to
+ */
+ bier_fmask_id_t fmid = {
+ .bfmi_nh = path->bier_fmask.fp_nh,
+ .bfmi_hdr_type = BIER_HDR_O_MPLS,
+ };
+
+ ASSERT(FIB_NODE_INDEX_INVALID == path->fp_via_bier_fmask);
+
+ path->fp_via_bier_fmask = bier_fmask_db_find(path->bier_fmask.fp_bier_fib,
+ &fmid);
+
+ /*
+ * become a dependent child of the entry so the path is
+ * informed when the forwarding for the entry changes.
+ */
+ path->fp_sibling = bier_fmask_child_add(path->fp_via_bier_fmask,
+ FIB_NODE_TYPE_PATH,
+ fib_path_get_index(path));
+
+ fib_path_bier_fmask_update(path, &path->fp_dpo);
+
+ break;
+ }
+ case FIB_PATH_TYPE_BIER_IMP:
+ bier_imp_lock(path->bier_imp.fp_bier_imp);
+ bier_imp_contribute_forwarding(path->bier_imp.fp_bier_imp,
+ DPO_PROTO_IP4,
+ &path->fp_dpo);
+ break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ {
+ /*
+ * Find/create the BIER table to link to
+ */
+ ASSERT(FIB_NODE_INDEX_INVALID == path->fp_via_bier_tbl);
+
+ path->fp_via_bier_tbl =
+ bier_table_ecmp_create_and_lock(&path->bier_table.fp_bier_tbl);
+
+ bier_table_contribute_forwarding(path->fp_via_bier_tbl,
+ &path->fp_dpo);
+ break;
+ }
case FIB_PATH_TYPE_SPECIAL:
/*
* Resolve via the drop
@@ -1833,11 +2081,45 @@ fib_path_get_resolving_interface (fib_node_index_t path_index)
case FIB_PATH_TYPE_SPECIAL:
case FIB_PATH_TYPE_DEAG:
case FIB_PATH_TYPE_EXCLUSIVE:
+ case FIB_PATH_TYPE_BIER_FMASK:
+ case FIB_PATH_TYPE_BIER_TABLE:
+ case FIB_PATH_TYPE_BIER_IMP:
break;
}
return (~0);
}
+index_t
+fib_path_get_resolving_index (fib_node_index_t path_index)
+{
+ fib_path_t *path;
+
+ path = fib_path_get(path_index);
+
+ switch (path->fp_type)
+ {
+ case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
+ case FIB_PATH_TYPE_ATTACHED:
+ case FIB_PATH_TYPE_RECEIVE:
+ case FIB_PATH_TYPE_INTF_RX:
+ case FIB_PATH_TYPE_SPECIAL:
+ case FIB_PATH_TYPE_DEAG:
+ case FIB_PATH_TYPE_EXCLUSIVE:
+ break;
+ case FIB_PATH_TYPE_UDP_ENCAP:
+ return (path->udp_encap.fp_udp_encap_id);
+ case FIB_PATH_TYPE_RECURSIVE:
+ return (path->fp_via_fib);
+ case FIB_PATH_TYPE_BIER_FMASK:
+ return (path->fp_via_bier_fmask);
+ case FIB_PATH_TYPE_BIER_TABLE:
+ return (path->fp_via_bier_tbl);
+ case FIB_PATH_TYPE_BIER_IMP:
+ return (path->bier_imp.fp_bier_imp);
+ }
+ return (~0);
+}
+
adj_index_t
fib_path_get_adj (fib_node_index_t path_index)
{
@@ -1877,6 +2159,23 @@ fib_path_get_preference (fib_node_index_t path_index)
return (path->fp_preference);
}
+u32
+fib_path_get_rpf_id (fib_node_index_t path_index)
+{
+ fib_path_t *path;
+
+ path = fib_path_get(path_index);
+
+ ASSERT(path);
+
+ if (FIB_PATH_CFG_FLAG_RPF_ID & path->fp_cfg_flags)
+ {
+ return (path->deag.fp_rpf_id);
+ }
+
+ return (~0);
+}
+
/**
* @brief Contribute the path's adjacency to the list passed.
* By calling this function over all paths, recursively, a child
@@ -1937,6 +2236,9 @@ fib_path_contribute_urpf (fib_node_index_t path_index,
case FIB_PATH_TYPE_RECEIVE:
case FIB_PATH_TYPE_INTF_RX:
case FIB_PATH_TYPE_UDP_ENCAP:
+ case FIB_PATH_TYPE_BIER_FMASK:
+ case FIB_PATH_TYPE_BIER_TABLE:
+ case FIB_PATH_TYPE_BIER_IMP:
/*
* these path types don't link to an adj
*/
@@ -1979,6 +2281,9 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index,
case FIB_PATH_TYPE_UDP_ENCAP:
case FIB_PATH_TYPE_EXCLUSIVE:
case FIB_PATH_TYPE_SPECIAL:
+ case FIB_PATH_TYPE_BIER_FMASK:
+ case FIB_PATH_TYPE_BIER_TABLE:
+ case FIB_PATH_TYPE_BIER_IMP:
break;
}
}
@@ -2036,8 +2341,9 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
}
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
- break;
- }
+ case FIB_FORW_CHAIN_TYPE_BIER:
+ break;
+ }
break;
case FIB_PATH_TYPE_RECURSIVE:
switch (fct)
@@ -2048,6 +2354,7 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_BIER:
fib_path_recursive_adj_update(path, fct, dpo);
break;
case FIB_FORW_CHAIN_TYPE_ETHERNET:
@@ -2056,6 +2363,47 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
break;
}
break;
+ case FIB_PATH_TYPE_BIER_TABLE:
+ switch (fct)
+ {
+ case FIB_FORW_CHAIN_TYPE_BIER:
+ bier_table_contribute_forwarding(path->fp_via_bier_tbl, dpo);
+ break;
+ case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
+ case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
+ case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
+ case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
+ case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_ETHERNET:
+ case FIB_FORW_CHAIN_TYPE_NSH:
+ ASSERT(0);
+ break;
+ }
+ break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ switch (fct)
+ {
+ case FIB_FORW_CHAIN_TYPE_BIER:
+ fib_path_bier_fmask_update(path, dpo);
+ break;
+ case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
+ case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
+ case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
+ case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
+ case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_ETHERNET:
+ case FIB_FORW_CHAIN_TYPE_NSH:
+ ASSERT(0);
+ break;
+ }
+ break;
+ case FIB_PATH_TYPE_BIER_IMP:
+ bier_imp_contribute_forwarding(path->bier_imp.fp_bier_imp,
+ fib_forw_chain_type_to_dpo_proto(fct),
+ dpo);
+ break;
case FIB_PATH_TYPE_DEAG:
switch (fct)
{
@@ -2074,6 +2422,8 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
break;
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+ case FIB_FORW_CHAIN_TYPE_BIER:
+ break;
case FIB_FORW_CHAIN_TYPE_ETHERNET:
case FIB_FORW_CHAIN_TYPE_NSH:
ASSERT(0);
@@ -2097,6 +2447,7 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
case FIB_FORW_CHAIN_TYPE_ETHERNET:
case FIB_FORW_CHAIN_TYPE_NSH:
+ case FIB_FORW_CHAIN_TYPE_BIER:
{
adj_index_t ai;
@@ -2263,6 +2614,10 @@ fib_path_encode (fib_node_index_t path_list_index,
api_rpath->rpath.frp_sw_if_index = path->attached_next_hop.fp_interface;
api_rpath->rpath.frp_addr = path->attached_next_hop.fp_nh;
break;
+ case FIB_PATH_TYPE_BIER_FMASK:
+ api_rpath->rpath.frp_fib_index = path->bier_fmask.fp_bier_fib;
+ api_rpath->rpath.frp_addr = path->bier_fmask.fp_nh;
+ break;
case FIB_PATH_TYPE_SPECIAL:
break;
case FIB_PATH_TYPE_DEAG:
diff --git a/src/vnet/fib/fib_path.h b/src/vnet/fib/fib_path.h
index 3a0544c1c42..861bda95933 100644
--- a/src/vnet/fib/fib_path.h
+++ b/src/vnet/fib/fib_path.h
@@ -35,6 +35,7 @@
#include <vnet/fib/fib_types.h>
#include <vnet/adj/adj_types.h>
+#include <vnet/bier/bier_types.h>
/**
* Enurmeration of path configuration attributes
@@ -173,8 +174,10 @@ extern adj_index_t fib_path_get_adj(fib_node_index_t path_index);
extern int fib_path_recursive_loop_detect(fib_node_index_t path_index,
fib_node_index_t **entry_indicies);
extern u32 fib_path_get_resolving_interface(fib_node_index_t fib_entry_index);
+extern index_t fib_path_get_resolving_index(fib_node_index_t path_index);
extern u16 fib_path_get_weight(fib_node_index_t path_index);
extern u16 fib_path_get_preference(fib_node_index_t path_index);
+extern u32 fib_path_get_rpf_id(fib_node_index_t path_index);
extern void fib_path_module_init(void);
extern fib_path_list_walk_rc_t fib_path_encode(fib_node_index_t path_list_index,
diff --git a/src/vnet/fib/fib_path_list.c b/src/vnet/fib/fib_path_list.c
index f30fd7ea0a4..f9477406ed3 100644
--- a/src/vnet/fib/fib_path_list.c
+++ b/src/vnet/fib/fib_path_list.c
@@ -583,6 +583,11 @@ fib_path_list_get_n_paths (fib_node_index_t path_list_index)
{
fib_path_list_t *path_list;
+ if (FIB_NODE_INDEX_INVALID == path_list_index)
+ {
+ return (0);
+ }
+
path_list = fib_path_list_get(path_list_index);
return (vec_len(path_list->fpl_paths));
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index d5625d83673..4dd6e7c5421 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -953,6 +953,7 @@ fib_table_get_flow_hash_config (u32 fib_index,
return (fib->ft_flow_hash_config);
}
+
flow_hash_config_t
fib_table_get_default_flow_hash_config (fib_protocol_t proto)
{
diff --git a/src/vnet/fib/fib_table.h b/src/vnet/fib/fib_table.h
index 6c2640458b9..d2522aa50c8 100644
--- a/src/vnet/fib/fib_table.h
+++ b/src/vnet/fib/fib_table.h
@@ -697,7 +697,7 @@ extern u32 fib_table_create_and_lock(fib_protocol_t proto,
* The index of the FIB
*
* @paran proto
- * The protocol of the FIB (and thus the entries therein)
+ * The protocol the packets the flow hash will be calculated for.
*
* @return The flow hash config
*/
diff --git a/src/vnet/fib/fib_test.c b/src/vnet/fib/fib_test.c
index 66a38236216..2658eb27811 100644
--- a/src/vnet/fib/fib_test.c
+++ b/src/vnet/fib/fib_test.c
@@ -13,6 +13,7 @@
* limitations under the License.
*/
+#include <vnet/fib/fib_test.h>
#include <vnet/fib/ip6_fib.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/fib/mpls_fib.h>
@@ -544,15 +545,31 @@ fib_test_validate_lb_v (const load_balance_t *lb,
dpo->dpoi_index,
exp->lb.lb);
break;
- case FT_LB_SPECIAL:
- FIB_TEST_I((DPO_DROP == dpo->dpoi_type),
- "bucket %d stacks on %U",
- bucket,
- format_dpo_type, dpo->dpoi_type);
- FIB_TEST_LB((exp->special.adj == dpo->dpoi_index),
- "bucket %d stacks on drop %d",
+ case FT_LB_BIER_TABLE:
+ FIB_TEST_LB((DPO_BIER_TABLE == dpo->dpoi_type),
+ "bucket %d stacks on %U",
+ bucket,
+ format_dpo_type, dpo->dpoi_type);
+ FIB_TEST_LB((exp->bier.table == dpo->dpoi_index),
+ "bucket %d stacks on lb %d",
+ bucket,
+ exp->bier.table);
+ break;
+ case FT_LB_BIER_FMASK:
+ FIB_TEST_LB((DPO_BIER_FMASK == dpo->dpoi_type),
+ "bucket %d stacks on %U",
+ bucket,
+ format_dpo_type, dpo->dpoi_type);
+ FIB_TEST_LB((exp->bier.fmask == dpo->dpoi_index),
+ "bucket %d stacks on lb %d",
bucket,
- exp->special.adj);
+ exp->bier.fmask);
+ break;
+ case FT_LB_DROP:
+ FIB_TEST_LB((DPO_DROP == dpo->dpoi_type),
+ "bucket %d stacks on %U",
+ bucket,
+ format_dpo_type, dpo->dpoi_type);
break;
}
}
@@ -560,6 +577,29 @@ fib_test_validate_lb_v (const load_balance_t *lb,
}
int
+fib_test_validate_lb (const dpo_id_t *dpo,
+ u16 n_buckets,
+ ...)
+{
+ const load_balance_t *lb;
+ va_list ap;
+ int res;
+
+ va_start(ap, n_buckets);
+
+ FIB_TEST_LB((DPO_LOAD_BALANCE == dpo->dpoi_type),
+ "Entry links to %U",
+ format_dpo_type, dpo->dpoi_type);
+ lb = load_balance_get(dpo->dpoi_index);
+
+ res = fib_test_validate_lb_v(lb, n_buckets, &ap);
+
+ va_end(ap);
+
+ return (res);
+}
+
+int
fib_test_validate_entry (fib_node_index_t fei,
fib_forward_chain_type_t fct,
int n_buckets,
@@ -6678,13 +6718,10 @@ fib_test_label (void)
* remove the other path with a valid label
*/
fib_test_lb_bucket_t bucket_drop = {
- .type = FT_LB_SPECIAL,
- .special = {
- .adj = DPO_PROTO_IP4,
- },
+ .type = FT_LB_DROP,
};
fib_test_lb_bucket_t mpls_bucket_drop = {
- .type = FT_LB_SPECIAL,
+ .type = FT_LB_DROP,
.special = {
.adj = DPO_PROTO_MPLS,
},
@@ -8497,13 +8534,13 @@ lfib_test (void)
* A recursive via a label that does not exist
*/
fib_test_lb_bucket_t bucket_drop = {
- .type = FT_LB_SPECIAL,
+ .type = FT_LB_DROP,
.special = {
.adj = DPO_PROTO_IP4,
},
};
fib_test_lb_bucket_t mpls_bucket_drop = {
- .type = FT_LB_SPECIAL,
+ .type = FT_LB_DROP,
.special = {
.adj = DPO_PROTO_MPLS,
},
diff --git a/src/vnet/fib/fib_test.h b/src/vnet/fib/fib_test.h
index a9463d60830..f3d8346aab3 100644
--- a/src/vnet/fib/fib_test.h
+++ b/src/vnet/fib/fib_test.h
@@ -17,16 +17,24 @@
#define __FIB_TEST_H__
#include <vnet/fib/fib_types.h>
+#include <vnet/mpls/mpls_types.h>
+#include <vnet/fib/fib_types.h>
+#include <vnet/mpls/packet.h>
+#include <vnet/dpo/load_balance.h>
+#include <vnet/adj/adj_types.h>
+#include <vnet/dpo/replicate_dpo.h>
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,
FT_LB_L2,
+ FT_LB_BIER_TABLE,
+ FT_LB_BIER_FMASK,
+ FT_LB_DROP,
+ FT_LB_ADJ,
} fib_test_lb_bucket_type_t;
typedef struct fib_test_lb_bucket_t_ {
@@ -68,6 +76,13 @@ typedef struct fib_test_lb_bucket_t_ {
{
index_t adj;
} special;
+ struct
+ {
+ union {
+ index_t table;
+ index_t fmask;
+ };
+ } bier;
};
} fib_test_lb_bucket_t;
@@ -105,9 +120,14 @@ extern int fib_test_validate_lb_v(const load_balance_t *lb,
u16 n_buckets,
va_list *ap);
+extern int fib_test_validate_lb(const dpo_id_t *dpo,
+ u16 n_buckets,
+ ...);
+
extern int fib_test_validate_entry(fib_node_index_t fei,
fib_forward_chain_type_t fct,
int n_buckets,
...);
+
#endif
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c
index d84642d29da..656966b2331 100644
--- a/src/vnet/fib/fib_types.c
+++ b/src/vnet/fib/fib_types.c
@@ -272,6 +272,8 @@ fib_forw_chain_type_from_dpo_proto (dpo_proto_t proto)
return (FIB_FORW_CHAIN_TYPE_ETHERNET);
case DPO_PROTO_NSH:
return (FIB_FORW_CHAIN_TYPE_NSH);
+ case DPO_PROTO_BIER:
+ return (FIB_FORW_CHAIN_TYPE_BIER);
}
ASSERT(0);
return (FIB_FORW_CHAIN_TYPE_UNICAST_IP4);
@@ -293,6 +295,7 @@ fib_forw_chain_type_to_link_type (fib_forward_chain_type_t fct)
case FIB_FORW_CHAIN_TYPE_NSH:
return (VNET_LINK_NSH);
case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
+ case FIB_FORW_CHAIN_TYPE_BIER:
/*
* insufficient information to to convert
*/
@@ -319,6 +322,8 @@ fib_forw_chain_type_to_dpo_proto (fib_forward_chain_type_t fct)
return (DPO_PROTO_ETHERNET);
case FIB_FORW_CHAIN_TYPE_NSH:
return (DPO_PROTO_NSH);
+ case FIB_FORW_CHAIN_TYPE_BIER:
+ return (DPO_PROTO_BIER);
case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
return (DPO_PROTO_MPLS);
diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h
index ec7f1b374dd..0a4b1699609 100644
--- a/src/vnet/fib/fib_types.h
+++ b/src/vnet/fib/fib_types.h
@@ -20,6 +20,7 @@
#include <vnet/ip/ip6_packet.h>
#include <vnet/mpls/packet.h>
#include <vnet/dpo/dpo.h>
+#include <vnet/bier/bier_types.h>
/**
* A typedef of a node index.
@@ -50,6 +51,12 @@ typedef enum fib_protocol_t_ {
#define FIB_PROTOCOL_MAX (FIB_PROTOCOL_MPLS + 1)
/**
+ * Definition outside of enum so it does not need to be included in non-defaulted
+ * switch statements
+ */
+#define FIB_PROTOCOL_IP_MAX (FIB_PROTOCOL_IP6 + 1)
+
+/**
* Not part of the enum so it does not have to be handled in switch statements
*/
#define FIB_PROTOCOL_NONE (FIB_PROTOCOL_MAX+1)
@@ -89,6 +96,10 @@ typedef enum fib_forward_chain_type_t_ {
*/
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
/**
+ * Contribute an object that is to be used to forward BIER packets.
+ */
+ FIB_FORW_CHAIN_TYPE_BIER,
+ /**
* Contribute an object that is to be used to forward end-of-stack
* MPLS packets. This is a convenient ID for clients. A real EOS chain
* must be pay-load protocol specific. This
@@ -117,6 +128,7 @@ typedef enum fib_forward_chain_type_t_ {
#define FIB_FORW_CHAINS { \
[FIB_FORW_CHAIN_TYPE_ETHERNET] = "ethernet", \
+ [FIB_FORW_CHAIN_TYPE_BIER] = "bier", \
[FIB_FORW_CHAIN_TYPE_UNICAST_IP4] = "unicast-ip4", \
[FIB_FORW_CHAIN_TYPE_UNICAST_IP6] = "unicast-ip6", \
[FIB_FORW_CHAIN_TYPE_MCAST_IP4] = "multicast-ip4", \
@@ -231,6 +243,11 @@ extern dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto);
extern fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto);
/**
+ * Convert from BIER next-hop proto to FIB proto
+ */
+extern fib_protocol_t bier_hdr_proto_to_fib(bier_hdr_proto_id_t bproto);
+
+/**
* Enurmeration of special path/entry types
*/
typedef enum fib_special_type_t_ {
@@ -311,6 +328,18 @@ typedef enum fib_route_path_flags_t_
* A path via a UDP encap object.
*/
FIB_ROUTE_PATH_UDP_ENCAP = (1 << 9),
+ /**
+ * A path that resolves via a BIER F-Mask
+ */
+ FIB_ROUTE_PATH_BIER_FMASK = (1 << 10),
+ /**
+ * A path that resolves via a BIER [ECMP] Table
+ */
+ FIB_ROUTE_PATH_BIER_TABLE = (1 << 11),
+ /**
+ * A path that resolves via a BIER impostion object
+ */
+ FIB_ROUTE_PATH_BIER_IMP = (1 << 12),
} fib_route_path_flags_t;
/**
@@ -349,47 +378,73 @@ typedef struct fib_route_path_t_ {
dpo_proto_t frp_proto;
union {
- /**
- * The next-hop address.
- * Will be NULL for attached paths.
- * Will be all zeros for attached-next-hop paths on a p2p interface
- * Will be all zeros for a deag path.
- */
- ip46_address_t frp_addr;
-
struct {
+ union {
+ /**
+ * The next-hop address.
+ * Will be NULL for attached paths.
+ * Will be all zeros for attached-next-hop paths on a p2p interface
+ * Will be all zeros for a deag path.
+ */
+ ip46_address_t frp_addr;
+
+ struct {
+ /**
+ * The MPLS local Label to reursively resolve through.
+ * This is valid when the path type is MPLS.
+ */
+ mpls_label_t frp_local_label;
+ /**
+ * EOS bit for the resolving label
+ */
+ mpls_eos_bit_t frp_eos;
+ };
+ };
+ union {
+ /**
+ * The interface.
+ * Will be invalid for recursive paths.
+ */
+ u32 frp_sw_if_index;
+ /**
+ * The RPF-ID
+ */
+ fib_rpf_id_t frp_rpf_id;
+ };
+ union {
+ /**
+ * The FIB index to lookup the nexthop
+ * Only valid for recursive paths.
+ */
+ u32 frp_fib_index;
+ /**
+ * The BIER table to resolve the fmask in
+ */
+ u32 frp_bier_fib_index;
+ };
/**
- * The MPLS local Label to reursively resolve through.
- * This is valid when the path type is MPLS.
+ * The outgoing MPLS label Stack. NULL implies no label.
*/
- mpls_label_t frp_local_label;
- /**
- * EOS bit for the resolving label
- */
- mpls_eos_bit_t frp_eos;
+ mpls_label_t *frp_label_stack;
};
- };
- union {
/**
- * The interface.
- * Will be invalid for recursive paths.
+ * A path that resolves via a BIER Table.
+ * This would be for a MPLS label at a BIER midpoint or tail
*/
- u32 frp_sw_if_index;
+ bier_table_id_t frp_bier_tbl;
+
/**
- * The RPF-ID
+ * A path via a BIER imposition object.
+ * Present in an mfib path list
*/
- fib_rpf_id_t frp_rpf_id;
+ index_t frp_bier_imp;
+
/**
* UDP encap ID
*/
u32 frp_udp_encap_id;
};
/**
- * The FIB index to lookup the nexthop
- * Only valid for recursive paths.
- */
- u32 frp_fib_index;
- /**
* [un]equal cost path weight
*/
u8 frp_weight;
@@ -403,10 +458,6 @@ typedef struct fib_route_path_t_ {
* flags on the path
*/
fib_route_path_flags_t frp_flags;
- /**
- * The outgoing MPLS label Stack. NULL implies no label.
- */
- mpls_label_t *frp_label_stack;
} fib_route_path_t;
/**