diff options
Diffstat (limited to 'net')
48 files changed, 228 insertions, 168 deletions
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index 1163c4f69899..8a56d8963025 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c | |||
| @@ -374,7 +374,8 @@ static int check_hbh_len(struct sk_buff *skb) | |||
| 374 | { | 374 | { |
| 375 | unsigned char *raw = (u8 *) (skb->nh.ipv6h + 1); | 375 | unsigned char *raw = (u8 *) (skb->nh.ipv6h + 1); |
| 376 | u32 pkt_len; | 376 | u32 pkt_len; |
| 377 | int off = raw - skb->nh.raw; | 377 | const unsigned char *nh = skb_network_header(skb); |
| 378 | int off = raw - nh; | ||
| 378 | int len = (raw[1] + 1) << 3; | 379 | int len = (raw[1] + 1) << 3; |
| 379 | 380 | ||
| 380 | if ((raw + len) - skb->data > skb_headlen(skb)) | 381 | if ((raw + len) - skb->data > skb_headlen(skb)) |
| @@ -384,9 +385,9 @@ static int check_hbh_len(struct sk_buff *skb) | |||
| 384 | len -= 2; | 385 | len -= 2; |
| 385 | 386 | ||
| 386 | while (len > 0) { | 387 | while (len > 0) { |
| 387 | int optlen = skb->nh.raw[off + 1] + 2; | 388 | int optlen = nh[off + 1] + 2; |
| 388 | 389 | ||
| 389 | switch (skb->nh.raw[off]) { | 390 | switch (nh[off]) { |
| 390 | case IPV6_TLV_PAD0: | 391 | case IPV6_TLV_PAD0: |
| 391 | optlen = 1; | 392 | optlen = 1; |
| 392 | break; | 393 | break; |
| @@ -395,9 +396,9 @@ static int check_hbh_len(struct sk_buff *skb) | |||
| 395 | break; | 396 | break; |
| 396 | 397 | ||
| 397 | case IPV6_TLV_JUMBO: | 398 | case IPV6_TLV_JUMBO: |
| 398 | if (skb->nh.raw[off + 1] != 4 || (off & 3) != 2) | 399 | if (nh[off + 1] != 4 || (off & 3) != 2) |
| 399 | goto bad; | 400 | goto bad; |
| 400 | pkt_len = ntohl(*(__be32 *) (skb->nh.raw + off + 2)); | 401 | pkt_len = ntohl(*(__be32 *) (nh + off + 2)); |
| 401 | if (pkt_len <= IPV6_MAXPLEN || | 402 | if (pkt_len <= IPV6_MAXPLEN || |
| 402 | skb->nh.ipv6h->payload_len) | 403 | skb->nh.ipv6h->payload_len) |
| 403 | goto bad; | 404 | goto bad; |
| @@ -406,6 +407,7 @@ static int check_hbh_len(struct sk_buff *skb) | |||
| 406 | if (pskb_trim_rcsum(skb, | 407 | if (pskb_trim_rcsum(skb, |
| 407 | pkt_len + sizeof(struct ipv6hdr))) | 408 | pkt_len + sizeof(struct ipv6hdr))) |
| 408 | goto bad; | 409 | goto bad; |
| 410 | nh = skb_network_header(skb); | ||
| 409 | break; | 411 | break; |
| 410 | default: | 412 | default: |
| 411 | if (optlen > len) | 413 | if (optlen > len) |
diff --git a/net/core/dev.c b/net/core/dev.c index 1b0758254ba0..54ffe9db9b02 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -1068,8 +1068,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) | |||
| 1068 | */ | 1068 | */ |
| 1069 | skb_reset_mac_header(skb2); | 1069 | skb_reset_mac_header(skb2); |
| 1070 | 1070 | ||
| 1071 | if (skb2->nh.raw < skb2->data || | 1071 | if (skb_network_header(skb2) < skb2->data || |
| 1072 | skb2->nh.raw > skb2->tail) { | 1072 | skb_network_header(skb2) > skb2->tail) { |
| 1073 | if (net_ratelimit()) | 1073 | if (net_ratelimit()) |
| 1074 | printk(KERN_CRIT "protocol %04x is " | 1074 | printk(KERN_CRIT "protocol %04x is " |
| 1075 | "buggy, dev %s\n", | 1075 | "buggy, dev %s\n", |
| @@ -1207,7 +1207,7 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features) | |||
| 1207 | BUG_ON(skb_shinfo(skb)->frag_list); | 1207 | BUG_ON(skb_shinfo(skb)->frag_list); |
| 1208 | 1208 | ||
| 1209 | skb_reset_mac_header(skb); | 1209 | skb_reset_mac_header(skb); |
| 1210 | skb->mac_len = skb->nh.raw - skb->data; | 1210 | skb->mac_len = skb->nh.raw - skb->mac.raw; |
| 1211 | __skb_pull(skb, skb->mac_len); | 1211 | __skb_pull(skb, skb->mac_len); |
| 1212 | 1212 | ||
| 1213 | if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) { | 1213 | if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) { |
| @@ -1224,7 +1224,8 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features) | |||
| 1224 | segs = ERR_PTR(err); | 1224 | segs = ERR_PTR(err); |
| 1225 | if (err || skb_gso_ok(skb, features)) | 1225 | if (err || skb_gso_ok(skb, features)) |
| 1226 | break; | 1226 | break; |
| 1227 | __skb_push(skb, skb->data - skb->nh.raw); | 1227 | __skb_push(skb, (skb->data - |
| 1228 | skb_network_header(skb))); | ||
| 1228 | } | 1229 | } |
| 1229 | segs = ptype->gso_segment(skb, features); | 1230 | segs = ptype->gso_segment(skb, features); |
| 1230 | break; | 1231 | break; |
diff --git a/net/core/filter.c b/net/core/filter.c index 1cc128d05422..d2358a5e6339 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
| @@ -42,7 +42,7 @@ static void *__load_pointer(struct sk_buff *skb, int k) | |||
| 42 | u8 *ptr = NULL; | 42 | u8 *ptr = NULL; |
| 43 | 43 | ||
| 44 | if (k >= SKF_NET_OFF) | 44 | if (k >= SKF_NET_OFF) |
| 45 | ptr = skb->nh.raw + k - SKF_NET_OFF; | 45 | ptr = skb_network_header(skb) + k - SKF_NET_OFF; |
| 46 | else if (k >= SKF_LL_OFF) | 46 | else if (k >= SKF_LL_OFF) |
| 47 | ptr = skb_mac_header(skb) + k - SKF_LL_OFF; | 47 | ptr = skb_mac_header(skb) + k - SKF_LL_OFF; |
| 48 | 48 | ||
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 7f51e8db3967..627d0c3c51cf 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
| @@ -261,8 +261,8 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req, | |||
| 261 | 261 | ||
| 262 | if (rxopt->srcrt) | 262 | if (rxopt->srcrt) |
| 263 | opt = ipv6_invert_rthdr(sk, | 263 | opt = ipv6_invert_rthdr(sk, |
| 264 | (struct ipv6_rt_hdr *)(pktopts->nh.raw + | 264 | (struct ipv6_rt_hdr *)(skb_network_header(pktopts) + |
| 265 | rxopt->srcrt)); | 265 | rxopt->srcrt)); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | if (opt != NULL && opt->srcrt != NULL) { | 268 | if (opt != NULL && opt->srcrt != NULL) { |
| @@ -573,8 +573,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, | |||
| 573 | 573 | ||
| 574 | if (rxopt->srcrt) | 574 | if (rxopt->srcrt) |
| 575 | opt = ipv6_invert_rthdr(sk, | 575 | opt = ipv6_invert_rthdr(sk, |
| 576 | (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw + | 576 | (struct ipv6_rt_hdr *)(skb_network_header(ireq6->pktopts) + |
| 577 | rxopt->srcrt)); | 577 | rxopt->srcrt)); |
| 578 | } | 578 | } |
| 579 | 579 | ||
| 580 | if (dst == NULL) { | 580 | if (dst == NULL) { |
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 34079b7ba1d3..32a7db36c9e5 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
| @@ -386,7 +386,7 @@ static int dn_return_short(struct sk_buff *skb) | |||
| 386 | __le16 tmp; | 386 | __le16 tmp; |
| 387 | 387 | ||
| 388 | /* Add back headers */ | 388 | /* Add back headers */ |
| 389 | skb_push(skb, skb->data - skb->nh.raw); | 389 | skb_push(skb, skb->data - skb_network_header(skb)); |
| 390 | 390 | ||
| 391 | if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL) | 391 | if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL) |
| 392 | return NET_RX_DROP; | 392 | return NET_RX_DROP; |
| @@ -425,7 +425,7 @@ static int dn_return_long(struct sk_buff *skb) | |||
| 425 | unsigned char tmp[ETH_ALEN]; | 425 | unsigned char tmp[ETH_ALEN]; |
| 426 | 426 | ||
| 427 | /* Add back all headers */ | 427 | /* Add back all headers */ |
| 428 | skb_push(skb, skb->data - skb->nh.raw); | 428 | skb_push(skb, skb->data - skb_network_header(skb)); |
| 429 | 429 | ||
| 430 | if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL) | 430 | if ((skb = skb_unshare(skb, GFP_ATOMIC)) == NULL) |
| 431 | return NET_RX_DROP; | 431 | return NET_RX_DROP; |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 6e5575b0abef..ab552a6098f9 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
| @@ -1184,7 +1184,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features) | |||
| 1184 | iph->id = htons(id++); | 1184 | iph->id = htons(id++); |
| 1185 | iph->tot_len = htons(skb->len - skb->mac_len); | 1185 | iph->tot_len = htons(skb->len - skb->mac_len); |
| 1186 | iph->check = 0; | 1186 | iph->check = 0; |
| 1187 | iph->check = ip_fast_csum(skb->nh.raw, iph->ihl); | 1187 | iph->check = ip_fast_csum(skb_network_header(skb), iph->ihl); |
| 1188 | } while ((skb = skb->next)); | 1188 | } while ((skb = skb->next)); |
| 1189 | 1189 | ||
| 1190 | out: | 1190 | out: |
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 7194eb40b6d0..95ddbbd1552a 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
| @@ -154,7 +154,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 154 | ah = (struct ip_auth_hdr*)skb->data; | 154 | ah = (struct ip_auth_hdr*)skb->data; |
| 155 | iph = skb->nh.iph; | 155 | iph = skb->nh.iph; |
| 156 | 156 | ||
| 157 | ihl = skb->data - skb->nh.raw; | 157 | ihl = skb->data - skb_network_header(skb); |
| 158 | memcpy(work_buf, iph, ihl); | 158 | memcpy(work_buf, iph, ihl); |
| 159 | 159 | ||
| 160 | iph->ttl = 0; | 160 | iph->ttl = 0; |
| @@ -181,7 +181,8 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 181 | } | 181 | } |
| 182 | } | 182 | } |
| 183 | ((struct iphdr*)work_buf)->protocol = ah->nexthdr; | 183 | ((struct iphdr*)work_buf)->protocol = ah->nexthdr; |
| 184 | skb->h.raw = memcpy(skb->nh.raw += ah_hlen, work_buf, ihl); | 184 | skb->nh.raw += ah_hlen; |
| 185 | skb->h.raw = memcpy(skb_network_header(skb), work_buf, ihl); | ||
| 185 | __skb_pull(skb, ah_hlen + ihl); | 186 | __skb_pull(skb, ah_hlen + ihl); |
| 186 | 187 | ||
| 187 | return 0; | 188 | return 0; |
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 31041127eeb8..222d21e5bbeb 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
| @@ -57,9 +57,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 57 | *(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2; | 57 | *(u8*)(trailer->tail + clen-skb->len - 2) = (clen - skb->len)-2; |
| 58 | pskb_put(skb, trailer, clen - skb->len); | 58 | pskb_put(skb, trailer, clen - skb->len); |
| 59 | 59 | ||
| 60 | __skb_push(skb, skb->data - skb->nh.raw); | 60 | __skb_push(skb, skb->data - skb_network_header(skb)); |
| 61 | top_iph = skb->nh.iph; | 61 | top_iph = skb->nh.iph; |
| 62 | esph = (struct ip_esp_hdr *)(skb->nh.raw + top_iph->ihl*4); | 62 | esph = (struct ip_esp_hdr *)(skb_network_header(skb) + |
| 63 | top_iph->ihl * 4); | ||
| 63 | top_iph->tot_len = htons(skb->len + alen); | 64 | top_iph->tot_len = htons(skb->len + alen); |
| 64 | *(u8*)(trailer->tail - 1) = top_iph->protocol; | 65 | *(u8*)(trailer->tail - 1) = top_iph->protocol; |
| 65 | 66 | ||
| @@ -222,7 +223,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 222 | 223 | ||
| 223 | if (x->encap) { | 224 | if (x->encap) { |
| 224 | struct xfrm_encap_tmpl *encap = x->encap; | 225 | struct xfrm_encap_tmpl *encap = x->encap; |
| 225 | struct udphdr *uh = (void *)(skb->nh.raw + ihl); | 226 | struct udphdr *uh = (void *)(skb_network_header(skb) + ihl); |
| 226 | 227 | ||
| 227 | /* | 228 | /* |
| 228 | * 1) if the NAT-T peer's IP or port changed then | 229 | * 1) if the NAT-T peer's IP or port changed then |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 4b7a0d946a0d..ff124d40c585 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
| @@ -484,7 +484,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
| 484 | u8 _inner_type, *itp; | 484 | u8 _inner_type, *itp; |
| 485 | 485 | ||
| 486 | itp = skb_header_pointer(skb_in, | 486 | itp = skb_header_pointer(skb_in, |
| 487 | skb_in->nh.raw + | 487 | skb_network_header(skb_in) + |
| 488 | (iph->ihl << 2) + | 488 | (iph->ihl << 2) + |
| 489 | offsetof(struct icmphdr, | 489 | offsetof(struct icmphdr, |
| 490 | type) - | 490 | type) - |
| @@ -536,7 +536,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
| 536 | icmp_param.data.icmph.un.gateway = info; | 536 | icmp_param.data.icmph.un.gateway = info; |
| 537 | icmp_param.data.icmph.checksum = 0; | 537 | icmp_param.data.icmph.checksum = 0; |
| 538 | icmp_param.skb = skb_in; | 538 | icmp_param.skb = skb_in; |
| 539 | icmp_param.offset = skb_in->nh.raw - skb_in->data; | 539 | icmp_param.offset = skb_network_offset(skb_in); |
| 540 | icmp_out_count(icmp_param.data.icmph.type); | 540 | icmp_out_count(icmp_param.data.icmph.type); |
| 541 | inet_sk(icmp_socket->sk)->tos = tos; | 541 | inet_sk(icmp_socket->sk)->tos = tos; |
| 542 | ipc.addr = iph->saddr; | 542 | ipc.addr = iph->saddr; |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 3dfd7581cfc6..268a6c7347f2 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
| @@ -658,7 +658,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev) | |||
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | skb_shinfo(head)->frag_list = head->next; | 660 | skb_shinfo(head)->frag_list = head->next; |
| 661 | skb_push(head, head->data - head->nh.raw); | 661 | skb_push(head, head->data - skb_network_header(head)); |
| 662 | atomic_sub(head->truesize, &ip_frag_mem); | 662 | atomic_sub(head->truesize, &ip_frag_mem); |
| 663 | 663 | ||
| 664 | for (fp=head->next; fp; fp = fp->next) { | 664 | for (fp=head->next; fp; fp = fp->next) { |
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index f906a80d5a87..f7e9db612565 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | void ip_options_build(struct sk_buff * skb, struct ip_options * opt, | 40 | void ip_options_build(struct sk_buff * skb, struct ip_options * opt, |
| 41 | __be32 daddr, struct rtable *rt, int is_frag) | 41 | __be32 daddr, struct rtable *rt, int is_frag) |
| 42 | { | 42 | { |
| 43 | unsigned char * iph = skb->nh.raw; | 43 | unsigned char *iph = skb_network_header(skb); |
| 44 | 44 | ||
| 45 | memcpy(&(IPCB(skb)->opt), opt, sizeof(struct ip_options)); | 45 | memcpy(&(IPCB(skb)->opt), opt, sizeof(struct ip_options)); |
| 46 | memcpy(iph+sizeof(struct iphdr), opt->__data, opt->optlen); | 46 | memcpy(iph+sizeof(struct iphdr), opt->__data, opt->optlen); |
| @@ -104,7 +104,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) | |||
| 104 | return 0; | 104 | return 0; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | sptr = skb->nh.raw; | 107 | sptr = skb_network_header(skb); |
| 108 | dptr = dopt->__data; | 108 | dptr = dopt->__data; |
| 109 | 109 | ||
| 110 | if (skb->dst) | 110 | if (skb->dst) |
| @@ -217,7 +217,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb) | |||
| 217 | 217 | ||
| 218 | void ip_options_fragment(struct sk_buff * skb) | 218 | void ip_options_fragment(struct sk_buff * skb) |
| 219 | { | 219 | { |
| 220 | unsigned char * optptr = skb->nh.raw + sizeof(struct iphdr); | 220 | unsigned char *optptr = skb_network_header(skb) + sizeof(struct iphdr); |
| 221 | struct ip_options * opt = &(IPCB(skb)->opt); | 221 | struct ip_options * opt = &(IPCB(skb)->opt); |
| 222 | int l = opt->optlen; | 222 | int l = opt->optlen; |
| 223 | int optlen; | 223 | int optlen; |
| @@ -264,7 +264,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb) | |||
| 264 | 264 | ||
| 265 | if (!opt) { | 265 | if (!opt) { |
| 266 | opt = &(IPCB(skb)->opt); | 266 | opt = &(IPCB(skb)->opt); |
| 267 | iph = skb->nh.raw; | 267 | iph = skb_network_header(skb); |
| 268 | opt->optlen = ((struct iphdr *)iph)->ihl*4 - sizeof(struct iphdr); | 268 | opt->optlen = ((struct iphdr *)iph)->ihl*4 - sizeof(struct iphdr); |
| 269 | optptr = iph + sizeof(struct iphdr); | 269 | optptr = iph + sizeof(struct iphdr); |
| 270 | opt->is_data = 0; | 270 | opt->is_data = 0; |
| @@ -563,7 +563,7 @@ void ip_forward_options(struct sk_buff *skb) | |||
| 563 | struct ip_options * opt = &(IPCB(skb)->opt); | 563 | struct ip_options * opt = &(IPCB(skb)->opt); |
| 564 | unsigned char * optptr; | 564 | unsigned char * optptr; |
| 565 | struct rtable *rt = (struct rtable*)skb->dst; | 565 | struct rtable *rt = (struct rtable*)skb->dst; |
| 566 | unsigned char *raw = skb->nh.raw; | 566 | unsigned char *raw = skb_network_header(skb); |
| 567 | 567 | ||
| 568 | if (opt->rr_needaddr) { | 568 | if (opt->rr_needaddr) { |
| 569 | optptr = (unsigned char *)raw + opt->rr; | 569 | optptr = (unsigned char *)raw + opt->rr; |
| @@ -609,7 +609,7 @@ int ip_options_rcv_srr(struct sk_buff *skb) | |||
| 609 | int srrspace, srrptr; | 609 | int srrspace, srrptr; |
| 610 | __be32 nexthop; | 610 | __be32 nexthop; |
| 611 | struct iphdr *iph = skb->nh.iph; | 611 | struct iphdr *iph = skb->nh.iph; |
| 612 | unsigned char * optptr = skb->nh.raw + opt->srr; | 612 | unsigned char *optptr = skb_network_header(skb) + opt->srr; |
| 613 | struct rtable *rt = (struct rtable*)skb->dst; | 613 | struct rtable *rt = (struct rtable*)skb->dst; |
| 614 | struct rtable *rt2; | 614 | struct rtable *rt2; |
| 615 | int err; | 615 | int err; |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 669f5d97c6eb..eae228469627 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
| @@ -503,7 +503,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) | |||
| 503 | frag->h.raw = frag->data; | 503 | frag->h.raw = frag->data; |
| 504 | __skb_push(frag, hlen); | 504 | __skb_push(frag, hlen); |
| 505 | skb_reset_network_header(frag); | 505 | skb_reset_network_header(frag); |
| 506 | memcpy(frag->nh.raw, iph, hlen); | 506 | memcpy(skb_network_header(frag), iph, hlen); |
| 507 | iph = frag->nh.iph; | 507 | iph = frag->nh.iph; |
| 508 | iph->tot_len = htons(frag->len); | 508 | iph->tot_len = htons(frag->len); |
| 509 | ip_copy_metadata(frag, skb); | 509 | ip_copy_metadata(frag, skb); |
| @@ -607,7 +607,7 @@ slow_path: | |||
| 607 | * Copy the packet header into the new buffer. | 607 | * Copy the packet header into the new buffer. |
| 608 | */ | 608 | */ |
| 609 | 609 | ||
| 610 | memcpy(skb2->nh.raw, skb->data, hlen); | 610 | memcpy(skb_network_header(skb2), skb->data, hlen); |
| 611 | 611 | ||
| 612 | /* | 612 | /* |
| 613 | * Copy a block of the IP datagram. | 613 | * Copy a block of the IP datagram. |
| @@ -1198,7 +1198,7 @@ int ip_push_pending_frames(struct sock *sk) | |||
| 1198 | tail_skb = &(skb_shinfo(skb)->frag_list); | 1198 | tail_skb = &(skb_shinfo(skb)->frag_list); |
| 1199 | 1199 | ||
| 1200 | /* move skb->data to ip header from ext header */ | 1200 | /* move skb->data to ip header from ext header */ |
| 1201 | if (skb->data < skb->nh.raw) | 1201 | if (skb->data < skb_network_header(skb)) |
| 1202 | __skb_pull(skb, skb_network_offset(skb)); | 1202 | __skb_pull(skb, skb_network_offset(skb)); |
| 1203 | while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { | 1203 | while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { |
| 1204 | __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); | 1204 | __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index f8ab654b6a35..70888e1ef6b7 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
| @@ -273,7 +273,8 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, | |||
| 273 | serr->ee.ee_pad = 0; | 273 | serr->ee.ee_pad = 0; |
| 274 | serr->ee.ee_info = info; | 274 | serr->ee.ee_info = info; |
| 275 | serr->ee.ee_data = 0; | 275 | serr->ee.ee_data = 0; |
| 276 | serr->addr_offset = (u8*)&(((struct iphdr*)(skb->h.icmph+1))->daddr) - skb->nh.raw; | 276 | serr->addr_offset = (u8 *)&(((struct iphdr *)(skb->h.icmph + 1))->daddr) - |
| 277 | skb_network_header(skb); | ||
| 277 | serr->port = port; | 278 | serr->port = port; |
| 278 | 279 | ||
| 279 | skb->h.raw = payload; | 280 | skb->h.raw = payload; |
| @@ -309,7 +310,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf | |||
| 309 | serr->ee.ee_pad = 0; | 310 | serr->ee.ee_pad = 0; |
| 310 | serr->ee.ee_info = info; | 311 | serr->ee.ee_info = info; |
| 311 | serr->ee.ee_data = 0; | 312 | serr->ee.ee_data = 0; |
| 312 | serr->addr_offset = (u8*)&iph->daddr - skb->nh.raw; | 313 | serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb); |
| 313 | serr->port = port; | 314 | serr->port = port; |
| 314 | 315 | ||
| 315 | skb->h.raw = skb->tail; | 316 | skb->h.raw = skb->tail; |
| @@ -355,7 +356,8 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len) | |||
| 355 | sin = (struct sockaddr_in *)msg->msg_name; | 356 | sin = (struct sockaddr_in *)msg->msg_name; |
| 356 | if (sin) { | 357 | if (sin) { |
| 357 | sin->sin_family = AF_INET; | 358 | sin->sin_family = AF_INET; |
| 358 | sin->sin_addr.s_addr = *(__be32*)(skb->nh.raw + serr->addr_offset); | 359 | sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + |
| 360 | serr->addr_offset); | ||
| 359 | sin->sin_port = serr->port; | 361 | sin->sin_port = serr->port; |
| 360 | memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); | 362 | memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); |
| 361 | } | 363 | } |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 51528d3cc334..4a8d99bca441 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
| @@ -563,7 +563,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
| 563 | */ | 563 | */ |
| 564 | msg = (struct igmpmsg*)skb_push(skb, sizeof(struct iphdr)); | 564 | msg = (struct igmpmsg*)skb_push(skb, sizeof(struct iphdr)); |
| 565 | skb->nh.raw = skb->h.raw = (u8*)msg; | 565 | skb->nh.raw = skb->h.raw = (u8*)msg; |
| 566 | memcpy(msg, pkt->nh.raw, sizeof(struct iphdr)); | 566 | memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr)); |
| 567 | msg->im_msgtype = IGMPMSG_WHOLEPKT; | 567 | msg->im_msgtype = IGMPMSG_WHOLEPKT; |
| 568 | msg->im_mbz = 0; | 568 | msg->im_mbz = 0; |
| 569 | msg->im_vif = reg_vif_num; | 569 | msg->im_vif = reg_vif_num; |
diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c index 22e104c6a493..f29d3a27eec6 100644 --- a/net/ipv4/ipvs/ip_vs_app.c +++ b/net/ipv4/ipvs/ip_vs_app.c | |||
| @@ -338,7 +338,7 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff **pskb, | |||
| 338 | if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th))) | 338 | if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th))) |
| 339 | return 0; | 339 | return 0; |
| 340 | 340 | ||
| 341 | th = (struct tcphdr *)((*pskb)->nh.raw + tcp_offset); | 341 | th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset); |
| 342 | 342 | ||
| 343 | /* | 343 | /* |
| 344 | * Remember seq number in case this pkt gets resized | 344 | * Remember seq number in case this pkt gets resized |
| @@ -413,7 +413,7 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff **pskb, | |||
| 413 | if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th))) | 413 | if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th))) |
| 414 | return 0; | 414 | return 0; |
| 415 | 415 | ||
| 416 | th = (struct tcphdr *)((*pskb)->nh.raw + tcp_offset); | 416 | th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset); |
| 417 | 417 | ||
| 418 | /* | 418 | /* |
| 419 | * Remember seq number in case this pkt gets resized | 419 | * Remember seq number in case this pkt gets resized |
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index 858686d616a2..5d54dd2ce12f 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c | |||
| @@ -559,7 +559,8 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, | |||
| 559 | { | 559 | { |
| 560 | struct iphdr *iph = skb->nh.iph; | 560 | struct iphdr *iph = skb->nh.iph; |
| 561 | unsigned int icmp_offset = iph->ihl*4; | 561 | unsigned int icmp_offset = iph->ihl*4; |
| 562 | struct icmphdr *icmph = (struct icmphdr *)(skb->nh.raw + icmp_offset); | 562 | struct icmphdr *icmph = (struct icmphdr *)(skb_network_header(skb) + |
| 563 | icmp_offset); | ||
| 563 | struct iphdr *ciph = (struct iphdr *)(icmph + 1); | 564 | struct iphdr *ciph = (struct iphdr *)(icmph + 1); |
| 564 | 565 | ||
| 565 | if (inout) { | 566 | if (inout) { |
diff --git a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c index 709db4d3f48f..af1c8593eb19 100644 --- a/net/ipv4/netfilter/arpt_mangle.c +++ b/net/ipv4/netfilter/arpt_mangle.c | |||
| @@ -31,7 +31,7 @@ target(struct sk_buff **pskb, | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | arp = (*pskb)->nh.arph; | 33 | arp = (*pskb)->nh.arph; |
| 34 | arpptr = (*pskb)->nh.raw + sizeof(*arp); | 34 | arpptr = skb_network_header(*pskb) + sizeof(*arp); |
| 35 | pln = arp->ar_pln; | 35 | pln = arp->ar_pln; |
| 36 | hln = arp->ar_hln; | 36 | hln = arp->ar_hln; |
| 37 | /* We assume that pln and hln were checked in the match */ | 37 | /* We assume that pln and hln were checked in the match */ |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 8f3e92d20df8..7cebbff0b0c3 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | |||
| @@ -105,7 +105,7 @@ ipv4_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff, | |||
| 105 | return -NF_DROP; | 105 | return -NF_DROP; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | *dataoff = (*pskb)->nh.raw - (*pskb)->data + (*pskb)->nh.iph->ihl*4; | 108 | *dataoff = skb_network_offset(*pskb) + (*pskb)->nh.iph->ihl * 4; |
| 109 | *protonum = (*pskb)->nh.iph->protocol; | 109 | *protonum = (*pskb)->nh.iph->protocol; |
| 110 | 110 | ||
| 111 | return NF_ACCEPT; | 111 | return NF_ACCEPT; |
| @@ -151,10 +151,9 @@ static unsigned int ipv4_conntrack_help(unsigned int hooknum, | |||
| 151 | if (!help || !help->helper) | 151 | if (!help || !help->helper) |
| 152 | return NF_ACCEPT; | 152 | return NF_ACCEPT; |
| 153 | 153 | ||
| 154 | return help->helper->help(pskb, | 154 | return help->helper->help(pskb, (skb_network_offset(*pskb) + |
| 155 | (*pskb)->nh.raw - (*pskb)->data | 155 | (*pskb)->nh.iph->ihl * 4), |
| 156 | + (*pskb)->nh.iph->ihl*4, | 156 | ct, ctinfo); |
| 157 | ct, ctinfo); | ||
| 158 | } | 157 | } |
| 159 | 158 | ||
| 160 | static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, | 159 | static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, |
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 67e5e3c035c1..a3d02fdfc066 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
| @@ -256,7 +256,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 256 | } | 256 | } |
| 257 | nf_reset(skb); | 257 | nf_reset(skb); |
| 258 | 258 | ||
| 259 | skb_push(skb, skb->data - skb->nh.raw); | 259 | skb_push(skb, skb->data - skb_network_header(skb)); |
| 260 | 260 | ||
| 261 | raw_rcv_skb(sk, skb); | 261 | raw_rcv_skb(sk, skb); |
| 262 | return 0; | 262 | return 0; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f5e019cefc15..00190835cea1 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -3634,7 +3634,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, | |||
| 3634 | return; | 3634 | return; |
| 3635 | 3635 | ||
| 3636 | skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head); | 3636 | skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head); |
| 3637 | nskb->nh.raw = nskb->data + (skb->nh.raw - skb->head); | 3637 | nskb->nh.raw = nskb->data + (skb_network_header(skb) - skb->head); |
| 3638 | nskb->h.raw = nskb->data + (skb->h.raw - skb->head); | 3638 | nskb->h.raw = nskb->data + (skb->h.raw - skb->head); |
| 3639 | 3639 | ||
| 3640 | skb_reserve(nskb, header); | 3640 | skb_reserve(nskb, header); |
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c index 78e80deb7e89..d89969c502dd 100644 --- a/net/ipv4/xfrm4_input.c +++ b/net/ipv4/xfrm4_input.c | |||
| @@ -146,7 +146,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type) | |||
| 146 | return 0; | 146 | return 0; |
| 147 | } else { | 147 | } else { |
| 148 | #ifdef CONFIG_NETFILTER | 148 | #ifdef CONFIG_NETFILTER |
| 149 | __skb_push(skb, skb->data - skb->nh.raw); | 149 | __skb_push(skb, skb->data - skb_network_header(skb)); |
| 150 | skb->nh.iph->tot_len = htons(skb->len); | 150 | skb->nh.iph->tot_len = htons(skb->len); |
| 151 | ip_send_check(skb->nh.iph); | 151 | ip_send_check(skb->nh.iph); |
| 152 | 152 | ||
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c index eaaf3565f3b2..505fca034a1f 100644 --- a/net/ipv4/xfrm4_mode_beet.c +++ b/net/ipv4/xfrm4_mode_beet.c | |||
| @@ -98,7 +98,7 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | skb->nh.raw = skb->data + (phlen - sizeof(*iph)); | 100 | skb->nh.raw = skb->data + (phlen - sizeof(*iph)); |
| 101 | memmove(skb->nh.raw, iph, sizeof(*iph)); | 101 | memmove(skb_network_header(skb), iph, sizeof(*iph)); |
| 102 | skb->h.raw = skb->data + (phlen + optlen); | 102 | skb->h.raw = skb->data + (phlen + optlen); |
| 103 | skb->data = skb->h.raw; | 103 | skb->data = skb->h.raw; |
| 104 | 104 | ||
| @@ -112,7 +112,7 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 112 | else | 112 | else |
| 113 | iph->protocol = protocol; | 113 | iph->protocol = protocol; |
| 114 | iph->check = 0; | 114 | iph->check = 0; |
| 115 | iph->check = ip_fast_csum(skb->nh.raw, iph->ihl); | 115 | iph->check = ip_fast_csum(skb_network_header(skb), iph->ihl); |
| 116 | err = 0; | 116 | err = 0; |
| 117 | out: | 117 | out: |
| 118 | return err; | 118 | return err; |
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c index a820dde2c862..b198087c073e 100644 --- a/net/ipv4/xfrm4_mode_transport.c +++ b/net/ipv4/xfrm4_mode_transport.c | |||
| @@ -34,7 +34,7 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 34 | 34 | ||
| 35 | skb_push(skb, x->props.header_len); | 35 | skb_push(skb, x->props.header_len); |
| 36 | skb_reset_network_header(skb); | 36 | skb_reset_network_header(skb); |
| 37 | memmove(skb->nh.raw, iph, ihl); | 37 | memmove(skb_network_header(skb), iph, ihl); |
| 38 | return 0; | 38 | return 0; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| @@ -51,7 +51,7 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 51 | int ihl = skb->data - skb->h.raw; | 51 | int ihl = skb->data - skb->h.raw; |
| 52 | 52 | ||
| 53 | if (skb->h.raw != skb->nh.raw) { | 53 | if (skb->h.raw != skb->nh.raw) { |
| 54 | memmove(skb->h.raw, skb->nh.raw, ihl); | 54 | memmove(skb->h.raw, skb_network_header(skb), ihl); |
| 55 | skb->nh.raw = skb->h.raw; | 55 | skb->nh.raw = skb->h.raw; |
| 56 | } | 56 | } |
| 57 | skb->nh.iph->tot_len = htons(skb->len + ihl); | 57 | skb->nh.iph->tot_len = htons(skb->len + ihl); |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 98a833ce1114..fbb1d3decf02 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
| @@ -210,7 +210,7 @@ static void | |||
| 210 | _decode_session4(struct sk_buff *skb, struct flowi *fl) | 210 | _decode_session4(struct sk_buff *skb, struct flowi *fl) |
| 211 | { | 211 | { |
| 212 | struct iphdr *iph = skb->nh.iph; | 212 | struct iphdr *iph = skb->nh.iph; |
| 213 | u8 *xprth = skb->nh.raw + iph->ihl*4; | 213 | u8 *xprth = skb_network_header(skb) + iph->ihl * 4; |
| 214 | 214 | ||
| 215 | memset(fl, 0, sizeof(struct flowi)); | 215 | memset(fl, 0, sizeof(struct flowi)); |
| 216 | if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { | 216 | if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 2ff070417955..7b917f856e1c 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
| @@ -693,7 +693,8 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) | |||
| 693 | if (np->rxopt.all) { | 693 | if (np->rxopt.all) { |
| 694 | if ((opt->hop && (np->rxopt.bits.hopopts || | 694 | if ((opt->hop && (np->rxopt.bits.hopopts || |
| 695 | np->rxopt.bits.ohopopts)) || | 695 | np->rxopt.bits.ohopopts)) || |
| 696 | ((IPV6_FLOWINFO_MASK & *(__be32*)skb->nh.raw) && | 696 | ((IPV6_FLOWINFO_MASK & |
| 697 | *(__be32 *)skb_network_header(skb)) && | ||
| 697 | np->rxopt.bits.rxflow) || | 698 | np->rxopt.bits.rxflow) || |
| 698 | (opt->srcrt && (np->rxopt.bits.srcrt || | 699 | (opt->srcrt && (np->rxopt.bits.srcrt || |
| 699 | np->rxopt.bits.osrcrt)) || | 700 | np->rxopt.bits.osrcrt)) || |
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index dc68b7269c3c..1c914386982f 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c | |||
| @@ -238,8 +238,8 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 238 | top_iph = (struct ipv6hdr *)skb->data; | 238 | top_iph = (struct ipv6hdr *)skb->data; |
| 239 | top_iph->payload_len = htons(skb->len - sizeof(*top_iph)); | 239 | top_iph->payload_len = htons(skb->len - sizeof(*top_iph)); |
| 240 | 240 | ||
| 241 | nexthdr = *skb->nh.raw; | 241 | nexthdr = *skb_network_header(skb); |
| 242 | *skb->nh.raw = IPPROTO_AH; | 242 | *skb_network_header(skb) = IPPROTO_AH; |
| 243 | 243 | ||
| 244 | /* When there are no extension headers, we only need to save the first | 244 | /* When there are no extension headers, we only need to save the first |
| 245 | * 8 bytes of the base IP header. | 245 | * 8 bytes of the base IP header. |
| @@ -341,7 +341,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 341 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | 341 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) |
| 342 | goto out; | 342 | goto out; |
| 343 | 343 | ||
| 344 | hdr_len = skb->data - skb->nh.raw; | 344 | hdr_len = skb->data - skb_network_header(skb); |
| 345 | ah = (struct ipv6_auth_hdr*)skb->data; | 345 | ah = (struct ipv6_auth_hdr*)skb->data; |
| 346 | ahp = x->data; | 346 | ahp = x->data; |
| 347 | nexthdr = ah->nexthdr; | 347 | nexthdr = ah->nexthdr; |
| @@ -354,7 +354,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 354 | if (!pskb_may_pull(skb, ah_hlen)) | 354 | if (!pskb_may_pull(skb, ah_hlen)) |
| 355 | goto out; | 355 | goto out; |
| 356 | 356 | ||
| 357 | tmp_hdr = kmemdup(skb->nh.raw, hdr_len, GFP_ATOMIC); | 357 | tmp_hdr = kmemdup(skb_network_header(skb), hdr_len, GFP_ATOMIC); |
| 358 | if (!tmp_hdr) | 358 | if (!tmp_hdr) |
| 359 | goto out; | 359 | goto out; |
| 360 | if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len, XFRM_POLICY_IN)) | 360 | if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len, XFRM_POLICY_IN)) |
| @@ -382,7 +382,9 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 382 | } | 382 | } |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | skb->h.raw = memcpy(skb->nh.raw += ah_hlen, tmp_hdr, hdr_len); | 385 | skb->nh.raw += ah_hlen; |
| 386 | memcpy(skb_network_header(skb), tmp_hdr, hdr_len); | ||
| 387 | skb->h.raw = skb->nh.raw; | ||
| 386 | __skb_pull(skb, ah_hlen + hdr_len); | 388 | __skb_pull(skb, ah_hlen + hdr_len); |
| 387 | 389 | ||
| 388 | kfree(tmp_hdr); | 390 | kfree(tmp_hdr); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 31a20f17c854..7a86db6163ee 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
| @@ -227,7 +227,8 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, | |||
| 227 | serr->ee.ee_pad = 0; | 227 | serr->ee.ee_pad = 0; |
| 228 | serr->ee.ee_info = info; | 228 | serr->ee.ee_info = info; |
| 229 | serr->ee.ee_data = 0; | 229 | serr->ee.ee_data = 0; |
| 230 | serr->addr_offset = (u8*)&(((struct ipv6hdr*)(icmph+1))->daddr) - skb->nh.raw; | 230 | serr->addr_offset = (u8 *)&(((struct ipv6hdr *)(icmph + 1))->daddr) - |
| 231 | skb_network_header(skb); | ||
| 231 | serr->port = port; | 232 | serr->port = port; |
| 232 | 233 | ||
| 233 | skb->h.raw = payload; | 234 | skb->h.raw = payload; |
| @@ -264,7 +265,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info) | |||
| 264 | serr->ee.ee_pad = 0; | 265 | serr->ee.ee_pad = 0; |
| 265 | serr->ee.ee_info = info; | 266 | serr->ee.ee_info = info; |
| 266 | serr->ee.ee_data = 0; | 267 | serr->ee.ee_data = 0; |
| 267 | serr->addr_offset = (u8*)&iph->daddr - skb->nh.raw; | 268 | serr->addr_offset = (u8 *)&iph->daddr - skb_network_header(skb); |
| 268 | serr->port = fl->fl_ip_dport; | 269 | serr->port = fl->fl_ip_dport; |
| 269 | 270 | ||
| 270 | skb->h.raw = skb->tail; | 271 | skb->h.raw = skb->tail; |
| @@ -310,21 +311,24 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) | |||
| 310 | 311 | ||
| 311 | sin = (struct sockaddr_in6 *)msg->msg_name; | 312 | sin = (struct sockaddr_in6 *)msg->msg_name; |
| 312 | if (sin) { | 313 | if (sin) { |
| 314 | const unsigned char *nh = skb_network_header(skb); | ||
| 313 | sin->sin6_family = AF_INET6; | 315 | sin->sin6_family = AF_INET6; |
| 314 | sin->sin6_flowinfo = 0; | 316 | sin->sin6_flowinfo = 0; |
| 315 | sin->sin6_port = serr->port; | 317 | sin->sin6_port = serr->port; |
| 316 | sin->sin6_scope_id = 0; | 318 | sin->sin6_scope_id = 0; |
| 317 | if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { | 319 | if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { |
| 318 | ipv6_addr_copy(&sin->sin6_addr, | 320 | ipv6_addr_copy(&sin->sin6_addr, |
| 319 | (struct in6_addr *)(skb->nh.raw + serr->addr_offset)); | 321 | (struct in6_addr *)(nh + serr->addr_offset)); |
| 320 | if (np->sndflow) | 322 | if (np->sndflow) |
| 321 | sin->sin6_flowinfo = *(__be32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK; | 323 | sin->sin6_flowinfo = |
| 324 | (*(__be32 *)(nh + serr->addr_offset - 24) & | ||
| 325 | IPV6_FLOWINFO_MASK); | ||
| 322 | if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) | 326 | if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) |
| 323 | sin->sin6_scope_id = IP6CB(skb)->iif; | 327 | sin->sin6_scope_id = IP6CB(skb)->iif; |
| 324 | } else { | 328 | } else { |
| 325 | ipv6_addr_set(&sin->sin6_addr, 0, 0, | 329 | ipv6_addr_set(&sin->sin6_addr, 0, 0, |
| 326 | htonl(0xffff), | 330 | htonl(0xffff), |
| 327 | *(__be32*)(skb->nh.raw + serr->addr_offset)); | 331 | *(__be32 *)(nh + serr->addr_offset)); |
| 328 | } | 332 | } |
| 329 | } | 333 | } |
| 330 | 334 | ||
| @@ -382,6 +386,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 382 | { | 386 | { |
| 383 | struct ipv6_pinfo *np = inet6_sk(sk); | 387 | struct ipv6_pinfo *np = inet6_sk(sk); |
| 384 | struct inet6_skb_parm *opt = IP6CB(skb); | 388 | struct inet6_skb_parm *opt = IP6CB(skb); |
| 389 | unsigned char *nh = skb_network_header(skb); | ||
| 385 | 390 | ||
| 386 | if (np->rxopt.bits.rxinfo) { | 391 | if (np->rxopt.bits.rxinfo) { |
| 387 | struct in6_pktinfo src_info; | 392 | struct in6_pktinfo src_info; |
| @@ -401,14 +406,14 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 401 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); | 406 | put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); |
| 402 | } | 407 | } |
| 403 | 408 | ||
| 404 | if (np->rxopt.bits.rxflow && (*(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { | 409 | if (np->rxopt.bits.rxflow && (*(__be32 *)nh & IPV6_FLOWINFO_MASK)) { |
| 405 | __be32 flowinfo = *(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK; | 410 | __be32 flowinfo = *(__be32 *)nh & IPV6_FLOWINFO_MASK; |
| 406 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); | 411 | put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); |
| 407 | } | 412 | } |
| 408 | 413 | ||
| 409 | /* HbH is allowed only once */ | 414 | /* HbH is allowed only once */ |
| 410 | if (np->rxopt.bits.hopopts && opt->hop) { | 415 | if (np->rxopt.bits.hopopts && opt->hop) { |
| 411 | u8 *ptr = skb->nh.raw + opt->hop; | 416 | u8 *ptr = nh + opt->hop; |
| 412 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); | 417 | put_cmsg(msg, SOL_IPV6, IPV6_HOPOPTS, (ptr[1]+1)<<3, ptr); |
| 413 | } | 418 | } |
| 414 | 419 | ||
| @@ -428,7 +433,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 428 | 433 | ||
| 429 | while (off <= opt->lastopt) { | 434 | while (off <= opt->lastopt) { |
| 430 | unsigned len; | 435 | unsigned len; |
| 431 | u8 *ptr = skb->nh.raw + off; | 436 | u8 *ptr = nh + off; |
| 432 | 437 | ||
| 433 | switch(nexthdr) { | 438 | switch(nexthdr) { |
| 434 | case IPPROTO_DSTOPTS: | 439 | case IPPROTO_DSTOPTS: |
| @@ -470,19 +475,19 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) | |||
| 470 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); | 475 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); |
| 471 | } | 476 | } |
| 472 | if (np->rxopt.bits.ohopopts && opt->hop) { | 477 | if (np->rxopt.bits.ohopopts && opt->hop) { |
| 473 | u8 *ptr = skb->nh.raw + opt->hop; | 478 | u8 *ptr = nh + opt->hop; |
| 474 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); | 479 | put_cmsg(msg, SOL_IPV6, IPV6_2292HOPOPTS, (ptr[1]+1)<<3, ptr); |
| 475 | } | 480 | } |
| 476 | if (np->rxopt.bits.odstopts && opt->dst0) { | 481 | if (np->rxopt.bits.odstopts && opt->dst0) { |
| 477 | u8 *ptr = skb->nh.raw + opt->dst0; | 482 | u8 *ptr = nh + opt->dst0; |
| 478 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); | 483 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 479 | } | 484 | } |
| 480 | if (np->rxopt.bits.osrcrt && opt->srcrt) { | 485 | if (np->rxopt.bits.osrcrt && opt->srcrt) { |
| 481 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(skb->nh.raw + opt->srcrt); | 486 | struct ipv6_rt_hdr *rthdr = (struct ipv6_rt_hdr *)(nh + opt->srcrt); |
| 482 | put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); | 487 | put_cmsg(msg, SOL_IPV6, IPV6_2292RTHDR, (rthdr->hdrlen+1) << 3, rthdr); |
| 483 | } | 488 | } |
| 484 | if (np->rxopt.bits.odstopts && opt->dst1) { | 489 | if (np->rxopt.bits.odstopts && opt->dst1) { |
| 485 | u8 *ptr = skb->nh.raw + opt->dst1; | 490 | u8 *ptr = nh + opt->dst1; |
| 486 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); | 491 | put_cmsg(msg, SOL_IPV6, IPV6_2292DSTOPTS, (ptr[1]+1)<<3, ptr); |
| 487 | } | 492 | } |
| 488 | return 0; | 493 | return 0; |
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 363e63ffecca..6e6b57ac8013 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
| @@ -92,8 +92,8 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 92 | top_iph = (struct ipv6hdr *)__skb_push(skb, hdr_len); | 92 | top_iph = (struct ipv6hdr *)__skb_push(skb, hdr_len); |
| 93 | esph = (struct ipv6_esp_hdr *)skb->h.raw; | 93 | esph = (struct ipv6_esp_hdr *)skb->h.raw; |
| 94 | top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph)); | 94 | top_iph->payload_len = htons(skb->len + alen - sizeof(*top_iph)); |
| 95 | *(u8*)(trailer->tail - 1) = *skb->nh.raw; | 95 | *(u8 *)(trailer->tail - 1) = *skb_network_header(skb); |
| 96 | *skb->nh.raw = IPPROTO_ESP; | 96 | *skb_network_header(skb) = IPPROTO_ESP; |
| 97 | 97 | ||
| 98 | esph->spi = x->id.spi; | 98 | esph->spi = x->id.spi; |
| 99 | esph->seq_no = htonl(++x->replay.oseq); | 99 | esph->seq_no = htonl(++x->replay.oseq); |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index fce5abde554f..9ebf120ba6d3 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
| @@ -50,13 +50,14 @@ | |||
| 50 | 50 | ||
| 51 | int ipv6_find_tlv(struct sk_buff *skb, int offset, int type) | 51 | int ipv6_find_tlv(struct sk_buff *skb, int offset, int type) |
| 52 | { | 52 | { |
| 53 | int packet_len = skb->tail - skb->nh.raw; | 53 | const unsigned char *nh = skb_network_header(skb); |
| 54 | int packet_len = skb->tail - nh; | ||
| 54 | struct ipv6_opt_hdr *hdr; | 55 | struct ipv6_opt_hdr *hdr; |
| 55 | int len; | 56 | int len; |
| 56 | 57 | ||
| 57 | if (offset + 2 > packet_len) | 58 | if (offset + 2 > packet_len) |
| 58 | goto bad; | 59 | goto bad; |
| 59 | hdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 60 | hdr = (struct ipv6_opt_hdr *)(nh + offset); |
| 60 | len = ((hdr->hdrlen + 1) << 3); | 61 | len = ((hdr->hdrlen + 1) << 3); |
| 61 | 62 | ||
| 62 | if (offset + len > packet_len) | 63 | if (offset + len > packet_len) |
| @@ -66,7 +67,7 @@ int ipv6_find_tlv(struct sk_buff *skb, int offset, int type) | |||
| 66 | len -= 2; | 67 | len -= 2; |
| 67 | 68 | ||
| 68 | while (len > 0) { | 69 | while (len > 0) { |
| 69 | int opttype = skb->nh.raw[offset]; | 70 | int opttype = nh[offset]; |
| 70 | int optlen; | 71 | int optlen; |
| 71 | 72 | ||
| 72 | if (opttype == type) | 73 | if (opttype == type) |
| @@ -77,7 +78,7 @@ int ipv6_find_tlv(struct sk_buff *skb, int offset, int type) | |||
| 77 | optlen = 1; | 78 | optlen = 1; |
| 78 | break; | 79 | break; |
| 79 | default: | 80 | default: |
| 80 | optlen = skb->nh.raw[offset + 1] + 2; | 81 | optlen = nh[offset + 1] + 2; |
| 81 | if (optlen > len) | 82 | if (optlen > len) |
| 82 | goto bad; | 83 | goto bad; |
| 83 | break; | 84 | break; |
| @@ -113,7 +114,7 @@ static int ip6_tlvopt_unknown(struct sk_buff **skbp, int optoff) | |||
| 113 | { | 114 | { |
| 114 | struct sk_buff *skb = *skbp; | 115 | struct sk_buff *skb = *skbp; |
| 115 | 116 | ||
| 116 | switch ((skb->nh.raw[optoff] & 0xC0) >> 6) { | 117 | switch ((skb_network_header(skb)[optoff] & 0xC0) >> 6) { |
| 117 | case 0: /* ignore */ | 118 | case 0: /* ignore */ |
| 118 | return 1; | 119 | return 1; |
| 119 | 120 | ||
| @@ -141,6 +142,7 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp) | |||
| 141 | { | 142 | { |
| 142 | struct sk_buff *skb = *skbp; | 143 | struct sk_buff *skb = *skbp; |
| 143 | struct tlvtype_proc *curr; | 144 | struct tlvtype_proc *curr; |
| 145 | const unsigned char *nh = skb_network_header(skb); | ||
| 144 | int off = skb->h.raw - skb->nh.raw; | 146 | int off = skb->h.raw - skb->nh.raw; |
| 145 | int len = ((skb->h.raw[1]+1)<<3); | 147 | int len = ((skb->h.raw[1]+1)<<3); |
| 146 | 148 | ||
| @@ -151,9 +153,9 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp) | |||
| 151 | len -= 2; | 153 | len -= 2; |
| 152 | 154 | ||
| 153 | while (len > 0) { | 155 | while (len > 0) { |
| 154 | int optlen = skb->nh.raw[off+1]+2; | 156 | int optlen = nh[off + 1] + 2; |
| 155 | 157 | ||
| 156 | switch (skb->nh.raw[off]) { | 158 | switch (nh[off]) { |
| 157 | case IPV6_TLV_PAD0: | 159 | case IPV6_TLV_PAD0: |
| 158 | optlen = 1; | 160 | optlen = 1; |
| 159 | break; | 161 | break; |
| @@ -165,7 +167,7 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp) | |||
| 165 | if (optlen > len) | 167 | if (optlen > len) |
| 166 | goto bad; | 168 | goto bad; |
| 167 | for (curr=procs; curr->type >= 0; curr++) { | 169 | for (curr=procs; curr->type >= 0; curr++) { |
| 168 | if (curr->type == skb->nh.raw[off]) { | 170 | if (curr->type == nh[off]) { |
| 169 | /* type specific length/alignment | 171 | /* type specific length/alignment |
| 170 | checks will be performed in the | 172 | checks will be performed in the |
| 171 | func(). */ | 173 | func(). */ |
| @@ -211,7 +213,7 @@ static int ipv6_dest_hao(struct sk_buff **skbp, int optoff) | |||
| 211 | opt->dsthao = opt->dst1; | 213 | opt->dsthao = opt->dst1; |
| 212 | opt->dst1 = 0; | 214 | opt->dst1 = 0; |
| 213 | 215 | ||
| 214 | hao = (struct ipv6_destopt_hao *)(skb->nh.raw + optoff); | 216 | hao = (struct ipv6_destopt_hao *)(skb_network_header(skb) + optoff); |
| 215 | 217 | ||
| 216 | if (hao->length != 16) { | 218 | if (hao->length != 16) { |
| 217 | LIMIT_NETDEBUG( | 219 | LIMIT_NETDEBUG( |
| @@ -244,8 +246,9 @@ static int ipv6_dest_hao(struct sk_buff **skbp, int optoff) | |||
| 244 | 246 | ||
| 245 | /* update all variable using below by copied skbuff */ | 247 | /* update all variable using below by copied skbuff */ |
| 246 | *skbp = skb = skb2; | 248 | *skbp = skb = skb2; |
| 247 | hao = (struct ipv6_destopt_hao *)(skb2->nh.raw + optoff); | 249 | hao = (struct ipv6_destopt_hao *)(skb_network_header(skb2) + |
| 248 | ipv6h = (struct ipv6hdr *)skb2->nh.raw; | 250 | optoff); |
| 251 | ipv6h = skb2->nh.ipv6h; | ||
| 249 | } | 252 | } |
| 250 | 253 | ||
| 251 | if (skb->ip_summed == CHECKSUM_COMPLETE) | 254 | if (skb->ip_summed == CHECKSUM_COMPLETE) |
| @@ -406,7 +409,8 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp) | |||
| 406 | default: | 409 | default: |
| 407 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), | 410 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), |
| 408 | IPSTATS_MIB_INHDRERRORS); | 411 | IPSTATS_MIB_INHDRERRORS); |
| 409 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw); | 412 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, |
| 413 | (&hdr->type) - skb_network_header(skb)); | ||
| 410 | return -1; | 414 | return -1; |
| 411 | } | 415 | } |
| 412 | 416 | ||
| @@ -443,7 +447,7 @@ looped_back: | |||
| 443 | skb->h.raw += (hdr->hdrlen + 1) << 3; | 447 | skb->h.raw += (hdr->hdrlen + 1) << 3; |
| 444 | opt->dst0 = opt->dst1; | 448 | opt->dst0 = opt->dst1; |
| 445 | opt->dst1 = 0; | 449 | opt->dst1 = 0; |
| 446 | opt->nhoff = (&hdr->nexthdr) - skb->nh.raw; | 450 | opt->nhoff = (&hdr->nexthdr) - skb_network_header(skb); |
| 447 | return 1; | 451 | return 1; |
| 448 | } | 452 | } |
| 449 | 453 | ||
| @@ -452,7 +456,9 @@ looped_back: | |||
| 452 | if (hdr->hdrlen & 0x01) { | 456 | if (hdr->hdrlen & 0x01) { |
| 453 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), | 457 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), |
| 454 | IPSTATS_MIB_INHDRERRORS); | 458 | IPSTATS_MIB_INHDRERRORS); |
| 455 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->hdrlen) - skb->nh.raw); | 459 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, |
| 460 | ((&hdr->hdrlen) - | ||
| 461 | skb_network_header(skb))); | ||
| 456 | return -1; | 462 | return -1; |
| 457 | } | 463 | } |
| 458 | break; | 464 | break; |
| @@ -479,7 +485,9 @@ looped_back: | |||
| 479 | if (hdr->segments_left > n) { | 485 | if (hdr->segments_left > n) { |
| 480 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), | 486 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), |
| 481 | IPSTATS_MIB_INHDRERRORS); | 487 | IPSTATS_MIB_INHDRERRORS); |
| 482 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->segments_left) - skb->nh.raw); | 488 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, |
| 489 | ((&hdr->segments_left) - | ||
| 490 | skb_network_header(skb))); | ||
| 483 | return -1; | 491 | return -1; |
| 484 | } | 492 | } |
| 485 | 493 | ||
| @@ -547,7 +555,7 @@ looped_back: | |||
| 547 | dst_release(xchg(&skb->dst, NULL)); | 555 | dst_release(xchg(&skb->dst, NULL)); |
| 548 | ip6_route_input(skb); | 556 | ip6_route_input(skb); |
| 549 | if (skb->dst->error) { | 557 | if (skb->dst->error) { |
| 550 | skb_push(skb, skb->data - skb->nh.raw); | 558 | skb_push(skb, skb->data - skb_network_header(skb)); |
| 551 | dst_input(skb); | 559 | dst_input(skb); |
| 552 | return -1; | 560 | return -1; |
| 553 | } | 561 | } |
| @@ -565,7 +573,7 @@ looped_back: | |||
| 565 | goto looped_back; | 573 | goto looped_back; |
| 566 | } | 574 | } |
| 567 | 575 | ||
| 568 | skb_push(skb, skb->data - skb->nh.raw); | 576 | skb_push(skb, skb->data - skb_network_header(skb)); |
| 569 | dst_input(skb); | 577 | dst_input(skb); |
| 570 | return -1; | 578 | return -1; |
| 571 | } | 579 | } |
| @@ -656,13 +664,14 @@ EXPORT_SYMBOL_GPL(ipv6_invert_rthdr); | |||
| 656 | static int ipv6_hop_ra(struct sk_buff **skbp, int optoff) | 664 | static int ipv6_hop_ra(struct sk_buff **skbp, int optoff) |
| 657 | { | 665 | { |
| 658 | struct sk_buff *skb = *skbp; | 666 | struct sk_buff *skb = *skbp; |
| 667 | const unsigned char *nh = skb_network_header(skb); | ||
| 659 | 668 | ||
| 660 | if (skb->nh.raw[optoff+1] == 2) { | 669 | if (nh[optoff + 1] == 2) { |
| 661 | IP6CB(skb)->ra = optoff; | 670 | IP6CB(skb)->ra = optoff; |
| 662 | return 1; | 671 | return 1; |
| 663 | } | 672 | } |
| 664 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", | 673 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", |
| 665 | skb->nh.raw[optoff+1]); | 674 | nh[optoff + 1]); |
| 666 | kfree_skb(skb); | 675 | kfree_skb(skb); |
| 667 | return 0; | 676 | return 0; |
| 668 | } | 677 | } |
| @@ -672,17 +681,18 @@ static int ipv6_hop_ra(struct sk_buff **skbp, int optoff) | |||
| 672 | static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff) | 681 | static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff) |
| 673 | { | 682 | { |
| 674 | struct sk_buff *skb = *skbp; | 683 | struct sk_buff *skb = *skbp; |
| 684 | const unsigned char *nh = skb_network_header(skb); | ||
| 675 | u32 pkt_len; | 685 | u32 pkt_len; |
| 676 | 686 | ||
| 677 | if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) { | 687 | if (nh[optoff + 1] != 4 || (optoff & 3) != 2) { |
| 678 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", | 688 | LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", |
| 679 | skb->nh.raw[optoff+1]); | 689 | nh[optoff+1]); |
| 680 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), | 690 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), |
| 681 | IPSTATS_MIB_INHDRERRORS); | 691 | IPSTATS_MIB_INHDRERRORS); |
| 682 | goto drop; | 692 | goto drop; |
| 683 | } | 693 | } |
| 684 | 694 | ||
| 685 | pkt_len = ntohl(*(__be32*)(skb->nh.raw+optoff+2)); | 695 | pkt_len = ntohl(*(__be32 *)(nh + optoff + 2)); |
| 686 | if (pkt_len <= IPV6_MAXPLEN) { | 696 | if (pkt_len <= IPV6_MAXPLEN) { |
| 687 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); | 697 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); |
| 688 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2); | 698 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2); |
| @@ -727,7 +737,7 @@ int ipv6_parse_hopopts(struct sk_buff **skbp) | |||
| 727 | struct inet6_skb_parm *opt = IP6CB(skb); | 737 | struct inet6_skb_parm *opt = IP6CB(skb); |
| 728 | 738 | ||
| 729 | /* | 739 | /* |
| 730 | * skb->nh.raw is equal to skb->data, and | 740 | * skb_network_header(skb) is equal to skb->data, and |
| 731 | * skb->h.raw - skb->nh.raw is always equal to | 741 | * skb->h.raw - skb->nh.raw is always equal to |
| 732 | * sizeof(struct ipv6hdr) by definition of | 742 | * sizeof(struct ipv6hdr) by definition of |
| 733 | * hop-by-hop options. | 743 | * hop-by-hop options. |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index aa4a0a59ffac..e5293b34229f 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -284,7 +284,8 @@ static void mip6_addr_swap(struct sk_buff *skb) | |||
| 284 | if (opt->dsthao) { | 284 | if (opt->dsthao) { |
| 285 | off = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO); | 285 | off = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO); |
| 286 | if (likely(off >= 0)) { | 286 | if (likely(off >= 0)) { |
| 287 | hao = (struct ipv6_destopt_hao *)(skb->nh.raw + off); | 287 | hao = (struct ipv6_destopt_hao *) |
| 288 | (skb_network_header(skb) + off); | ||
| 288 | ipv6_addr_copy(&tmp, &iph->saddr); | 289 | ipv6_addr_copy(&tmp, &iph->saddr); |
| 289 | ipv6_addr_copy(&iph->saddr, &hao->addr); | 290 | ipv6_addr_copy(&iph->saddr, &hao->addr); |
| 290 | ipv6_addr_copy(&hao->addr, &tmp); | 291 | ipv6_addr_copy(&hao->addr, &tmp); |
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 61e7a6c8141d..aecc74da0721 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
| @@ -163,7 +163,7 @@ resubmit: | |||
| 163 | if (!pskb_pull(skb, skb->h.raw - skb->data)) | 163 | if (!pskb_pull(skb, skb->h.raw - skb->data)) |
| 164 | goto discard; | 164 | goto discard; |
| 165 | nhoff = IP6CB(skb)->nhoff; | 165 | nhoff = IP6CB(skb)->nhoff; |
| 166 | nexthdr = skb->nh.raw[nhoff]; | 166 | nexthdr = skb_network_header(skb)[nhoff]; |
| 167 | 167 | ||
| 168 | raw_sk = sk_head(&raw_v6_htable[nexthdr & (MAX_INET_PROTOS - 1)]); | 168 | raw_sk = sk_head(&raw_v6_htable[nexthdr & (MAX_INET_PROTOS - 1)]); |
| 169 | if (raw_sk && !ipv6_raw_deliver(skb, nexthdr)) | 169 | if (raw_sk && !ipv6_raw_deliver(skb, nexthdr)) |
| @@ -181,7 +181,7 @@ resubmit: | |||
| 181 | indefinitely. */ | 181 | indefinitely. */ |
| 182 | nf_reset(skb); | 182 | nf_reset(skb); |
| 183 | 183 | ||
| 184 | skb_postpull_rcsum(skb, skb->nh.raw, | 184 | skb_postpull_rcsum(skb, skb_network_header(skb), |
| 185 | skb->h.raw - skb->nh.raw); | 185 | skb->h.raw - skb->nh.raw); |
| 186 | hdr = skb->nh.ipv6h; | 186 | hdr = skb->nh.ipv6h; |
| 187 | if (ipv6_addr_is_multicast(&hdr->daddr) && | 187 | if (ipv6_addr_is_multicast(&hdr->daddr) && |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 47d00210cba1..f1dfcc319717 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -323,10 +323,11 @@ static int ip6_forward_proxy_check(struct sk_buff *skb) | |||
| 323 | if (nexthdr == IPPROTO_ICMPV6) { | 323 | if (nexthdr == IPPROTO_ICMPV6) { |
| 324 | struct icmp6hdr *icmp6; | 324 | struct icmp6hdr *icmp6; |
| 325 | 325 | ||
| 326 | if (!pskb_may_pull(skb, skb->nh.raw + offset + 1 - skb->data)) | 326 | if (!pskb_may_pull(skb, (skb_network_header(skb) + |
| 327 | offset + 1 - skb->data))) | ||
| 327 | return 0; | 328 | return 0; |
| 328 | 329 | ||
| 329 | icmp6 = (struct icmp6hdr *)(skb->nh.raw + offset); | 330 | icmp6 = (struct icmp6hdr *)(skb_network_header(skb) + offset); |
| 330 | 331 | ||
| 331 | switch (icmp6->icmp6_type) { | 332 | switch (icmp6->icmp6_type) { |
| 332 | case NDISC_ROUTER_SOLICITATION: | 333 | case NDISC_ROUTER_SOLICITATION: |
| @@ -392,7 +393,7 @@ int ip6_forward(struct sk_buff *skb) | |||
| 392 | * that different fragments will go along one path. --ANK | 393 | * that different fragments will go along one path. --ANK |
| 393 | */ | 394 | */ |
| 394 | if (opt->ra) { | 395 | if (opt->ra) { |
| 395 | u8 *ptr = skb->nh.raw + opt->ra; | 396 | u8 *ptr = skb_network_header(skb) + opt->ra; |
| 396 | if (ip6_call_ra_chain(skb, (ptr[2]<<8) + ptr[3])) | 397 | if (ip6_call_ra_chain(skb, (ptr[2]<<8) + ptr[3])) |
| 397 | return 0; | 398 | return 0; |
| 398 | } | 399 | } |
| @@ -527,7 +528,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
| 527 | { | 528 | { |
| 528 | u16 offset = sizeof(struct ipv6hdr); | 529 | u16 offset = sizeof(struct ipv6hdr); |
| 529 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); | 530 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); |
| 530 | unsigned int packet_len = skb->tail - skb->nh.raw; | 531 | unsigned int packet_len = skb->tail - skb_network_header(skb); |
| 531 | int found_rhdr = 0; | 532 | int found_rhdr = 0; |
| 532 | *nexthdr = &skb->nh.ipv6h->nexthdr; | 533 | *nexthdr = &skb->nh.ipv6h->nexthdr; |
| 533 | 534 | ||
| @@ -554,7 +555,8 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
| 554 | 555 | ||
| 555 | offset += ipv6_optlen(exthdr); | 556 | offset += ipv6_optlen(exthdr); |
| 556 | *nexthdr = &exthdr->nexthdr; | 557 | *nexthdr = &exthdr->nexthdr; |
| 557 | exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 558 | exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + |
| 559 | offset); | ||
| 558 | } | 560 | } |
| 559 | 561 | ||
| 560 | return offset; | 562 | return offset; |
| @@ -620,7 +622,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 620 | /* BUILD HEADER */ | 622 | /* BUILD HEADER */ |
| 621 | 623 | ||
| 622 | *prevhdr = NEXTHDR_FRAGMENT; | 624 | *prevhdr = NEXTHDR_FRAGMENT; |
| 623 | tmp_hdr = kmemdup(skb->nh.raw, hlen, GFP_ATOMIC); | 625 | tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC); |
| 624 | if (!tmp_hdr) { | 626 | if (!tmp_hdr) { |
| 625 | IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS); | 627 | IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS); |
| 626 | return -ENOMEM; | 628 | return -ENOMEM; |
| @@ -630,7 +632,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 630 | fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr)); | 632 | fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr)); |
| 631 | __skb_push(skb, hlen); | 633 | __skb_push(skb, hlen); |
| 632 | skb_reset_network_header(skb); | 634 | skb_reset_network_header(skb); |
| 633 | memcpy(skb->nh.raw, tmp_hdr, hlen); | 635 | memcpy(skb_network_header(skb), tmp_hdr, hlen); |
| 634 | 636 | ||
| 635 | ipv6_select_ident(skb, fh); | 637 | ipv6_select_ident(skb, fh); |
| 636 | fh->nexthdr = nexthdr; | 638 | fh->nexthdr = nexthdr; |
| @@ -654,7 +656,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 654 | fh = (struct frag_hdr*)__skb_push(frag, sizeof(struct frag_hdr)); | 656 | fh = (struct frag_hdr*)__skb_push(frag, sizeof(struct frag_hdr)); |
| 655 | __skb_push(frag, hlen); | 657 | __skb_push(frag, hlen); |
| 656 | skb_reset_network_header(frag); | 658 | skb_reset_network_header(frag); |
| 657 | memcpy(frag->nh.raw, tmp_hdr, hlen); | 659 | memcpy(skb_network_header(frag), tmp_hdr, |
| 660 | hlen); | ||
| 658 | offset += skb->len - hlen - sizeof(struct frag_hdr); | 661 | offset += skb->len - hlen - sizeof(struct frag_hdr); |
| 659 | fh->nexthdr = nexthdr; | 662 | fh->nexthdr = nexthdr; |
| 660 | fh->reserved = 0; | 663 | fh->reserved = 0; |
| @@ -753,7 +756,7 @@ slow_path: | |||
| 753 | /* | 756 | /* |
| 754 | * Copy the packet header into the new buffer. | 757 | * Copy the packet header into the new buffer. |
| 755 | */ | 758 | */ |
| 756 | memcpy(frag->nh.raw, skb->data, hlen); | 759 | memcpy(skb_network_header(frag), skb->data, hlen); |
| 757 | 760 | ||
| 758 | /* | 761 | /* |
| 759 | * Build fragment header. | 762 | * Build fragment header. |
| @@ -1329,7 +1332,7 @@ int ip6_push_pending_frames(struct sock *sk) | |||
| 1329 | tail_skb = &(skb_shinfo(skb)->frag_list); | 1332 | tail_skb = &(skb_shinfo(skb)->frag_list); |
| 1330 | 1333 | ||
| 1331 | /* move skb->data to ip header from ext header */ | 1334 | /* move skb->data to ip header from ext header */ |
| 1332 | if (skb->data < skb->nh.raw) | 1335 | if (skb->data < skb_network_header(skb)) |
| 1333 | __skb_pull(skb, skb_network_offset(skb)); | 1336 | __skb_pull(skb, skb_network_offset(skb)); |
| 1334 | while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { | 1337 | while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) { |
| 1335 | __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); | 1338 | __skb_pull(tmp_skb, skb->h.raw - skb->nh.raw); |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index a1e4f39c6793..aafbdfa8d785 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -995,9 +995,10 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 995 | !ip6_tnl_xmit_ctl(t) || ip6_tnl_addr_conflict(t, ipv6h)) | 995 | !ip6_tnl_xmit_ctl(t) || ip6_tnl_addr_conflict(t, ipv6h)) |
| 996 | return -1; | 996 | return -1; |
| 997 | 997 | ||
| 998 | if ((offset = parse_tlv_tnl_enc_lim(skb, skb->nh.raw)) > 0) { | 998 | offset = parse_tlv_tnl_enc_lim(skb, skb_network_header(skb)); |
| 999 | if (offset > 0) { | ||
| 999 | struct ipv6_tlv_tnl_enc_lim *tel; | 1000 | struct ipv6_tlv_tnl_enc_lim *tel; |
| 1000 | tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->nh.raw[offset]; | 1001 | tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset]; |
| 1001 | if (tel->encap_limit == 0) { | 1002 | if (tel->encap_limit == 0) { |
| 1002 | icmpv6_send(skb, ICMPV6_PARAMPROB, | 1003 | icmpv6_send(skb, ICMPV6_PARAMPROB, |
| 1003 | ICMPV6_HDR_FIELD, offset + 2, skb->dev); | 1004 | ICMPV6_HDR_FIELD, offset + 2, skb->dev); |
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 5724ba9f75de..3e71d1691b7d 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
| @@ -166,10 +166,10 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 166 | top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); | 166 | top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); |
| 167 | 167 | ||
| 168 | ipch = (struct ipv6_comp_hdr *)start; | 168 | ipch = (struct ipv6_comp_hdr *)start; |
| 169 | ipch->nexthdr = *skb->nh.raw; | 169 | ipch->nexthdr = *skb_network_header(skb); |
| 170 | ipch->flags = 0; | 170 | ipch->flags = 0; |
| 171 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); | 171 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); |
| 172 | *skb->nh.raw = IPPROTO_COMP; | 172 | *skb_network_header(skb) = IPPROTO_COMP; |
| 173 | 173 | ||
| 174 | out_ok: | 174 | out_ok: |
| 175 | return 0; | 175 | return 0; |
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c index 0afcabdd8ed6..bb4033553f3b 100644 --- a/net/ipv6/mip6.c +++ b/net/ipv6/mip6.c | |||
| @@ -99,14 +99,16 @@ int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) | |||
| 99 | if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { | 99 | if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { |
| 100 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n", | 100 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n", |
| 101 | mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type)); | 101 | mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type)); |
| 102 | mip6_param_prob(skb, 0, (&mh->ip6mh_hdrlen) - skb->nh.raw); | 102 | mip6_param_prob(skb, 0, ((&mh->ip6mh_hdrlen) - |
| 103 | skb_network_header(skb))); | ||
| 103 | return -1; | 104 | return -1; |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | if (mh->ip6mh_proto != IPPROTO_NONE) { | 107 | if (mh->ip6mh_proto != IPPROTO_NONE) { |
| 107 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", | 108 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", |
| 108 | mh->ip6mh_proto); | 109 | mh->ip6mh_proto); |
| 109 | mip6_param_prob(skb, 0, (&mh->ip6mh_proto) - skb->nh.raw); | 110 | mip6_param_prob(skb, 0, ((&mh->ip6mh_proto) - |
| 111 | skb_network_header(skb))); | ||
| 110 | return -1; | 112 | return -1; |
| 111 | } | 113 | } |
| 112 | 114 | ||
| @@ -152,8 +154,8 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 152 | iph = (struct ipv6hdr *)skb->data; | 154 | iph = (struct ipv6hdr *)skb->data; |
| 153 | iph->payload_len = htons(skb->len - sizeof(*iph)); | 155 | iph->payload_len = htons(skb->len - sizeof(*iph)); |
| 154 | 156 | ||
| 155 | nexthdr = *skb->nh.raw; | 157 | nexthdr = *skb_network_header(skb); |
| 156 | *skb->nh.raw = IPPROTO_DSTOPTS; | 158 | *skb_network_header(skb) = IPPROTO_DSTOPTS; |
| 157 | 159 | ||
| 158 | dstopt = (struct ipv6_destopt_hdr *)skb->h.raw; | 160 | dstopt = (struct ipv6_destopt_hdr *)skb->h.raw; |
| 159 | dstopt->nexthdr = nexthdr; | 161 | dstopt->nexthdr = nexthdr; |
| @@ -215,7 +217,8 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct | |||
| 215 | if (likely(opt->dsthao)) { | 217 | if (likely(opt->dsthao)) { |
| 216 | offset = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO); | 218 | offset = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO); |
| 217 | if (likely(offset >= 0)) | 219 | if (likely(offset >= 0)) |
| 218 | hao = (struct ipv6_destopt_hao *)(skb->nh.raw + offset); | 220 | hao = (struct ipv6_destopt_hao *) |
| 221 | (skb_network_header(skb) + offset); | ||
| 219 | } | 222 | } |
| 220 | 223 | ||
| 221 | skb_get_timestamp(skb, &stamp); | 224 | skb_get_timestamp(skb, &stamp); |
| @@ -254,7 +257,8 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
| 254 | { | 257 | { |
| 255 | u16 offset = sizeof(struct ipv6hdr); | 258 | u16 offset = sizeof(struct ipv6hdr); |
| 256 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); | 259 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); |
| 257 | unsigned int packet_len = skb->tail - skb->nh.raw; | 260 | const unsigned char *nh = skb_network_header(skb); |
| 261 | unsigned int packet_len = skb->tail - nh; | ||
| 258 | int found_rhdr = 0; | 262 | int found_rhdr = 0; |
| 259 | 263 | ||
| 260 | *nexthdr = &skb->nh.ipv6h->nexthdr; | 264 | *nexthdr = &skb->nh.ipv6h->nexthdr; |
| @@ -288,7 +292,7 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
| 288 | 292 | ||
| 289 | offset += ipv6_optlen(exthdr); | 293 | offset += ipv6_optlen(exthdr); |
| 290 | *nexthdr = &exthdr->nexthdr; | 294 | *nexthdr = &exthdr->nexthdr; |
| 291 | exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 295 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); |
| 292 | } | 296 | } |
| 293 | 297 | ||
| 294 | return offset; | 298 | return offset; |
| @@ -361,8 +365,8 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb) | |||
| 361 | iph = (struct ipv6hdr *)skb->data; | 365 | iph = (struct ipv6hdr *)skb->data; |
| 362 | iph->payload_len = htons(skb->len - sizeof(*iph)); | 366 | iph->payload_len = htons(skb->len - sizeof(*iph)); |
| 363 | 367 | ||
| 364 | nexthdr = *skb->nh.raw; | 368 | nexthdr = *skb_network_header(skb); |
| 365 | *skb->nh.raw = IPPROTO_ROUTING; | 369 | *skb_network_header(skb) = IPPROTO_ROUTING; |
| 366 | 370 | ||
| 367 | rt2 = (struct rt2_hdr *)skb->h.raw; | 371 | rt2 = (struct rt2_hdr *)skb->h.raw; |
| 368 | rt2->rt_hdr.nexthdr = nexthdr; | 372 | rt2->rt_hdr.nexthdr = nexthdr; |
| @@ -384,7 +388,8 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
| 384 | { | 388 | { |
| 385 | u16 offset = sizeof(struct ipv6hdr); | 389 | u16 offset = sizeof(struct ipv6hdr); |
| 386 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); | 390 | struct ipv6_opt_hdr *exthdr = (struct ipv6_opt_hdr*)(skb->nh.ipv6h + 1); |
| 387 | unsigned int packet_len = skb->tail - skb->nh.raw; | 391 | const unsigned char *nh = skb_network_header(skb); |
| 392 | unsigned int packet_len = skb->tail - nh; | ||
| 388 | int found_rhdr = 0; | 393 | int found_rhdr = 0; |
| 389 | 394 | ||
| 390 | *nexthdr = &skb->nh.ipv6h->nexthdr; | 395 | *nexthdr = &skb->nh.ipv6h->nexthdr; |
| @@ -397,7 +402,7 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
| 397 | case NEXTHDR_ROUTING: | 402 | case NEXTHDR_ROUTING: |
| 398 | if (offset + 3 <= packet_len) { | 403 | if (offset + 3 <= packet_len) { |
| 399 | struct ipv6_rt_hdr *rt; | 404 | struct ipv6_rt_hdr *rt; |
| 400 | rt = (struct ipv6_rt_hdr *)(skb->nh.raw + offset); | 405 | rt = (struct ipv6_rt_hdr *)(nh + offset); |
| 401 | if (rt->type != 0) | 406 | if (rt->type != 0) |
| 402 | return offset; | 407 | return offset; |
| 403 | } | 408 | } |
| @@ -417,7 +422,7 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
| 417 | 422 | ||
| 418 | offset += ipv6_optlen(exthdr); | 423 | offset += ipv6_optlen(exthdr); |
| 419 | *nexthdr = &exthdr->nexthdr; | 424 | *nexthdr = &exthdr->nexthdr; |
| 420 | exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 425 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); |
| 421 | } | 426 | } |
| 422 | 427 | ||
| 423 | return offset; | 428 | return offset; |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index c311b9a12ca6..bc1d09584008 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -408,11 +408,12 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, | |||
| 408 | return -1; | 408 | return -1; |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | if (skb->ip_summed == CHECKSUM_COMPLETE) | 411 | if (skb->ip_summed == CHECKSUM_COMPLETE) { |
| 412 | const unsigned char *nh = skb_network_header(skb); | ||
| 412 | skb->csum = csum_sub(skb->csum, | 413 | skb->csum = csum_sub(skb->csum, |
| 413 | csum_partial(skb->nh.raw, | 414 | csum_partial(nh, (u8 *)(fhdr + 1) - nh, |
| 414 | (u8*)(fhdr + 1) - skb->nh.raw, | ||
| 415 | 0)); | 415 | 0)); |
| 416 | } | ||
| 416 | 417 | ||
| 417 | /* Is this the final fragment? */ | 418 | /* Is this the final fragment? */ |
| 418 | if (!(fhdr->frag_off & htons(IP6_MF))) { | 419 | if (!(fhdr->frag_off & htons(IP6_MF))) { |
| @@ -583,7 +584,9 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 583 | BUG_TRAP(NFCT_FRAG6_CB(head)->offset == 0); | 584 | BUG_TRAP(NFCT_FRAG6_CB(head)->offset == 0); |
| 584 | 585 | ||
| 585 | /* Unfragmented part is taken from the first segment. */ | 586 | /* Unfragmented part is taken from the first segment. */ |
| 586 | payload_len = (head->data - head->nh.raw) - sizeof(struct ipv6hdr) + fq->len - sizeof(struct frag_hdr); | 587 | payload_len = ((head->data - skb_network_header(head)) - |
| 588 | sizeof(struct ipv6hdr) + fq->len - | ||
| 589 | sizeof(struct frag_hdr)); | ||
| 587 | if (payload_len > IPV6_MAXPLEN) { | 590 | if (payload_len > IPV6_MAXPLEN) { |
| 588 | DEBUGP("payload len is too large.\n"); | 591 | DEBUGP("payload len is too large.\n"); |
| 589 | goto out_oversize; | 592 | goto out_oversize; |
| @@ -624,7 +627,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 624 | 627 | ||
| 625 | /* We have to remove fragment header from datagram and to relocate | 628 | /* We have to remove fragment header from datagram and to relocate |
| 626 | * header in order to calculate ICV correctly. */ | 629 | * header in order to calculate ICV correctly. */ |
| 627 | head->nh.raw[fq->nhoffset] = head->h.raw[0]; | 630 | skb_network_header(head)[fq->nhoffset] = head->h.raw[0]; |
| 628 | memmove(head->head + sizeof(struct frag_hdr), head->head, | 631 | memmove(head->head + sizeof(struct frag_hdr), head->head, |
| 629 | (head->data - head->head) - sizeof(struct frag_hdr)); | 632 | (head->data - head->head) - sizeof(struct frag_hdr)); |
| 630 | head->mac.raw += sizeof(struct frag_hdr); | 633 | head->mac.raw += sizeof(struct frag_hdr); |
| @@ -632,7 +635,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 632 | 635 | ||
| 633 | skb_shinfo(head)->frag_list = head->next; | 636 | skb_shinfo(head)->frag_list = head->next; |
| 634 | head->h.raw = head->data; | 637 | head->h.raw = head->data; |
| 635 | skb_push(head, head->data - head->nh.raw); | 638 | skb_push(head, head->data - skb_network_header(head)); |
| 636 | atomic_sub(head->truesize, &nf_ct_frag6_mem); | 639 | atomic_sub(head->truesize, &nf_ct_frag6_mem); |
| 637 | 640 | ||
| 638 | for (fp=head->next; fp; fp = fp->next) { | 641 | for (fp=head->next; fp; fp = fp->next) { |
| @@ -653,7 +656,9 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) | |||
| 653 | 656 | ||
| 654 | /* Yes, and fold redundant checksum back. 8) */ | 657 | /* Yes, and fold redundant checksum back. 8) */ |
| 655 | if (head->ip_summed == CHECKSUM_COMPLETE) | 658 | if (head->ip_summed == CHECKSUM_COMPLETE) |
| 656 | head->csum = csum_partial(head->nh.raw, head->h.raw-head->nh.raw, head->csum); | 659 | head->csum = csum_partial(skb_network_header(head), |
| 660 | head->h.raw - head->nh.raw, | ||
| 661 | head->csum); | ||
| 657 | 662 | ||
| 658 | fq->fragments = NULL; | 663 | fq->fragments = NULL; |
| 659 | 664 | ||
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 5f26645195dc..9b2bcde73f19 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
| @@ -361,7 +361,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 361 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 361 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 362 | 362 | ||
| 363 | if (skb->ip_summed == CHECKSUM_COMPLETE) { | 363 | if (skb->ip_summed == CHECKSUM_COMPLETE) { |
| 364 | skb_postpull_rcsum(skb, skb->nh.raw, | 364 | skb_postpull_rcsum(skb, skb_network_header(skb), |
| 365 | skb->h.raw - skb->nh.raw); | 365 | skb->h.raw - skb->nh.raw); |
| 366 | if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr, | 366 | if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr, |
| 367 | &skb->nh.ipv6h->daddr, | 367 | &skb->nh.ipv6h->daddr, |
| @@ -488,7 +488,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, | |||
| 488 | goto out; | 488 | goto out; |
| 489 | 489 | ||
| 490 | offset = rp->offset; | 490 | offset = rp->offset; |
| 491 | total_len = inet_sk(sk)->cork.length - (skb->nh.raw - skb->data); | 491 | total_len = inet_sk(sk)->cork.length - (skb_network_header(skb) - |
| 492 | skb->data); | ||
| 492 | if (offset >= total_len - 1) { | 493 | if (offset >= total_len - 1) { |
| 493 | err = -EINVAL; | 494 | err = -EINVAL; |
| 494 | ip6_flush_pending_frames(sk); | 495 | ip6_flush_pending_frames(sk); |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 1dde449379fb..f85e49acb91a 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -436,13 +436,18 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, | |||
| 436 | if ((unsigned int)end > IPV6_MAXPLEN) { | 436 | if ((unsigned int)end > IPV6_MAXPLEN) { |
| 437 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), | 437 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), |
| 438 | IPSTATS_MIB_INHDRERRORS); | 438 | IPSTATS_MIB_INHDRERRORS); |
| 439 | icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw); | 439 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, |
| 440 | ((u8 *)&fhdr->frag_off - | ||
| 441 | skb_network_header(skb))); | ||
| 440 | return; | 442 | return; |
| 441 | } | 443 | } |
| 442 | 444 | ||
| 443 | if (skb->ip_summed == CHECKSUM_COMPLETE) | 445 | if (skb->ip_summed == CHECKSUM_COMPLETE) { |
| 446 | const unsigned char *nh = skb_network_header(skb); | ||
| 444 | skb->csum = csum_sub(skb->csum, | 447 | skb->csum = csum_sub(skb->csum, |
| 445 | csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0)); | 448 | csum_partial(nh, (u8 *)(fhdr + 1) - nh, |
| 449 | 0)); | ||
| 450 | } | ||
| 446 | 451 | ||
| 447 | /* Is this the final fragment? */ | 452 | /* Is this the final fragment? */ |
| 448 | if (!(fhdr->frag_off & htons(IP6_MF))) { | 453 | if (!(fhdr->frag_off & htons(IP6_MF))) { |
| @@ -605,7 +610,9 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in, | |||
| 605 | BUG_TRAP(FRAG6_CB(head)->offset == 0); | 610 | BUG_TRAP(FRAG6_CB(head)->offset == 0); |
| 606 | 611 | ||
| 607 | /* Unfragmented part is taken from the first segment. */ | 612 | /* Unfragmented part is taken from the first segment. */ |
| 608 | payload_len = (head->data - head->nh.raw) - sizeof(struct ipv6hdr) + fq->len - sizeof(struct frag_hdr); | 613 | payload_len = ((head->data - skb_network_header(head)) - |
| 614 | sizeof(struct ipv6hdr) + fq->len - | ||
| 615 | sizeof(struct frag_hdr)); | ||
| 609 | if (payload_len > IPV6_MAXPLEN) | 616 | if (payload_len > IPV6_MAXPLEN) |
| 610 | goto out_oversize; | 617 | goto out_oversize; |
| 611 | 618 | ||
| @@ -639,7 +646,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in, | |||
| 639 | /* We have to remove fragment header from datagram and to relocate | 646 | /* We have to remove fragment header from datagram and to relocate |
| 640 | * header in order to calculate ICV correctly. */ | 647 | * header in order to calculate ICV correctly. */ |
| 641 | nhoff = fq->nhoffset; | 648 | nhoff = fq->nhoffset; |
| 642 | head->nh.raw[nhoff] = head->h.raw[0]; | 649 | skb_network_header(head)[nhoff] = head->h.raw[0]; |
| 643 | memmove(head->head + sizeof(struct frag_hdr), head->head, | 650 | memmove(head->head + sizeof(struct frag_hdr), head->head, |
| 644 | (head->data - head->head) - sizeof(struct frag_hdr)); | 651 | (head->data - head->head) - sizeof(struct frag_hdr)); |
| 645 | head->mac.raw += sizeof(struct frag_hdr); | 652 | head->mac.raw += sizeof(struct frag_hdr); |
| @@ -647,7 +654,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in, | |||
| 647 | 654 | ||
| 648 | skb_shinfo(head)->frag_list = head->next; | 655 | skb_shinfo(head)->frag_list = head->next; |
| 649 | head->h.raw = head->data; | 656 | head->h.raw = head->data; |
| 650 | skb_push(head, head->data - head->nh.raw); | 657 | skb_push(head, head->data - skb_network_header(head)); |
| 651 | atomic_sub(head->truesize, &ip6_frag_mem); | 658 | atomic_sub(head->truesize, &ip6_frag_mem); |
| 652 | 659 | ||
| 653 | for (fp=head->next; fp; fp = fp->next) { | 660 | for (fp=head->next; fp; fp = fp->next) { |
| @@ -671,7 +678,9 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in, | |||
| 671 | 678 | ||
| 672 | /* Yes, and fold redundant checksum back. 8) */ | 679 | /* Yes, and fold redundant checksum back. 8) */ |
| 673 | if (head->ip_summed == CHECKSUM_COMPLETE) | 680 | if (head->ip_summed == CHECKSUM_COMPLETE) |
| 674 | head->csum = csum_partial(head->nh.raw, head->h.raw-head->nh.raw, head->csum); | 681 | head->csum = csum_partial(skb_network_header(head), |
| 682 | head->h.raw - head->nh.raw, | ||
| 683 | head->csum); | ||
| 675 | 684 | ||
| 676 | rcu_read_lock(); | 685 | rcu_read_lock(); |
| 677 | IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMOKS); | 686 | IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMOKS); |
| @@ -725,7 +734,7 @@ static int ipv6_frag_rcv(struct sk_buff **skbp) | |||
| 725 | skb->h.raw += sizeof(struct frag_hdr); | 734 | skb->h.raw += sizeof(struct frag_hdr); |
| 726 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMOKS); | 735 | IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMOKS); |
| 727 | 736 | ||
| 728 | IP6CB(skb)->nhoff = (u8*)fhdr - skb->nh.raw; | 737 | IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb); |
| 729 | return 1; | 738 | return 1; |
| 730 | } | 739 | } |
| 731 | 740 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 92f99927d12d..80a52ab1e384 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
| @@ -486,7 +486,9 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, | |||
| 486 | struct sk_buff *pktopts = treq->pktopts; | 486 | struct sk_buff *pktopts = treq->pktopts; |
| 487 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); | 487 | struct inet6_skb_parm *rxopt = IP6CB(pktopts); |
| 488 | if (rxopt->srcrt) | 488 | if (rxopt->srcrt) |
| 489 | opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(pktopts->nh.raw + rxopt->srcrt)); | 489 | opt = ipv6_invert_rthdr(sk, |
| 490 | (struct ipv6_rt_hdr *)(skb_network_header(pktopts) + | ||
| 491 | rxopt->srcrt)); | ||
| 490 | } | 492 | } |
| 491 | 493 | ||
| 492 | if (opt && opt->srcrt) { | 494 | if (opt && opt->srcrt) { |
| @@ -1389,7 +1391,9 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1389 | opt == NULL && treq->pktopts) { | 1391 | opt == NULL && treq->pktopts) { |
| 1390 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); | 1392 | struct inet6_skb_parm *rxopt = IP6CB(treq->pktopts); |
| 1391 | if (rxopt->srcrt) | 1393 | if (rxopt->srcrt) |
| 1392 | opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr *)(treq->pktopts->nh.raw + rxopt->srcrt)); | 1394 | opt = ipv6_invert_rthdr(sk, |
| 1395 | (struct ipv6_rt_hdr *)(skb_network_header(treq->pktopts) + | ||
| 1396 | rxopt->srcrt)); | ||
| 1393 | } | 1397 | } |
| 1394 | 1398 | ||
| 1395 | if (dst == NULL) { | 1399 | if (dst == NULL) { |
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c index 33a1b9200431..5c929f886129 100644 --- a/net/ipv6/xfrm6_input.c +++ b/net/ipv6/xfrm6_input.c | |||
| @@ -28,7 +28,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi) | |||
| 28 | unsigned int nhoff; | 28 | unsigned int nhoff; |
| 29 | 29 | ||
| 30 | nhoff = IP6CB(skb)->nhoff; | 30 | nhoff = IP6CB(skb)->nhoff; |
| 31 | nexthdr = skb->nh.raw[nhoff]; | 31 | nexthdr = skb_network_header(skb)[nhoff]; |
| 32 | 32 | ||
| 33 | seq = 0; | 33 | seq = 0; |
| 34 | if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) | 34 | if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) |
| @@ -58,7 +58,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi) | |||
| 58 | if (nexthdr <= 0) | 58 | if (nexthdr <= 0) |
| 59 | goto drop_unlock; | 59 | goto drop_unlock; |
| 60 | 60 | ||
| 61 | skb->nh.raw[nhoff] = nexthdr; | 61 | skb_network_header(skb)[nhoff] = nexthdr; |
| 62 | 62 | ||
| 63 | if (x->props.replay_window) | 63 | if (x->props.replay_window) |
| 64 | xfrm_replay_advance(x, seq); | 64 | xfrm_replay_advance(x, seq); |
| @@ -113,7 +113,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi) | |||
| 113 | } else { | 113 | } else { |
| 114 | #ifdef CONFIG_NETFILTER | 114 | #ifdef CONFIG_NETFILTER |
| 115 | skb->nh.ipv6h->payload_len = htons(skb->len); | 115 | skb->nh.ipv6h->payload_len = htons(skb->len); |
| 116 | __skb_push(skb, skb->data - skb->nh.raw); | 116 | __skb_push(skb, skb->data - skb_network_header(skb)); |
| 117 | 117 | ||
| 118 | NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL, | 118 | NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL, |
| 119 | ip6_rcv_finish); | 119 | ip6_rcv_finish); |
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c index c015bfde2b1c..247e2d5d2acf 100644 --- a/net/ipv6/xfrm6_mode_beet.c +++ b/net/ipv6/xfrm6_mode_beet.c | |||
| @@ -67,7 +67,7 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 67 | goto out; | 67 | goto out; |
| 68 | 68 | ||
| 69 | skb_push(skb, size); | 69 | skb_push(skb, size); |
| 70 | memmove(skb->data, skb->nh.raw, size); | 70 | memmove(skb->data, skb_network_header(skb), size); |
| 71 | skb_reset_network_header(skb); | 71 | skb_reset_network_header(skb); |
| 72 | 72 | ||
| 73 | old_mac = skb_mac_header(skb); | 73 | old_mac = skb_mac_header(skb); |
diff --git a/net/ipv6/xfrm6_mode_transport.c b/net/ipv6/xfrm6_mode_transport.c index 3a4b39b12bad..ace0bbf4f25d 100644 --- a/net/ipv6/xfrm6_mode_transport.c +++ b/net/ipv6/xfrm6_mode_transport.c | |||
| @@ -53,8 +53,10 @@ static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 53 | { | 53 | { |
| 54 | int ihl = skb->data - skb->h.raw; | 54 | int ihl = skb->data - skb->h.raw; |
| 55 | 55 | ||
| 56 | if (skb->h.raw != skb->nh.raw) | 56 | if (skb->h.raw != skb->nh.raw) { |
| 57 | skb->nh.raw = memmove(skb->h.raw, skb->nh.raw, ihl); | 57 | memmove(skb->h.raw, skb_network_header(skb), ihl); |
| 58 | skb->nh.raw = skb->h.raw; | ||
| 59 | } | ||
| 58 | skb->nh.ipv6h->payload_len = htons(skb->len + ihl - | 60 | skb->nh.ipv6h->payload_len = htons(skb->len + ihl - |
| 59 | sizeof(struct ipv6hdr)); | 61 | sizeof(struct ipv6hdr)); |
| 60 | skb->h.raw = skb->data; | 62 | skb->h.raw = skb->data; |
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index 8ce5ef2d0b1c..498f17b5c42f 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c | |||
| @@ -87,9 +87,10 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 87 | { | 87 | { |
| 88 | int err = -EINVAL; | 88 | int err = -EINVAL; |
| 89 | const unsigned char *old_mac; | 89 | const unsigned char *old_mac; |
| 90 | const unsigned char *nh = skb_network_header(skb); | ||
| 90 | 91 | ||
| 91 | if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6 | 92 | if (nh[IP6CB(skb)->nhoff] != IPPROTO_IPV6 && |
| 92 | && skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPIP) | 93 | nh[IP6CB(skb)->nhoff] != IPPROTO_IPIP) |
| 93 | goto out; | 94 | goto out; |
| 94 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) | 95 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) |
| 95 | goto out; | 96 | goto out; |
| @@ -98,7 +99,8 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 98 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) | 99 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) |
| 99 | goto out; | 100 | goto out; |
| 100 | 101 | ||
| 101 | if (skb->nh.raw[IP6CB(skb)->nhoff] == IPPROTO_IPV6) { | 102 | nh = skb_network_header(skb); |
| 103 | if (nh[IP6CB(skb)->nhoff] == IPPROTO_IPV6) { | ||
| 102 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) | 104 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) |
| 103 | ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h); | 105 | ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h); |
| 104 | if (!(x->props.flags & XFRM_STATE_NOECN)) | 106 | if (!(x->props.flags & XFRM_STATE_NOECN)) |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index d8a585bd2cb4..cb5a723d4cb4 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
| @@ -273,14 +273,16 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl) | |||
| 273 | u16 offset = skb->h.raw - skb->nh.raw; | 273 | u16 offset = skb->h.raw - skb->nh.raw; |
| 274 | struct ipv6hdr *hdr = skb->nh.ipv6h; | 274 | struct ipv6hdr *hdr = skb->nh.ipv6h; |
| 275 | struct ipv6_opt_hdr *exthdr; | 275 | struct ipv6_opt_hdr *exthdr; |
| 276 | u8 nexthdr = skb->nh.raw[IP6CB(skb)->nhoff]; | 276 | const unsigned char *nh = skb_network_header(skb); |
| 277 | u8 nexthdr = nh[IP6CB(skb)->nhoff]; | ||
| 277 | 278 | ||
| 278 | memset(fl, 0, sizeof(struct flowi)); | 279 | memset(fl, 0, sizeof(struct flowi)); |
| 279 | ipv6_addr_copy(&fl->fl6_dst, &hdr->daddr); | 280 | ipv6_addr_copy(&fl->fl6_dst, &hdr->daddr); |
| 280 | ipv6_addr_copy(&fl->fl6_src, &hdr->saddr); | 281 | ipv6_addr_copy(&fl->fl6_src, &hdr->saddr); |
| 281 | 282 | ||
| 282 | while (pskb_may_pull(skb, skb->nh.raw + offset + 1 - skb->data)) { | 283 | while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) { |
| 283 | exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 284 | nh = skb_network_header(skb); |
| 285 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); | ||
| 284 | 286 | ||
| 285 | switch (nexthdr) { | 287 | switch (nexthdr) { |
| 286 | case NEXTHDR_ROUTING: | 288 | case NEXTHDR_ROUTING: |
| @@ -288,7 +290,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl) | |||
| 288 | case NEXTHDR_DEST: | 290 | case NEXTHDR_DEST: |
| 289 | offset += ipv6_optlen(exthdr); | 291 | offset += ipv6_optlen(exthdr); |
| 290 | nexthdr = exthdr->nexthdr; | 292 | nexthdr = exthdr->nexthdr; |
| 291 | exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset); | 293 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); |
| 292 | break; | 294 | break; |
| 293 | 295 | ||
| 294 | case IPPROTO_UDP: | 296 | case IPPROTO_UDP: |
| @@ -296,7 +298,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl) | |||
| 296 | case IPPROTO_TCP: | 298 | case IPPROTO_TCP: |
| 297 | case IPPROTO_SCTP: | 299 | case IPPROTO_SCTP: |
| 298 | case IPPROTO_DCCP: | 300 | case IPPROTO_DCCP: |
| 299 | if (pskb_may_pull(skb, skb->nh.raw + offset + 4 - skb->data)) { | 301 | if (pskb_may_pull(skb, nh + offset + 4 - skb->data)) { |
| 300 | __be16 *ports = (__be16 *)exthdr; | 302 | __be16 *ports = (__be16 *)exthdr; |
| 301 | 303 | ||
| 302 | fl->fl_ip_sport = ports[0]; | 304 | fl->fl_ip_sport = ports[0]; |
| @@ -306,7 +308,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl) | |||
| 306 | return; | 308 | return; |
| 307 | 309 | ||
| 308 | case IPPROTO_ICMPV6: | 310 | case IPPROTO_ICMPV6: |
| 309 | if (pskb_may_pull(skb, skb->nh.raw + offset + 2 - skb->data)) { | 311 | if (pskb_may_pull(skb, nh + offset + 2 - skb->data)) { |
| 310 | u8 *icmp = (u8 *)exthdr; | 312 | u8 *icmp = (u8 *)exthdr; |
| 311 | 313 | ||
| 312 | fl->fl_icmp_type = icmp[0]; | 314 | fl->fl_icmp_type = icmp[0]; |
| @@ -317,7 +319,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl) | |||
| 317 | 319 | ||
| 318 | #ifdef CONFIG_IPV6_MIP6 | 320 | #ifdef CONFIG_IPV6_MIP6 |
| 319 | case IPPROTO_MH: | 321 | case IPPROTO_MH: |
| 320 | if (pskb_may_pull(skb, skb->nh.raw + offset + 3 - skb->data)) { | 322 | if (pskb_may_pull(skb, nh + offset + 3 - skb->data)) { |
| 321 | struct ip6_mh *mh; | 323 | struct ip6_mh *mh; |
| 322 | mh = (struct ip6_mh *)exthdr; | 324 | mh = (struct ip6_mh *)exthdr; |
| 323 | 325 | ||
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c index db7e38c08de2..afc0c60e19d5 100644 --- a/net/netfilter/xt_TCPMSS.c +++ b/net/netfilter/xt_TCPMSS.c | |||
| @@ -54,7 +54,7 @@ tcpmss_mangle_packet(struct sk_buff **pskb, | |||
| 54 | return -1; | 54 | return -1; |
| 55 | 55 | ||
| 56 | tcplen = (*pskb)->len - tcphoff; | 56 | tcplen = (*pskb)->len - tcphoff; |
| 57 | tcph = (struct tcphdr *)((*pskb)->nh.raw + tcphoff); | 57 | tcph = (struct tcphdr *)(skb_network_header(*pskb) + tcphoff); |
| 58 | 58 | ||
| 59 | /* Since it passed flags test in tcp match, we know it is is | 59 | /* Since it passed flags test in tcp match, we know it is is |
| 60 | not a fragment, and has data >= tcp header length. SYN | 60 | not a fragment, and has data >= tcp header length. SYN |
| @@ -113,7 +113,7 @@ tcpmss_mangle_packet(struct sk_buff **pskb, | |||
| 113 | return -1; | 113 | return -1; |
| 114 | kfree_skb(*pskb); | 114 | kfree_skb(*pskb); |
| 115 | *pskb = newskb; | 115 | *pskb = newskb; |
| 116 | tcph = (struct tcphdr *)((*pskb)->nh.raw + tcphoff); | 116 | tcph = (struct tcphdr *)(skb_network_header(*pskb) + tcphoff); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | skb_put((*pskb), TCPOLEN_MSS); | 119 | skb_put((*pskb), TCPOLEN_MSS); |
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 3d6a2fcc9ce4..20813eee8af4 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
| @@ -136,7 +136,7 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a, | |||
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | pptr = skb->nh.raw; | 139 | pptr = skb_network_header(skb); |
| 140 | 140 | ||
| 141 | spin_lock(&p->tcf_lock); | 141 | spin_lock(&p->tcf_lock); |
| 142 | 142 | ||
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 0bcb16928d25..695b34051b9f 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
| @@ -119,7 +119,7 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re | |||
| 119 | } stack[TC_U32_MAXDEPTH]; | 119 | } stack[TC_U32_MAXDEPTH]; |
| 120 | 120 | ||
| 121 | struct tc_u_hnode *ht = (struct tc_u_hnode*)tp->root; | 121 | struct tc_u_hnode *ht = (struct tc_u_hnode*)tp->root; |
| 122 | u8 *ptr = skb->nh.raw; | 122 | u8 *ptr = skb_network_header(skb); |
| 123 | struct tc_u_knode *n; | 123 | struct tc_u_knode *n; |
| 124 | int sdepth = 0; | 124 | int sdepth = 0; |
| 125 | int off2 = 0; | 125 | int off2 = 0; |
diff --git a/net/sched/em_u32.c b/net/sched/em_u32.c index cd0600c67969..0a2a7fe08de3 100644 --- a/net/sched/em_u32.c +++ b/net/sched/em_u32.c | |||
| @@ -22,7 +22,7 @@ static int em_u32_match(struct sk_buff *skb, struct tcf_ematch *em, | |||
| 22 | struct tcf_pkt_info *info) | 22 | struct tcf_pkt_info *info) |
| 23 | { | 23 | { |
| 24 | struct tc_u32_key *key = (struct tc_u32_key *) em->data; | 24 | struct tc_u32_key *key = (struct tc_u32_key *) em->data; |
| 25 | unsigned char *ptr = skb->nh.raw; | 25 | const unsigned char *ptr = skb_network_header(skb); |
| 26 | 26 | ||
| 27 | if (info) { | 27 | if (info) { |
| 28 | if (info->ptr) | 28 | if (info->ptr) |
