session: cleanup attach flags

Change-Id: I39d21d15677f57e10b69b8842f2cbca277abddf0
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/src/svm/svm_fifo_segment.c b/src/svm/svm_fifo_segment.c
index e43c084..a56a714 100644
--- a/src/svm/svm_fifo_segment.c
+++ b/src/svm/svm_fifo_segment.c
@@ -229,11 +229,11 @@
   u32 rnd_size = 0;
   int i;
 
-  if (a->private_segment_count && a->private_segment_size)
+  if (a->private_segment_count)
     {
       u8 *heap;
       u32 pagesize = clib_mem_get_page_size ();
-      rnd_size = (a->private_segment_size + (pagesize - 1)) & ~pagesize;
+      rnd_size = (a->segment_size + (pagesize - 1)) & ~pagesize;
 
       for (i = 0; i < a->private_segment_count; i++)
 	{
diff --git a/src/svm/svm_fifo_segment.h b/src/svm/svm_fifo_segment.h
index 5b77132..7a30efa 100644
--- a/src/svm/svm_fifo_segment.h
+++ b/src/svm/svm_fifo_segment.h
@@ -72,7 +72,6 @@
   u32 tx_fifo_size;
   u32 preallocated_fifo_pairs;
   u32 private_segment_count;
-  u32 private_segment_size;
 } svm_fifo_segment_create_args_t;
 
 static inline svm_fifo_segment_private_t *
diff --git a/src/uri/uri_tcp_test.c b/src/uri/uri_tcp_test.c
index d3c4a75..8bdcac3 100755
--- a/src/uri/uri_tcp_test.c
+++ b/src/uri/uri_tcp_test.c
@@ -192,10 +192,10 @@
   bmp->options[APP_OPTIONS_FLAGS] =
     APP_OPTIONS_FLAGS_ACCEPT_REDIRECT | APP_OPTIONS_FLAGS_ADD_SEGMENT;
   bmp->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = 16;
-  bmp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = fifo_size;
-  bmp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = fifo_size;
-  bmp->options[SESSION_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
-  bmp->options[SESSION_OPTIONS_SEGMENT_SIZE] = 256 << 20;
+  bmp->options[APP_OPTIONS_RX_FIFO_SIZE] = fifo_size;
+  bmp->options[APP_OPTIONS_TX_FIFO_SIZE] = fifo_size;
+  bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
+  bmp->options[APP_OPTIONS_SEGMENT_SIZE] = 256 << 20;
   vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & bmp);
 }
 
@@ -246,6 +246,7 @@
       return;
     }
 
+  memset (a, 0, sizeof (*a));
   a->segment_name = (char *) mp->segment_name;
   a->segment_size = mp->segment_size;
 
diff --git a/src/uri/uri_udp_test.c b/src/uri/uri_udp_test.c
index 27e70cf..ac94118 100644
--- a/src/uri/uri_udp_test.c
+++ b/src/uri/uri_udp_test.c
@@ -176,11 +176,11 @@
   bmp->options[APP_OPTIONS_FLAGS] =
     APP_OPTIONS_FLAGS_ACCEPT_REDIRECT | APP_OPTIONS_FLAGS_ADD_SEGMENT;
   bmp->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = 2;
-  bmp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = fifo_size;
-  bmp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = fifo_size;
-  bmp->options[SESSION_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
-  bmp->options[SESSION_OPTIONS_SEGMENT_SIZE] = 256 << 20;
-  bmp->options[APP_EVT_QUEUE_SIZE] = 16768;
+  bmp->options[APP_OPTIONS_RX_FIFO_SIZE] = fifo_size;
+  bmp->options[APP_OPTIONS_TX_FIFO_SIZE] = fifo_size;
+  bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = 128 << 20;
+  bmp->options[APP_OPTIONS_SEGMENT_SIZE] = 256 << 20;
+  bmp->options[APP_OPTIONS_EVT_QUEUE_SIZE] = 16768;
   vl_msg_api_send_shmem (utm->vl_input_queue, (u8 *) & bmp);
 }
 
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 8ea331f..ce222a7 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -553,12 +553,13 @@
   bmp->options[APP_OPTIONS_PROXY_TRANSPORT] =
     (vcm->cfg.app_proxy_transport_tcp ? 1 << TRANSPORT_PROTO_TCP : 0) |
     (vcm->cfg.app_proxy_transport_udp ? 1 << TRANSPORT_PROTO_UDP : 0);
-  bmp->options[SESSION_OPTIONS_SEGMENT_SIZE] = vcm->cfg.segment_size;
-  bmp->options[SESSION_OPTIONS_ADD_SEGMENT_SIZE] = vcm->cfg.add_segment_size;
-  bmp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = vcm->cfg.rx_fifo_size;
-  bmp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = vcm->cfg.tx_fifo_size;
+  bmp->options[APP_OPTIONS_SEGMENT_SIZE] = vcm->cfg.segment_size;
+  bmp->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = vcm->cfg.add_segment_size;
+  bmp->options[APP_OPTIONS_RX_FIFO_SIZE] = vcm->cfg.rx_fifo_size;
+  bmp->options[APP_OPTIONS_TX_FIFO_SIZE] = vcm->cfg.tx_fifo_size;
   bmp->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
     vcm->cfg.preallocated_fifo_pairs;
+  bmp->options[APP_OPTIONS_EVT_QUEUE_SIZE] = vcm->cfg.event_queue_size;
   if (nsid_len)
     {
       bmp->namespace_id_len = nsid_len;
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 3e6ac98..f6151b6 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -237,8 +237,8 @@
   u32 default_rx_fifo_size = 16 << 10, default_tx_fifo_size = 16 << 10;
   int rv;
 
-  app_evt_queue_size = options[APP_EVT_QUEUE_SIZE] > 0 ?
-    options[APP_EVT_QUEUE_SIZE] : default_app_evt_queue_size;
+  app_evt_queue_size = options[APP_OPTIONS_EVT_QUEUE_SIZE] > 0 ?
+    options[APP_OPTIONS_EVT_QUEUE_SIZE] : default_app_evt_queue_size;
 
   /*
    * Setup segment manager
@@ -247,11 +247,11 @@
   sm->app_index = app->index;
   props = segment_manager_properties_alloc ();
   app->sm_properties = segment_manager_properties_index (props);
-  props->add_segment_size = options[SESSION_OPTIONS_ADD_SEGMENT_SIZE];
-  props->rx_fifo_size = options[SESSION_OPTIONS_RX_FIFO_SIZE];
+  props->add_segment_size = options[APP_OPTIONS_ADD_SEGMENT_SIZE];
+  props->rx_fifo_size = options[APP_OPTIONS_RX_FIFO_SIZE];
   props->rx_fifo_size =
     props->rx_fifo_size ? props->rx_fifo_size : default_rx_fifo_size;
-  props->tx_fifo_size = options[SESSION_OPTIONS_TX_FIFO_SIZE];
+  props->tx_fifo_size = options[APP_OPTIONS_TX_FIFO_SIZE];
   props->tx_fifo_size =
     props->tx_fifo_size ? props->tx_fifo_size : default_tx_fifo_size;
   props->add_segment = props->add_segment_size != 0;
@@ -259,9 +259,8 @@
   props->use_private_segment = options[APP_OPTIONS_FLAGS]
     & APP_OPTIONS_FLAGS_IS_BUILTIN;
   props->private_segment_count = options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT];
-  props->private_segment_size = options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE];
 
-  first_seg_size = options[SESSION_OPTIONS_SEGMENT_SIZE];
+  first_seg_size = options[APP_OPTIONS_SEGMENT_SIZE];
   if ((rv = segment_manager_init (sm, app->sm_properties, first_seg_size)))
     return rv;
   sm->first_is_protected = 1;
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 686b418..68973a9 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -101,21 +101,19 @@
 /* Application attach options */
 typedef enum
 {
-  APP_EVT_QUEUE_SIZE,
   APP_OPTIONS_FLAGS,
-  APP_OPTIONS_PREALLOC_FIFO_PAIRS,
+  APP_OPTIONS_EVT_QUEUE_SIZE,
+  APP_OPTIONS_SEGMENT_SIZE,
+  APP_OPTIONS_ADD_SEGMENT_SIZE,
   APP_OPTIONS_PRIVATE_SEGMENT_COUNT,
-  APP_OPTIONS_PRIVATE_SEGMENT_SIZE,
+  APP_OPTIONS_RX_FIFO_SIZE,
+  APP_OPTIONS_TX_FIFO_SIZE,
+  APP_OPTIONS_PREALLOC_FIFO_PAIRS,
   APP_OPTIONS_NAMESPACE,
   APP_OPTIONS_NAMESPACE_SECRET,
   APP_OPTIONS_PROXY_TRANSPORT,
-  SESSION_OPTIONS_SEGMENT_SIZE,
-  SESSION_OPTIONS_ADD_SEGMENT_SIZE,
-  SESSION_OPTIONS_RX_FIFO_SIZE,
-  SESSION_OPTIONS_TX_FIFO_SIZE,
-  SESSION_OPTIONS_PREALLOCATED_FIFO_PAIRS,
-  SESSION_OPTIONS_ACCEPT_COOKIE,
-  SESSION_OPTIONS_N_OPTIONS
+  APP_OPTIONS_ACCEPT_COOKIE,
+  APP_OPTIONS_N_OPTIONS
 } app_attach_options_index_t;
 
 #define foreach_app_options_flags				\
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index e448023..9e6a1b5 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -116,16 +116,11 @@
       u64 approx_total_size;
 
       ca->segment_name = "process-private-segment";
-      ca->segment_size = ~0;
+      ca->segment_size = segment_size;
       ca->rx_fifo_size = props->rx_fifo_size;
       ca->tx_fifo_size = props->tx_fifo_size;
       ca->preallocated_fifo_pairs = props->preallocated_fifo_pairs;
       ca->private_segment_count = props->private_segment_count;
-      ca->private_segment_size = props->private_segment_size;
-
-      /* Default to a small private segment */
-      if (ca->private_segment_size == 0)
-	ca->private_segment_size = 128 << 20;
 
       /* Calculate space requirements */
       rx_rounded_data_size = (1 << (max_log2 (ca->rx_fifo_size)));
@@ -136,9 +131,8 @@
 
       approx_total_size = (u64) ca->preallocated_fifo_pairs
 	* (rx_fifo_size + tx_fifo_size);
-      approx_segment_count =
-	(approx_total_size +
-	 (ca->private_segment_size - 1)) / (u64) ca->private_segment_size;
+      approx_segment_count = (approx_total_size + (ca->segment_size - 1))
+	/ (u64) ca->segment_size;
 
       /* The user asked us to figure it out... */
       if (ca->private_segment_count == 0)
@@ -148,9 +142,8 @@
       /* Follow directions, but issue a warning */
       else if (approx_segment_count != ca->private_segment_count)
 	{
-	  clib_warning
-	    ("Honoring segment count %u, but calculated count was %u",
-	     ca->private_segment_count, approx_segment_count);
+	  clib_warning ("Honoring segment count %u, calculated count was %u",
+			ca->private_segment_count, approx_segment_count);
 	}
 
       if (svm_fifo_segment_create_process_private (ca))
@@ -624,7 +617,7 @@
       segments = svm_fifo_segment_segments_pool ();
       vlib_cli_output (vm, "%d svm fifo segments allocated",
 		       pool_elts (segments));
-      vlib_cli_output (vm, "%-20s%=12s%=16s%=16s%=16s", "Name",
+      vlib_cli_output (vm, "%-25s%15s%16s%16s%16s", "Name",
 		       "HeapSize (M)", "ActiveFifos", "FreeFifos", "Address");
 
       /* *INDENT-OFF* */
@@ -647,7 +640,7 @@
 	  }
 	active_fifos = svm_fifo_segment_num_fifos (seg);
         free_fifos = svm_fifo_segment_num_free_fifos (seg, ~0 /* size */);
-	vlib_cli_output (vm, "%-20v%=16llu%=16u%=16u%16llx",
+	vlib_cli_output (vm, "%-25v%15llu%16u%16u%16llx",
                          name, size >> 20ULL, active_fifos, free_fifos,
 			 address);
         if (verbose)
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index f649461..9d2d141 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -42,7 +42,6 @@
 
   /** Use one or more private mheaps, instead of the global heap */
   u32 private_segment_count;
-  u32 private_segment_size;
 } segment_manager_properties_t;
 
 typedef struct _segment_manager
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 57f55eb..1fd84ab 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -253,8 +253,8 @@
     }
 
   props = segment_manager_properties_get (app->sm_properties);
-  mp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = props->rx_fifo_size;
-  mp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = props->tx_fifo_size;
+  mp->options[APP_OPTIONS_RX_FIFO_SIZE] = props->rx_fifo_size;
+  mp->options[APP_OPTIONS_TX_FIFO_SIZE] = props->tx_fifo_size;
 
   /*
    * Bounce message handlers MUST NOT block the data-plane.
@@ -321,7 +321,7 @@
       goto done;
     }
 
-  STATIC_ASSERT (sizeof (u64) * SESSION_OPTIONS_N_OPTIONS <=
+  STATIC_ASSERT (sizeof (u64) * APP_OPTIONS_N_OPTIONS <=
 		 sizeof (mp->options),
 		 "Out of options, fix api message definition");
 
diff --git a/src/vnet/session/session_test.c b/src/vnet/session/session_test.c
index 1303e8b..64657c1 100644
--- a/src/vnet/session/session_test.c
+++ b/src/vnet/session/session_test.c
@@ -102,7 +102,7 @@
 session_test_basic (vlib_main_t * vm, unformat_input_t * input)
 {
   session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
-  u64 options[SESSION_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
+  u64 options[APP_OPTIONS_N_OPTIONS], bind4_handle, bind6_handle;
   u8 segment_name[128];
   clib_error_t *error = 0;
   u32 server_index;
@@ -167,7 +167,7 @@
 static int
 session_test_namespace (vlib_main_t * vm, unformat_input_t * input)
 {
-  u64 options[SESSION_OPTIONS_N_OPTIONS], dummy_secret = 1234;
+  u64 options[APP_OPTIONS_N_OPTIONS], dummy_secret = 1234;
   u32 server_index, server_st_index, server_local_st_index;
   u32 dummy_port = 1234, local_listener, client_index;
   u32 dummy_api_context = 4321, dummy_client_api_index = 1234;
@@ -774,7 +774,7 @@
 session_test_rules (vlib_main_t * vm, unformat_input_t * input)
 {
   session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
-  u64 options[SESSION_OPTIONS_N_OPTIONS];
+  u64 options[APP_OPTIONS_N_OPTIONS];
   u16 lcl_port = 1234, rmt_port = 4321;
   u32 server_index, server_index2, app_index;
   u32 dummy_server_api_index = ~0;
@@ -1335,7 +1335,7 @@
 static int
 session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
 {
-  u64 options[SESSION_OPTIONS_N_OPTIONS];
+  u64 options[APP_OPTIONS_N_OPTIONS];
   char *show_listeners = "sh session listeners tcp verbose";
   char *show_local_listeners = "sh app ns table default";
   unformat_input_t tmp_input;
diff --git a/src/vnet/tcp/builtin_client.c b/src/vnet/tcp/builtin_client.c
index 2b4f07d..b90773b 100644
--- a/src/vnet/tcp/builtin_client.c
+++ b/src/vnet/tcp/builtin_client.c
@@ -429,10 +429,10 @@
 attach_builtin_test_clients_app (u8 * appns_id, u64 appns_flags,
 				 u64 appns_secret)
 {
+  u32 segment_name_length, prealloc_fifos, segment_size = 2 << 20;
   tclient_main_t *tm = &tclient_main;
   vnet_app_attach_args_t _a, *a = &_a;
   u8 segment_name[128];
-  u32 segment_name_length, prealloc_fifos;
   u64 options[16];
   clib_error_t *error = 0;
 
@@ -448,12 +448,14 @@
 
   prealloc_fifos = tm->prealloc_fifos ? tm->expected_connections : 1;
 
-  options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
-  options[SESSION_OPTIONS_SEGMENT_SIZE] = (2ULL << 32);
-  options[SESSION_OPTIONS_RX_FIFO_SIZE] = tm->fifo_size;
-  options[SESSION_OPTIONS_TX_FIFO_SIZE] = tm->fifo_size;
+  if (tm->private_segment_size)
+    segment_size = tm->private_segment_size;
+
+  options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
+  options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
+  options[APP_OPTIONS_RX_FIFO_SIZE] = tm->fifo_size;
+  options[APP_OPTIONS_TX_FIFO_SIZE] = tm->fifo_size;
   options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = tm->private_segment_count;
-  options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = tm->private_segment_size;
   options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = prealloc_fifos;
 
   options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
diff --git a/src/vnet/tcp/builtin_http_server.c b/src/vnet/tcp/builtin_http_server.c
index 6d58aab..6e1cd8e 100644
--- a/src/vnet/tcp/builtin_http_server.c
+++ b/src/vnet/tcp/builtin_http_server.c
@@ -511,23 +511,26 @@
 {
   http_server_main_t *hsm = &http_server_main;
   u8 segment_name[128];
-  u64 options[SESSION_OPTIONS_N_OPTIONS];
+  u64 options[APP_OPTIONS_N_OPTIONS];
   vnet_app_attach_args_t _a, *a = &_a;
+  u32 segment_size = 128 << 20;
 
   memset (a, 0, sizeof (*a));
   memset (options, 0, sizeof (options));
 
+  if (hsm->private_segment_size)
+    segment_size = hsm->private_segment_size;
+
   a->api_client_index = hsm->my_client_index;
   a->session_cb_vft = &builtin_session_cb_vft;
   a->options = options;
-  a->options[SESSION_OPTIONS_SEGMENT_SIZE] = 128 << 20;
-  a->options[SESSION_OPTIONS_RX_FIFO_SIZE] =
+  a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
+  a->options[APP_OPTIONS_RX_FIFO_SIZE] =
     hsm->fifo_size ? hsm->fifo_size : 8 << 10;
-  a->options[SESSION_OPTIONS_TX_FIFO_SIZE] =
+  a->options[APP_OPTIONS_TX_FIFO_SIZE] =
     hsm->fifo_size ? hsm->fifo_size : 32 << 10;
   a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
   a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = hsm->prealloc_fifos;
-  a->options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = hsm->private_segment_size;
   a->segment_name = segment_name;
   a->segment_name_length = ARRAY_LEN (segment_name);
 
diff --git a/src/vnet/tcp/builtin_proxy.c b/src/vnet/tcp/builtin_proxy.c
index 779e9b6..7f70df3 100644
--- a/src/vnet/tcp/builtin_proxy.c
+++ b/src/vnet/tcp/builtin_proxy.c
@@ -383,20 +383,22 @@
 {
   builtin_proxy_main_t *bpm = &builtin_proxy_main;
   u8 segment_name[128];
-  u64 options[SESSION_OPTIONS_N_OPTIONS];
+  u64 options[APP_OPTIONS_N_OPTIONS];
   vnet_app_attach_args_t _a, *a = &_a;
+  u32 segment_size = 512 << 20;
 
   memset (a, 0, sizeof (*a));
   memset (options, 0, sizeof (options));
 
+  if (bpm->private_segment_size)
+    segment_size = bpm->private_segment_size;
   a->api_client_index = bpm->server_client_index;
   a->session_cb_vft = &builtin_session_cb_vft;
   a->options = options;
-  a->options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20;
-  a->options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
-  a->options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
+  a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
+  a->options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
+  a->options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
   a->options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count;
-  a->options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size;
   a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
     bpm->prealloc_fifos ? bpm->prealloc_fifos : 1;
 
@@ -434,12 +436,11 @@
   a->segment_name_length = segment_name_length;
   a->session_cb_vft = &builtin_clients;
 
-  options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
-  options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20;
-  options[SESSION_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
-  options[SESSION_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
+  options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
+  options[APP_OPTIONS_SEGMENT_SIZE] = 512 << 20;
+  options[APP_OPTIONS_RX_FIFO_SIZE] = bpm->fifo_size;
+  options[APP_OPTIONS_TX_FIFO_SIZE] = bpm->fifo_size;
   options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bpm->private_segment_count;
-  options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bpm->private_segment_size;
   options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
     bpm->prealloc_fifos ? bpm->prealloc_fifos : 1;
 
diff --git a/src/vnet/tcp/builtin_server.c b/src/vnet/tcp/builtin_server.c
index b613b3a..26cbfe7 100644
--- a/src/vnet/tcp/builtin_server.c
+++ b/src/vnet/tcp/builtin_server.c
@@ -273,8 +273,9 @@
 {
   builtin_server_main_t *bsm = &builtin_server_main;
   u8 segment_name[128];
-  u64 options[SESSION_OPTIONS_N_OPTIONS];
+  u64 options[APP_OPTIONS_N_OPTIONS];
   vnet_app_attach_args_t _a, *a = &_a;
+  u32 segment_size = 512 << 20;
 
   memset (a, 0, sizeof (*a));
   memset (options, 0, sizeof (options));
@@ -285,14 +286,17 @@
   else
     builtin_session_cb_vft.builtin_server_rx_callback =
       builtin_server_rx_callback;
+
+  if (bsm->private_segment_size)
+    segment_size = bsm->private_segment_size;
+
   a->api_client_index = bsm->my_client_index;
   a->session_cb_vft = &builtin_session_cb_vft;
   a->options = options;
-  a->options[SESSION_OPTIONS_SEGMENT_SIZE] = 512 << 20;
-  a->options[SESSION_OPTIONS_RX_FIFO_SIZE] = bsm->fifo_size;
-  a->options[SESSION_OPTIONS_TX_FIFO_SIZE] = bsm->fifo_size;
+  a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
+  a->options[APP_OPTIONS_RX_FIFO_SIZE] = bsm->fifo_size;
+  a->options[APP_OPTIONS_TX_FIFO_SIZE] = bsm->fifo_size;
   a->options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = bsm->private_segment_count;
-  a->options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE] = bsm->private_segment_size;
   a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
     bsm->prealloc_fifos ? bsm->prealloc_fifos : 1;
 
diff --git a/src/vnet/udp/builtin_server.c b/src/vnet/udp/builtin_server.c
index 29c33be..05a4703 100644
--- a/src/vnet/udp/builtin_server.c
+++ b/src/vnet/udp/builtin_server.c
@@ -125,8 +125,8 @@
   a->segment_name_length = segment_name_length;
   a->session_cb_vft = &builtin_server;
 
-  options[SESSION_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
-  options[SESSION_OPTIONS_SEGMENT_SIZE] = (2 << 30);	/*$$$$ config / arg */
+  options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
+  options[APP_OPTIONS_SEGMENT_SIZE] = (2 << 30);	/*$$$$ config / arg */
   options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
   options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = 1024;