diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-01 17:59:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-01 17:59:04 -0500 |
commit | 2774c131b1d19920b4587db1cfbd6f0750ad1f15 (patch) | |
tree | 3a0482c727cf4dcc046a211214f12459dcba8271 /net/ipv6 | |
parent | 69ead7afdf6028184f713a77376ee26f8aaafdcd (diff) |
xfrm: Handle blackhole route creation via afinfo.
That way we don't have to potentially do this in every xfrm_lookup()
caller.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_output.c | 32 | ||||
-rw-r--r-- | net/ipv6/route.c | 3 | ||||
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 1 |
3 files changed, 12 insertions, 24 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index ac16f3b2a029..35a4ad90a0f5 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1025,18 +1025,12 @@ struct dst_entry *ip6_dst_lookup_flow(struct sock *sk, struct flowi *fl, | |||
1025 | return ERR_PTR(err); | 1025 | return ERR_PTR(err); |
1026 | if (final_dst) | 1026 | if (final_dst) |
1027 | ipv6_addr_copy(&fl->fl6_dst, final_dst); | 1027 | ipv6_addr_copy(&fl->fl6_dst, final_dst); |
1028 | if (can_sleep) { | 1028 | if (can_sleep) |
1029 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; | 1029 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; |
1030 | err = __xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | 1030 | |
1031 | if (err == -EREMOTE) | 1031 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); |
1032 | return ip6_dst_blackhole(sock_net(sk), dst); | 1032 | if (err) |
1033 | if (err) | 1033 | return ERR_PTR(err); |
1034 | return ERR_PTR(err); | ||
1035 | } else { | ||
1036 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | ||
1037 | if (err) | ||
1038 | return ERR_PTR(err); | ||
1039 | } | ||
1040 | return dst; | 1034 | return dst; |
1041 | } | 1035 | } |
1042 | EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow); | 1036 | EXPORT_SYMBOL_GPL(ip6_dst_lookup_flow); |
@@ -1070,18 +1064,12 @@ struct dst_entry *ip6_sk_dst_lookup_flow(struct sock *sk, struct flowi *fl, | |||
1070 | return ERR_PTR(err); | 1064 | return ERR_PTR(err); |
1071 | if (final_dst) | 1065 | if (final_dst) |
1072 | ipv6_addr_copy(&fl->fl6_dst, final_dst); | 1066 | ipv6_addr_copy(&fl->fl6_dst, final_dst); |
1073 | if (can_sleep) { | 1067 | if (can_sleep) |
1074 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; | 1068 | fl->flags |= FLOWI_FLAG_CAN_SLEEP; |
1075 | err = __xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | 1069 | |
1076 | if (err == -EREMOTE) | 1070 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); |
1077 | return ip6_dst_blackhole(sock_net(sk), dst); | 1071 | if (err) |
1078 | if (err) | 1072 | return ERR_PTR(err); |
1079 | return ERR_PTR(err); | ||
1080 | } else { | ||
1081 | err = xfrm_lookup(sock_net(sk), &dst, fl, sk, 0); | ||
1082 | if (err) | ||
1083 | return ERR_PTR(err); | ||
1084 | } | ||
1085 | return dst; | 1073 | return dst; |
1086 | } | 1074 | } |
1087 | EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow); | 1075 | EXPORT_SYMBOL_GPL(ip6_sk_dst_lookup_flow); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index cf6fdeabb6f2..053a92ebf2d5 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -870,7 +870,7 @@ struct dst_entry * ip6_route_output(struct net *net, struct sock *sk, | |||
870 | 870 | ||
871 | EXPORT_SYMBOL(ip6_route_output); | 871 | EXPORT_SYMBOL(ip6_route_output); |
872 | 872 | ||
873 | struct dst_entry *ip6_dst_blackhole(struct net *net, struct dst_entry *dst_orig) | 873 | struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig) |
874 | { | 874 | { |
875 | struct rt6_info *rt = dst_alloc(&ip6_dst_blackhole_ops, 1); | 875 | struct rt6_info *rt = dst_alloc(&ip6_dst_blackhole_ops, 1); |
876 | struct rt6_info *ort = (struct rt6_info *) dst_orig; | 876 | struct rt6_info *ort = (struct rt6_info *) dst_orig; |
@@ -907,7 +907,6 @@ struct dst_entry *ip6_dst_blackhole(struct net *net, struct dst_entry *dst_orig) | |||
907 | dst_release(dst_orig); | 907 | dst_release(dst_orig); |
908 | return new ? new : ERR_PTR(-ENOMEM); | 908 | return new ? new : ERR_PTR(-ENOMEM); |
909 | } | 909 | } |
910 | EXPORT_SYMBOL_GPL(ip6_dst_blackhole); | ||
911 | 910 | ||
912 | /* | 911 | /* |
913 | * Destination cache support functions | 912 | * Destination cache support functions |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index c128ca1affe3..48ce496802fd 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -274,6 +274,7 @@ static struct xfrm_policy_afinfo xfrm6_policy_afinfo = { | |||
274 | .get_tos = xfrm6_get_tos, | 274 | .get_tos = xfrm6_get_tos, |
275 | .init_path = xfrm6_init_path, | 275 | .init_path = xfrm6_init_path, |
276 | .fill_dst = xfrm6_fill_dst, | 276 | .fill_dst = xfrm6_fill_dst, |
277 | .blackhole_route = ip6_blackhole_route, | ||
277 | }; | 278 | }; |
278 | 279 | ||
279 | static int __init xfrm6_policy_init(void) | 280 | static int __init xfrm6_policy_init(void) |