FIB Inherited Srouce
[vpp.git] / src / vnet / fib / fib_entry.h
index cd954e3..273a5e6 100644 (file)
  * The lower the value the higher the priority
  */
 typedef enum fib_source_t_ {
-    /**
-     * An invalid source of value 0
-     */
-    FIB_SOURCE_INVALID,
     /**
      * Marker. Add new values after this one.
      */
@@ -146,7 +142,6 @@ STATIC_ASSERT (sizeof(fib_source_t) == 1,
 #define FIB_SOURCE_MAX (FIB_SOURCE_LAST+1)
 
 #define FIB_SOURCES {                                  \
-    [FIB_SOURCE_INVALID] = "invalid",                  \
     [FIB_SOURCE_SPECIAL] = "special",                  \
     [FIB_SOURCE_INTERFACE] = "interface",              \
     [FIB_SOURCE_PROXY] = "proxy",                       \
@@ -217,10 +212,15 @@ typedef enum fib_entry_attribute_t_ {
      * To be used with caution
      */
     FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT,
+    /**
+     * This FIB entry imposes its source information on all prefixes
+     * that is covers
+     */
+    FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT,
     /**
      * Marker. add new entries before this one.
      */
-    FIB_ENTRY_ATTRIBUTE_LAST = FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT,
+    FIB_ENTRY_ATTRIBUTE_LAST = FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT,
 } fib_entry_attribute_t;
 
 #define FIB_ENTRY_ATTRIBUTES {                         \
@@ -232,6 +232,7 @@ typedef enum fib_entry_attribute_t_ {
     [FIB_ENTRY_ATTRIBUTE_LOCAL]     = "local",         \
     [FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT] = "uRPF-exempt",  \
     [FIB_ENTRY_ATTRIBUTE_MULTICAST] = "multicast",     \
+    [FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT] = "covered-inherit",  \
 }
 
 #define FOR_EACH_FIB_ATTRIBUTE(_item)                  \
@@ -249,6 +250,7 @@ typedef enum fib_entry_flag_t_ {
     FIB_ENTRY_FLAG_IMPORT    = (1 << FIB_ENTRY_ATTRIBUTE_IMPORT),
     FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT = (1 << FIB_ENTRY_ATTRIBUTE_URPF_EXEMPT),
     FIB_ENTRY_FLAG_MULTICAST = (1 << FIB_ENTRY_ATTRIBUTE_MULTICAST),
+    FIB_ENTRY_FLAG_COVERED_INHERIT = (1 << FIB_ENTRY_ATTRIBUTE_COVERED_INHERIT),
 } __attribute__((packed)) fib_entry_flag_t;
 
 /**
@@ -267,10 +269,14 @@ typedef enum fib_entry_src_attribute_t_ {
      * the source is active/best
      */
     FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE,
+    /**
+     * the source is inherited from its cover
+     */
+    FIB_ENTRY_SRC_ATTRIBUTE_INHERITED,
     /**
      * Marker. add new entries before this one.
      */
-    FIB_ENTRY_SRC_ATTRIBUTE_LAST = FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE,
+    FIB_ENTRY_SRC_ATTRIBUTE_LAST = FIB_ENTRY_SRC_ATTRIBUTE_INHERITED,
 } fib_entry_src_attribute_t;
 
 #define FIB_ENTRY_SRC_ATTRIBUTE_MAX (FIB_ENTRY_SRC_ATTRIBUTE_LAST+1)
@@ -278,12 +284,19 @@ typedef enum fib_entry_src_attribute_t_ {
 #define FIB_ENTRY_SRC_ATTRIBUTES {              \
     [FIB_ENTRY_SRC_ATTRIBUTE_ADDED]  = "added",         \
     [FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE] = "active", \
+    [FIB_ENTRY_SRC_ATTRIBUTE_INHERITED] = "inherited", \
 }
 
+#define FOR_EACH_FIB_SRC_ATTRIBUTE(_item)                      \
+    for (_item = FIB_ENTRY_SRC_ATTRIBUTE_FIRST;                \
+        _item < FIB_ENTRY_SRC_ATTRIBUTE_MAX;           \
+        _item++)
+
 typedef enum fib_entry_src_flag_t_ {
     FIB_ENTRY_SRC_FLAG_NONE   = 0,
     FIB_ENTRY_SRC_FLAG_ADDED  = (1 << FIB_ENTRY_SRC_ATTRIBUTE_ADDED),
     FIB_ENTRY_SRC_FLAG_ACTIVE = (1 << FIB_ENTRY_SRC_ATTRIBUTE_ACTIVE),
+    FIB_ENTRY_SRC_FLAG_INHERITED = (1 << FIB_ENTRY_SRC_ATTRIBUTE_INHERITED),
 } __attribute__ ((packed)) fib_entry_src_flag_t;
 
 /*
@@ -381,29 +394,6 @@ typedef struct fib_entry_src_t_ {
     };
 } fib_entry_src_t;
 
-/**
- * FIB entry flags.
- *  these are stored in the pad space within the fib_node_t
- */
-typedef enum fib_entry_node_attribute_t_
-{
-    /**
-     * FIB entry has multiple sources, so the fe_srcs union
-     * uses the vector
-     */
-    FIB_ENTRY_NODE_ATTR_MULTIPLE_SRCS,
-} fib_entry_node_attribute_t;
-
-#define FIB_ENTRY_NODE_FLAG_NAMES {                            \
-    [FIB_ENTRY_NODE_ATTR_MULTIPLE_SRCS] = "multiple-srcs",     \
-}
-
-typedef enum fib_entry_node_flags_t_
-{
-    FIB_ENTRY_NODE_FLAG_MULTIPLE_SRCS = (1 << FIB_ENTRY_NODE_ATTR_MULTIPLE_SRCS),
-} fib_entry_node_flags_t;
-
-
 /**
  * An entry in a FIB table.
  *
@@ -437,20 +427,12 @@ typedef struct fib_entry_t_ {
      *     type to derive the EOS bit value.
      */
     dpo_id_t fe_lb;
-
     /**
-     * Source info.
-     * in the majority of cases a FIB entry will have only one source.
-     * so to save the extra memory allocation of the source's vector, we
-     * store space for one source inline. When two sources are present, 
-     * we burn extra memory.
-     * The union is switched based on the FIB_ENTRY_NODE_FLAG_MULTIPLE_SRCS
+     * Vector of source infos.
+     * Most entries will only have 1 source. So we optimise for memory usage,
+     * which is preferable since we have many entries.
      */
-    union {
-        fib_entry_src_t *fe_srcs;
-        fib_entry_src_t fe_src;
-    } fe_u_src;
-
+    fib_entry_src_t *fe_srcs;
     /**
      * the path-list for which this entry is a child. This is also the path-list
      * that is contributing forwarding for this entry.
@@ -513,6 +495,10 @@ extern fib_entry_src_flag_t fib_entry_special_remove(fib_node_index_t fib_entry_
 extern fib_entry_src_flag_t fib_entry_path_remove(fib_node_index_t fib_entry_index,
                                                  fib_source_t source,
                                                  const fib_route_path_t *rpath);
+
+extern void fib_entry_inherit(fib_node_index_t cover,
+                              fib_node_index_t covered);
+
 extern fib_entry_src_flag_t fib_entry_delete(fib_node_index_t fib_entry_index,
                                             fib_source_t source);