diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-04-25 20:54:47 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:25:14 -0400 |
commit | 0660e03f6b18f19b6bbafe7583265a51b90daf36 (patch) | |
tree | 82cc819ead5ab7858ba211ee8719a3e6d2bb984f /net/ipv6/tcp_ipv6.c | |
parent | d0a92be05ed4aea7d35c2b257e3f9173565fe4eb (diff) |
[SK_BUFF]: Introduce ipv6_hdr(), remove skb->nh.ipv6h
Now the skb->nh union has just one member, .raw, i.e. it is just like the
skb->mac union, strange, no? I'm just leaving it like that till the transport
layer is done with, when we'll rename skb->mac.raw to skb->mac_header (or
->mac_header_offset?), ditto for ->{h,nh}.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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.c | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 80a52ab1e384..85b3e89110f9 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -115,8 +115,8 @@ static __inline__ __sum16 tcp_v6_check(struct tcphdr *th, int len, | |||
115 | 115 | ||
116 | static __u32 tcp_v6_init_sequence(struct sk_buff *skb) | 116 | static __u32 tcp_v6_init_sequence(struct sk_buff *skb) |
117 | { | 117 | { |
118 | return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, | 118 | return secure_tcpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32, |
119 | skb->nh.ipv6h->saddr.s6_addr32, | 119 | ipv6_hdr(skb)->saddr.s6_addr32, |
120 | skb->h.th->dest, | 120 | skb->h.th->dest, |
121 | skb->h.th->source); | 121 | skb->h.th->source); |
122 | } | 122 | } |
@@ -837,7 +837,7 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
837 | { | 837 | { |
838 | __u8 *hash_location = NULL; | 838 | __u8 *hash_location = NULL; |
839 | struct tcp_md5sig_key *hash_expected; | 839 | struct tcp_md5sig_key *hash_expected; |
840 | struct ipv6hdr *ip6h = skb->nh.ipv6h; | 840 | struct ipv6hdr *ip6h = ipv6_hdr(skb); |
841 | struct tcphdr *th = skb->h.th; | 841 | struct tcphdr *th = skb->h.th; |
842 | int length = (th->doff << 2) - sizeof (*th); | 842 | int length = (th->doff << 2) - sizeof (*th); |
843 | int genhash; | 843 | int genhash; |
@@ -966,7 +966,7 @@ static int tcp_v6_gso_send_check(struct sk_buff *skb) | |||
966 | if (!pskb_may_pull(skb, sizeof(*th))) | 966 | if (!pskb_may_pull(skb, sizeof(*th))) |
967 | return -EINVAL; | 967 | return -EINVAL; |
968 | 968 | ||
969 | ipv6h = skb->nh.ipv6h; | 969 | ipv6h = ipv6_hdr(skb); |
970 | th = skb->h.th; | 970 | th = skb->h.th; |
971 | 971 | ||
972 | th->check = 0; | 972 | th->check = 0; |
@@ -995,7 +995,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) | |||
995 | 995 | ||
996 | #ifdef CONFIG_TCP_MD5SIG | 996 | #ifdef CONFIG_TCP_MD5SIG |
997 | if (sk) | 997 | if (sk) |
998 | key = tcp_v6_md5_do_lookup(sk, &skb->nh.ipv6h->daddr); | 998 | key = tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr); |
999 | else | 999 | else |
1000 | key = NULL; | 1000 | key = NULL; |
1001 | 1001 | ||
@@ -1039,20 +1039,18 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) | |||
1039 | (TCPOPT_NOP << 16) | | 1039 | (TCPOPT_NOP << 16) | |
1040 | (TCPOPT_MD5SIG << 8) | | 1040 | (TCPOPT_MD5SIG << 8) | |
1041 | TCPOLEN_MD5SIG); | 1041 | TCPOLEN_MD5SIG); |
1042 | tcp_v6_do_calc_md5_hash((__u8*)&opt[1], | 1042 | tcp_v6_do_calc_md5_hash((__u8 *)&opt[1], key, |
1043 | key, | 1043 | &ipv6_hdr(skb)->daddr, |
1044 | &skb->nh.ipv6h->daddr, | 1044 | &ipv6_hdr(skb)->saddr, |
1045 | &skb->nh.ipv6h->saddr, | 1045 | t1, IPPROTO_TCP, tot_len); |
1046 | t1, IPPROTO_TCP, | ||
1047 | tot_len); | ||
1048 | } | 1046 | } |
1049 | #endif | 1047 | #endif |
1050 | 1048 | ||
1051 | buff->csum = csum_partial((char *)t1, sizeof(*t1), 0); | 1049 | buff->csum = csum_partial((char *)t1, sizeof(*t1), 0); |
1052 | 1050 | ||
1053 | memset(&fl, 0, sizeof(fl)); | 1051 | memset(&fl, 0, sizeof(fl)); |
1054 | ipv6_addr_copy(&fl.fl6_dst, &skb->nh.ipv6h->saddr); | 1052 | ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr); |
1055 | ipv6_addr_copy(&fl.fl6_src, &skb->nh.ipv6h->daddr); | 1053 | ipv6_addr_copy(&fl.fl6_src, &ipv6_hdr(skb)->daddr); |
1056 | 1054 | ||
1057 | t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, | 1055 | t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, |
1058 | sizeof(*t1), IPPROTO_TCP, | 1056 | sizeof(*t1), IPPROTO_TCP, |
@@ -1093,7 +1091,7 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw, | |||
1093 | 1091 | ||
1094 | #ifdef CONFIG_TCP_MD5SIG | 1092 | #ifdef CONFIG_TCP_MD5SIG |
1095 | if (!tw && skb->sk) { | 1093 | if (!tw && skb->sk) { |
1096 | key = tcp_v6_md5_do_lookup(skb->sk, &skb->nh.ipv6h->daddr); | 1094 | key = tcp_v6_md5_do_lookup(skb->sk, &ipv6_hdr(skb)->daddr); |
1097 | } else if (tw && tw->tw_md5_keylen) { | 1095 | } else if (tw && tw->tw_md5_keylen) { |
1098 | tw_key.key = tw->tw_md5_key; | 1096 | tw_key.key = tw->tw_md5_key; |
1099 | tw_key.keylen = tw->tw_md5_keylen; | 1097 | tw_key.keylen = tw->tw_md5_keylen; |
@@ -1142,20 +1140,18 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw, | |||
1142 | if (key) { | 1140 | if (key) { |
1143 | *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | | 1141 | *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
1144 | (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); | 1142 | (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); |
1145 | tcp_v6_do_calc_md5_hash((__u8 *)topt, | 1143 | tcp_v6_do_calc_md5_hash((__u8 *)topt, key, |
1146 | key, | 1144 | &ipv6_hdr(skb)->daddr, |
1147 | &skb->nh.ipv6h->daddr, | 1145 | &ipv6_hdr(skb)->saddr, |
1148 | &skb->nh.ipv6h->saddr, | 1146 | t1, IPPROTO_TCP, tot_len); |
1149 | t1, IPPROTO_TCP, | ||
1150 | tot_len); | ||
1151 | } | 1147 | } |
1152 | #endif | 1148 | #endif |
1153 | 1149 | ||
1154 | buff->csum = csum_partial((char *)t1, tot_len, 0); | 1150 | buff->csum = csum_partial((char *)t1, tot_len, 0); |
1155 | 1151 | ||
1156 | memset(&fl, 0, sizeof(fl)); | 1152 | memset(&fl, 0, sizeof(fl)); |
1157 | ipv6_addr_copy(&fl.fl6_dst, &skb->nh.ipv6h->saddr); | 1153 | ipv6_addr_copy(&fl.fl6_dst, &ipv6_hdr(skb)->saddr); |
1158 | ipv6_addr_copy(&fl.fl6_src, &skb->nh.ipv6h->daddr); | 1154 | ipv6_addr_copy(&fl.fl6_src, &ipv6_hdr(skb)->daddr); |
1159 | 1155 | ||
1160 | t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, | 1156 | t1->check = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, |
1161 | tot_len, IPPROTO_TCP, | 1157 | tot_len, IPPROTO_TCP, |
@@ -1204,13 +1200,13 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) | |||
1204 | 1200 | ||
1205 | /* Find possible connection requests. */ | 1201 | /* Find possible connection requests. */ |
1206 | req = inet6_csk_search_req(sk, &prev, th->source, | 1202 | req = inet6_csk_search_req(sk, &prev, th->source, |
1207 | &skb->nh.ipv6h->saddr, | 1203 | &ipv6_hdr(skb)->saddr, |
1208 | &skb->nh.ipv6h->daddr, inet6_iif(skb)); | 1204 | &ipv6_hdr(skb)->daddr, inet6_iif(skb)); |
1209 | if (req) | 1205 | if (req) |
1210 | return tcp_check_req(sk, skb, req, prev); | 1206 | return tcp_check_req(sk, skb, req, prev); |
1211 | 1207 | ||
1212 | nsk = __inet6_lookup_established(&tcp_hashinfo, &skb->nh.ipv6h->saddr, | 1208 | nsk = __inet6_lookup_established(&tcp_hashinfo, &ipv6_hdr(skb)->saddr, |
1213 | th->source, &skb->nh.ipv6h->daddr, | 1209 | th->source, &ipv6_hdr(skb)->daddr, |
1214 | ntohs(th->dest), inet6_iif(skb)); | 1210 | ntohs(th->dest), inet6_iif(skb)); |
1215 | 1211 | ||
1216 | if (nsk) { | 1212 | if (nsk) { |
@@ -1277,8 +1273,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1277 | tcp_openreq_init(req, &tmp_opt, skb); | 1273 | tcp_openreq_init(req, &tmp_opt, skb); |
1278 | 1274 | ||
1279 | treq = inet6_rsk(req); | 1275 | treq = inet6_rsk(req); |
1280 | ipv6_addr_copy(&treq->rmt_addr, &skb->nh.ipv6h->saddr); | 1276 | ipv6_addr_copy(&treq->rmt_addr, &ipv6_hdr(skb)->saddr); |
1281 | ipv6_addr_copy(&treq->loc_addr, &skb->nh.ipv6h->daddr); | 1277 | ipv6_addr_copy(&treq->loc_addr, &ipv6_hdr(skb)->daddr); |
1282 | TCP_ECN_create_request(req, skb->h.th); | 1278 | TCP_ECN_create_request(req, skb->h.th); |
1283 | treq->pktopts = NULL; | 1279 | treq->pktopts = NULL; |
1284 | if (ipv6_opt_accepted(sk, skb) || | 1280 | if (ipv6_opt_accepted(sk, skb) || |
@@ -1365,7 +1361,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1365 | newnp->pktoptions = NULL; | 1361 | newnp->pktoptions = NULL; |
1366 | newnp->opt = NULL; | 1362 | newnp->opt = NULL; |
1367 | newnp->mcast_oif = inet6_iif(skb); | 1363 | newnp->mcast_oif = inet6_iif(skb); |
1368 | newnp->mcast_hops = skb->nh.ipv6h->hop_limit; | 1364 | newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; |
1369 | 1365 | ||
1370 | /* | 1366 | /* |
1371 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count | 1367 | * No need to charge this sock to the relevant IPv6 refcnt debug socks count |
@@ -1473,7 +1469,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1473 | } | 1469 | } |
1474 | newnp->opt = NULL; | 1470 | newnp->opt = NULL; |
1475 | newnp->mcast_oif = inet6_iif(skb); | 1471 | newnp->mcast_oif = inet6_iif(skb); |
1476 | newnp->mcast_hops = skb->nh.ipv6h->hop_limit; | 1472 | newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; |
1477 | 1473 | ||
1478 | /* Clone native IPv6 options from listening socket (if any) | 1474 | /* Clone native IPv6 options from listening socket (if any) |
1479 | 1475 | ||
@@ -1532,15 +1528,16 @@ out: | |||
1532 | static __sum16 tcp_v6_checksum_init(struct sk_buff *skb) | 1528 | static __sum16 tcp_v6_checksum_init(struct sk_buff *skb) |
1533 | { | 1529 | { |
1534 | if (skb->ip_summed == CHECKSUM_COMPLETE) { | 1530 | if (skb->ip_summed == CHECKSUM_COMPLETE) { |
1535 | if (!tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr, | 1531 | if (!tcp_v6_check(skb->h.th, skb->len, &ipv6_hdr(skb)->saddr, |
1536 | &skb->nh.ipv6h->daddr,skb->csum)) { | 1532 | &ipv6_hdr(skb)->daddr, skb->csum)) { |
1537 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1533 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
1538 | return 0; | 1534 | return 0; |
1539 | } | 1535 | } |
1540 | } | 1536 | } |
1541 | 1537 | ||
1542 | skb->csum = ~csum_unfold(tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr, | 1538 | skb->csum = ~csum_unfold(tcp_v6_check(skb->h.th, skb->len, |
1543 | &skb->nh.ipv6h->daddr, 0)); | 1539 | &ipv6_hdr(skb)->saddr, |
1540 | &ipv6_hdr(skb)->daddr, 0)); | ||
1544 | 1541 | ||
1545 | if (skb->len <= 76) { | 1542 | if (skb->len <= 76) { |
1546 | return __skb_checksum_complete(skb); | 1543 | return __skb_checksum_complete(skb); |
@@ -1668,7 +1665,7 @@ ipv6_pktoptions: | |||
1668 | if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) | 1665 | if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo) |
1669 | np->mcast_oif = inet6_iif(opt_skb); | 1666 | np->mcast_oif = inet6_iif(opt_skb); |
1670 | if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) | 1667 | if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) |
1671 | np->mcast_hops = opt_skb->nh.ipv6h->hop_limit; | 1668 | np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; |
1672 | if (ipv6_opt_accepted(sk, opt_skb)) { | 1669 | if (ipv6_opt_accepted(sk, opt_skb)) { |
1673 | skb_set_owner_r(opt_skb, sk); | 1670 | skb_set_owner_r(opt_skb, sk); |
1674 | opt_skb = xchg(&np->pktoptions, opt_skb); | 1671 | opt_skb = xchg(&np->pktoptions, opt_skb); |
@@ -1718,11 +1715,11 @@ static int tcp_v6_rcv(struct sk_buff **pskb) | |||
1718 | skb->len - th->doff*4); | 1715 | skb->len - th->doff*4); |
1719 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); | 1716 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); |
1720 | TCP_SKB_CB(skb)->when = 0; | 1717 | TCP_SKB_CB(skb)->when = 0; |
1721 | TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(skb->nh.ipv6h); | 1718 | TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb)); |
1722 | TCP_SKB_CB(skb)->sacked = 0; | 1719 | TCP_SKB_CB(skb)->sacked = 0; |
1723 | 1720 | ||
1724 | sk = __inet6_lookup(&tcp_hashinfo, &skb->nh.ipv6h->saddr, th->source, | 1721 | sk = __inet6_lookup(&tcp_hashinfo, &ipv6_hdr(skb)->saddr, th->source, |
1725 | &skb->nh.ipv6h->daddr, ntohs(th->dest), | 1722 | &ipv6_hdr(skb)->daddr, ntohs(th->dest), |
1726 | inet6_iif(skb)); | 1723 | inet6_iif(skb)); |
1727 | 1724 | ||
1728 | if (!sk) | 1725 | if (!sk) |
@@ -1802,7 +1799,7 @@ do_time_wait: | |||
1802 | struct sock *sk2; | 1799 | struct sock *sk2; |
1803 | 1800 | ||
1804 | sk2 = inet6_lookup_listener(&tcp_hashinfo, | 1801 | sk2 = inet6_lookup_listener(&tcp_hashinfo, |
1805 | &skb->nh.ipv6h->daddr, | 1802 | &ipv6_hdr(skb)->daddr, |
1806 | ntohs(th->dest), inet6_iif(skb)); | 1803 | ntohs(th->dest), inet6_iif(skb)); |
1807 | if (sk2 != NULL) { | 1804 | if (sk2 != NULL) { |
1808 | struct inet_timewait_sock *tw = inet_twsk(sk); | 1805 | struct inet_timewait_sock *tw = inet_twsk(sk); |