vppinfra: bihash walk cb typedef and continue/stop controls
[vpp.git] / src / vnet / ip / reass / ip4_sv_reass.c
index 25119e8..d713062 100644 (file)
@@ -148,8 +148,8 @@ typedef struct
   u32 fq_index;
   u32 fq_feature_index;
 
-  // reference count for enabling/disabling feature
-  u32 feature_use_refcount;
+  // reference count for enabling/disabling feature - per interface
+  u32 *feature_use_refcount_per_intf;
 
 } ip4_sv_reass_main_t;
 
@@ -711,7 +711,7 @@ typedef struct
 } ip4_rehash_cb_ctx;
 
 #ifndef CLIB_MARCH_VARIANT
-static void
+static int
 ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
 {
   ip4_rehash_cb_ctx *ctx = _ctx;
@@ -719,6 +719,7 @@ ip4_rehash_cb (clib_bihash_kv_16_8_t * kv, void *_ctx)
     {
       ctx->failure = 1;
     }
+  return (BIHASH_WALK_CONTINUE);
 }
 
 static void
@@ -822,6 +823,8 @@ ip4_sv_reass_init_function (vlib_main_t * vm)
   rm->fq_feature_index =
     vlib_frame_queue_main_init (ip4_sv_reass_node_feature.index, 0);
 
+  rm->feature_use_refcount_per_intf = NULL;
+
   return error;
 }
 
@@ -1160,26 +1163,27 @@ int
 ip4_sv_reass_enable_disable_with_refcnt (u32 sw_if_index, int is_enable)
 {
   ip4_sv_reass_main_t *rm = &ip4_sv_reass_main;
+  vec_validate (rm->feature_use_refcount_per_intf, sw_if_index);
   if (is_enable)
     {
-      if (!rm->feature_use_refcount)
+      if (!rm->feature_use_refcount_per_intf[sw_if_index])
        {
-         ++rm->feature_use_refcount;
+         ++rm->feature_use_refcount_per_intf[sw_if_index];
          return vnet_feature_enable_disable ("ip4-unicast",
                                              "ip4-sv-reassembly-feature",
                                              sw_if_index, 1, 0, 0);
        }
-      ++rm->feature_use_refcount;
+      ++rm->feature_use_refcount_per_intf[sw_if_index];
     }
   else
     {
-      --rm->feature_use_refcount;
-      if (!rm->feature_use_refcount)
+      --rm->feature_use_refcount_per_intf[sw_if_index];
+      if (!rm->feature_use_refcount_per_intf[sw_if_index])
        return vnet_feature_enable_disable ("ip4-unicast",
                                            "ip4-sv-reassembly-feature",
                                            sw_if_index, 0, 0, 0);
     }
-  return -1;
+  return 0;
 }
 
 uword