diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-01 16:19:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-01 16:19:07 -0500 |
commit | 68d0c6d34d586a893292d4fb633a3bf8c547b222 (patch) | |
tree | b6d812307621873cf16000171563c1f68b5bc255 /net/ipv6/inet6_connection_sock.c | |
parent | 903ab86d195cca295379699299c5fc10beba31c7 (diff) |
ipv6: Consolidate route lookup sequences.
Route lookups follow a general pattern in the ipv6 code wherein
we first find the non-IPSEC route, potentially override the
flow destination address due to ipv6 options settings, and then
finally make an IPSEC search using either xfrm_lookup() or
__xfrm_lookup().
__xfrm_lookup() is used when we want to generate a blackhole route
if the key manager needs to resolve the IPSEC rules (in this case
-EREMOTE is returned and the original 'dst' is left unchanged).
Otherwise plain xfrm_lookup() is used and when asynchronous IPSEC
resolution is necessary, we simply fail the lookup completely.
All of these cases are encapsulated into two routines,
ip6_dst_lookup_flow and ip6_sk_dst_lookup_flow. The latter of which
handles unconnected UDP datagram sockets.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/inet6_connection_sock.c')
-rw-r--r-- | net/ipv6/inet6_connection_sock.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index d144e629d2b4..d687e1397333 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c | |||
@@ -74,13 +74,8 @@ struct dst_entry *inet6_csk_route_req(struct sock *sk, | |||
74 | fl.fl_ip_sport = inet_rsk(req)->loc_port; | 74 | fl.fl_ip_sport = inet_rsk(req)->loc_port; |
75 | security_req_classify_flow(req, &fl); | 75 | security_req_classify_flow(req, &fl); |
76 | 76 | ||
77 | if (ip6_dst_lookup(sk, &dst, &fl)) | 77 | dst = ip6_dst_lookup_flow(sk, &fl, final_p, false); |
78 | return NULL; | 78 | if (IS_ERR(dst)) |
79 | |||
80 | if (final_p) | ||
81 | ipv6_addr_copy(&fl.fl6_dst, final_p); | ||
82 | |||
83 | if ((xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) | ||
84 | return NULL; | 79 | return NULL; |
85 | 80 | ||
86 | return dst; | 81 | return dst; |
@@ -234,21 +229,13 @@ int inet6_csk_xmit(struct sk_buff *skb) | |||
234 | dst = __inet6_csk_dst_check(sk, np->dst_cookie); | 229 | dst = __inet6_csk_dst_check(sk, np->dst_cookie); |
235 | 230 | ||
236 | if (dst == NULL) { | 231 | if (dst == NULL) { |
237 | int err = ip6_dst_lookup(sk, &dst, &fl); | 232 | dst = ip6_dst_lookup_flow(sk, &fl, final_p, false); |
238 | |||
239 | if (err) { | ||
240 | sk->sk_err_soft = -err; | ||
241 | kfree_skb(skb); | ||
242 | return err; | ||
243 | } | ||
244 | |||
245 | if (final_p) | ||
246 | ipv6_addr_copy(&fl.fl6_dst, final_p); | ||
247 | 233 | ||
248 | if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0) { | 234 | if (IS_ERR(dst)) { |
235 | sk->sk_err_soft = -PTR_ERR(dst); | ||
249 | sk->sk_route_caps = 0; | 236 | sk->sk_route_caps = 0; |
250 | kfree_skb(skb); | 237 | kfree_skb(skb); |
251 | return err; | 238 | return PTR_ERR(dst); |
252 | } | 239 | } |
253 | 240 | ||
254 | __inet6_csk_dst_store(sk, dst, NULL, NULL); | 241 | __inet6_csk_dst_store(sk, dst, NULL, NULL); |