tcp: fix cwnd rollover introduced by ABC

Changes for TCP Appropriate Byte Counting introduce a potential cwnd
rollover by not taking into account integer promotion on tcpwnd_size_t
during inequality comparisions

This fixes the issue by introducing a macro TCP_WND_INC which detects
the rollover correctly and now holds the tcpwnd_size_t at the maximum
value rather than not incrementing the window.  This provides a slight
performance improvement by allowing full use of the tcpwnd_size_t number
space for the congestion window
This commit is contained in:
Joel Cunningham
2017-06-01 12:31:17 -05:00
parent 0df2c4f2be
commit 3eaf976152
2 changed files with 13 additions and 13 deletions

View File

@@ -143,6 +143,14 @@ typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
#define TCPWND16(x) (x)
#define TCP_WND_MAX(pcb) TCP_WND
#endif
/* Increments a tcpwnd_size_t and holds at max value rather than rollover */
#define TCP_WND_INC(wnd, inc) do { \
if ((tcpwnd_size_t)(wnd + inc) >= wnd) { \
wnd += inc; \
} else { \
wnd = (tcpwnd_size_t)-1; \
} \
} while(0)
#if LWIP_WND_SCALE || TCP_LISTEN_BACKLOG || LWIP_TCP_TIMESTAMPS
typedef u16_t tcpflags_t;