fib: make deag entries urpf extempt

Change-Id: Ie8f6bb4fcd3e4fa269e86a77d2f21c87f372b783
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/vnet/fib/fib_entry_src.c b/src/vnet/fib/fib_entry_src.c
index 1d73af3..66f5987 100644
--- a/src/vnet/fib/fib_entry_src.c
+++ b/src/vnet/fib/fib_entry_src.c
@@ -1077,6 +1077,10 @@
 	{
 	    esrc->fes_entry_flags &= ~FIB_ENTRY_FLAG_ATTACHED;
 	}
+	if (rpath->frp_flags & FIB_ROUTE_PATH_DEAG)
+	{
+	    esrc->fes_entry_flags |= FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT;
+	}
     }
     if (fib_route_attached_cross_table(fib_entry, rpath))
     {
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index f7fed26..fddb8ec 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -1294,6 +1294,11 @@
         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 (~0 != rpath->frp_sw_if_index)
     {
         if (ip46_address_is_zero(&rpath->frp_addr))
diff --git a/src/vnet/fib/fib_types.c b/src/vnet/fib/fib_types.c
index 48f2bd1..f38c815 100644
--- a/src/vnet/fib/fib_types.c
+++ b/src/vnet/fib/fib_types.c
@@ -416,6 +416,7 @@
         {
             rpath->frp_proto = *payload_proto;
             rpath->frp_sw_if_index = ~0;
+            rpath->frp_flags |= FIB_ROUTE_PATH_DEAG;
         }
         else if (unformat (input, "resolve-via-host"))
         {
diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h
index 94c9422..5742c69 100644
--- a/src/vnet/fib/fib_types.h
+++ b/src/vnet/fib/fib_types.h
@@ -340,6 +340,10 @@
      * A path that resolves via a BIER impostion object
      */
     FIB_ROUTE_PATH_BIER_IMP = (1 << 12),
+    /**
+     * A path that resolves via another table
+     */
+    FIB_ROUTE_PATH_DEAG = (1 << 13),
 } fib_route_path_flags_t;
 
 /**
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index fefaccf..db88d7b 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -911,6 +911,11 @@
       path_flags |= FIB_ROUTE_PATH_UDP_ENCAP;
       path.frp_udp_encap_id = next_hop_id;
     }
+  if (path.frp_sw_if_index == ~0 && ip46_address_is_zero (&path.frp_addr)
+      && path.frp_fib_index != ~0)
+    {
+      path_flags |= FIB_ROUTE_PATH_DEAG;
+    }
 
   path.frp_flags = path_flags;