fib: make deag entries urpf extempt
[vpp.git] / src / vnet / fib / fib_entry_src.c
index ff73cbf..66f5987 100644 (file)
  */
 static fib_entry_src_vft_t fib_entry_src_vft[FIB_SOURCE_MAX];
 
-static fib_protocol_t
-fib_entry_get_proto (const fib_entry_t * fib_entry)
-{
-    return (fib_entry->fe_prefix.fp_proto);
-}
-
 void
 fib_entry_src_register (fib_source_t source,
                        const fib_entry_src_vft_t *vft)
@@ -265,6 +259,23 @@ fib_entry_chain_type_fixup (const fib_entry_t *entry,
     return (dfct);
 }
 
+static dpo_proto_t
+fib_prefix_get_payload_proto (const fib_prefix_t *pfx)
+{
+    switch (pfx->fp_proto)
+    {
+    case FIB_PROTOCOL_IP4:
+        return (DPO_PROTO_IP4);
+    case FIB_PROTOCOL_IP6:
+        return (DPO_PROTO_IP6);
+    case FIB_PROTOCOL_MPLS:
+        return (pfx->fp_payload_proto);
+    }
+
+    ASSERT(0);
+    return (DPO_PROTO_IP4);
+}
+
 static void
 fib_entry_src_get_path_forwarding (fib_node_index_t path_index,
                                    fib_entry_src_collect_forwarding_ctx_t *ctx)
@@ -281,6 +292,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
          */
@@ -318,7 +330,7 @@ fib_entry_src_get_path_forwarding (fib_node_index_t path_index,
                                                                       ctx->fct),
                                            &nh->path_dpo);
             fib_path_stack_mpls_disp(path_index,
-                                     ctx->fib_entry->fe_prefix.fp_payload_proto,
+                                     fib_prefix_get_payload_proto(&ctx->fib_entry->fe_prefix),
                                      &nh->path_dpo);
 
             break;
@@ -486,8 +498,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
@@ -495,16 +507,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,
@@ -861,7 +874,7 @@ fib_entry_src_action_add (fib_entry_t *fib_entry,
        fib_entry_src_vft[source].fesv_add(esrc,
                                           fib_entry,
                                           flags,
-                                          fib_entry_get_proto(fib_entry),
+                                           fib_entry_get_dpo_proto(fib_entry),
                                           dpo);
     }
 
@@ -914,7 +927,7 @@ fib_entry_src_action_update (fib_entry_t *fib_entry,
        fib_entry_src_vft[source].fesv_add(esrc,
                                           fib_entry,
                                           flags,
-                                          fib_entry_get_proto(fib_entry),
+                                          fib_entry_get_dpo_proto(fib_entry),
                                           dpo);
     }
 
@@ -1064,6 +1077,10 @@ fib_entry_flags_update (const fib_entry_t *fib_entry,
        {
            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))
     {
@@ -1106,8 +1123,7 @@ fib_entry_src_action_path_add (fib_entry_t *fib_entry,
                                      source,
                                      flags,
                                      drop_dpo_get(
-                                         fib_proto_to_dpo(
-                                             fib_entry_get_proto(fib_entry))));
+                                         fib_entry_get_dpo_proto(fib_entry)));
        esrc = fib_entry_src_find(fib_entry, source, NULL);
     }
 
@@ -1166,8 +1182,7 @@ fib_entry_src_action_path_swap (fib_entry_t *fib_entry,
                                             source,
                                             flags,
                                              drop_dpo_get(
-                                                 fib_proto_to_dpo(
-                                                     fib_entry_get_proto(fib_entry))));
+                                                 fib_entry_get_dpo_proto(fib_entry)));
        esrc = fib_entry_src_find(fib_entry, source, NULL);
     }
 
@@ -1310,6 +1325,7 @@ fib_entry_get_dpo_for_source (fib_node_index_t fib_entry_index,
            fib_path_list_contribute_forwarding(
                esrc->fes_pl,
                fib_entry_get_default_chain_type(fib_entry),
+                FIB_PATH_LIST_FWD_FLAG_NONE,
                dpo);
 
            return (dpo_id_is_valid(dpo));