From d291a10c50434707405d8cd1437ec62e10c43bb5 Mon Sep 17 00:00:00 2001 From: Daniele Di Proietto Date: Fri, 15 Apr 2016 17:04:53 -0700 Subject: datapath-windows: Fix bug in OvsTcpGetWscale(). The userspace conntrack had a bug in tcp_wscale_get(), where the length of an option would be read from the third octet of the option TLV instead of the second. This could cause an incorrect wscale value to be returned, and it would at least impact performance. Also use 'int' instead of 'unsigned' for 'len', since the value can be negative. CC: Sairam Venugopal Signed-off-by: Daniele Di Proietto Acked-by: Sairam Venugopal --- datapath-windows/ovsext/Conntrack-tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'datapath-windows/ovsext/Conntrack-tcp.c') diff --git a/datapath-windows/ovsext/Conntrack-tcp.c b/datapath-windows/ovsext/Conntrack-tcp.c index ebf0c9555..24f5e7c80 100644 --- a/datapath-windows/ovsext/Conntrack-tcp.c +++ b/datapath-windows/ovsext/Conntrack-tcp.c @@ -159,7 +159,7 @@ OvsConntrackValidateTcpFlags(const TCPHdr *tcp) static __inline uint8_t OvsTcpGetWscale(const TCPHdr *tcp) { - unsigned len = tcp->doff * 4 - sizeof *tcp; + int len = tcp->doff * 4 - sizeof *tcp; const uint8_t *opt = (const uint8_t *)(tcp + 1); uint8_t wscale = 0; uint8_t optlen; @@ -178,7 +178,7 @@ OvsTcpGetWscale(const TCPHdr *tcp) wscale |= CT_WSCALE_FLAG; /* fall through */ default: - optlen = opt[2]; + optlen = opt[1]; if (optlen < 2) { optlen = 2; } @@ -522,4 +522,4 @@ OvsConntrackCreateTcpEntry(const TCPHdr *tcp, OvsConntrackUpdateExpiration(newconn, now, CT_ENTRY_TIMEOUT); return &newconn->up; -} \ No newline at end of file +} -- cgit v1.2.1