Remove usued, redundant and deprecated code from lookup.h
[vpp.git] / src / vnet / sr / sr_steering.c
index be1bb7a..0464619 100755 (executable)
@@ -72,16 +72,14 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
   memset (&key, 0, sizeof (sr_steering_key_t));
 
   /* Compute the steer policy key */
-  if (prefix)
+  if (traffic_type == SR_STEER_IPV4 || traffic_type == SR_STEER_IPV6)
     {
       key.l3.prefix.as_u64[0] = prefix->as_u64[0];
       key.l3.prefix.as_u64[1] = prefix->as_u64[1];
       key.l3.mask_width = mask_width;
       key.l3.fib_table = (table_id != (u32) ~ 0 ? table_id : 0);
-      if (traffic_type != SR_STEER_IPV4 && traffic_type != SR_STEER_IPV6)
-       return -1;
     }
-  else
+  else if (traffic_type == SR_STEER_L2)
     {
       key.l2.sw_if_index = sw_if_index;
 
@@ -94,9 +92,9 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
        vnet_get_sw_interface (sm->vnet_main, sw_if_index);
       if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
        return -3;
-      if (traffic_type != SR_STEER_L2)
-       return -1;
     }
+  else
+    return -1;
 
   key.traffic_type = traffic_type;
 
@@ -117,10 +115,10 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
              pfx.fp_len = steer_pl->classify.l3.mask_width;
              pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
 
-             fib_table_entry_delete (fib_table_id_find_fib_index
+             fib_table_entry_delete (fib_table_find
                                      (FIB_PROTOCOL_IP6,
-                                      steer_pl->classify.l3.fib_table), &pfx,
-                                     FIB_SOURCE_SR);
+                                      steer_pl->classify.l3.fib_table),
+                                     &pfx, FIB_SOURCE_SR);
            }
          else if (steer_pl->classify.traffic_type == SR_STEER_IPV4)
            {
@@ -129,7 +127,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
              pfx.fp_len = steer_pl->classify.l3.mask_width;
              pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
 
-             fib_table_entry_delete (fib_table_id_find_fib_index
+             fib_table_entry_delete (fib_table_find
                                      (FIB_PROTOCOL_IP4,
                                       steer_pl->classify.l3.fib_table), &pfx,
                                      FIB_SOURCE_SR);
@@ -196,10 +194,10 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
              pfx.fp_len = steer_pl->classify.l3.mask_width;
              pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
 
-             fib_table_entry_delete (fib_table_id_find_fib_index
+             fib_table_entry_delete (fib_table_find
                                      (FIB_PROTOCOL_IP6,
-                                      steer_pl->classify.l3.fib_table), &pfx,
-                                     FIB_SOURCE_SR);
+                                      steer_pl->classify.l3.fib_table),
+                                     &pfx, FIB_SOURCE_SR);
 
              /* Create a new one */
              goto update_fib;
@@ -211,10 +209,10 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
              pfx.fp_len = steer_pl->classify.l3.mask_width;
              pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
 
-             fib_table_entry_delete (fib_table_id_find_fib_index
+             fib_table_entry_delete (fib_table_find
                                      (FIB_PROTOCOL_IP4,
-                                      steer_pl->classify.l3.fib_table), &pfx,
-                                     FIB_SOURCE_SR);
+                                      steer_pl->classify.l3.fib_table),
+                                     &pfx, FIB_SOURCE_SR);
 
              /* Create a new one */
              goto update_fib;
@@ -280,8 +278,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
        goto cleanup_error_encap;
 
       if (vnet_feature_enable_disable
-         ("device-input", "sr-policy-rewrite-encaps-l2", sw_if_index, 1, 0,
-          0))
+         ("device-input", "sr-pl-rewrite-encaps-l2", sw_if_index, 1, 0, 0))
        goto cleanup_error_redirection;
 
       /* Set promiscous mode on interface */
@@ -307,11 +304,12 @@ update_fib:
       pfx.fp_len = steer_pl->classify.l3.mask_width;
       pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
 
-      fib_table_entry_path_add (fib_table_id_find_fib_index (FIB_PROTOCOL_IP6,
-                                                            (table_id !=
-                                                             (u32) ~ 0 ?
-                                                             table_id : 0)),
-                               &pfx, FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE,
+      fib_table_entry_path_add (fib_table_find (FIB_PROTOCOL_IP6,
+                                               (table_id !=
+                                                (u32) ~ 0 ?
+                                                table_id : 0)),
+                               &pfx, FIB_SOURCE_SR,
+                               FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT,
                                FIB_PROTOCOL_IP6,
                                (ip46_address_t *) & sr_policy->bsid, ~0,
                                sm->fib_table_ip6, 1, NULL,
@@ -323,11 +321,12 @@ update_fib:
       pfx.fp_len = steer_pl->classify.l3.mask_width;
       pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
 
-      fib_table_entry_path_add (fib_table_id_find_fib_index (FIB_PROTOCOL_IP4,
-                                                            (table_id !=
-                                                             (u32) ~ 0 ?
-                                                             table_id : 0)),
-                               &pfx, FIB_SOURCE_CLI, FIB_ENTRY_FLAG_NONE,
+      fib_table_entry_path_add (fib_table_find (FIB_PROTOCOL_IP4,
+                                               (table_id !=
+                                                (u32) ~ 0 ?
+                                                table_id : 0)),
+                               &pfx, FIB_SOURCE_SR,
+                               FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT,
                                FIB_PROTOCOL_IP6,
                                (ip46_address_t *) & sr_policy->bsid, ~0,
                                sm->fib_table_ip4, 1, NULL,
@@ -552,13 +551,18 @@ sr_steering_init (vlib_main_t * vm)
   return 0;
 }
 
+/* *INDENT-OFF* */
 VLIB_INIT_FUNCTION (sr_steering_init);
+/* *INDENT-ON* */
 
-VNET_FEATURE_INIT (sr_policy_rewrite_encaps_l2, static) =
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT (sr_pl_rewrite_encaps_l2, static) =
 {
-.arc_name = "device-input",.node_name =
-    "sr-pl-rewrite-encaps-l2",.runs_before =
-    VNET_FEATURES ("ethernet-input"),};
+  .arc_name = "device-input",
+  .node_name = "sr-pl-rewrite-encaps-l2",
+  .runs_before = VNET_FEATURES ("ethernet-input"),
+};
+/* *INDENT-ON* */
 
 /*
 * fd.io coding-style-patch-verification: ON