aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-21 01:47:35 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:10 -0400
commiteddc9ec53be2ecdbf4efe0efd4a83052594f0ac0 (patch)
tree4a38ab4dbd9d61fdf5a5ea6ed61463e0b9e33ba7 /net/ipv4/tcp_ipv4.c
parente023dd643798c4f06c16466af90b4d250e4b8bd7 (diff)
[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3326681b8429..3a86d6b887ac 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -125,8 +125,8 @@ void tcp_unhash(struct sock *sk)
125 125
126static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) 126static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb)
127{ 127{
128 return secure_tcp_sequence_number(skb->nh.iph->daddr, 128 return secure_tcp_sequence_number(ip_hdr(skb)->daddr,
129 skb->nh.iph->saddr, 129 ip_hdr(skb)->saddr,
130 skb->h.th->dest, 130 skb->h.th->dest,
131 skb->h.th->source); 131 skb->h.th->source);
132} 132}
@@ -515,13 +515,13 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
515 515
516int tcp_v4_gso_send_check(struct sk_buff *skb) 516int tcp_v4_gso_send_check(struct sk_buff *skb)
517{ 517{
518 struct iphdr *iph; 518 const struct iphdr *iph;
519 struct tcphdr *th; 519 struct tcphdr *th;
520 520
521 if (!pskb_may_pull(skb, sizeof(*th))) 521 if (!pskb_may_pull(skb, sizeof(*th)))
522 return -EINVAL; 522 return -EINVAL;
523 523
524 iph = skb->nh.iph; 524 iph = ip_hdr(skb);
525 th = skb->h.th; 525 th = skb->h.th;
526 526
527 th->check = 0; 527 th->check = 0;
@@ -585,7 +585,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
585 arg.iov[0].iov_len = sizeof(rep.th); 585 arg.iov[0].iov_len = sizeof(rep.th);
586 586
587#ifdef CONFIG_TCP_MD5SIG 587#ifdef CONFIG_TCP_MD5SIG
588 key = sk ? tcp_v4_md5_do_lookup(sk, skb->nh.iph->daddr) : NULL; 588 key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr) : NULL;
589 if (key) { 589 if (key) {
590 rep.opt[0] = htonl((TCPOPT_NOP << 24) | 590 rep.opt[0] = htonl((TCPOPT_NOP << 24) |
591 (TCPOPT_NOP << 16) | 591 (TCPOPT_NOP << 16) |
@@ -597,14 +597,14 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
597 597
598 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[1], 598 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[1],
599 key, 599 key,
600 skb->nh.iph->daddr, 600 ip_hdr(skb)->daddr,
601 skb->nh.iph->saddr, 601 ip_hdr(skb)->saddr,
602 &rep.th, IPPROTO_TCP, 602 &rep.th, IPPROTO_TCP,
603 arg.iov[0].iov_len); 603 arg.iov[0].iov_len);
604 } 604 }
605#endif 605#endif
606 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, 606 arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr,
607 skb->nh.iph->saddr, /* XXX */ 607 ip_hdr(skb)->saddr, /* XXX */
608 sizeof(struct tcphdr), IPPROTO_TCP, 0); 608 sizeof(struct tcphdr), IPPROTO_TCP, 0);
609 arg.csumoffset = offsetof(struct tcphdr, check) / 2; 609 arg.csumoffset = offsetof(struct tcphdr, check) / 2;
610 610
@@ -670,7 +670,7 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk,
670 * skb->sk) holds true, but we program defensively. 670 * skb->sk) holds true, but we program defensively.
671 */ 671 */
672 if (!twsk && skb->sk) { 672 if (!twsk && skb->sk) {
673 key = tcp_v4_md5_do_lookup(skb->sk, skb->nh.iph->daddr); 673 key = tcp_v4_md5_do_lookup(skb->sk, ip_hdr(skb)->daddr);
674 } else if (twsk && twsk->tw_md5_keylen) { 674 } else if (twsk && twsk->tw_md5_keylen) {
675 tw_key.key = twsk->tw_md5_key; 675 tw_key.key = twsk->tw_md5_key;
676 tw_key.keylen = twsk->tw_md5_keylen; 676 tw_key.keylen = twsk->tw_md5_keylen;
@@ -690,14 +690,14 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk,
690 690
691 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[offset], 691 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[offset],
692 key, 692 key,
693 skb->nh.iph->daddr, 693 ip_hdr(skb)->daddr,
694 skb->nh.iph->saddr, 694 ip_hdr(skb)->saddr,
695 &rep.th, IPPROTO_TCP, 695 &rep.th, IPPROTO_TCP,
696 arg.iov[0].iov_len); 696 arg.iov[0].iov_len);
697 } 697 }
698#endif 698#endif
699 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, 699 arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr,
700 skb->nh.iph->saddr, /* XXX */ 700 ip_hdr(skb)->saddr, /* XXX */
701 arg.iov[0].iov_len, IPPROTO_TCP, 0); 701 arg.iov[0].iov_len, IPPROTO_TCP, 0);
702 arg.csumoffset = offsetof(struct tcphdr, check) / 2; 702 arg.csumoffset = offsetof(struct tcphdr, check) / 2;
703 703
@@ -1133,7 +1133,7 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb)
1133 */ 1133 */
1134 __u8 *hash_location = NULL; 1134 __u8 *hash_location = NULL;
1135 struct tcp_md5sig_key *hash_expected; 1135 struct tcp_md5sig_key *hash_expected;
1136 struct iphdr *iph = skb->nh.iph; 1136 const struct iphdr *iph = ip_hdr(skb);
1137 struct tcphdr *th = skb->h.th; 1137 struct tcphdr *th = skb->h.th;
1138 int length = (th->doff << 2) - sizeof(struct tcphdr); 1138 int length = (th->doff << 2) - sizeof(struct tcphdr);
1139 int genhash; 1139 int genhash;
@@ -1251,8 +1251,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1251 struct inet_request_sock *ireq; 1251 struct inet_request_sock *ireq;
1252 struct tcp_options_received tmp_opt; 1252 struct tcp_options_received tmp_opt;
1253 struct request_sock *req; 1253 struct request_sock *req;
1254 __be32 saddr = skb->nh.iph->saddr; 1254 __be32 saddr = ip_hdr(skb)->saddr;
1255 __be32 daddr = skb->nh.iph->daddr; 1255 __be32 daddr = ip_hdr(skb)->daddr;
1256 __u32 isn = TCP_SKB_CB(skb)->when; 1256 __u32 isn = TCP_SKB_CB(skb)->when;
1257 struct dst_entry *dst = NULL; 1257 struct dst_entry *dst = NULL;
1258#ifdef CONFIG_SYN_COOKIES 1258#ifdef CONFIG_SYN_COOKIES
@@ -1439,7 +1439,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1439 newinet->opt = ireq->opt; 1439 newinet->opt = ireq->opt;
1440 ireq->opt = NULL; 1440 ireq->opt = NULL;
1441 newinet->mc_index = inet_iif(skb); 1441 newinet->mc_index = inet_iif(skb);
1442 newinet->mc_ttl = skb->nh.iph->ttl; 1442 newinet->mc_ttl = ip_hdr(skb)->ttl;
1443 inet_csk(newsk)->icsk_ext_hdr_len = 0; 1443 inet_csk(newsk)->icsk_ext_hdr_len = 0;
1444 if (newinet->opt) 1444 if (newinet->opt)
1445 inet_csk(newsk)->icsk_ext_hdr_len = newinet->opt->optlen; 1445 inet_csk(newsk)->icsk_ext_hdr_len = newinet->opt->optlen;
@@ -1482,7 +1482,7 @@ exit:
1482static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) 1482static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1483{ 1483{
1484 struct tcphdr *th = skb->h.th; 1484 struct tcphdr *th = skb->h.th;
1485 struct iphdr *iph = skb->nh.iph; 1485 const struct iphdr *iph = ip_hdr(skb);
1486 struct sock *nsk; 1486 struct sock *nsk;
1487 struct request_sock **prev; 1487 struct request_sock **prev;
1488 /* Find possible connection requests. */ 1488 /* Find possible connection requests. */
@@ -1491,9 +1491,8 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1491 if (req) 1491 if (req)
1492 return tcp_check_req(sk, skb, req, prev); 1492 return tcp_check_req(sk, skb, req, prev);
1493 1493
1494 nsk = inet_lookup_established(&tcp_hashinfo, skb->nh.iph->saddr, 1494 nsk = inet_lookup_established(&tcp_hashinfo, iph->saddr, th->source,
1495 th->source, skb->nh.iph->daddr, 1495 iph->daddr, th->dest, inet_iif(skb));
1496 th->dest, inet_iif(skb));
1497 1496
1498 if (nsk) { 1497 if (nsk) {
1499 if (nsk->sk_state != TCP_TIME_WAIT) { 1498 if (nsk->sk_state != TCP_TIME_WAIT) {
@@ -1513,15 +1512,17 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1513 1512
1514static __sum16 tcp_v4_checksum_init(struct sk_buff *skb) 1513static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
1515{ 1514{
1515 const struct iphdr *iph = ip_hdr(skb);
1516
1516 if (skb->ip_summed == CHECKSUM_COMPLETE) { 1517 if (skb->ip_summed == CHECKSUM_COMPLETE) {
1517 if (!tcp_v4_check(skb->len, skb->nh.iph->saddr, 1518 if (!tcp_v4_check(skb->len, iph->saddr,
1518 skb->nh.iph->daddr, skb->csum)) { 1519 iph->daddr, skb->csum)) {
1519 skb->ip_summed = CHECKSUM_UNNECESSARY; 1520 skb->ip_summed = CHECKSUM_UNNECESSARY;
1520 return 0; 1521 return 0;
1521 } 1522 }
1522 } 1523 }
1523 1524
1524 skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr, skb->nh.iph->daddr, 1525 skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
1525 skb->len, IPPROTO_TCP, 0); 1526 skb->len, IPPROTO_TCP, 0);
1526 1527
1527 if (skb->len <= 76) { 1528 if (skb->len <= 76) {
@@ -1610,6 +1611,7 @@ csum_err:
1610 1611
1611int tcp_v4_rcv(struct sk_buff *skb) 1612int tcp_v4_rcv(struct sk_buff *skb)
1612{ 1613{
1614 const struct iphdr *iph;
1613 struct tcphdr *th; 1615 struct tcphdr *th;
1614 struct sock *sk; 1616 struct sock *sk;
1615 int ret; 1617 int ret;
@@ -1639,18 +1641,17 @@ int tcp_v4_rcv(struct sk_buff *skb)
1639 goto bad_packet; 1641 goto bad_packet;
1640 1642
1641 th = skb->h.th; 1643 th = skb->h.th;
1644 iph = ip_hdr(skb);
1642 TCP_SKB_CB(skb)->seq = ntohl(th->seq); 1645 TCP_SKB_CB(skb)->seq = ntohl(th->seq);
1643 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + 1646 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
1644 skb->len - th->doff * 4); 1647 skb->len - th->doff * 4);
1645 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 1648 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1646 TCP_SKB_CB(skb)->when = 0; 1649 TCP_SKB_CB(skb)->when = 0;
1647 TCP_SKB_CB(skb)->flags = skb->nh.iph->tos; 1650 TCP_SKB_CB(skb)->flags = iph->tos;
1648 TCP_SKB_CB(skb)->sacked = 0; 1651 TCP_SKB_CB(skb)->sacked = 0;
1649 1652
1650 sk = __inet_lookup(&tcp_hashinfo, skb->nh.iph->saddr, th->source, 1653 sk = __inet_lookup(&tcp_hashinfo, iph->saddr, th->source,
1651 skb->nh.iph->daddr, th->dest, 1654 iph->daddr, th->dest, inet_iif(skb));
1652 inet_iif(skb));
1653
1654 if (!sk) 1655 if (!sk)
1655 goto no_tcp_socket; 1656 goto no_tcp_socket;
1656 1657
@@ -1724,8 +1725,7 @@ do_time_wait:
1724 switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) { 1725 switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {
1725 case TCP_TW_SYN: { 1726 case TCP_TW_SYN: {
1726 struct sock *sk2 = inet_lookup_listener(&tcp_hashinfo, 1727 struct sock *sk2 = inet_lookup_listener(&tcp_hashinfo,
1727 skb->nh.iph->daddr, 1728 iph->daddr, th->dest,
1728 th->dest,
1729 inet_iif(skb)); 1729 inet_iif(skb));
1730 if (sk2) { 1730 if (sk2) {
1731 inet_twsk_deschedule(inet_twsk(sk), &tcp_death_row); 1731 inet_twsk_deschedule(inet_twsk(sk), &tcp_death_row);