Skip to content

Commit

Permalink
hsa: proxy rcv wnd update acks after full fifos
Browse files Browse the repository at this point in the history
Avoid rcv wnd probing after zero window advertisments by registering for
tx dequeue notifications and forcing acks that open the rcv wnd.

Type: feature

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I8f33e3cf917f8c83d412f370ca66013aa4cd6e67
  • Loading branch information
florincoras authored and Dave Barach committed Jan 28, 2020
1 parent 7d08e39 commit dda2dbe
Showing 1 changed file with 87 additions and 6 deletions.
93 changes: 87 additions & 6 deletions src/plugins/hs_apps/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);

Expand All @@ -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
{
Expand Down Expand Up @@ -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
};

Expand Down Expand Up @@ -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;
}

Expand All @@ -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* */

Expand Down

0 comments on commit dda2dbe

Please sign in to comment.