DVR: run L3 output features
[vpp.git] / src / vnet / fib / fib_path.c
index 4fccca8..ffb7ad2 100644 (file)
@@ -23,7 +23,8 @@
 #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/dpo/dvr_dpo.h>
+#include <vnet/dpo/drop_dpo.h>
 
 #include <vnet/adj/adj.h>
 #include <vnet/adj/adj_mcast.h>
 #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>
+#include <vnet/bier/bier_disp_table.h>
 
 /**
  * Enurmeration of path types
@@ -82,10 +87,26 @@ typedef enum fib_path_type_t_ {
      * receive. it's for-us.
      */
     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,
+    /**
+     * via a DVR.
+     */
+    FIB_PATH_TYPE_DVR,
     /**
      * 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 +124,16 @@ 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",          \
+    [FIB_PATH_TYPE_DVR]               = "dvr",                 \
 }
 
-#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,11 +279,37 @@ 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 {
+            /**
+             * BIER FMask ID
+             */
+            index_t fp_bier_fmask;
+       } 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
@@ -297,6 +350,12 @@ typedef struct fib_path_t_ {
             */
            u32 fp_udp_encap_id;
        } udp_encap;
+       struct {
+           /**
+            * The interface
+            */
+           u32 fp_interface;
+       } dvr;
     };
     STRUCT_MARK(path_hash_end);
 
@@ -311,11 +370,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-table
+         */
+        index_t fp_via_bier_tbl;
+        /**
+         * the resolving bier-fmask
+         */
+        index_t fp_via_bier_fmask;
+    };
 
     /**
      * The Data-path objects through which this path resolves for IP.
@@ -348,8 +417,8 @@ static fib_path_t *fib_path_pool;
 {                                                              \
     u8 *_tmp = NULL;                                           \
     _tmp = fib_path_format(fib_path_get_index(_p), _tmp);      \
-    clib_warning("path:[%d:%s]:" _fmt,                         \
-                fib_path_get_index(_p), _tmp,                  \
+    clib_warning("path:[%d:%U]:" _fmt,                         \
+                fib_path_get_index(_p), format_fib_path, _p, 0,\
                 ##_args);                                      \
     vec_free(_tmp);                                            \
 }
@@ -378,21 +447,24 @@ fib_path_get_node (fib_node_index_t index)
 static fib_path_t*
 fib_path_from_fib_node (fib_node_t *node)
 {
-#if CLIB_DEBUG > 0
     ASSERT(FIB_NODE_TYPE_PATH == node->fn_type);
-#endif
     return ((fib_path_t*)node);
 }
 
 u8 *
 format_fib_path (u8 * s, va_list * args)
 {
-    fib_path_t *path = va_arg (*args, fib_path_t *);
+    fib_node_index_t path_index = va_arg (*args, fib_node_index_t);
+    u32 indent = va_arg (*args, u32);
     vnet_main_t * vnm = vnet_get_main();
     fib_path_oper_attribute_t oattr;
     fib_path_cfg_attribute_t cattr;
+    fib_path_t *path;
+
+    path = fib_path_get(path_index);
 
-    s = format (s, "      index:%d ", fib_path_get_index(path));
+    s = format (s, "%Upath:[%d] ", format_white_space, indent,
+                fib_path_get_index(path));
     s = format (s, "pl-index:%d ", path->fp_pl_index);
     s = format (s, "%U ", format_dpo_proto, path->fp_nh_proto);
     s = format (s, "weight=%d ", path->fp_weight);
@@ -414,7 +486,7 @@ format_fib_path (u8 * s, va_list * args)
            }
        }
     }
-    s = format(s, "\n       ");
+    s = format(s, "\n%U", format_white_space, indent+2);
 
     switch (path->fp_type)
     {
@@ -442,19 +514,20 @@ format_fib_path (u8 * s, va_list * args)
        }
        if (!dpo_id_is_valid(&path->fp_dpo))
        {
-           s = format(s, "\n          unresolved");
+           s = format(s, "\n%Uunresolved", format_white_space, indent+2);
        }
        else
        {
-           s = format(s, "\n          %U",
-                      format_dpo_id,
+           s = format(s, "\n%U%U",
+                      format_white_space, indent,
+                       format_dpo_id,
                       &path->fp_dpo, 13);
        }
        break;
     case FIB_PATH_TYPE_ATTACHED:
        if (path->fp_oper_flags & FIB_PATH_OPER_FLAG_DROP)
        {
-           s = format (s, " if_index:%d", path->attached_next_hop.fp_interface);
+           s = format (s, "if_index:%d", path->attached_next_hop.fp_interface);
        }
        else
        {
@@ -492,7 +565,33 @@ format_fib_path (u8 * s, va_list * args)
 
        break;
     case FIB_PATH_TYPE_UDP_ENCAP:
-        s = format (s, " UDP-encap ID:%d", path->udp_encap.fp_udp_encap_id);
+        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-fmask:%d", path->bier_fmask.fp_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_DVR:
+        s = format (s, " %U",
+                    format_vnet_sw_interface_name,
+                    vnm,
+                    vnet_get_sw_interface(
+                        vnm,
+                        path->dvr.fp_interface));
         break;
     case FIB_PATH_TYPE_RECEIVE:
     case FIB_PATH_TYPE_INTF_RX:
@@ -502,7 +601,7 @@ format_fib_path (u8 * s, va_list * args)
        if (dpo_id_is_valid(&path->fp_dpo))
        {
            s = format(s, "%U", format_dpo_id,
-                      &path->fp_dpo, 2);
+                      &path->fp_dpo, indent+2);
        }
        break;
     }
@@ -520,29 +619,6 @@ fib_path_format (fib_node_index_t pi, u8 *s)
     return (format (s, "%U", format_fib_path, path));
 }
 
-u8 *
-fib_path_adj_format (fib_node_index_t pi,
-                    u32 indent,
-                    u8 *s)
-{
-    fib_path_t *path;
-
-    path = fib_path_get(pi);
-    ASSERT(NULL != path);
-
-    if (!dpo_id_is_valid(&path->fp_dpo))
-    {
-       s = format(s, " unresolved");
-    }
-    else
-    {
-       s = format(s, "%U", format_dpo_id,
-                  &path->fp_dpo, 2);
-    }
-
-    return (s);
-}
-
 /*
  * fib_path_last_lock_gone
  *
@@ -741,6 +817,28 @@ fib_path_recursive_adj_update (fib_path_t *path,
     dpo_reset(&via_dpo);
 }
 
+/*
+ * 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->bier_fmask.fp_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
  *
@@ -786,18 +884,25 @@ fib_path_unresolve (fib_path_t *path)
            path->fp_via_fib = FIB_NODE_INDEX_INVALID;
        }
        break;
+    case FIB_PATH_TYPE_BIER_FMASK:
+        bier_fmask_child_remove(path->fp_via_bier_fmask,
+                                path->fp_sibling);
+       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);
         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);
-        }
+        adj_child_remove(path->fp_dpo.dpoi_index,
+                         path->fp_sibling);
+        adj_unlock(path->fp_dpo.dpoi_index);
         break;
     case FIB_PATH_TYPE_UDP_ENCAP:
        udp_encap_unlock_w_index(path->fp_dpo.dpoi_index);
@@ -809,6 +914,7 @@ fib_path_unresolve (fib_path_t *path)
     case FIB_PATH_TYPE_RECEIVE:
     case FIB_PATH_TYPE_INTF_RX:
     case FIB_PATH_TYPE_DEAG:
+    case FIB_PATH_TYPE_DVR:
         /*
          * these hold only the path's DPO, which is reset below.
          */
@@ -890,6 +996,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
@@ -988,6 +1118,7 @@ FIXME comment
         }
        break;
     case FIB_PATH_TYPE_ATTACHED:
+    case FIB_PATH_TYPE_DVR:
        /*
         * FIXME; this could schedule a lower priority walk, since attached
         * routes are not usually in ECMP configurations so the backwalk to
@@ -1043,6 +1174,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 +1297,31 @@ 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_bier_fmask = rpath->frp_bier_fmask;
+    }
+    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 (rpath->frp_flags & FIB_ROUTE_PATH_DEAG)
+    {
+       path->fp_type = FIB_PATH_TYPE_DEAG;
+       path->deag.fp_tbl_id = rpath->frp_fib_index;
+    }
+    else if (rpath->frp_flags & FIB_ROUTE_PATH_DVR)
+    {
+       path->fp_type = FIB_PATH_TYPE_DVR;
+       path->dvr.fp_interface = rpath->frp_sw_if_index;
+    }
     else if (~0 != rpath->frp_sw_if_index)
     {
         if (ip46_address_is_zero(&rpath->frp_addr))
@@ -1204,7 +1362,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 +1544,18 @@ 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 = (path1->bier_fmask.fp_bier_fmask -
+                   path2->bier_fmask.fp_bier_fmask);
+           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)
@@ -1399,6 +1569,9 @@ fib_path_cmp_i (const fib_path_t *path1,
        case FIB_PATH_TYPE_UDP_ENCAP:
            res = (path1->udp_encap.fp_udp_encap_id - path2->udp_encap.fp_udp_encap_id);
            break;
+       case FIB_PATH_TYPE_DVR:
+           res = (path1->dvr.fp_interface - path2->dvr.fp_interface);
+           break;
        case FIB_PATH_TYPE_SPECIAL:
        case FIB_PATH_TYPE_RECEIVE:
        case FIB_PATH_TYPE_EXCLUSIVE:
@@ -1510,6 +1683,16 @@ 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 = (path->bier_fmask.fp_bier_fmask - rpath->frp_bier_fmask);
+           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;
@@ -1523,6 +1706,9 @@ fib_path_cmp_w_route_path (fib_node_index_t path_index,
                 res = (path->deag.fp_rpf_id - rpath->frp_rpf_id);
             }
             break;
+       case FIB_PATH_TYPE_DVR:
+           res = (path->dvr.fp_interface - rpath->frp_sw_if_index);
+           break;
        case FIB_PATH_TYPE_SPECIAL:
        case FIB_PATH_TYPE_RECEIVE:
        case FIB_PATH_TYPE_EXCLUSIVE:
@@ -1619,10 +1805,14 @@ fib_path_recursive_loop_detect (fib_node_index_t path_index,
     case FIB_PATH_TYPE_ATTACHED:
     case FIB_PATH_TYPE_SPECIAL:
     case FIB_PATH_TYPE_DEAG:
+    case FIB_PATH_TYPE_DVR:
     case FIB_PATH_TYPE_RECEIVE:
     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.
@@ -1661,35 +1851,27 @@ fib_path_resolve (fib_node_index_t path_index)
        fib_path_attached_next_hop_set(path);
        break;
     case FIB_PATH_TYPE_ATTACHED:
-        if (DPO_PROTO_ETHERNET == path->fp_nh_proto)
+        /*
+         * path->attached.fp_interface
+         */
+        if (!vnet_sw_interface_is_admin_up(vnet_get_main(),
+                                           path->attached.fp_interface))
         {
-            l2_bridge_dpo_add_or_lock(path->attached.fp_interface,
-                                      &path->fp_dpo);
+            path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED;
         }
-        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)));
+        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));
-        }
+        /*
+         * 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:
     {
@@ -1742,6 +1924,41 @@ fib_path_resolve (fib_node_index_t path_index)
 
        break;
     }
+    case FIB_PATH_TYPE_BIER_FMASK:
+    {
+        /*
+         * 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->bier_fmask.fp_bier_fmask,
+                                                FIB_NODE_TYPE_PATH,
+                                                fib_path_get_index(path));
+
+        path->fp_via_bier_fmask = path->bier_fmask.fp_bier_fmask;
+        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
@@ -1750,28 +1967,41 @@ fib_path_resolve (fib_node_index_t path_index)
        break;
     case FIB_PATH_TYPE_DEAG:
     {
-       /*
-        * Resolve via a lookup DPO.
-         * FIXME. control plane should add routes with a table ID
-        */
-        lookup_input_t input;
-        lookup_cast_t cast;
-
-        cast = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_RPF_ID ?
-                LOOKUP_MULTICAST :
-                LOOKUP_UNICAST);
-        input = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_DEAG_SRC ?
-                LOOKUP_INPUT_SRC_ADDR :
-                LOOKUP_INPUT_DST_ADDR);
-
-        lookup_dpo_add_or_lock_w_fib_index(path->deag.fp_tbl_id,
-                                           path->fp_nh_proto,
-                                           cast,
-                                           input,
-                                           LOOKUP_TABLE_FROM_CONFIG,
-                                           &path->fp_dpo);
-       break;
+        if (DPO_PROTO_BIER == path->fp_nh_proto)
+        {
+            bier_disp_table_contribute_forwarding(path->deag.fp_tbl_id,
+                                                  &path->fp_dpo);
+        }
+        else
+        {
+            /*
+             * Resolve via a lookup DPO.
+             * FIXME. control plane should add routes with a table ID
+             */
+            lookup_input_t input;
+            lookup_cast_t cast;
+
+            cast = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_RPF_ID ?
+                    LOOKUP_MULTICAST :
+                    LOOKUP_UNICAST);
+            input = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_DEAG_SRC ?
+                     LOOKUP_INPUT_SRC_ADDR :
+                     LOOKUP_INPUT_DST_ADDR);
+
+            lookup_dpo_add_or_lock_w_fib_index(path->deag.fp_tbl_id,
+                                               path->fp_nh_proto,
+                                               cast,
+                                               input,
+                                               LOOKUP_TABLE_FROM_CONFIG,
+                                               &path->fp_dpo);
+        }
+        break;
     }
+    case FIB_PATH_TYPE_DVR:
+        dvr_dpo_add_or_lock(path->attached.fp_interface,
+                            path->fp_nh_proto,
+                            &path->fp_dpo);
+        break;
     case FIB_PATH_TYPE_RECEIVE:
        /*
         * Resolve via a receive DPO.
@@ -1828,16 +2058,53 @@ fib_path_get_resolving_interface (fib_node_index_t path_index)
             return (fib_entry_get_resolving_interface(path->fp_via_fib));
         }
         break;
+    case FIB_PATH_TYPE_DVR:
+       return (path->dvr.fp_interface);
     case FIB_PATH_TYPE_INTF_RX:
     case FIB_PATH_TYPE_UDP_ENCAP:
     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_DVR:
+    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->bier_fmask.fp_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 +2144,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
@@ -1933,10 +2217,16 @@ fib_path_contribute_urpf (fib_node_index_t path_index,
        }
        break;
     }
+    case FIB_PATH_TYPE_DVR:
+       fib_urpf_list_append(urpf, path->dvr.fp_interface);
+       break;
     case FIB_PATH_TYPE_DEAG:
     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
         */
@@ -1957,6 +2247,18 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index,
 
     switch (path->fp_type)
     {
+    case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
+    {
+        dpo_id_t tmp = DPO_INVALID;
+
+        dpo_copy(&tmp, dpo);
+        dpo_set(dpo,
+                DPO_MPLS_DISPOSITION,
+                payload_proto,
+                mpls_disp_dpo_create(payload_proto, ~0, &tmp));
+        dpo_reset(&tmp);
+        break;
+    }                
     case FIB_PATH_TYPE_DEAG:
     {
         dpo_id_t tmp = DPO_INVALID;
@@ -1973,12 +2275,15 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index,
     }
     case FIB_PATH_TYPE_RECEIVE:
     case FIB_PATH_TYPE_ATTACHED:
-    case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
     case FIB_PATH_TYPE_RECURSIVE:
     case FIB_PATH_TYPE_INTF_RX:
     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:
+    case FIB_PATH_TYPE_DVR:
         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);
@@ -2084,11 +2434,6 @@ 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:
@@ -2097,6 +2442,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;
 
@@ -2145,6 +2491,7 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
             break;
         case FIB_PATH_TYPE_RECEIVE:
         case FIB_PATH_TYPE_SPECIAL:
+        case FIB_PATH_TYPE_DVR:
             dpo_copy(dpo, &path->fp_dpo);
             break;
        }
@@ -2247,27 +2594,28 @@ fib_path_encode (fib_node_index_t path_list_index,
     api_rpath->rpath.frp_preference = path->fp_preference;
     api_rpath->rpath.frp_proto = path->fp_nh_proto;
     api_rpath->rpath.frp_sw_if_index = ~0;
-    api_rpath->dpo = path->exclusive.fp_ex_dpo;
+    api_rpath->dpo = path->fp_dpo;
+
     switch (path->fp_type)
       {
       case FIB_PATH_TYPE_RECEIVE:
         api_rpath->rpath.frp_addr = path->receive.fp_addr;
         api_rpath->rpath.frp_sw_if_index = path->receive.fp_interface;
-        api_rpath->dpo = path->fp_dpo;
         break;
       case FIB_PATH_TYPE_ATTACHED:
         api_rpath->rpath.frp_sw_if_index = path->attached.fp_interface;
-        api_rpath->dpo = path->fp_dpo;
         break;
       case FIB_PATH_TYPE_ATTACHED_NEXT_HOP:
         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_bier_fmask = path->bier_fmask.fp_bier_fmask;
+        break;
       case FIB_PATH_TYPE_SPECIAL:
         break;
       case FIB_PATH_TYPE_DEAG:
         api_rpath->rpath.frp_fib_index = path->deag.fp_tbl_id;
-        api_rpath->dpo = path->fp_dpo;
         break;
       case FIB_PATH_TYPE_RECURSIVE:
         api_rpath->rpath.frp_addr = path->recursive.fp_nh.fp_ip;
@@ -2275,6 +2623,7 @@ fib_path_encode (fib_node_index_t path_list_index,
       default:
         break;
       }
+
     return (FIB_PATH_LIST_WALK_CONTINUE);
 }
 
@@ -2310,7 +2659,7 @@ show_fib_path_command (vlib_main_t * vm,
        if (!pool_is_free_index(fib_path_pool, pi))
        {
            path = fib_path_get(pi);
-           u8 *s = fib_path_format(pi, NULL);
+           u8 *s = format(NULL, "%U", format_fib_path, pi, 1);
            s = format(s, "children:");
            s = fib_node_children_format(path->fp_node.fn_children, s);
            vlib_cli_output (vm, "%s", s);
@@ -2324,9 +2673,9 @@ show_fib_path_command (vlib_main_t * vm,
     else
     {
        vlib_cli_output (vm, "FIB Paths");
-       pool_foreach(path, fib_path_pool,
+       pool_foreach_index (pi, fib_path_pool,
        ({
-           vlib_cli_output (vm, "%U", format_fib_path, path);
+           vlib_cli_output (vm, "%U", format_fib_path, pi, 0);
        }));
     }