diff --git a/src/svm/svm_fifo_segment.c b/src/svm/svm_fifo_segment.c
index a56a714..4d1833e 100644
--- a/src/svm/svm_fifo_segment.c
+++ b/src/svm/svm_fifo_segment.c
@@ -58,7 +58,7 @@
 
 static void
 preallocate_fifo_pairs (svm_fifo_segment_private_t * s,
-			svm_fifo_segment_create_args_t * a)
+			svm_fifo_segment_create_args_t * a, u32 protect_size)
 {
   svm_fifo_segment_header_t *fsh = s->h;
   u32 rx_fifo_size, tx_fifo_size, pairs_to_allocate;
@@ -99,18 +99,17 @@
 
   /* Calculate space requirements */
   pair_size = 2 * sizeof (*f) + rx_rounded_data_size + tx_rounded_data_size;
-  pairs_to_allocate = clib_min (s->ssvm.ssvm_size / pair_size,
-				a->preallocated_fifo_pairs);
+  if (protect_size)
+    protect_size += mheap_bytes (s->ssvm.sh->heap);
+  pairs_to_allocate =
+    clib_min ((s->ssvm.ssvm_size - protect_size) / pair_size,
+	      a->preallocated_fifo_pairs);
   rx_fifo_size = (sizeof (*f) + rx_rounded_data_size) * pairs_to_allocate;
   tx_fifo_size = (sizeof (*f) + tx_rounded_data_size) * pairs_to_allocate;
 
   vec_validate_init_empty (fsh->free_fifos,
 			   clib_max (rx_freelist_index, tx_freelist_index),
 			   0);
-  if (0)
-    clib_warning ("rx_fifo_size %u (%d mb), tx_fifo_size %u (%d mb)",
-		  rx_fifo_size, rx_fifo_size >> 20,
-		  tx_fifo_size, tx_fifo_size >> 20);
 
   /* Allocate rx fifo space. May fail. */
   rx_fifo_space = clib_mem_alloc_aligned_at_offset
@@ -164,16 +163,18 @@
   a->preallocated_fifo_pairs -= pairs_to_allocate;
 }
 
-/** (master) create an svm fifo segment */
+/**
+ * Create an svm fifo segment and initialize as master
+ */
 int
 svm_fifo_segment_create (svm_fifo_segment_create_args_t * a)
 {
-  int rv;
-  svm_fifo_segment_private_t *s;
   svm_fifo_segment_main_t *sm = &svm_fifo_segment_main;
+  svm_fifo_segment_private_t *s;
   ssvm_shared_header_t *sh;
   svm_fifo_segment_header_t *fsh;
   void *oldheap;
+  int rv;
 
   /* Allocate a fresh segment */
   pool_get (sm->segments, s);
@@ -185,16 +186,14 @@
   s->ssvm.name = format (0, "%s%c", a->segment_name, 0);
   s->ssvm.requested_va = sm->next_baseva;
 
-  rv = ssvm_master_init (&s->ssvm, s - sm->segments);
-
-  if (rv)
+  if ((rv = ssvm_master_init (&s->ssvm, a->segment_type)))
     {
-      _vec_len (s) = vec_len (s) - 1;
+      pool_put (sm->segments, s);
       return (rv);
     }
 
   /* Note: requested_va updated due to seg base addr randomization */
-  sm->next_baseva = s->ssvm.requested_va + a->segment_size;
+  sm->next_baseva = s->ssvm.sh->ssvm_va + a->segment_size;
 
   sh = s->ssvm.sh;
   oldheap = ssvm_push_heap (sh);
@@ -202,10 +201,8 @@
   /* Set up svm_fifo_segment shared header */
   fsh = clib_mem_alloc (sizeof (*fsh));
   memset (fsh, 0, sizeof (*fsh));
-  sh->opaque[0] = fsh;
-  s->h = fsh;
-  fsh->segment_name = format (0, "%s%c", a->segment_name, 0);
-  preallocate_fifo_pairs (s, a);
+  s->h = sh->opaque[0] = fsh;
+  preallocate_fifo_pairs (s, a, a->seg_protected_space);
 
   ssvm_pop_heap (oldheap);
 
@@ -214,7 +211,9 @@
   return (0);
 }
 
-/** Create an svm fifo segment in process-private memory */
+/**
+ * Create an svm fifo segment in process-private memory
+ */
 int
 svm_fifo_segment_create_process_private (svm_fifo_segment_create_args_t * a)
 {
@@ -272,12 +271,10 @@
       /* Set up svm_fifo_segment shared header */
       fsh = clib_mem_alloc (sizeof (*fsh));
       memset (fsh, 0, sizeof (*fsh));
-      sh->opaque[0] = fsh;
-      s->h = fsh;
       fsh->flags = FIFO_SEGMENT_F_IS_PRIVATE;
+      s->h = sh->opaque[0] = fsh;
       if (!a->private_segment_count)
 	fsh->flags |= FIFO_SEGMENT_F_IS_MAIN_HEAP;
-      fsh->segment_name = format (0, "%s%c", a->segment_name, 0);
 
       if (a->private_segment_count)
 	{
@@ -285,7 +282,7 @@
 	    fsh->flags |= FIFO_SEGMENT_F_IS_PREALLOCATED;
 	  oldheap = clib_mem_get_heap ();
 	  clib_mem_set_heap (sh->heap);
-	  preallocate_fifo_pairs (s, a);
+	  preallocate_fifo_pairs (s, a, i == 0 ? a->seg_protected_space : 0);
 	  clib_mem_set_heap (oldheap);
 	}
       sh->ready = 1;
@@ -295,15 +292,15 @@
   return (0);
 }
 
-/** (slave) attach to an svm fifo segment */
+/**
+ * Attach as slave to an svm fifo segment
+ */
 int
 svm_fifo_segment_attach (svm_fifo_segment_create_args_t * a)
 {
-  int rv;
-  svm_fifo_segment_private_t *s;
   svm_fifo_segment_main_t *sm = &svm_fifo_segment_main;
-  ssvm_shared_header_t *sh;
-  svm_fifo_segment_header_t *fsh;
+  svm_fifo_segment_private_t *s;
+  int rv;
 
   /* Allocate a fresh segment */
   pool_get (sm->segments, s);
@@ -313,19 +310,19 @@
   s->ssvm.my_pid = getpid ();
   s->ssvm.name = format (0, "%s%c", a->segment_name, 0);
   s->ssvm.requested_va = sm->next_baseva;
+  if (a->segment_type == SSVM_SEGMENT_MEMFD)
+    s->ssvm.fd = a->memfd_fd;
+  else
+    s->ssvm.attach_timeout = sm->timeout_in_seconds;
 
-  rv = ssvm_slave_init (&s->ssvm, sm->timeout_in_seconds);
-
-  if (rv)
+  if ((rv = ssvm_slave_init (&s->ssvm, a->segment_type)))
     {
       _vec_len (s) = vec_len (s) - 1;
       return (rv);
     }
 
   /* Fish the segment header */
-  sh = s->ssvm.sh;
-  fsh = (svm_fifo_segment_header_t *) sh->opaque[0];
-  s->h = fsh;
+  s->h = s->ssvm.sh->opaque[0];
 
   vec_add1 (a->new_segment_indices, s - sm->segments);
   return (0);
@@ -335,6 +332,7 @@
 svm_fifo_segment_delete (svm_fifo_segment_private_t * s)
 {
   svm_fifo_segment_main_t *sm = &svm_fifo_segment_main;
+
   if (s->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
     {
       /* Don't try to free vpp's heap! */
@@ -342,15 +340,18 @@
 	mheap_free (s->ssvm.sh->heap);
       clib_mem_free (s->ssvm.sh);
       clib_mem_free (s->h);
-      pool_put (sm->segments, s);
     }
   else
     {
       ssvm_delete (&s->ssvm);
-      pool_put (sm->segments, s);
     }
+  memset (s, 0xfe, sizeof (*s));
+  pool_put (sm->segments, s);
 }
 
+/**
+ * Allocate fifo in svm segment
+ */
 svm_fifo_t *
 svm_fifo_segment_alloc_fifo (svm_fifo_segment_private_t * s,
 			     u32 data_size_in_bytes,
@@ -590,6 +591,53 @@
   return count;
 }
 
+void
+svm_fifo_segment_info (svm_fifo_segment_private_t * seg, uword * address,
+		       u64 * size)
+{
+  if (seg->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
+    {
+      mheap_t *heap_header;
+
+      *address = pointer_to_uword (seg->ssvm.sh->heap);
+      heap_header = mheap_header (seg->ssvm.sh->heap);
+      *size = heap_header->max_size;
+    }
+  else
+    {
+      *address = seg->ssvm.sh->ssvm_va;
+      *size = seg->ssvm.ssvm_size;
+    }
+}
+
+mheap_t *
+svm_fifo_segment_heap (svm_fifo_segment_private_t * seg)
+{
+  return seg->ssvm.sh->heap;
+}
+
+u8 *
+format_svm_fifo_segment_type (u8 * s, va_list * args)
+{
+  svm_fifo_segment_private_t *sp;
+  sp = va_arg (*args, svm_fifo_segment_private_t *);
+  ssvm_segment_type_t st = ssvm_type (&sp->ssvm);
+
+  if ((sp->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
+      && !(sp->h->flags & FIFO_SEGMENT_F_IS_MAIN_HEAP))
+    s = format (s, "%s", "private-heap");
+  else if ((sp->h->flags & FIFO_SEGMENT_F_IS_PRIVATE)
+	   && (sp->h->flags & FIFO_SEGMENT_F_IS_MAIN_HEAP))
+    s = format (s, "%s", "main-heap");
+  else if (st == SSVM_SEGMENT_MEMFD)
+    s = format (s, "%s", "memfd");
+  else if (st == SSVM_SEGMENT_SHM)
+    s = format (s, "%s", "shm");
+  else
+    s = format (s, "%s", "unknown");
+  return s;
+}
+
 /**
  * Segment format function
  */
@@ -599,18 +647,14 @@
   svm_fifo_segment_private_t *sp
     = va_arg (*args, svm_fifo_segment_private_t *);
   int verbose = va_arg (*args, int);
-  ssvm_shared_header_t *sh;
-  svm_fifo_segment_header_t *fsh;
+  svm_fifo_segment_header_t *fsh = sp->h;
+  u32 count, indent;
   svm_fifo_t *f;
   int i;
-  u32 count;
-  u32 indent = format_get_indent (s) + 2;
 
-  sh = sp->ssvm.sh;
-  fsh = (svm_fifo_segment_header_t *) sh->opaque[0];
-
-  s = format (s, "%USegment Heap: %U\n", format_white_space, indent,
-	      format_mheap, sh->heap, verbose);
+  indent = format_get_indent (s) + 2;
+  s = format (s, "%U segment heap: %U\n", format_white_space, indent,
+	      format_mheap, svm_fifo_segment_heap (sp), verbose);
   s = format (s, "%U segment has %u active fifos\n",
 	      format_white_space, indent, svm_fifo_segment_num_fifos (sp));
 
