Skip to contentSkip to conversation

netfilter: don't scale the size of the window up twice

PATCH Applied Changli Gao 3 participants 4 messages Apr 2, 2012 – Apr 10, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: don't scale the size of the window up twice

For a picked up connection, the window win is scaled twice: one is by the initialization code, and the other is by the sender updating code.

I use the temporary variable swin instead of modifying the variable win.

---
 net/netfilter/nf_conntrack_proto_tcp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +2 -2
index 361eade..0d07a1d 100644
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
 			 * Let's try to use the data from the packet.
 			 */
 			sender->td_end = end;
-			win <<= sender->td_scale;
-			sender->td_maxwin = (win == 0 ? 1 : win);
+			swin = win << sender->td_scale;
+			sender->td_maxwin = (swin == 0 ? 1 : swin);
 			sender->td_maxend = end + sender->td_maxwin;
 			/*
 			 * We haven't seen traffic in the other direction yet
#1 lore raw
Quoted 14 lines · Changli Gao

For a picked up connection, the window win is scaled twice: one is by the initialization code, and the other is by the sender updating code.

I use the temporary variable swin instead of modifying the variable win.

---
 net/netfilter/nf_conntrack_proto_tcp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +0 -0
index 361eade..0d07a1d 100644

net/netfilter/nf_conntrack_proto_tcp.c static bool tcp_in_window(const struct nf_conn *ct, · line 591

Quoted 10 lines
net/netfilter/nf_conntrack_proto_tcp.c +2 -2
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
 			 * Let's try to use the data from the packet.
 			 */
 			sender->td_end = end;
-			win <<= sender->td_scale;
-			sender->td_maxwin = (win == 0 ? 1 : win);
+			swin = win << sender->td_scale;
+			sender->td_maxwin = (swin == 0 ? 1 : swin);
 			sender->td_maxend = end + sender->td_maxwin;
 			/*
 			 * We haven't seen traffic in the other direction yet

Jozsef, do you remember if this is intentional?

I'm going to test this patch in my testbed to make sure this does not break conntrackd.

#2 lore raw
Quoted 19 lines · Pablo Neira Ayuso
Quoted 18 lines · Changli Gao

For a picked up connection, the window win is scaled twice: one is by the initialization code, and the other is by the sender updating code.

I use the temporary variable swin instead of modifying the variable win.

---
 net/netfilter/nf_conntrack_proto_tcp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +0 -1
index 361eade..0d07a1d 100644
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
 			 * Let's try to use the data from the packet.
 			 */
 			sender->td_end = end;
-			win <<= sender->td_scale;
Quoted 8 lines

net/netfilter/nf_conntrack_proto_tcp.c static bool tcp_in_window(const struct nf_conn *ct, · line 591

Quoted 6 lines
net/netfilter/nf_conntrack_proto_tcp.c +2 -1
-			sender->td_maxwin = (win == 0 ? 1 : win);
+			swin = win << sender->td_scale;
+			sender->td_maxwin = (swin == 0 ? 1 : swin);
 			sender->td_maxend = end + sender->td_maxwin;
 			/*
 			 * We haven't seen traffic in the other direction yet

Jozsef, do you remember if this is intentional?

No, it's a good spotting.

Quoted 2 lines

I'm going to test this patch in my testbed to make sure this does not break conntrackd.

A checking in a testbed doesn't hurt :-).

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences

          H-1525 Budapest 114, POB. 49, Hungary
maintainer Applied
#3 lore raw
Quoted 30 lines · Jozsef Kadlecsik
Quoted 19 lines · Pablo Neira Ayuso
Quoted 18 lines · Changli Gao

For a picked up connection, the window win is scaled twice: one is by the initialization code, and the other is by the sender updating code.

I use the temporary variable swin instead of modifying the variable win.

---
 net/netfilter/nf_conntrack_proto_tcp.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +0 -1
index 361eade..0d07a1d 100644
@@ -584,8 +584,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
 			 * Let's try to use the data from the packet.
 			 */
 			sender->td_end = end;
-			win <<= sender->td_scale;
Quoted 8 lines

net/netfilter/nf_conntrack_proto_tcp.c static bool tcp_in_window(const struct nf_conn *ct, · line 591

Quoted 6 lines
net/netfilter/nf_conntrack_proto_tcp.c +2 -1
-			sender->td_maxwin = (win == 0 ? 1 : win);
+			swin = win << sender->td_scale;
+			sender->td_maxwin = (swin == 0 ? 1 : swin);
 			sender->td_maxend = end + sender->td_maxwin;
 			/*
 			 * We haven't seen traffic in the other direction yet

Jozsef, do you remember if this is intentional?

Quoted 3 lines

No, it's a good spotting.

Applied, thanks.