aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-09-16 08:14:01 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-09-16 08:14:01 +0200
commit45d9b0000e7690f03f4fdf56bebacc96392e0178 (patch)
tree8598fa5add2828bb142863cb8bcd2398e49c2740 /tcp.c
parent474b8e6fb7f1d8dab214ac47dd3de78bf69d6dd0 (diff)
downloadpasst-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar.gz
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar.bz2
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar.lz
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar.xz
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.tar.zst
passt-45d9b0000e7690f03f4fdf56bebacc96392e0178.zip
tcp: Read SO_SNDBUF unconditionally
Checking it only when the cached value is smaller than the current window of the receiver is not enough: it might shrink further while the receiver window is growing. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/tcp.c b/tcp.c
index bc0dc61..231b842 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1150,16 +1150,13 @@ static int tcp_send_to_tap(struct ctx *c, struct tcp_tap_conn *conn,
return err;
}
- if (info.tcpi_snd_wnd > conn->sndbuf) {
- sl = sizeof(conn->sndbuf);
- if (getsockopt(conn->sock, SOL_SOCKET, SO_SNDBUF,
- &conn->sndbuf, &sl))
- conn->sndbuf = USHRT_MAX;
-
- info.tcpi_snd_wnd = MIN(info.tcpi_snd_wnd,
- conn->sndbuf / 100 * 90);
- }
+ sl = sizeof(conn->sndbuf);
+ if (getsockopt(conn->sock, SOL_SOCKET, SO_SNDBUF,
+ &conn->sndbuf, &sl))
+ conn->sndbuf = USHRT_MAX;
+ info.tcpi_snd_wnd = MIN(info.tcpi_snd_wnd,
+ conn->sndbuf * 90 / 100);
conn->tcpi_snd_wnd = info.tcpi_snd_wnd;
}
@@ -1766,15 +1763,12 @@ recvmmsg:
&sl))
goto err;
- if (info.tcpi_snd_wnd > conn->sndbuf) {
- if (getsockopt(conn->sock, SOL_SOCKET,
- SO_SNDBUF, &conn->sndbuf, &sl))
- conn->sndbuf = USHRT_MAX;
+ if (getsockopt(conn->sock, SOL_SOCKET,
+ SO_SNDBUF, &conn->sndbuf, &sl))
+ conn->sndbuf = USHRT_MAX;
- info.tcpi_snd_wnd = MIN(info.tcpi_snd_wnd,
- conn->sndbuf / 100
- * 90);
- }
+ info.tcpi_snd_wnd = MIN(info.tcpi_snd_wnd,
+ conn->sndbuf * 90 / 100);
if (conn->state == ESTABLISHED)
conn->seq_ack_to_tap = conn->seq_from_tap;