diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-02 16:27:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-02 16:27:41 -0500 |
commit | 452edd598f60522c11f7f88fdbab27eb36509d1a (patch) | |
tree | df1510e9848e591a412c8bfa724253470c48c4c2 /net/ipv6 | |
parent | 3872b284087081ee5cb0e4630954c2f7a2153cf5 (diff) |
xfrm: Return dst directly from xfrm_lookup()
Instead of on the stack.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/icmp.c | 37 | ||||
-rw-r--r-- | net/ipv6/ip6_output.c | 10 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 8 | ||||
-rw-r--r-- | net/ipv6/mcast.c | 13 | ||||
-rw-r--r-- | net/ipv6/ndisc.c | 8 | ||||
-rw-r--r-- | net/ipv6/netfilter.c | 3 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_REJECT.c | 3 |
7 files changed, 45 insertions, 37 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index e332bae104ee..55665956b3a8 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -324,17 +324,15 @@ static struct dst_entry *icmpv6_route_lookup(struct net *net, struct sk_buff *sk | |||
324 | /* No need to clone since we're just using its address. */ | 324 | /* No need to clone since we're just using its address. */ |
325 | dst2 = dst; | 325 | dst2 = dst; |
326 | 326 | ||
327 | err = xfrm_lookup(net, &dst, fl, sk, 0); | 327 | dst = xfrm_lookup(net, dst, fl, sk, 0); |
328 | switch (err) { | 328 | if (!IS_ERR(dst)) { |
329 | case 0: | ||
330 | if (dst != dst2) | 329 | if (dst != dst2) |
331 | return dst; | 330 | return dst; |
332 | break; | 331 | } else { |
333 | case -EPERM: | 332 | if (PTR_ERR(dst) == -EPERM) |
334 | dst = NULL; | 333 | dst = NULL; |
335 | break; | 334 | else |
336 | default: | 335 | return dst; |
337 | return ERR_PTR(err); | ||
338 | } | 336 | } |
339 | 337 | ||
340 | err = xfrm_decode_session_reverse(skb, &fl2, AF_INET6); | 338 | err = xfrm_decode_session_reverse(skb, &fl2, AF_INET6); |
@@ -345,17 +343,17 @@ static struct dst_entry *icmpv6_route_lookup(struct net *net, struct sk_buff *sk | |||
345 | if (err) | 343 | if (err) |
346 | goto relookup_failed; | 344 | goto relookup_failed; |
347 | 345 | ||
348 | err = xfrm_lookup(net, &dst2, &fl2, sk, XFRM_LOOKUP_ICMP); | 346 | dst2 = xfrm_lookup(net, dst2, &fl2, sk, XFRM_LOOKUP_ICMP); |
349 | switch (err) { | 347 | if (!IS_ERR(dst2)) { |
350 | case 0: | ||
351 | dst_release(dst); | 348 | dst_release(dst); |
352 | dst = dst2; | 349 | dst = dst2; |
353 | break; | 350 | } else { |
354 | case -EPERM: | 351 | err = PTR_ERR(dst2); |
355 | dst_release(dst); | 352 | if (err == -EPERM) { |
356 | return ERR_PTR(err); | 353 | dst_release(dst); |
357 | default: | 354 | return dst2; |
358 | goto relookup_failed; | 355 | } else |
356 | goto relookup_failed; | ||
359 | } | 357 | } |
360 | 358 | ||
361 | relookup_failed: | 359 | relookup_failed: |
@@ -560,7 +558,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
560 | err = ip6_dst_lookup(sk, &dst, &fl); | 558 | err = ip6_dst_lookup(sk, &dst, &fl); |
561 | if (err) | 559 | if (err) |
562 | goto out; | 560 | goto out; |
563 | if ((err = xfrm_lookup(net, &dst, &fl, sk, 0)) < 0) | 561 | dst = xfrm_lookup(net, dst, &fl, sk, 0); |
562 | if (IS_ERR(dst)) | ||
564 | goto out; | 563 | goto out; |
565 | 564 | ||
566 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) | 565 | if (ipv6_addr_is_multicast(&fl.fl6_dst)) |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 35a4ad90a0f5..adaffaf84555 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1028,10 +1028,7 @@ struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi *fl, | |||
1028 | if (can_sleep) | 1028 | if (can_sleep) |
1029 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; | 1029 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; |
1030 | 1030 | ||
1031 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | 1031 | return xfrm_lookup(sock_net(sk), dst, fl, sk, 0); |
1032 | if (err) | ||
1033 | return ERR_PTR(err); | ||
1034 | return dst; | ||
1035 | } | 1032 | } |
1036 | EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow); | 1033 | EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow); |
1037 | 1034 | ||
@@ -1067,10 +1064,7 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi *fl, | |||
1067 | if (can_sleep) | 1064 | if (can_sleep) |
1068 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; | 1065 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; |
1069 | 1066 | ||
1070 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | 1067 | return xfrm_lookup(sock_net(sk), dst, fl, sk, 0); |
1071 | if (err) | ||
1072 | return ERR_PTR(err); | ||
1073 | return dst; | ||
1074 | } | 1068 | } |
1075 | EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow); | 1069 | EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow); |
1076 | 1070 | ||
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 4f4483e697bd..da43038ae18e 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -903,8 +903,14 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, | |||
903 | else { | 903 | else { |
904 | dst = ip6_route_output(net, NULL, fl); | 904 | dst = ip6_route_output(net, NULL, fl); |
905 | 905 | ||
906 | if (dst->error || xfrm_lookup(net, &dst, fl, NULL, 0) < 0) | 906 | if (dst->error) |
907 | goto tx_err_link_failure; | 907 | goto tx_err_link_failure; |
908 | dst = xfrm_lookup(net, dst, fl, NULL, 0); | ||
909 | if (IS_ERR(dst)) { | ||
910 | err = PTR_ERR(dst); | ||
911 | dst = NULL; | ||
912 | goto tx_err_link_failure; | ||
913 | } | ||
908 | } | 914 | } |
909 | 915 | ||
910 | tdev = dst->dev; | 916 | tdev = dst->dev; |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 49f986d626a0..7b27d08ee281 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -1429,7 +1429,12 @@ static void mld_sendpack(struct sk_buff *skb) | |||
1429 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, | 1429 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, |
1430 | skb->dev->ifindex); | 1430 | skb->dev->ifindex); |
1431 | 1431 | ||
1432 | err = xfrm_lookup(net, &dst, &fl, NULL, 0); | 1432 | dst = xfrm_lookup(net, dst, &fl, NULL, 0); |
1433 | err = 0; | ||
1434 | if (IS_ERR(dst)) { | ||
1435 | err = PTR_ERR(dst); | ||
1436 | dst = NULL; | ||
1437 | } | ||
1433 | skb_dst_set(skb, dst); | 1438 | skb_dst_set(skb, dst); |
1434 | if (err) | 1439 | if (err) |
1435 | goto err_out; | 1440 | goto err_out; |
@@ -1796,9 +1801,11 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type) | |||
1796 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, | 1801 | &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, |
1797 | skb->dev->ifindex); | 1802 | skb->dev->ifindex); |
1798 | 1803 | ||
1799 | err = xfrm_lookup(net, &dst, &fl, NULL, 0); | 1804 | dst = xfrm_lookup(net, dst, &fl, NULL, 0); |
1800 | if (err) | 1805 | if (IS_ERR(dst)) { |
1806 | err = PTR_ERR(dst); | ||
1801 | goto err_out; | 1807 | goto err_out; |
1808 | } | ||
1802 | 1809 | ||
1803 | skb_dst_set(skb, dst); | 1810 | skb_dst_set(skb, dst); |
1804 | err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, skb, NULL, skb->dev, | 1811 | err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, skb, NULL, skb->dev, |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 7254ce364006..9360d3be94f0 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -529,8 +529,8 @@ void ndisc_send_skb(struct sk_buff *skb, | |||
529 | return; | 529 | return; |
530 | } | 530 | } |
531 | 531 | ||
532 | err = xfrm_lookup(net, &dst, &fl, NULL, 0); | 532 | dst = xfrm_lookup(net, dst, &fl, NULL, 0); |
533 | if (err < 0) { | 533 | if (IS_ERR(dst)) { |
534 | kfree_skb(skb); | 534 | kfree_skb(skb); |
535 | return; | 535 | return; |
536 | } | 536 | } |
@@ -1542,8 +1542,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
1542 | if (dst == NULL) | 1542 | if (dst == NULL) |
1543 | return; | 1543 | return; |
1544 | 1544 | ||
1545 | err = xfrm_lookup(net, &dst, &fl, NULL, 0); | 1545 | dst = xfrm_lookup(net, dst, &fl, NULL, 0); |
1546 | if (err) | 1546 | if (IS_ERR(dst)) |
1547 | return; | 1547 | return; |
1548 | 1548 | ||
1549 | rt = (struct rt6_info *) dst; | 1549 | rt = (struct rt6_info *) dst; |
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c index 35915e8617f0..8d74116ae27d 100644 --- a/net/ipv6/netfilter.c +++ b/net/ipv6/netfilter.c | |||
@@ -39,7 +39,8 @@ int ip6_route_me_harder(struct sk_buff *skb) | |||
39 | if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && | 39 | if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && |
40 | xfrm_decode_session(skb, &fl, AF_INET6) == 0) { | 40 | xfrm_decode_session(skb, &fl, AF_INET6) == 0) { |
41 | skb_dst_set(skb, NULL); | 41 | skb_dst_set(skb, NULL); |
42 | if (xfrm_lookup(net, &dst, &fl, skb->sk, 0)) | 42 | dst = xfrm_lookup(net, dst, &fl, skb->sk, 0); |
43 | if (IS_ERR(dst)) | ||
43 | return -1; | 44 | return -1; |
44 | skb_dst_set(skb, dst); | 45 | skb_dst_set(skb, dst); |
45 | } | 46 | } |
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index bf998feac14e..91f6a61cefab 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -101,7 +101,8 @@ static void send_reset(struct net *net, struct sk_buff *oldskb) | |||
101 | dst_release(dst); | 101 | dst_release(dst); |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | if (xfrm_lookup(net, &dst, &fl, NULL, 0)) | 104 | dst = xfrm_lookup(net, dst, &fl, NULL, 0); |
105 | if (IS_ERR(dst)) | ||
105 | return; | 106 | return; |
106 | 107 | ||
107 | hh_len = (dst->dev->hard_header_len + 15)&~15; | 108 | hh_len = (dst->dev->hard_header_len + 15)&~15; |