aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/xfrm6_policy.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/xfrm6_policy.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/xfrm6_policy.c')
-rw-r--r--net/ipv6/xfrm6_policy.c16
1 files changed, 9 insertions, 7 deletions
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