aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-10 23:50:43 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:24:59 -0400
commitd56f90a7c96da5187f0cdf07ee7434fe6aa78bbc (patch)
tree3b9073cecfbb3b6a1e25ab2b5dd2a22a43aef238 /net/ipv4
parentbbe735e4247dba32568a305553b010081c8dea99 (diff)
[SK_BUFF]: Introduce skb_network_header()
For the places where we need a pointer to the network header, it is still legal to touch skb->nh.raw directly if just adding to, subtracting from or setting it to another layer header. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/ah4.c5
-rw-r--r--net/ipv4/esp4.c7
-rw-r--r--net/ipv4/icmp.c4
-rw-r--r--net/ipv4/ip_fragment.c2
-rw-r--r--net/ipv4/ip_options.c12
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ip_sockglue.c8
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_app.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c3
-rw-r--r--net/ipv4/netfilter/arpt_mangle.c2
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c9
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/xfrm4_input.c2
-rw-r--r--net/ipv4/xfrm4_mode_beet.c4
-rw-r--r--net/ipv4/xfrm4_mode_transport.c4
-rw-r--r--net/ipv4/xfrm4_policy.c2
19 files changed, 43 insertions, 39 deletions
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
1190out: 1190out:
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 @@
40void ip_options_build(struct sk_buff * skb, struct ip_options * opt, 40void 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
218void ip_options_fragment(struct sk_buff * skb) 218void 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
160static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, 159static 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;
117out: 117out:
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))) {