diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-07-27 00:50:53 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-07-27 00:50:53 +0200 |
commit | fd5050ccbacfbcf7dee4075144ef3cd8f282f493 (patch) | |
tree | 9ce43b894592c761284a84e7dd57d415d0144cb7 /tcp.c | |
parent | d372c42460a56ecb9dfdc80f861f2e6a925ba25b (diff) | |
download | passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar.gz passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar.bz2 passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar.lz passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar.xz passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.tar.zst passt-fd5050ccbacfbcf7dee4075144ef3cd8f282f493.zip |
tcp: Limit TCP_INFO getsockopt() syscalls
There's no need to constantly query the socket for number of
acknowledged bytes if we're far from exhausting the sending window,
just do it if we're at least down to 90% of it.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1075,13 +1075,14 @@ static void tcp_rst(struct ctx *c, struct tcp_tap_conn *conn); static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn, int flags, char *in, int len) { + uint32_t ack_offset = conn->seq_from_tap - conn->seq_ack_to_tap; char buf[USHRT_MAX] = { 0 }, *data; struct tcp_info info = { 0 }; socklen_t sl = sizeof(info); struct tcphdr *th; int ws = 0, err; - if (conn->seq_from_tap == conn->seq_ack_to_tap && !flags && len) { + if (ack_offset < conn->tcpi_snd_wnd / 10 && !flags) { err = 0; info.tcpi_bytes_acked = conn->tcpi_acked_last; info.tcpi_snd_wnd = conn->tcpi_snd_wnd; |