aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2016-05-13 12:16:40 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-16 13:46:23 -0400
commitea1627c20c3462168a087ccecc69084b55b9c0b2 (patch)
treee0b21e3af57979d1f5b1faf718582aaa4a6566b0 /net/ipv6/tcp_ipv6.c
parent5022524308c64f2954ac206a8781b64a98cddf00 (diff)
tcp: minor optimizations around tcp_hdr() usage
tcp_hdr() is slightly more expensive than using skb->data in contexts where we know they point to the same byte. In receive path, tcp_v4_rcv() and tcp_v6_rcv() are in this situation, as tcp header has not been pulled yet. In output path, the same can be said when we just pushed the tcp header in the skb, in tcp_transmit_skb() and tcp_make_synack() Also factorize the two checks for tcb->tcp_flags & TCPHDR_SYN in tcp_transmit_skb() and pass tcp header pointer to tcp_ecn_send(), so that compiler can further optimize and avoid a reload. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index c4efaa97280c..79e33e02f11a 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1369,9 +1369,9 @@ static int tcp_v6_rcv(struct sk_buff *skb)
1369 if (!pskb_may_pull(skb, sizeof(struct tcphdr))) 1369 if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
1370 goto discard_it; 1370 goto discard_it;
1371 1371
1372 th = tcp_hdr(skb); 1372 th = (const struct tcphdr *)skb->data;
1373 1373
1374 if (th->doff < sizeof(struct tcphdr)/4) 1374 if (unlikely(th->doff < sizeof(struct tcphdr)/4))
1375 goto bad_packet; 1375 goto bad_packet;
1376 if (!pskb_may_pull(skb, th->doff*4)) 1376 if (!pskb_may_pull(skb, th->doff*4))
1377 goto discard_it; 1377 goto discard_it;
@@ -1379,7 +1379,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
1379 if (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo)) 1379 if (skb_checksum_init(skb, IPPROTO_TCP, ip6_compute_pseudo))
1380 goto csum_error; 1380 goto csum_error;
1381 1381
1382 th = tcp_hdr(skb); 1382 th = (const struct tcphdr *)skb->data;
1383 hdr = ipv6_hdr(skb); 1383 hdr = ipv6_hdr(skb);
1384 1384
1385lookup: 1385lookup: