Skip to contentSkip to conversation

Fix wrong mss bug.

PATCH In review Tao Wu 2 participants 2 messages Apr 20, 2017 – Apr 21, 2017

lore
Share & tools
lore

Tao Wu

author
#0 lore raw

PATCH 1/1 Fix wrong mss bug.

This bug was introduced by https://github.com/qemu/qemu/commit/98c6305

---
 slirp/tcp_input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
slirp/tcp_input.c +2 -2
index edb98f06f3..07bcbdb2dd 100644
@@ -1587,11 +1587,11 @@ tcp_mss(struct tcpcb *tp, u_int offer)
 	switch (so->so_ffamily) {
 	case AF_INET:
             mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
-	                              + sizeof(struct ip);
+	                              - sizeof(struct ip);
 	    break;
 	case AF_INET6:
             mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
-	                              + sizeof(struct ip6);
+	                              - sizeof(struct ip6);
 	    break;
 	default:
 	    g_assert_not_reached();
Signature · 1 line
2.12.2.816.g2cccc81164-goog
Reviewed-by on v1 1/1
#1 lore raw

Hi Tao,

Quoted 1 line · Tao Wu

This bug was introduced by https://github.com/qemu/qemu/commit/98c6305

Nice catch...

In 98c6305 Guillaume probably missed parentheses :S
- mss = min(IF_MTU, IF_MRU) - sizeof(struct tcpiphdr);
+ mss = min(IF_MTU, IF_MRU) - sizeof(struct tcphdr) + sizeof(struct ip);

This would have been ok:
mss = min(IF_MTU, IF_MRU) - (sizeof(struct tcphdr) + sizeof(struct ip));

"The MSS value to be sent in an MSS option should be equal to the effective MTU minus the fixed IP and TCP headers." (RFC6691)

Quoted 1 line
Quoted 23 lines
---
 slirp/tcp_input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
slirp/tcp_input.c +2 -2
index edb98f06f3..07bcbdb2dd 100644
@@ -1587,11 +1587,11 @@ tcp_mss(struct tcpcb *tp, u_int offer)
 	switch (so->so_ffamily) {
 	case AF_INET:
             mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
-	                              + sizeof(struct ip);
+	                              - sizeof(struct ip);
 	    break;
 	case AF_INET6:
             mss = MIN(IF_MTU, IF_MRU) - sizeof(struct tcphdr)
-	                              + sizeof(struct ip6);
+	                              - sizeof(struct ip6);
 	    break;
 	default:
 	    g_assert_not_reached();