diff --git a/extras/libmemif/Makefile.am b/extras/libmemif/Makefile.am
index 8640cf8..f66ef96 100644
--- a/extras/libmemif/Makefile.am
+++ b/extras/libmemif/Makefile.am
@@ -78,7 +78,15 @@
 icmpr_mt_LDADD = libmemif.la -lpthread
 icmpr_mt_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/examples/icmp_responder
 
-noinst_PROGRAMS = icmpr icmpr-epoll icmpr-mt
+#
+# ICMP responder external buffer example
+#
+icmpr_eb_SOURCES = examples/icmp_responder-eb/main.c\
+			examples/icmp_responder/icmp_proto.c
+icmpr_eb_LDADD = libmemif.la -lpthread
+icmpr_eb_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/examples/icmp_responder
+
+noinst_PROGRAMS = icmpr icmpr-epoll icmpr-mt icmpr-eb
 
 include_HEADERS = src/libmemif.h
 
diff --git a/extras/libmemif/examples/icmp_responder-eb/main.c b/extras/libmemif/examples/icmp_responder-eb/main.c
new file mode 100644
index 0000000..9e71d28
--- /dev/null
+++ b/extras/libmemif/examples/icmp_responder-eb/main.c
@@ -0,0 +1,1073 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdint.h>
+#include <net/if.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/uio.h>
+#include <sys/mman.h>
+#include <sys/prctl.h>
+#include <inttypes.h>
+#include <string.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <linux/ip.h>
+#include <linux/icmp.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <asm/byteorder.h>
+#include <byteswap.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <errno.h>
+#include <unistd.h>
+#include <signal.h>
+#include <pthread.h>
+#include <time.h>
+
+#ifndef TIME_UTC
+#define TIME_UTC 1
+#endif /* TIME_UTC */
+
+#include <libmemif.h>
+#include <icmp_proto.h>
+
+#define APP_NAME	"ICMP_Responder"
+#define IF_NAME		"memif_connection"
+
+#ifdef ICMP_DBG
+#define DBG(...) do {						\
+			printf(APP_NAME":%s:%d",__func__,__LINE__);	\
+			printf(__VA_ARGS__);				\
+			printf("\n");					\
+		} while (0)
+#else
+#define DBG(...)
+#endif /* ICMP_DBG */
+
+#define INFO(...) do {					\
+			printf("INFO: "__VA_ARGS__);	\
+			printf("\n");			\
+		} while (0)
+
+#define MAX_MEMIF_BUFS	256
+#define MAX_CONNS	50
+
+
+#ifndef __NR_memfd_create
+#if defined __x86_64__
+#define __NR_memfd_create 319
+#elif defined __arm__
+#define __NR_memfd_create 385
+#elif defined __aarch64__
+#define __NR_memfd_create 279
+#else
+#error "__NR_memfd_create unknown for this architecture"
+#endif
+#endif
+
+#ifndef HAVE_MEMFD_CREATE
+static inline int
+memfd_create (const char *name, unsigned int flags)
+{
+  return syscall (__NR_memfd_create, name, flags);
+}
+#endif
+
+#ifndef F_LINUX_SPECIFIC_BASE
+#define F_LINUX_SPECIFIC_BASE 1024
+#endif
+
+#ifndef MFD_ALLOW_SEALING
+#define MFD_ALLOW_SEALING       0x0002U
+#endif
+
+#ifndef F_ADD_SEALS
+#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
+#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
+
+#define F_SEAL_SEAL     0x0001	/* prevent further seals from being set */
+#define F_SEAL_SHRINK   0x0002	/* prevent file from shrinking */
+#define F_SEAL_GROW     0x0004	/* prevent file from growing */
+#define F_SEAL_WRITE    0x0008	/* prevent writes */
+#endif
+
+typedef struct
+{
+  uint16_t index;
+
+  memif_conn_handle_t conn;
+
+  uint16_t tx_buf_num;
+  uint16_t rx_buf_num;
+  memif_buffer_t *tx_bufs;
+  memif_buffer_t *rx_bufs;
+
+  uint8_t ip_addr[4];
+  uint64_t tx_counter, rx_counter, tx_err_counter;
+  uint64_t t_sec, t_nsec;
+} memif_connection_t;
+
+typedef struct
+{
+  uint16_t index;
+  uint64_t packet_num;
+  uint8_t ip_daddr[4];
+  uint8_t hw_daddr[6];
+} icmpr_thread_data_t;
+
+icmpr_thread_data_t icmpr_thread_data[MAX_CONNS];
+pthread_t thread[MAX_CONNS];
+int epfd;
+long ctx[MAX_CONNS];
+memif_connection_t memif_connection[MAX_CONNS];
+
+static void
+print_help ()
+{
+  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
+#ifdef ICMP_DBG
+  printf (" (debug)");
+#endif
+  printf ("\n");
+  printf ("==============================\n");
+  printf ("libmemif version: %s", LIBMEMIF_VERSION);
+#ifdef MEMIF_DBG
+  printf (" (debug)");
+#endif
+  printf ("\n");
+  printf ("memif version: %d\n", memif_get_version ());
+  printf ("commands:\n");
+  printf ("\thelp - prints this help\n");
+  printf ("\texit - exit app\n");
+  printf
+    ("\tconn <index> <mode> <interrupt> - create memif. index used as interface id. mode: 0 = slave | 1 = master. interrupt: none = default | 1 = handle ARP only\n");
+  printf ("\tdel <index> - delete memif\n");
+  printf ("\tshow - show connection details\n");
+  printf ("\tsend <index> <tx> <ip> <mac> - send icmp\n");
+}
+
+static void
+print_memif_details ()
+{
+  memif_details_t md;
+  ssize_t buflen;
+  char *buf;
+  int err, i, e;
+  buflen = 2048;
+  buf = malloc (buflen);
+  printf ("MEMIF DETAILS\n");
+  printf ("==============================\n");
+  for (i = 0; i < MAX_CONNS; i++)
+    {
+      memif_connection_t *c = &memif_connection[i];
+
+      memset (&md, 0, sizeof (md));
+      memset (buf, 0, buflen);
+
+      err = memif_get_details (c->conn, &md, buf, buflen);
+      if (err != MEMIF_ERR_SUCCESS)
+	{
+	  if (err != MEMIF_ERR_NOCONN)
+	    INFO ("%s", memif_strerror (err));
+	  continue;
+	}
+
+      printf ("interface index: %d\n", i);
+
+      printf ("\tinterface ip: %u.%u.%u.%u\n",
+	      c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
+      printf ("\tinterface name: %s\n", (char *) md.if_name);
+      printf ("\tapp name: %s\n", (char *) md.inst_name);
+      printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
+      printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
+      printf ("\tid: %u\n", md.id);
+      printf ("\tsecret: %s\n", (char *) md.secret);
+      printf ("\trole: ");
+      if (md.role)
+	printf ("slave\n");
+      else
+	printf ("master\n");
+      printf ("\tmode: ");
+      switch (md.mode)
+	{
+	case 0:
+	  printf ("ethernet\n");
+	  break;
+	case 1:
+	  printf ("ip\n");
+	  break;
+	case 2:
+	  printf ("punt/inject\n");
+	  break;
+	default:
+	  printf ("unknown\n");
+	  break;
+	}
+      printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
+      printf ("\tregions:\n");
+      for (e = 0; e < md.regions_num; e++)
+	{
+	  printf ("\t\tindex: %u\n", md.regions[e].index);
+	  printf ("\t\taddress: %p\n", md.regions[e].addr);
+	  printf ("\t\tsize: %u\n", md.regions[e].size);
+	  printf ("\t\tfd: %d\n", md.regions[e].fd);
+	  if (md.regions[e].is_external)
+	    printf ("\t\texternal\n");
+	}
+      printf ("\trx queues:\n");
+      for (e = 0; e < md.rx_queues_num; e++)
+	{
+	  printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
+	  printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
+	  printf ("\t\tring rx mode: %s\n",
+		  md.rx_queues[e].flags ? "polling" : "interrupt");
+	  printf ("\t\tring head: %u\n", md.rx_queues[e].head);
+	  printf ("\t\tring tail: %u\n", md.rx_queues[e].tail);
+	  printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
+	}
+      printf ("\ttx queues:\n");
+      for (e = 0; e < md.tx_queues_num; e++)
+	{
+	  printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
+	  printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
+	  printf ("\t\tring rx mode: %s\n",
+		  md.tx_queues[e].flags ? "polling" : "interrupt");
+	  printf ("\t\tring head: %u\n", md.tx_queues[e].head);
+	  printf ("\t\tring tail: %u\n", md.tx_queues[e].tail);
+	  printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
+	}
+      printf ("\tlink: ");
+      if (md.link_up_down)
+	printf ("up\n");
+      else
+	printf ("down\n");
+    }
+  free (buf);
+}
+
+void
+icmpr_print_counters ()
+{
+  int i;
+  for (i = 0; i < MAX_CONNS; i++)
+    {
+      memif_connection_t *c = &memif_connection[i];
+      if (c->conn == NULL)
+	continue;
+      printf ("===============================\n");
+      printf ("interface index: %d\n", c->index);
+      printf ("\trx: %lu\n", c->rx_counter);
+      printf ("\ttx: %lu\n", c->tx_counter);
+      printf ("\ttx_err: %lu\n", c->tx_err_counter);
+    }
+}
+
+void
+icmpr_reset_counters ()
+{
+  int i;
+  for (i = 0; i < MAX_CONNS; i++)
+    {
+      memif_connection_t *c = &memif_connection[i];
+      if (c->conn == NULL)
+	continue;
+      c->tx_err_counter = c->tx_counter = c->rx_counter = 0;
+    }
+}
+
+int
+add_epoll_fd (int fd, uint32_t events)
+{
+  if (fd < 0)
+    {
+      DBG ("invalid fd %d", fd);
+      return -1;
+    }
+  struct epoll_event evt;
+  memset (&evt, 0, sizeof (evt));
+  evt.events = events;
+  evt.data.fd = fd;
+  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
+    {
+      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
+      return -1;
+    }
+  DBG ("fd %d added to epoll", fd);
+  return 0;
+}
+
+int
+mod_epoll_fd (int fd, uint32_t events)
+{
+  if (fd < 0)
+    {
+      DBG ("invalid fd %d", fd);
+      return -1;
+    }
+  struct epoll_event evt;
+  memset (&evt, 0, sizeof (evt));
+  evt.events = events;
+  evt.data.fd = fd;
+  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
+    {
+      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
+      return -1;
+    }
+  DBG ("fd %d moddified on epoll", fd);
+  return 0;
+}
+
+int
+del_epoll_fd (int fd)
+{
+  if (fd < 0)
+    {
+      DBG ("invalid fd %d", fd);
+      return -1;
+    }
+  struct epoll_event evt;
+  memset (&evt, 0, sizeof (evt));
+  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
+    {
+      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
+      return -1;
+    }
+  DBG ("fd %d removed from epoll", fd);
+  return 0;
+}
+
+int
+on_connect (memif_conn_handle_t conn, void *private_ctx)
+{
+  INFO ("memif connected!");
+  memif_refill_queue (conn, 0, -1, 0);
+  return 0;
+}
+
+int
+on_disconnect (memif_conn_handle_t conn, void *private_ctx)
+{
+  INFO ("memif disconnected!");
+  return 0;
+}
+
+int
+control_fd_update (int fd, uint8_t events)
+{
+  /* convert memif event definitions to epoll events */
+  if (events & MEMIF_FD_EVENT_DEL)
+    return del_epoll_fd (fd);
+
+  uint32_t evt = 0;
+  if (events & MEMIF_FD_EVENT_READ)
+    evt |= EPOLLIN;
+  if (events & MEMIF_FD_EVENT_WRITE)
+    evt |= EPOLLOUT;
+
+  if (events & MEMIF_FD_EVENT_MOD)
+    return mod_epoll_fd (fd, evt);
+
+  return add_epoll_fd (fd, evt);
+}
+
+int
+icmpr_memif_delete (long index)
+{
+  if (index >= MAX_CONNS)
+    {
+      INFO ("connection array overflow");
+      return 0;
+    }
+  if (index < 0)
+    {
+      INFO ("don't even try...");
+      return 0;
+    }
+  memif_connection_t *c = &memif_connection[index];
+
+  if (c->rx_bufs)
+    free (c->rx_bufs);
+  c->rx_bufs = NULL;
+  c->rx_buf_num = 0;
+  if (c->tx_bufs)
+    free (c->tx_bufs);
+  c->tx_bufs = NULL;
+  c->tx_buf_num = 0;
+
+  int err;
+  /* disconenct then delete memif connection */
+  err = memif_delete (&c->conn);
+  if (err != MEMIF_ERR_SUCCESS)
+    INFO ("memif_delete: %s", memif_strerror (err));
+  if (c->conn != NULL)
+    INFO ("memif delete fail");
+  return 0;
+}
+
+int
+icmpr_free ()
+{
+  /* application cleanup */
+  int err;
+  long i;
+  for (i = 0; i < MAX_CONNS; i++)
+    {
+      memif_connection_t *c = &memif_connection[i];
+      if (c->conn)
+	icmpr_memif_delete (i);
+    }
+
+  err = memif_cleanup ();
+  if (err != MEMIF_ERR_SUCCESS)
+    INFO ("memif_delete: %s", memif_strerror (err));
+
+  return 0;
+}
+
+int
+icmpr_add_external_region (void * *addr, uint32_t size, int *fd,
+			   void *private_ctx)
+{
+
+  int rfd;
+  void *raddr;
+  int err;
+
+  rfd = memfd_create ("memif region 1", MFD_ALLOW_SEALING);
+
+  fcntl (rfd, F_ADD_SEALS, F_SEAL_SHRINK);
+
+  err = ftruncate (rfd, size);
+
+  raddr = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, rfd, 0);
+
+  *addr = raddr;
+  *fd = rfd;
+
+  return 0;
+}
+
+void *
+icmpr_get_external_region_addr (uint32_t size, int fd, void *private_ctx)
+{
+  return mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+}
+
+int
+icmpr_del_external_region (void *addr, uint32_t size, int fd,
+			   void *private_ctx)
+{
+  munmap (addr, size);
+  if (fd > 0)
+    close (fd);
+  fd = -1;
+  return 0;
+}
+
+int
+on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
+{
+  long index = *((long *) private_ctx);
+  memif_connection_t *c = &memif_connection[index];
+  if (c->index != index)
+    {
+      INFO ("invalid context: %ld/%u", index, c->index);
+      return 0;
+    }
+
+  int err = MEMIF_ERR_SUCCESS, ret_val;
+  uint16_t rx = 0, tx = 0;
+  uint16_t fb = 0;
+  int i = 0;
+  int j = 0;
+
+  do
+    {
+      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
+      ret_val = err;
+      c->rx_counter += rx;
+      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
+	{
+	  INFO ("memif_rx_burst: %s", memif_strerror (err));
+	  goto error;
+	}
+      i = 0;
+      memset (c->tx_bufs, 0, sizeof (memif_buffer_t) * rx);
+      err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, rx, &tx, 128);
+      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
+	{
+	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
+	  goto error;
+	}
+      j = 0;
+      c->tx_err_counter += rx - tx;
+
+      while (tx)
+	{
+	  resolve_packet ((void *) (c->rx_bufs + i)->data,
+			  (c->rx_bufs + i)->len,
+			  (void *) (c->tx_bufs + j)->data,
+			  &(c->tx_bufs + j)->len, c->ip_addr);
+	  i++;
+	  j++;
+	  tx--;
+	}
+
+      err = memif_refill_queue (c->conn, qid, rx, 0);
+      if (err != MEMIF_ERR_SUCCESS)
+	INFO ("memif_buffer_free: %s", memif_strerror (err));
+      rx -= rx;
+
+      DBG ("%u/%u alloc/free buffers", rx, MAX_MEMIF_BUFS - rx);
+
+      err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
+      if (err != MEMIF_ERR_SUCCESS)
+	{
+	  INFO ("memif_tx_burst: %s", memif_strerror (err));
+	  goto error;
+	}
+      c->tx_counter += tx;
+    }
+  while (ret_val == MEMIF_ERR_NOBUF);
+
+  return 0;
+
+error:
+  err = memif_refill_queue (c->conn, qid, rx, 0);
+  if (err != MEMIF_ERR_SUCCESS)
+    INFO ("memif_buffer_free: %s", memif_strerror (err));
+  c->rx_buf_num -= rx;
+  DBG ("freed %d buffers. %u/%u alloc/free buffers", fb, c->rx_buf_num,
+       MAX_MEMIF_BUFS - c->rx_buf_num);
+  return 0;
+}
+
+int
+on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
+{
+  long index = *((long *) private_ctx);
+  memif_connection_t *c = &memif_connection[index];
+  if (c->index != index)
+    {
+      INFO ("invalid context: %ld/%u", index, c->index);
+      return 0;
+    }
+
+  int err = MEMIF_ERR_SUCCESS, ret_val;
+  int i;
+  uint16_t rx, tx;
+  uint16_t fb;
+  uint16_t pck_seq;
+
+  do
+    {
+      /* receive data from shared memory buffers */
+      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
+      ret_val = err;
+      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
+	{
+	  INFO ("memif_rx_burst: %s", memif_strerror (err));
+	  goto error;
+	}
+      c->rx_buf_num += rx;
+      c->rx_counter += rx;
+
+      for (i = 0; i < rx; i++)
+	{
+	  if (((struct ether_header *) (c->rx_bufs + i)->data)->ether_type ==
+	      0x0608)
+	    {
+	      err =
+		memif_buffer_alloc (c->conn, qid, c->tx_bufs, 1, &tx, 128);
+	      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
+		{
+		  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
+		  goto error;
+		}
+	      resolve_packet ((void *) (c->rx_bufs + i)->data,
+			      (c->rx_bufs + i)->len,
+			      (void *) (c->tx_bufs + i)->data,
+			      &(c->tx_bufs + i)->len, c->ip_addr);
+	      err =
+		memif_tx_burst (c->conn, qid, c->tx_bufs, c->tx_buf_num, &tx);
+	      if (err != MEMIF_ERR_SUCCESS)
+		INFO ("memif_tx_burst: %s", memif_strerror (err));
+	      c->tx_buf_num -= tx;
+	      c->tx_counter += tx;
+	    }
+	}
+
+      err = memif_refill_queue (c->conn, qid, rx, 0);
+      if (err != MEMIF_ERR_SUCCESS)
+	INFO ("memif_buffer_free: %s", memif_strerror (err));
+      c->rx_buf_num -= rx;
+
+
+    }
+  while (ret_val == MEMIF_ERR_NOBUF);
+
+  return 0;
+
+error:
+  err = memif_refill_queue (c->conn, qid, rx, 0);
+  if (err != MEMIF_ERR_SUCCESS)
+    INFO ("memif_buffer_free: %s", memif_strerror (err));
+  c->rx_buf_num -= rx;
+  DBG ("freed %d buffers. %u/%u alloc/free buffers",
+       fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
+  return 0;
+}
+
+int
+icmpr_memif_create (long index, long mode, char *s)
+{
+  if (index >= MAX_CONNS)
+    {
+      INFO ("connection array overflow");
+      return 0;
+    }
+  if (index < 0)
+    {
+      INFO ("...");
+      return 0;
+    }
+  memif_connection_t *c = &memif_connection[index];
+
+  memif_conn_args_t args;
+  int fd = -1;
+  memset (&args, 0, sizeof (args));
+  args.is_master = mode;
+  args.log2_ring_size = 11;
+  args.buffer_size = 2048;
+  args.num_s2m_rings = 1;
+  args.num_m2s_rings = 1;
+  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
+  args.mode = 0;
+  args.interface_id = index;
+
+  int err;
+  if (s == NULL)
+    {
+      err = memif_create (&c->conn,
+			  &args, on_connect, on_disconnect, on_interrupt,
+			  &ctx[index]);
+      if (err != MEMIF_ERR_SUCCESS)
+	{
+	  INFO ("memif_create: %s", memif_strerror (err));
+	  return 0;
+	}
+    }
+  else
+    {
+      if (strncmp (s, "1", 1) == 0)
+	{
+	  err = memif_create (&c->conn,
+			      &args, on_connect, on_disconnect, on_interrupt1,
+			      &ctx[index]);
+	  if (err != MEMIF_ERR_SUCCESS)
+	    {
+	      INFO ("memif_create: %s", memif_strerror (err));
+	      return 0;
+	    }
+	}
+      else
+	{
+	  INFO ("Unknown interrupt descriptor");
+	  goto done;
+	}
+    }
+
+  c->index = index;
+  c->rx_buf_num = 0;
+  c->rx_bufs =
+    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
+  c->tx_buf_num = 0;
+  c->tx_bufs =
+    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
+
+  c->ip_addr[0] = 192;
+  c->ip_addr[1] = 168;
+  c->ip_addr[2] = c->index + 1;
+  c->ip_addr[3] = 2;
+
+done:
+  return 0;
+}
+
+void *
+icmpr_send_proc (void *data)
+{
+  icmpr_thread_data_t *d = (icmpr_thread_data_t *) data;
+  int index = d->index;
+  uint64_t count = d->packet_num;
+  memif_connection_t *c = &memif_connection[index];
+  if (c->conn == NULL)
+    {
+      INFO ("No connection at index %d.", index);
+      goto error;
+    }
+  uint16_t tx, i;
+  int err = MEMIF_ERR_SUCCESS;
+  uint32_t seq = 0;
+  struct timespec start, end;
+  memset (&start, 0, sizeof (start));
+  memset (&end, 0, sizeof (end));
+
+  timespec_get (&start, TIME_UTC);
+  while (count)
+    {
+      i = 0;
+      err =
+	memif_buffer_alloc (c->conn, 0, c->tx_bufs,
+			    MAX_MEMIF_BUFS > count ? count : MAX_MEMIF_BUFS,
+			    &tx, 128);
+
+      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
+	{
+	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
+	  goto error;
+	}
+      c->tx_buf_num += tx;
+
+      while (tx)
+	{
+	  while (tx > 4)
+	    {
+	      generate_packet ((void *) c->tx_bufs[i].data,
+			       &c->tx_bufs[i].len, c->ip_addr, d->ip_daddr,
+			       d->hw_daddr, seq++);
+	      generate_packet ((void *) c->tx_bufs[i + 1].data,
+			       &c->tx_bufs[i + 1].len, c->ip_addr,
+			       d->ip_daddr, d->hw_daddr, seq++);
+	      generate_packet ((void *) c->tx_bufs[i + 2].data,
+			       &c->tx_bufs[i + 2].len, c->ip_addr,
+			       d->ip_daddr, d->hw_daddr, seq++);
+	      generate_packet ((void *) c->tx_bufs[i + 3].data,
+			       &c->tx_bufs[i + 3].len, c->ip_addr,
+			       d->ip_daddr, d->hw_daddr, seq++);
+	      i += 4;
+	      tx -= 4;
+	    }
+	  generate_packet ((void *) c->tx_bufs[i].data, &c->tx_bufs[i].len,
+			   c->ip_addr, d->ip_daddr, d->hw_daddr, seq++);
+	  i++;
+	  tx--;
+	}
+
+      err = memif_tx_burst (c->conn, 0, c->tx_bufs, c->tx_buf_num, &tx);
+      if (err != MEMIF_ERR_SUCCESS)
+	{
+	  INFO ("memif_tx_burst: %s", memif_strerror (err));
+	  goto error;
+	}
+      c->tx_buf_num -= tx;
+      c->tx_counter += tx;
+      count -= tx;
+    }
+
+  timespec_get (&end, TIME_UTC);
+  INFO ("\n\nPacket sequence finished!\nSeq len: %u", seq);
+  uint64_t t1 = end.tv_sec - start.tv_sec;
+  uint64_t t2;
+  if (end.tv_nsec > start.tv_nsec)
+    {
+      t2 = end.tv_nsec - start.tv_nsec;
+    }
+  else
+    {
+      t2 = start.tv_nsec - end.tv_nsec;
+      t1--;
+    }
+  c->t_sec = t1;
+  c->t_nsec = t2;
+  double tmp = t1;
+  tmp += t2 / 1e+9;
+  tmp = seq / tmp;
+  INFO ("Seq time: %lus %luns\nAverage pps: %f", t1, t2, tmp);
+
+error:
+  INFO ("Thread exiting...");
+  pthread_exit (NULL);
+}
+
+
+int
+icmpr_send (long index, long packet_num, char *hw, char *ip)
+{
+  if (index >= MAX_CONNS)
+    {
+      INFO ("connection array overflow");
+      return 0;
+    }
+  if (index < 0)
+    {
+      INFO ("...");
+      return 0;
+    }
+  memif_connection_t *c = &memif_connection[index];
+  if (c->conn == NULL)
+    return -1;
+  int err, i;
+  uint16_t tx = 0, rx = 0;
+  char *end, *ui;
+  uint8_t tmp[6];
+  icmpr_thread_data_t *data = &icmpr_thread_data[index];
+  data->index = index;
+  data->packet_num = packet_num;
+
+  ui = strtok (ip, ".");
+  if (ui == NULL)
+    goto error;
+  tmp[0] = strtol (ui, &end, 10);
+  ui = strtok (NULL, ".");
+  if (ui == NULL)
+    goto error;
+  tmp[1] = strtol (ui, &end, 10);
+  ui = strtok (NULL, ".");
+  if (ui == NULL)
+    goto error;
+  tmp[2] = strtol (ui, &end, 10);
+  ui = strtok (NULL, ".");
+  if (ui == NULL)
+    goto error;
+  tmp[3] = strtol (ui, &end, 10);
+
+  data->ip_daddr[0] = tmp[0];
+  data->ip_daddr[1] = tmp[1];
+  data->ip_daddr[2] = tmp[2];
+  data->ip_daddr[3] = tmp[3];
+
+  ui = strtok (hw, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[0] = strtol (ui, &end, 16);
+  ui = strtok (NULL, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[1] = strtol (ui, &end, 16);
+  ui = strtok (NULL, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[2] = strtol (ui, &end, 16);
+  ui = strtok (NULL, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[3] = strtol (ui, &end, 16);
+  ui = strtok (NULL, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[4] = strtol (ui, &end, 16);
+  ui = strtok (NULL, ":");
+  if (ui == NULL)
+    goto error;
+  tmp[5] = strtol (ui, &end, 16);
+
+  pthread_create (&thread[index], NULL, icmpr_send_proc, (void *) data);
+  return 0;
+
+error:
+  INFO ("Invalid input\n");
+  return 0;
+}
+
+int
+user_input_handler ()
+{
+  char *in = (char *) malloc (256);
+  char *ui = fgets (in, 256, stdin);
+  char *end;
+  long a;
+
+  if (in[0] == '\n')
+    goto done;
+
+  ui = strtok (in, " ");
+
+  if (strncmp (ui, "exit", 4) == 0)
+    {
+      free (in);
+      icmpr_free ();
+      exit (EXIT_SUCCESS);
+    }
+  else if (strncmp (ui, "help", 4) == 0)
+    {
+      print_help ();
+      goto done;
+    }
+  else if (strncmp (ui, "conn", 4) == 0)
+    {
+      ui = strtok (NULL, " ");
+      if (ui != NULL)
+	a = strtol (ui, &end, 10);
+      else
+	{
+	  INFO ("expected id");
+	  goto done;
+	}
+      ui = strtok (NULL, " ");
+      if (ui != NULL)
+	icmpr_memif_create (a, strtol (ui, &end, 10), strtok (NULL, " "));
+      else
+	INFO ("expected mode <0|1>");
+      goto done;
+    }
+  else if (strncmp (ui, "del", 3) == 0)
+    {
+      ui = strtok (NULL, " ");
+      if (ui != NULL)
+	icmpr_memif_delete (strtol (ui, &end, 10));
+      else
+	{
+	  INFO ("expected id");
+	  goto done;
+	}
+    }
+  else if (strncmp (ui, "send", 4) == 0)
+    {
+      ui = strtok (NULL, " ");
+      if (ui != NULL)
+	a = strtol (ui, &end, 10);
+      else
+	{
+	  INFO ("expected id");
+	  goto done;
+	}
+      ui = strtok (NULL, " ");
+      if (ui != NULL)
+	icmpr_send (a, strtol (ui, &end, 10), strtok (NULL, " "),
+		    strtok (NULL, " "));
+      else
+	INFO ("expected count");
+      goto done;
+    }
+  else if (strncmp (ui, "show", 4) == 0)
+    {
+      print_memif_details ();
+      goto done;
+    }
+
+done:
+  free (in);
+  return 0;
+}
+
+int
+poll_event (int timeout)
+{
+  struct epoll_event evt, *e;
+  int app_err = 0, memif_err = 0, en = 0;
+  int tmp, nfd;
+  uint32_t events = 0;
+  memset (&evt, 0, sizeof (evt));
+  evt.events = EPOLLIN | EPOLLOUT;
+  sigset_t sigset;
+  sigemptyset (&sigset);
+  en = epoll_pwait (epfd, &evt, 1, timeout, &sigset);
+  /* id event polled */
+  if (en < 0)
+    {
+      DBG ("epoll_pwait: %s", strerror (errno));
+      return -1;
+    }
+  if (en > 0)
+    {
+      /* this app does not use any other file descriptors than stds and memif control fds */
+      if (evt.data.fd > 2)
+	{
+	  /* event of memif control fd */
+	  /* convert epolle events to memif events */
+	  if (evt.events & EPOLLIN)
+	    events |= MEMIF_FD_EVENT_READ;
+	  if (evt.events & EPOLLOUT)
+	    events |= MEMIF_FD_EVENT_WRITE;
+	  if (evt.events & EPOLLERR)
+	    events |= MEMIF_FD_EVENT_ERROR;
+	  memif_err = memif_control_fd_handler (evt.data.fd, events);
+	  if (memif_err != MEMIF_ERR_SUCCESS)
+	    INFO ("memif_control_fd_handler: %s", memif_strerror (memif_err));
+	}
+      else if (evt.data.fd == 0)
+	{
+	  app_err = user_input_handler ();
+	}
+      else
+	{
+	  DBG ("unexpected event at memif_epfd. fd %d", evt.data.fd);
+	}
+    }
+
+  if ((app_err < 0) || (memif_err < 0))
+    {
+      if (app_err < 0)
+	DBG ("user input handler error");
+      if (memif_err < 0)
+	DBG ("memif control fd handler error");
+      return -1;
+    }
+
+  return 0;
+}
+
+int
+main ()
+{
+  epfd = epoll_create (1);
+  add_epoll_fd (0, EPOLLIN);
+
+  /* initialize memory interface */
+  int err, i;
+  /* if valid callback is passed as argument, fd event polling will be done by user
+     all file descriptors and events will be passed to user in this callback */
+  /* if callback is set to NULL libmemif will handle fd event polling */
+  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
+  if (err != MEMIF_ERR_SUCCESS)
+    {
+      INFO ("memif_init: %s", memif_strerror (err));
+      icmpr_free ();
+      exit (-1);
+    }
+
+  for (i = 0; i < MAX_CONNS; i++)
+    {
+      memset (&memif_connection[i], 0, sizeof (memif_connection_t));
+      ctx[i] = i;
+    }
+
+  memif_register_external_region (icmpr_add_external_region,
+				  icmpr_get_external_region_addr,
+				  icmpr_del_external_region, NULL);
+
+  print_help ();
+
+  /* main loop */
+  while (1)
+    {
+      if (poll_event (-1) < 0)
+	{
+	  DBG ("poll_event error!");
+	}
+    }
+}
diff --git a/extras/libmemif/examples/icmp_responder-epoll/main.c b/extras/libmemif/examples/icmp_responder-epoll/main.c
index fd354a3..70095dd 100644
--- a/extras/libmemif/examples/icmp_responder-epoll/main.c
+++ b/extras/libmemif/examples/icmp_responder-epoll/main.c
@@ -86,6 +86,8 @@
 #define MAX_MEMIF_BUFS  256
 #define MAX_CONNS       50
 
+#define ICMPR_HEADROOM	64
+
 int epfd;
 int out_fd;
 uint8_t enable_log;
@@ -282,7 +284,7 @@
 on_connect (memif_conn_handle_t conn, void *private_ctx)
 {
   INFO ("memif connected!");
-  memif_refill_queue (conn, 0, -1, 0);
+  memif_refill_queue (conn, 0, -1, ICMPR_HEADROOM);
   enable_log = 1;
   return 0;
 }
@@ -406,13 +408,12 @@
 	  tx--;
 	}
 
-      err = memif_refill_queue (c->conn, qid, rx, 0);
+      err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
       if (err != MEMIF_ERR_SUCCESS)
 	INFO ("memif_buffer_free: %s", memif_strerror (err));
       rx -= rx;
 
-      DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	   rx, rx, MAX_MEMIF_BUFS - rx);
+      DBG ("%u/%u alloc/free buffers", rx, MAX_MEMIF_BUFS - rx);
 
       err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
       if (err != MEMIF_ERR_SUCCESS)
@@ -428,7 +429,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
+  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;
@@ -514,7 +515,7 @@
 	    }
 	  /* mark memif buffers and shared memory buffers as free */
 	  /* free processed buffers */
-	  err = memif_refill_queue (c->conn, qid, j, 0);
+	  err = memif_refill_queue (c->conn, qid, j, ICMPR_HEADROOM);
 	  if (err != MEMIF_ERR_SUCCESS)
 	    INFO ("memif_buffer_free: %s", memif_strerror (err));
 	  rx -= j;
@@ -540,7 +541,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
+  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;
@@ -597,7 +598,7 @@
 	    }
 	}
 
-      err = memif_refill_queue (c->conn, qid, rx, 0);
+      err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
       if (err != MEMIF_ERR_SUCCESS)
 	INFO ("memif_buffer_free: %s", memif_strerror (err));
       c->rx_buf_num -= rx;
@@ -609,7 +610,7 @@
   return 0;
 
 error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
+  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_buffer_free: %s", memif_strerror (err));
   c->rx_buf_num -= rx;
@@ -992,6 +993,7 @@
       count -= tx;
     }
   timespec_get (&end, TIME_UTC);
+  printf ("\n\n");
   INFO ("Pakcet sequence finished!");
   INFO ("Seq len: %u", seq);
   uint64_t t1 = end.tv_sec - start.tv_sec;
@@ -1297,7 +1299,7 @@
   /* if valid callback is passed as argument, fd event polling will be done by user
      all file descriptors and events will be passed to user in this callback */
   /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL);
+  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
   if (err != MEMIF_ERR_SUCCESS)
     {
       INFO ("memif_init: %s", memif_strerror (err));
diff --git a/extras/libmemif/examples/icmp_responder-mt/main.c b/extras/libmemif/examples/icmp_responder-mt/main.c
index c4ac907..8fa64cf 100644
--- a/extras/libmemif/examples/icmp_responder-mt/main.c
+++ b/extras/libmemif/examples/icmp_responder-mt/main.c
@@ -894,7 +894,7 @@
   /* if valid callback is passed as argument, fd event polling will be done by user
      all file descriptors and events will be passed to user in this callback */
   /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL);
+  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_init: %s", memif_strerror (err));
 
diff --git a/extras/libmemif/examples/icmp_responder/main.c b/extras/libmemif/examples/icmp_responder/main.c
index 5e78acd..fa7bcb9 100644
--- a/extras/libmemif/examples/icmp_responder/main.c
+++ b/extras/libmemif/examples/icmp_responder/main.c
@@ -395,7 +395,7 @@
   /* if valid callback is passed as argument, fd event polling will be done by user
      all file descriptors and events will be passed to user in this callback */
   /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (NULL, APP_NAME, NULL, NULL);
+  err = memif_init (NULL, APP_NAME, NULL, NULL, NULL);
   if (err != MEMIF_ERR_SUCCESS)
     INFO ("memif_init: %s", memif_strerror (err));
 
diff --git a/extras/libmemif/src/libmemif.h b/extras/libmemif/src/libmemif.h
index 88b6a10..32fda2a 100644
--- a/extras/libmemif/src/libmemif.h
+++ b/extras/libmemif/src/libmemif.h
@@ -106,6 +106,15 @@
 */
 typedef void *(memif_alloc_t) (size_t size);
 
+
+/** \brief Memif realloc
+    @param ptr - pointer to memory block
+    @param size - requested allocation size
+
+    custom memory reallocation
+*/
+typedef void *(memif_realloc_t) (void *ptr, size_t size);
+
 /** \brief Memif allocator free
     @param size - requested allocation size
 
@@ -148,6 +157,68 @@
 */
 typedef int (memif_interrupt_t) (memif_conn_handle_t conn, void *private_ctx,
 				 uint16_t qid);
+
+/** @} */
+
+/**
+ * @defgroup EXTERNAL_REGION External region APIs
+ * @ingroup libmemif
+ *
+ * @{
+ */
+
+/** \brief Get external buffer offset (optional)
+    @param private_ctx - private context
+
+    Find unallocated external buffer and return its offset.
+*/
+typedef uint32_t (memif_get_external_buffer_offset_t) (void *private_ctx);
+
+/** \brief Add external region
+    @param[out] addr - region address
+    @param size - requested region size
+    @param fd[out] - file descriptor
+    @param private_ctx - private context
+
+    Called by slave. Add external region created by client.
+*/
+typedef int (memif_add_external_region_t) (void * *addr, uint32_t size,
+					   int *fd, void *private_ctx);
+
+/** \brief Get external region address
+    @param size - requested region size
+    @param fd - file descriptor
+    @param private_ctx - private context
+
+    Called by master. Get region address from client.
+
+   \return region address
+*/
+typedef void *(memif_get_external_region_addr_t) (uint32_t size, int fd,
+						  void *private_ctx);
+
+/** \brief Delete external region
+    @param addr - region address
+    @param size - region size
+    @param fd - file descriptor
+    @param private_ctx - private context
+
+    Delete external region.
+*/
+typedef int (memif_del_external_region_t) (void *addr, uint32_t size, int fd,
+					   void *private_ctx);
+
+/** \brief Register external region
+    @param ar - add external region callback
+    @param gr - get external region addr callback
+    @param dr - delete external region callback
+    @param go - get external buffer offset callback (optional)
+*/
+void memif_register_external_region (memif_add_external_region_t * ar,
+				     memif_get_external_region_addr_t * gr,
+				     memif_del_external_region_t * dr,
+				     memif_get_external_buffer_offset_t * go);
+
 /** @} */
 
 /**
@@ -230,6 +301,7 @@
  */
 
 /** \brief Memif queue details
+    @param region - region index
     @param qid - queue id
     @param ring_size - size of ring buffer in sharem memory
     @param flags - ring flags
@@ -239,6 +311,7 @@
 */
 typedef struct
 {
+  uint8_t region;
   uint8_t qid;
   uint32_t ring_size;
 /** if set queue is in polling mode, else in interrupt mode */
@@ -249,6 +322,22 @@
   uint16_t buffer_size;
 } memif_queue_details_t;
 
+/** \brief Memif region details
+    @param index - region index
+    @param addr - region address
+    @param size - region size
+    @param fd - file descriptor
+    @param is_external - if not zero then region is defined by client
+*/
+typedef struct
+{
+  uint8_t index;
+  void *addr;
+  uint32_t size;
+  int fd;
+  uint8_t is_external;
+} memif_region_details_t;
+
 /** \brief Memif details
     @param if_name - interface name
     @param inst_name - application name
@@ -258,7 +347,9 @@
     @param secret - secret
     @param role - 0 = master, 1 = slave
     @param mode - 0 = ethernet, 1 = ip , 2 = punt/inject
-    @param socket_filename = socket filename
+    @param socket_filename - socket filename
+    @param regions_num - number of regions
+    @param regions - struct containing region details
     @param rx_queues_num - number of receive queues
     @param tx_queues_num - number of transmit queues
     @param rx_queues - struct containing receive queue details
@@ -277,6 +368,8 @@
   uint8_t role;			/* 0 = master, 1 = slave */
   uint8_t mode;			/* 0 = ethernet, 1 = ip, 2 = punt/inject */
   uint8_t *socket_filename;
+  uint8_t regions_num;
+  memif_region_details_t *regions;
   uint8_t rx_queues_num;
   uint8_t tx_queues_num;
   memif_queue_details_t *rx_queues;
@@ -343,6 +436,7 @@
     @param on_control_fd_update - if control fd updates inform user to watch new fd
     @param app_name - application name (will be truncated to 32 chars)
     @param memif_alloc - cutom memory allocator, NULL = default
+    @param memif_realloc - custom memory reallocation, NULL = default
     @param memif_free - custom memory free, NULL = default
 
     if param on_control_fd_update is set to NULL,
@@ -359,7 +453,7 @@
 */
 int memif_init (memif_control_fd_update_t * on_control_fd_update,
 		char *app_name, memif_alloc_t * memif_alloc,
-		memif_free_t * memif_free);
+		memif_realloc_t * memif_realloc, memif_free_t * memif_free);
 
 /** \brief Memif cleanup
 
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c
index 1f4672c..5d8f03a 100644
--- a/extras/libmemif/src/main.c
+++ b/extras/libmemif/src/main.c
@@ -325,7 +325,7 @@
 	}
     }
   memif_list_elt_t *tmp;
-  tmp = realloc (*list, sizeof (memif_list_elt_t) * *len * 2);
+  tmp = lm->realloc (*list, sizeof (memif_list_elt_t) * *len * 2);
   if (tmp == NULL)
     return -1;
 
@@ -411,6 +411,19 @@
   lm->control_fd_update = cb;
 }
 
+void
+memif_register_external_region (memif_add_external_region_t * ar,
+				memif_get_external_region_addr_t * gr,
+				memif_del_external_region_t * dr,
+				memif_get_external_buffer_offset_t * go)
+{
+  libmemif_main_t *lm = &libmemif_main;
+  lm->add_external_region = ar;
+  lm->get_external_region_addr = gr;
+  lm->del_external_region = dr;
+  lm->get_external_buffer_offset = go;
+}
+
 static void
 memif_alloc_register (memif_alloc_t * ma)
 {
@@ -419,6 +432,13 @@
 }
 
 static void
+memif_realloc_register (memif_realloc_t * mr)
+{
+  libmemif_main_t *lm = &libmemif_main;
+  lm->realloc = mr;
+}
+
+static void
 memif_free_register (memif_free_t * mf)
 {
   libmemif_main_t *lm = &libmemif_main;
@@ -427,7 +447,8 @@
 
 int
 memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name,
-	    memif_alloc_t * memif_alloc, memif_free_t * memif_free)
+	    memif_alloc_t * memif_alloc, memif_realloc_t * memif_realloc,
+	    memif_free_t * memif_free)
 {
   int err = MEMIF_ERR_SUCCESS;	/* 0 */
   libmemif_main_t *lm = &libmemif_main;
@@ -440,6 +461,13 @@
   else
     memif_alloc_register (malloc);
 
+  if (memif_realloc != NULL)
+    {
+      memif_realloc_register (memif_realloc);
+    }
+  else
+    memif_realloc_register (realloc);
+
   if (memif_free != NULL)
     memif_free_register (memif_free);
   else
@@ -564,7 +592,7 @@
 {
   if (&conn->regions[0] == NULL)
     return NULL;
-  void *p = conn->regions[0].shm;
+  void *p = conn->regions[0].addr;
   int ring_size =
     sizeof (memif_ring_t) +
     sizeof (memif_desc_t) * (1 << conn->run_args.log2_ring_size);
@@ -887,7 +915,7 @@
 
 	      sun.sun_family = AF_UNIX;
 
-	      strncpy (sun.sun_path, (char*) conn->args.socket_filename,
+	      strncpy (sun.sun_path, (char *) conn->args.socket_filename,
 		       sizeof (sun.sun_path) - 1);
 
 	      if (connect (sockfd, (struct sockaddr *) &sun,
@@ -1149,16 +1177,26 @@
       c->rx_queues = NULL;
     }
 
-  if (c->regions != NULL)
+  for (i = 0; i < c->regions_num; i++)
     {
-      if (munmap (c->regions[0].shm, c->regions[0].region_size) < 0)
-	return memif_syscall_error_handler (errno);
-      if (c->regions[0].fd > 0)
-	close (c->regions[0].fd);
-      c->regions[0].fd = -1;
-      lm->free (c->regions);
-      c->regions = NULL;
+      if (c->regions[i].is_external != 0)
+	{
+	  lm->del_external_region (c->regions[i].addr,
+				   c->regions[i].region_size,
+				   c->regions[i].fd, c->private_ctx);
+	}
+      else
+	{
+	  if (munmap (c->regions[i].addr, c->regions[i].region_size) < 0)
+	    return memif_syscall_error_handler (errno);
+	  if (c->regions[i].fd > 0)
+	    close (c->regions[i].fd);
+	  c->regions[i].fd = -1;
+	}
     }
+  lm->free (c->regions);
+  c->regions = NULL;
+  c->regions_num = 0;
 
   memset (&c->run_args, 0, sizeof (memif_conn_run_args_t));
 
@@ -1259,56 +1297,67 @@
 memif_connect1 (memif_connection_t * c)
 {
   libmemif_main_t *lm = &libmemif_main;
-  memif_region_t *mr = c->regions;
+  memif_region_t *mr;
   memif_queue_t *mq;
   int i;
   uint16_t num;
 
-  if (mr != NULL)
+  for (i = 0; i < c->regions_num; i++)
     {
-      if (!mr->shm)
+      mr = &c->regions[i];
+      if (mr != NULL)
 	{
-	  if (mr->fd < 0)
-	    return MEMIF_ERR_NO_SHMFD;
-
-	  if ((mr->shm = mmap (NULL, mr->region_size, PROT_READ | PROT_WRITE,
-			       MAP_SHARED, mr->fd, 0)) == MAP_FAILED)
+	  if (!mr->addr)
 	    {
-	      return memif_syscall_error_handler (errno);
+	      if (mr->is_external)
+		{
+		  if (lm->get_external_region_addr == NULL)
+		    return 99;	/* FIXME: propper error report */
+		  mr->addr =
+		    lm->get_external_region_addr (mr->region_size, mr->fd,
+						  c->private_ctx);
+		}
+	      else
+		{
+		  if (mr->fd < 0)
+		    return MEMIF_ERR_NO_SHMFD;
+
+		  if ((mr->addr =
+		       mmap (NULL, mr->region_size, PROT_READ | PROT_WRITE,
+			     MAP_SHARED, mr->fd, 0)) == MAP_FAILED)
+		    {
+		      return memif_syscall_error_handler (errno);
+		    }
+		}
 	    }
 	}
     }
 
-  num =
-    (c->args.is_master) ? c->run_args.num_m2s_rings : c->run_args.
-    num_s2m_rings;
-  for (i = 0; i < num; i++)
+  for (i = 0; i < c->rx_queues_num; i++)
     {
-      mq = &c->tx_queues[i];
+      mq = &c->rx_queues[i];
       if (mq != NULL)
 	{
-	  mq->ring = c->regions[mq->region].shm + mq->offset;
+	  mq->ring = c->regions[mq->region].addr + mq->offset;
 	  if (mq->ring->cookie != MEMIF_COOKIE)
 	    {
-	      DBG ("wrong cookie on tx ring %u", i);
+	      DBG ("wrong cookie on rx ring %u", i);
 	      return MEMIF_ERR_COOKIE;
 	    }
 	  mq->ring->head = mq->ring->tail = mq->last_head = mq->alloc_bufs =
 	    0;
 	}
     }
-  num =
-    (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
-    num_m2s_rings;
-  for (i = 0; i < num; i++)
+
+  for (i = 0; i < c->tx_queues_num; i++)
     {
-      mq = &c->rx_queues[i];
+      mq = &c->tx_queues[i];
       if (mq != NULL)
 	{
-	  mq->ring = c->regions[mq->region].shm + mq->offset;
+	  mq->ring = c->regions[mq->region].addr + mq->offset;
 	  if (mq->ring->cookie != MEMIF_COOKIE)
 	    {
-	      DBG ("wrong cookie on rx ring %u", i);
+	      DBG ("wrong cookie on tx ring %u", i);
 	      return MEMIF_ERR_COOKIE;
 	    }
 	  mq->ring->head = mq->ring->tail = mq->last_head = mq->alloc_bufs =
@@ -1321,32 +1370,40 @@
   return 0;
 }
 
-int
-memif_init_regions_and_queues (memif_connection_t * conn)
+static inline int
+memif_add_region (libmemif_main_t * lm, memif_connection_t * conn,
+		  uint8_t has_buffers)
 {
-  memif_ring_t *ring = NULL;
   memif_region_t *r;
-  int i, j;
-  libmemif_main_t *lm = &libmemif_main;
-  memif_list_elt_t e;
 
-  conn->regions = (memif_region_t *) lm->alloc (sizeof (memif_region_t));
-  if (conn->regions == NULL)
+  r =
+    lm->realloc (conn->regions,
+		 sizeof (memif_region_t) * ++conn->regions_num);
+  if (r == NULL)
     return MEMIF_ERR_NOMEM;
-  r = conn->regions;
 
-  r->buffer_offset =
-    (conn->run_args.num_s2m_rings +
-     conn->run_args.num_m2s_rings) * (sizeof (memif_ring_t) +
-				      sizeof (memif_desc_t) *
-				      (1 << conn->run_args.log2_ring_size));
+  conn->regions = r;
+  r = &conn->regions[conn->regions_num - 1];
+  memset (r, 0, sizeof (memif_region_t));
 
-  r->region_size = r->buffer_offset +
+  if (has_buffers != 0)
+    {
+      r->buffer_offset = 0;
+    }
+  else
+    {
+      r->buffer_offset =
+	(conn->run_args.num_s2m_rings +
+	 conn->run_args.num_m2s_rings) * (sizeof (memif_ring_t) +
+					  sizeof (memif_desc_t) *
+					  (1 << conn->run_args.
+					   log2_ring_size));
+    }
+
+  r->region_size = (has_buffers == 0) ? r->buffer_offset : r->buffer_offset +
     conn->run_args.buffer_size * (1 << conn->run_args.log2_ring_size) *
     (conn->run_args.num_s2m_rings + conn->run_args.num_m2s_rings);
 
-  if ((r->fd =
-       memfd_create ("memif region 0", MFD_ALLOW_SEALING)) == -1)
   if ((r->fd = memfd_create ("memif region 0", MFD_ALLOW_SEALING)) == -1)
     return memif_syscall_error_handler (errno);
 
@@ -1356,10 +1413,19 @@
   if ((ftruncate (r->fd, r->region_size)) == -1)
     return memif_syscall_error_handler (errno);
 
-  if ((r->shm = mmap (NULL, r->region_size, PROT_READ | PROT_WRITE,
-		      MAP_SHARED, r->fd, 0)) == MAP_FAILED)
+  if ((r->addr = mmap (NULL, r->region_size, PROT_READ | PROT_WRITE,
+		       MAP_SHARED, r->fd, 0)) == MAP_FAILED)
     return memif_syscall_error_handler (errno);
 
+  return MEMIF_ERR_SUCCESS;
+}
+
+static inline int
+memif_init_queues (libmemif_main_t * lm, memif_connection_t * conn)
+{
+  int i, j;
+  memif_ring_t *ring;
+
   for (i = 0; i < conn->run_args.num_s2m_rings; i++)
     {
       ring = memif_get_ring (conn, MEMIF_RING_S2M, i);
@@ -1370,8 +1436,9 @@
       for (j = 0; j < (1 << conn->run_args.log2_ring_size); j++)
 	{
 	  uint16_t slot = i * (1 << conn->run_args.log2_ring_size) + j;
-	  ring->desc[j].region = 0;
-	  ring->desc[j].offset = r->buffer_offset +
+	  ring->desc[j].region = 1;
+	  ring->desc[j].offset =
+	    conn->regions[1].buffer_offset +
 	    (uint32_t) (slot * conn->run_args.buffer_size);
 	  ring->desc[j].length = conn->run_args.buffer_size;
 	}
@@ -1385,28 +1452,30 @@
       ring->flags = 0;
       for (j = 0; j < (1 << conn->run_args.log2_ring_size); j++)
 	{
-	  uint16_t slot =
-	    (i +
-	     conn->run_args.num_s2m_rings) *
+	  uint16_t slot = (i + conn->run_args.num_s2m_rings) *
 	    (1 << conn->run_args.log2_ring_size) + j;
-	  ring->desc[j].region = 0;
-	  ring->desc[j].offset = r->buffer_offset +
+	  ring->desc[j].region = 1;
+	  ring->desc[j].offset =
+	    conn->regions[1].buffer_offset +
 	    (uint32_t) (slot * conn->run_args.buffer_size);
 	  ring->desc[j].length = conn->run_args.buffer_size;
 	}
     }
   memif_queue_t *mq;
+  DBG ("alloc: %p", lm->alloc);
+  DBG ("size: %lu", sizeof (memif_queue_t) * conn->run_args.num_s2m_rings);
   mq =
     (memif_queue_t *) lm->alloc (sizeof (memif_queue_t) *
 				 conn->run_args.num_s2m_rings);
   if (mq == NULL)
     return MEMIF_ERR_NOMEM;
+
   int x;
+  memif_list_elt_t e;
   for (x = 0; x < conn->run_args.num_s2m_rings; x++)
     {
       if ((mq[x].int_fd = eventfd (0, EFD_NONBLOCK)) < 0)
 	return memif_syscall_error_handler (errno);
-      /* add int fd to interrupt fd list */
       e.key = mq[x].int_fd;
       e.data_struct = conn;
       add_list_elt (&e, &lm->interrupt_list, &lm->interrupt_list_len);
@@ -1416,8 +1485,8 @@
       mq[x].log2_ring_size = conn->run_args.log2_ring_size;
       mq[x].region = 0;
       mq[x].offset =
-	(void *) mq[x].ring - (void *) conn->regions[mq->region].shm;
-      mq[x].last_head = 0;
+	(void *) mq[x].ring - (void *) conn->regions[mq->region].addr;
+      mq[x].last_head = mq[x].last_tail = 0;
       mq[x].alloc_bufs = 0;
     }
   conn->tx_queues = mq;
@@ -1427,11 +1496,11 @@
 				 conn->run_args.num_m2s_rings);
   if (mq == NULL)
     return MEMIF_ERR_NOMEM;
+
   for (x = 0; x < conn->run_args.num_m2s_rings; x++)
     {
       if ((mq[x].int_fd = eventfd (0, EFD_NONBLOCK)) < 0)
 	return memif_syscall_error_handler (errno);
-      /* add int fd to interrupt fd list */
       e.key = mq[x].int_fd;
       e.data_struct = conn;
       add_list_elt (&e, &lm->interrupt_list, &lm->interrupt_list_len);
@@ -1441,12 +1510,54 @@
       mq[x].log2_ring_size = conn->run_args.log2_ring_size;
       mq[x].region = 0;
       mq[x].offset =
-	(void *) mq[x].ring - (void *) conn->regions[mq->region].shm;
-      mq[x].last_head = 0;
+	(void *) mq[x].ring - (void *) conn->regions[mq->region].addr;
+      mq[x].last_head = mq[x].last_tail = 0;
       mq[x].alloc_bufs = 0;
     }
   conn->rx_queues = mq;
 
+  return MEMIF_ERR_SUCCESS;
+}
+
+int
+memif_init_regions_and_queues (memif_connection_t * conn)
+{
+  memif_ring_t *ring = NULL;
+  memif_region_t *r;
+  int i, j;
+  libmemif_main_t *lm = &libmemif_main;
+  memif_list_elt_t e;
+
+  /* region 0. rings */
+  memif_add_region (lm, conn, /* has_buffers */ 0);
+
+  /* region 1. buffers */
+  if (lm->add_external_region)
+    {
+      r =
+	(memif_region_t *) lm->realloc (conn->regions,
+					sizeof (memif_region_t) *
+					++conn->regions_num);
+      if (r == NULL)
+	return MEMIF_ERR_NOMEM;
+      conn->regions = r;
+
+      conn->regions[1].region_size =
+	conn->run_args.buffer_size * (1 << conn->run_args.log2_ring_size) *
+	(conn->run_args.num_s2m_rings + conn->run_args.num_m2s_rings);
+      conn->regions[1].buffer_offset = 0;
+      lm->add_external_region (&conn->regions[1].addr,
+			       conn->regions[1].region_size,
+			       &conn->regions[1].fd, conn->private_ctx);
+      conn->regions[1].is_external = 1;
+    }
+  else
+    {
+      memif_add_region (lm, conn, 1);
+    }
+
+  memif_init_queues (lm, conn);
+
   return 0;
 }
 
@@ -1501,7 +1612,8 @@
       ((memif_ring_t *) b0->ring)->desc[b0->desc_index & mask].offset = ring->desc[slot & mask].offset;	/* put free buffer on rx ring */
 
       ring->desc[slot & mask].offset =
-	(uint32_t) (b0->data - c->regions->shm);
+	(uint32_t) (b0->data -
+		    c->regions[ring->desc[slot & mask].region].addr);
       ring->desc[slot & mask].flags |=
 	(b0->flags & MEMIF_BUFFER_FLAG_NEXT) ? MEMIF_DESC_FLAG_NEXT : 0;
 
@@ -1547,10 +1659,12 @@
   if (EXPECT_FALSE (!count_out))
     return MEMIF_ERR_INVAL_ARG;
 
+  libmemif_main_t *lm = &libmemif_main;
   memif_queue_t *mq = &c->tx_queues[qid];
   memif_ring_t *ring = mq->ring;
   memif_buffer_t *b0, *b1;
   uint16_t mask = (1 << mq->log2_ring_size) - 1;
+  uint32_t offset_mask = c->run_args.buffer_size - 1;
   uint16_t ring_size;
   uint16_t slot, ns;
   int i, err = MEMIF_ERR_SUCCESS;	/* 0 */
@@ -1620,14 +1734,13 @@
 	  /* slave resets buffer offset */
 	  if (c->args.is_master == 0)
 	    {
-	      uint16_t x =
-		(ring->desc[slot & mask].offset -
-		 c->regions->buffer_offset) / c->run_args.buffer_size;
-	      ring->desc[slot & mask].offset =
-		c->regions->buffer_offset + (x * c->run_args.buffer_size);
+	      memif_desc_t *d = &ring->desc[slot & mask];
+	      if (lm->get_external_buffer_offset)
+		d->offset = lm->get_external_buffer_offset (c->private_ctx);
+	      else
+		d->offset = d->offset - (d->offset & offset_mask);
 	    }
-
-	  b0->data = c->regions->shm + ring->desc[slot & mask].offset;
+	  b0->data = memif_get_buffer (c, ring, slot & mask);
 
 	  src_left -= b0->len;
 	  dst_left -= b0->len;
@@ -1673,6 +1786,7 @@
   memif_queue_t *mq = &c->rx_queues[qid];
   memif_ring_t *ring = mq->ring;
   uint16_t mask = (1 << mq->log2_ring_size) - 1;
+  uint32_t offset_mask = c->run_args.buffer_size - 1;
   uint16_t slot;
 
   if (c->args.is_master)
@@ -1688,20 +1802,18 @@
   uint16_t ns = (1 << mq->log2_ring_size) - head + mq->last_tail;
   head += (count < ns) ? count : ns;
 
-  if (headroom)
+  slot = ring->head;
+  memif_desc_t *d;
+  while (slot < head)
     {
-      slot = ring->head;
-      while (slot < head)
-	{
-	  uint16_t x =
-	    (ring->desc[slot & mask].offset -
-	     c->regions->buffer_offset) / c->run_args.buffer_size;
-	  ring->desc[slot & mask].offset =
-	    c->regions->buffer_offset + (x * c->run_args.buffer_size) +
-	    headroom;
-
-	  slot++;
-	}
+      d = &ring->desc[slot & mask];
+      d->region = 1;
+      d->length = c->run_args.buffer_size - headroom;
+      if (lm->get_external_buffer_offset)
+	d->offset = lm->get_external_buffer_offset (c->private_ctx);
+      else
+	d->offset = d->offset - (d->offset & offset_mask) + headroom;
+      slot++;
     }
 
   MEMIF_MEMORY_BARRIER ();
@@ -1878,7 +1990,8 @@
   l1 = strlen ((char *) c->args.interface_name);
   if (l0 + l1 < buflen)
     {
-      md->if_name = (uint8_t *) strcpy (buf + l0, (char *) c->args.interface_name);
+      md->if_name =
+	(uint8_t *) strcpy (buf + l0, (char *) c->args.interface_name);
       l0 += l1 + 1;
     }
   else
@@ -1896,7 +2009,8 @@
   l1 = strlen ((char *) c->remote_if_name);
   if (l0 + l1 < buflen)
     {
-      md->remote_if_name = (uint8_t *) strcpy (buf + l0, (char *) c->remote_if_name);
+      md->remote_if_name =
+	(uint8_t *) strcpy (buf + l0, (char *) c->remote_if_name);
       l0 += l1 + 1;
     }
   else
@@ -1905,7 +2019,8 @@
   l1 = strlen ((char *) c->remote_name);
   if (l0 + l1 < buflen)
     {
-      md->remote_inst_name = (uint8_t *) strcpy (buf + l0, (char *) c->remote_name);
+      md->remote_inst_name =
+	(uint8_t *) strcpy (buf + l0, (char *) c->remote_name);
       l0 += l1 + 1;
     }
   else
@@ -1913,7 +2028,7 @@
 
   md->id = c->args.interface_id;
 
-  if (strlen((char *) c->args.secret) > 0)
+  if (strlen ((char *) c->args.secret) > 0)
     {
       l1 = strlen ((char *) c->args.secret);
       if (l0 + l1 < buflen)
@@ -1938,6 +2053,25 @@
   else
     err = MEMIF_ERR_NOBUF_DET;
 
+  md->regions_num = c->regions_num;
+  l1 = sizeof (memif_region_details_t) * md->regions_num;
+  if (l0 + l1 <= buflen)
+    {
+      md->regions = (memif_region_details_t *) buf + l0;
+      l0 += l1;
+    }
+  else
+    err = MEMIF_ERR_NOBUF_DET;
+
+  for (i = 0; i < md->regions_num; i++)
+    {
+      md->regions[i].index = i;
+      md->regions[i].addr = c->regions[i].addr;
+      md->regions[i].size = c->regions[i].region_size;
+      md->regions[i].fd = c->regions[i].fd;
+      md->regions[i].is_external = c->regions[i].is_external;
+    }
+
   md->rx_queues_num =
     (c->args.is_master) ? c->run_args.num_s2m_rings : c->run_args.
     num_m2s_rings;
@@ -1953,6 +2087,7 @@
 
   for (i = 0; i < md->rx_queues_num; i++)
     {
+      md->rx_queues[i].region = c->rx_queues[i].region;
       md->rx_queues[i].qid = i;
       md->rx_queues[i].ring_size = (1 << c->rx_queues[i].log2_ring_size);
       md->rx_queues[i].flags = c->rx_queues[i].ring->flags;
@@ -1976,6 +2111,7 @@
 
   for (i = 0; i < md->tx_queues_num; i++)
     {
+      md->tx_queues[i].region = c->tx_queues[i].region;
       md->tx_queues[i].qid = i;
       md->tx_queues[i].ring_size = (1 << c->tx_queues[i].log2_ring_size);
       md->tx_queues[i].flags = c->tx_queues[i].ring->flags;
diff --git a/extras/libmemif/src/memif_private.h b/extras/libmemif/src/memif_private.h
index 5ea5494..deca80c 100644
--- a/extras/libmemif/src/memif_private.h
+++ b/extras/libmemif/src/memif_private.h
@@ -67,10 +67,11 @@
 
 typedef struct
 {
-  void *shm;
+  void *addr;
   uint32_t region_size;
   uint32_t buffer_offset;
   int fd;
+  uint8_t is_external;
 } memif_region_t;
 
 typedef struct
@@ -133,8 +134,11 @@
   uint8_t remote_name[MEMIF_NAME_LEN];
   uint8_t remote_disconnect_string[96];
 
+  uint8_t regions_num;
   memif_region_t *regions;
 
+  uint8_t rx_queues_num;
+  uint8_t tx_queues_num;
   memif_queue_t *rx_queues;
   memif_queue_t *tx_queues;
 
@@ -165,7 +169,13 @@
   uint16_t disconn_slaves;
   uint8_t app_name[MEMIF_NAME_LEN];
 
+  memif_add_external_region_t *add_external_region;
+  memif_get_external_region_addr_t *get_external_region_addr;
+  memif_del_external_region_t *del_external_region;
+  memif_get_external_buffer_offset_t *get_external_buffer_offset;
+
   memif_alloc_t *alloc;
+  memif_realloc_t *realloc;
   memif_free_t *free;
 
   uint16_t control_list_len;
@@ -226,7 +236,7 @@
 memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring,
 		  uint16_t index)
 {
-  return (conn->regions[ring->desc[index].region].shm +
+  return (conn->regions[ring->desc[index].region].addr +
 	  ring->desc[index].offset);
 }
 
diff --git a/extras/libmemif/src/socket.c b/extras/libmemif/src/socket.c
index 3982c96..7c4bbd4 100644
--- a/extras/libmemif/src/socket.c
+++ b/extras/libmemif/src/socket.c
@@ -112,7 +112,8 @@
   h->max_region = MEMIF_MAX_REGION;
   h->max_log2_ring_size = MEMIF_MAX_LOG2_RING_SIZE;
 
-  strncpy ((char *) h->name, (char *) lm->app_name, strlen ((char *) lm->app_name));
+  strncpy ((char *) h->name, (char *) lm->app_name,
+	   strlen ((char *) lm->app_name));
 
   /* msg hello is not enqueued but sent directly,
      because it is the first msg to be sent */
@@ -141,7 +142,7 @@
 
   strncpy ((char *) i->name, (char *) lm->app_name,
 	   strlen ((char *) lm->app_name));
-  if (strlen((char *) c->args.secret) > 0)
+  if (strlen ((char *) c->args.secret) > 0)
     strncpy ((char *) i->secret, (char *) c->args.secret, sizeof (i->secret));
 
   e->next = NULL;
@@ -166,7 +167,6 @@
 memif_msg_enq_add_region (memif_connection_t * c, uint8_t region_index)
 {
   libmemif_main_t *lm = &libmemif_main;
-  /* maybe check if region is valid? */
   memif_region_t *mr = &c->regions[region_index];
 
   memif_msg_queue_elt_t *e =
@@ -424,10 +424,10 @@
   strncpy ((char *) c->remote_name, (char *) i->name,
 	   strlen ((char *) i->name));
 
-  if (strlen((char *) c->args.secret) > 0)
+  if (strlen ((char *) c->args.secret) > 0)
     {
       int r;
-      if (strlen((char *) i->secret) > 0)
+      if (strlen ((char *) i->secret) > 0)
 	{
 	  if (strlen ((char *) c->args.secret) != strlen ((char *) i->secret))
 	    {
@@ -484,6 +484,8 @@
 memif_msg_receive_add_region (memif_connection_t * c, memif_msg_t * msg,
 			      int fd)
 {
+  libmemif_main_t *lm = &libmemif_main;
+
   memif_msg_add_region_t *ar = &msg->add_region;
   memif_region_t *mr;
   if (fd < 0)
@@ -493,14 +495,19 @@
     return MEMIF_ERR_MAXREG;
 
   mr =
-    (memif_region_t *) realloc (c->regions,
-				sizeof (memif_region_t) * (ar->index + 1));
+    (memif_region_t *) lm->realloc (c->regions,
+				    sizeof (memif_region_t) *
+				    (++c->regions_num));
   if (mr == NULL)
     return memif_syscall_error_handler (errno);
+  memset (mr + ar->index, 0, sizeof (memif_region_t));
   c->regions = mr;
   c->regions[ar->index].fd = fd;
   c->regions[ar->index].region_size = ar->size;
-  c->regions[ar->index].shm = NULL;
+  c->regions[ar->index].addr = NULL;
+
+  if (lm->get_external_region_addr)
+    c->regions[ar->index].is_external = 1;
 
   return MEMIF_ERR_SUCCESS;	/* 0 */
 }
@@ -510,6 +517,8 @@
 static_fn int
 memif_msg_receive_add_ring (memif_connection_t * c, memif_msg_t * msg, int fd)
 {
+  libmemif_main_t *lm = &libmemif_main;
+
   memif_msg_add_ring_t *ar = &msg->add_ring;
 
   memif_queue_t *mq;
@@ -528,8 +537,9 @@
 	return MEMIF_ERR_MAXRING;
 
       mq =
-	(memif_queue_t *) realloc (c->rx_queues,
-				   sizeof (memif_queue_t) * (ar->index + 1));
+	(memif_queue_t *) lm->realloc (c->rx_queues,
+				       sizeof (memif_queue_t) *
+				       (++c->rx_queues_num));
       memset (mq + ar->index, 0, sizeof (memif_queue_t));
       if (mq == NULL)
 	return memif_syscall_error_handler (errno);
@@ -548,8 +558,9 @@
 	return MEMIF_ERR_MAXRING;
 
       mq =
-	(memif_queue_t *) realloc (c->tx_queues,
-				   sizeof (memif_queue_t) * (ar->index + 1));
+	(memif_queue_t *) lm->realloc (c->tx_queues,
+				       sizeof (memif_queue_t) *
+				       (++c->tx_queues_num));
       memset (mq + ar->index, 0, sizeof (memif_queue_t));
       if (mq == NULL)
 	return memif_syscall_error_handler (errno);
@@ -718,8 +729,11 @@
 	return err;
       if ((err = memif_msg_enq_init (c)) != MEMIF_ERR_SUCCESS)
 	return err;
-      if ((err = memif_msg_enq_add_region (c, 0)) != MEMIF_ERR_SUCCESS)
-	return err;
+      for (i = 0; i < c->regions_num; i++)
+	{
+	  if ((err = memif_msg_enq_add_region (c, i)) != MEMIF_ERR_SUCCESS)
+	    return err;
+	}
       for (i = 0; i < c->run_args.num_s2m_rings; i++)
 	{
 	  if ((err =
