Skip to content

Commit

Permalink
Fix Issue #1632 fq-rate works in reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Larsen authored and swlars committed Feb 9, 2024
1 parent 0e90ae5 commit d3e676c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/iperf_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ iperf_tcp_accept(struct iperf_test * test)
i_errno = IESTREAMCONNECT;
return -1;
}
#if defined(HAVE_SO_MAX_PACING_RATE)
/* If fq socket pacing is specified, enable it. */

if (test->settings->fqrate) {
/* Convert bits per second to bytes per second */
unsigned int fqrate = test->settings->fqrate / 8;
if (fqrate > 0) {
if (test->debug) {
printf("Setting fair-queue socket pacing to %u\n", fqrate);
}
if (setsockopt(s, SOL_SOCKET, SO_MAX_PACING_RATE, &fqrate, sizeof(fqrate)) < 0) {
warning("Unable to set socket pacing");
}
}
}
#endif /* HAVE_SO_MAX_PACING_RATE */

if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) {
i_errno = IERECVCOOKIE;
Expand Down Expand Up @@ -240,21 +256,6 @@ iperf_tcp_listen(struct iperf_test *test)
return -1;
}
}
#if defined(HAVE_SO_MAX_PACING_RATE)
/* If fq socket pacing is specified, enable it. */
if (test->settings->fqrate) {
/* Convert bits per second to bytes per second */
unsigned int fqrate = test->settings->fqrate / 8;
if (fqrate > 0) {
if (test->debug) {
printf("Setting fair-queue socket pacing to %u\n", fqrate);
}
if (setsockopt(s, SOL_SOCKET, SO_MAX_PACING_RATE, &fqrate, sizeof(fqrate)) < 0) {
warning("Unable to set socket pacing");
}
}
}
#endif /* HAVE_SO_MAX_PACING_RATE */
{
unsigned int rate = test->settings->rate / 8;
if (rate > 0) {
Expand Down

0 comments on commit d3e676c

Please sign in to comment.