summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/hs_apps/proxy.c')
-rw-r--r--src/plugins/hs_apps/proxy.c93
1 files changed, 87 insertions, 6 deletions
diff --git a/src/plugins/hs_apps/proxy.c b/src/plugins/hs_apps/proxy.c
index e2a44e1706b..ad5b292c56d 100644
--- a/src/plugins/hs_apps/proxy.c
+++ b/src/plugins/hs_apps/proxy.c
@@ -18,9 +18,12 @@
#include <vnet/session/application.h>
#include <vnet/session/application_interface.h>
#include <hs_apps/proxy.h>
+#include <vnet/tcp/tcp.h>
proxy_main_t proxy_main;
+#define TCP_MSS 1460
+
typedef struct
{
char uri[128];
@@ -189,7 +192,7 @@ proxy_rx_callback (session_t * s)
proxy_session_t *ps;
int proxy_index;
uword *p;
- svm_fifo_t *active_open_tx_fifo;
+ svm_fifo_t *ao_tx_fifo;
ASSERT (s->thread_index == thread_index);
@@ -199,20 +202,23 @@ proxy_rx_callback (session_t * s)
if (PREDICT_TRUE (p != 0))
{
clib_spinlock_unlock_if_init (&pm->sessions_lock);
- active_open_tx_fifo = s->rx_fifo;
+ ao_tx_fifo = s->rx_fifo;
/*
* Send event for active open tx fifo
*/
- if (svm_fifo_set_event (active_open_tx_fifo))
+ if (svm_fifo_set_event (ao_tx_fifo))
{
- u32 ao_thread_index = active_open_tx_fifo->master_thread_index;
- u32 ao_session_index = active_open_tx_fifo->master_session_index;
+ u32 ao_thread_index = ao_tx_fifo->master_thread_index;
+ u32 ao_session_index = ao_tx_fifo->master_session_index;
if (session_send_io_evt_to_thread_custom (&ao_session_index,
ao_thread_index,
SESSION_IO_EVT_TX))
clib_warning ("failed to enqueue tx evt");
}
+
+ if (svm_fifo_max_enqueue (ao_tx_fifo) <= TCP_MSS)
+ svm_fifo_add_want_deq_ntf (ao_tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
}
else
{
@@ -257,12 +263,48 @@ proxy_rx_callback (session_t * s)
return 0;
}
+static int
+proxy_tx_callback (session_t * proxy_s)
+{
+ proxy_main_t *pm = &proxy_main;
+ transport_connection_t *tc;
+ session_handle_t handle;
+ proxy_session_t *ps;
+ session_t *ao_s;
+ uword *p;
+
+ clib_spinlock_lock_if_init (&pm->sessions_lock);
+
+ handle = session_handle (proxy_s);
+ p = hash_get (pm->proxy_session_by_server_handle, handle);
+ if (!p)
+ return 0;
+
+ if (pool_is_free_index (pm->sessions, p[0]))
+ return 0;
+
+ ps = pool_elt_at_index (pm->sessions, p[0]);
+ if (ps->vpp_active_open_handle == ~0)
+ return 0;
+
+ ao_s = session_get_from_handle (ps->vpp_active_open_handle);
+
+ /* Force ack on active open side to update rcv wnd */
+ tc = session_get_transport (ao_s);
+ tcp_send_ack ((tcp_connection_t *) tc);
+
+ clib_spinlock_unlock_if_init (&pm->sessions_lock);
+
+ return 0;
+}
+
static session_cb_vft_t proxy_session_cb_vft = {
.session_accept_callback = proxy_accept_callback,
.session_disconnect_callback = proxy_disconnect_callback,
.session_connected_callback = proxy_connected_callback,
.add_segment_callback = proxy_add_segment_callback,
.builtin_app_rx_callback = proxy_rx_callback,
+ .builtin_app_tx_callback = proxy_tx_callback,
.session_reset_callback = proxy_reset_callback
};
@@ -358,6 +400,44 @@ active_open_rx_callback (session_t * s)
SESSION_IO_EVT_TX);
}
+ if (svm_fifo_max_enqueue (proxy_tx_fifo) <= TCP_MSS)
+ svm_fifo_add_want_deq_ntf (proxy_tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
+
+ return 0;
+}
+
+static int
+active_open_tx_callback (session_t * ao_s)
+{
+ proxy_main_t *pm = &proxy_main;
+ transport_connection_t *tc;
+ session_handle_t handle;
+ proxy_session_t *ps;
+ session_t *proxy_s;
+ uword *p;
+
+ clib_spinlock_lock_if_init (&pm->sessions_lock);
+
+ handle = session_handle (ao_s);
+ p = hash_get (pm->proxy_session_by_active_open_handle, handle);
+ if (!p)
+ return 0;
+
+ if (pool_is_free_index (pm->sessions, p[0]))
+ return 0;
+
+ ps = pool_elt_at_index (pm->sessions, p[0]);
+ if (ps->vpp_server_handle == ~0)
+ return 0;
+
+ proxy_s = session_get_from_handle (ps->vpp_server_handle);
+
+ /* Force ack on proxy side to update rcv wnd */
+ tc = session_get_transport (proxy_s);
+ tcp_send_ack ((tcp_connection_t *) tc);
+
+ clib_spinlock_unlock_if_init (&pm->sessions_lock);
+
return 0;
}
@@ -367,7 +447,8 @@ static session_cb_vft_t active_open_clients = {
.session_connected_callback = active_open_connected_callback,
.session_accept_callback = active_open_create_callback,
.session_disconnect_callback = active_open_disconnect_callback,
- .builtin_app_rx_callback = active_open_rx_callback
+ .builtin_app_rx_callback = active_open_rx_callback,
+ .builtin_app_tx_callback = active_open_tx_callback,
};
/* *INDENT-ON* */