tcp: avoid rcv wnd more than RX fifo can enqueue
[vpp.git] / src / vppinfra / bihash_template.c
index f7d8807..dac42a8 100644 (file)
@@ -38,7 +38,7 @@ static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes)
       void *base, *rv;
       uword alloc = alloc_arena_next (h) - alloc_arena_mapped (h);
       int mmap_flags = MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS;
-      int mmap_flags_huge = (mmap_flags | MAP_HUGETLB |
+      int mmap_flags_huge = (mmap_flags | MAP_HUGETLB | MAP_LOCKED |
                             BIHASH_LOG2_HUGEPAGE_SIZE << MAP_HUGE_SHIFT);
 
       /* new allocation is 25% of existing one */
@@ -53,7 +53,7 @@ static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes)
       rv = mmap (base, alloc, PROT_READ | PROT_WRITE, mmap_flags_huge, -1, 0);
 
       /* fallback - maybe we are still able to allocate normal pages */
-      if (rv == MAP_FAILED)
+      if (rv == MAP_FAILED || mlock (base, alloc) != 0)
        rv = mmap (base, alloc, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
 
       if (rv == MAP_FAILED)
@@ -568,6 +568,9 @@ static_always_inline int BV (clib_bihash_add_del_inline_with_hash)
        BV (clib_bihash_instantiate) (h);
       BV (clib_bihash_alloc_unlock) (h);
     }
+#else
+  /* Debug image: make sure the table has been instantiated */
+  ASSERT (h->instantiated != 0);
 #endif
 
   b = BV (clib_bihash_get_bucket) (h, hash);