fib: P2P interfaces do not need specific multicast adjacencies
[vpp.git] / src / vnet / fib / fib_path.c
index eebba1b..60ba92b 100644 (file)
@@ -26,6 +26,7 @@
 #include <vnet/dpo/dvr_dpo.h>
 #include <vnet/dpo/ip_null_dpo.h>
 #include <vnet/dpo/classify_dpo.h>
+#include <vnet/dpo/pw_cw.h>
 
 #include <vnet/adj/adj.h>
 #include <vnet/adj/adj_mcast.h>
@@ -675,7 +676,7 @@ static void
 fib_path_attached_next_hop_set (fib_path_t *path)
 {
     /*
-     * resolve directly via the adjacnecy discribed by the
+     * resolve directly via the adjacency discribed by the
      * interface and next-hop
      */
     dpo_set(&path->fp_dpo,
@@ -1233,6 +1234,8 @@ fib_path_route_flags_to_cfg_flags (const fib_route_path_t *rpath)
 {
     fib_path_cfg_flags_t cfg_flags = FIB_PATH_CFG_FLAG_NONE;
 
+    if (rpath->frp_flags & FIB_ROUTE_PATH_POP_PW_CW)
+       cfg_flags |= FIB_PATH_CFG_FLAG_POP_PW_CW;
     if (rpath->frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_HOST)
        cfg_flags |= FIB_PATH_CFG_FLAG_RESOLVE_HOST;
     if (rpath->frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED)
@@ -2381,6 +2384,16 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index,
     case FIB_PATH_TYPE_DVR:
         break;
     }
+
+    if (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_POP_PW_CW)
+    {
+        dpo_id_t tmp = DPO_INVALID;
+
+        dpo_copy(&tmp, dpo);
+
+        pw_cw_dpo_create(&tmp, dpo);
+        dpo_reset(&tmp);
+    }
 }
 
 void
@@ -2558,9 +2571,24 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
                     /*
                      * Create the adj needed for sending IP multicast traffic
                      */
-                    ai = adj_mcast_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto),
-                                               fib_forw_chain_type_to_link_type(fct),
-                                               path->attached.fp_interface);
+                    if (vnet_sw_interface_is_p2p(vnet_get_main(),
+                                                 path->attached.fp_interface))
+                    {
+                        /*
+                         * point-2-point interfaces do not require a glean, since
+                         * there is nothing to ARP. Install a rewrite/nbr adj instead
+                         */
+                        ai = adj_nbr_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto),
+                                                 fib_forw_chain_type_to_link_type(fct),
+                                                 &zero_addr,
+                                                 path->attached.fp_interface);
+                    }
+                    else
+                    {
+                        ai = adj_mcast_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto),
+                                                   fib_forw_chain_type_to_link_type(fct),
+                                                   path->attached.fp_interface);
+                    }
                     dpo_set(dpo, DPO_ADJACENCY,
                             fib_forw_chain_type_to_dpo_proto(fct),
                             ai);