[PATCH] tcp: remove duplicate th = tcp_hdr(skb)

Subsystems: networking [general], networking [tcp], the rest

STALE5760d

3 messages, 3 authors, 2011-01-13 · open the first message on its own page

[PATCH] tcp: remove duplicate th = tcp_hdr(skb)

From: Christoph Paasch <hidden>
Date: 2011-01-13 15:47:13

th is already set some lines before to be th = tcp_hdr(skb).

Signed-off-by: Christoph Paasch <redacted>
---
 net/ipv4/tcp_ipv4.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 856f684..7fe29c6 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1644,7 +1644,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	if (!skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb))
 		goto bad_packet;
 
-	th = tcp_hdr(skb);
 	iph = ip_hdr(skb);
 	TCP_SKB_CB(skb)->seq = ntohl(th->seq);
 	TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
-- 
1.7.1

Re: [PATCH] tcp: remove duplicate th = tcp_hdr(skb)

From: Jesse Gross <hidden>
Date: 2011-01-13 15:54:16

On Thu, Jan 13, 2011 at 10:41 AM, Christoph Paasch
[off-list ref] wrote:
quoted hunk
th is already set some lines before to be th = tcp_hdr(skb).

Signed-off-by: Christoph Paasch <redacted>
---
 net/ipv4/tcp_ipv4.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 856f684..7fe29c6 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1644,7 +1644,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
       if (!skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb))
               goto bad_packet;

-       th = tcp_hdr(skb);
It needs to be reloaded because pskb_may_pull() may reallocate the buffer.

Re: [PATCH] tcp: remove duplicate th = tcp_hdr(skb)

From: Eric Dumazet <hidden>
Date: 2011-01-13 15:59:09

Le jeudi 13 janvier 2011 à 16:41 +0100, Christoph Paasch a écrit :
quoted hunk
th is already set some lines before to be th = tcp_hdr(skb).

Signed-off-by: Christoph Paasch <redacted>
---
 net/ipv4/tcp_ipv4.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 856f684..7fe29c6 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1644,7 +1644,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
 	if (!skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb))
 		goto bad_packet;
 
Well... no please.
quoted hunk
-	th = tcp_hdr(skb);
 	iph = ip_hdr(skb);
 	TCP_SKB_CB(skb)->seq = ntohl(th->seq);
 	TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
Hint : pskb_may_pull() can change tcp_hdr(skb) result.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help