diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-04-10 23:50:43 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:59 -0400 |
commit | d56f90a7c96da5187f0cdf07ee7434fe6aa78bbc (patch) | |
tree | 3b9073cecfbb3b6a1e25ab2b5dd2a22a43aef238 /net/ipv6/mip6.c | |
parent | bbe735e4247dba32568a305553b010081c8dea99 (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/mip6.c')
-rw-r--r-- | net/ipv6/mip6.c | 29 |
1 files changed, 17 insertions, 12 deletions
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; |