session: return bound listener for proxy accepts 82/9582/3
authorFlorin Coras <fcoras@cisco.com>
Mon, 27 Nov 2017 11:12:00 +0000 (03:12 -0800)
committerDave Wallace <dwallacelf@gmail.com>
Mon, 27 Nov 2017 20:35:37 +0000 (20:35 +0000)
This, if such a listener exists.

Change-Id: I974cc858c1e2fee50189c3c67e4abb76be32a98a
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/session/application.c
src/vnet/session/session.h
src/vnet/session/session_api.c

index 17770be..9a540f6 100644 (file)
@@ -523,7 +523,8 @@ application_first_listener (application_t * app, u8 fib_proto,
   /* *INDENT-OFF* */
    hash_foreach (handle, sm_index, app->listeners_table, ({
      listener = listen_session_get_from_handle (handle);
-     if (listener->session_type == sst)
+     if (listener->session_type == sst
+        && listener->listener_index != SESSION_PROXY_LISTENER_INDEX)
        return listener;
    }));
   /* *INDENT-ON* */
@@ -550,6 +551,7 @@ application_start_stop_proxy_fib_proto (application_t * app, u8 fib_proto,
       sep.transport_proto = transport_proto;
       application_start_listen (app, &sep, &handle);
       s = listen_session_get_from_handle (handle);
+      s->listener_index = SESSION_PROXY_LISTENER_INDEX;
     }
   else
     {
index bd854d4..cf1bc9d 100644 (file)
@@ -24,6 +24,7 @@
 
 #define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0)
 #define INVALID_INDEX ((u32)~0)
+#define SESSION_PROXY_LISTENER_INDEX ((u32)~0 - 1)
 
 /* TODO decide how much since we have pre-data as well */
 #define MAX_HDRS_LEN    100    /* Max number of bytes for headers */
index f15d2f6..c54e635 100755 (executable)
@@ -106,6 +106,16 @@ send_session_accept_callback (stream_session_t * s)
   tp_vft = transport_protocol_get_vft (s->session_type);
   tc = tp_vft->get_connection (s->connection_index, s->thread_index);
   mp->listener_handle = listen_session_get_handle (listener);
+
+  if (application_is_proxy (server))
+    {
+      listener =
+       application_first_listener (server,
+                                   transport_connection_fib_proto (tc),
+                                   tc->proto);
+      if (listener)
+       mp->listener_handle = listen_session_get_handle (listener);
+    }
   mp->handle = session_handle (s);
   mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
   mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);