aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ip6_output.c
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/ipv6/ip6_output.c
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/ipv6/ip6_output.c')
-rw-r--r--net/ipv6/ip6_output.c23
1 files changed, 13 insertions, 10 deletions
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);