aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-01 17:59:04 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-01 17:59:04 -0500
commit2774c131b1d19920b4587db1cfbd6f0750ad1f15 (patch)
tree3a0482c727cf4dcc046a211214f12459dcba8271 /net/ipv4
parent69ead7afdf6028184f713a77376ee26f8aaafdcd (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/ipv4')
-rw-r--r--net/ipv4/route.c20
-rw-r--r--net/ipv4/xfrm4_policy.c1
2 files changed, 8 insertions, 13 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 23d205043d92..e24e4cf2a112 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2675,12 +2675,10 @@ static struct dst_ops ipv4_dst_blackhole_ops = {
2675 .update_pmtu = ipv4_rt_blackhole_update_pmtu, 2675 .update_pmtu = ipv4_rt_blackhole_update_pmtu,
2676}; 2676};
2677 2677
2678 2678struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig)
2679static int ipv4_dst_blackhole(struct net *net, struct rtable **rp, struct flowi *flp)
2680{ 2679{
2681 struct rtable *ort = *rp; 2680 struct rtable *rt = dst_alloc(&ipv4_dst_blackhole_ops, 1);
2682 struct rtable *rt = (struct rtable *) 2681 struct rtable *ort = (struct rtable *) dst_orig;
2683 dst_alloc(&ipv4_dst_blackhole_ops, 1);
2684 2682
2685 if (rt) { 2683 if (rt) {
2686 struct dst_entry *new = &rt->dst; 2684 struct dst_entry *new = &rt->dst;
@@ -2714,9 +2712,9 @@ static int ipv4_dst_blackhole(struct net *net, struct rtable **rp, struct flowi
2714 dst_free(new); 2712 dst_free(new);
2715 } 2713 }
2716 2714
2717 dst_release(&(*rp)->dst); 2715 dst_release(dst_orig);
2718 *rp = rt; 2716
2719 return rt ? 0 : -ENOMEM; 2717 return rt ? &rt->dst : ERR_PTR(-ENOMEM);
2720} 2718}
2721 2719
2722int ip_route_output_flow(struct net *net, struct rtable **rp, struct flowi *flp, 2720int ip_route_output_flow(struct net *net, struct rtable **rp, struct flowi *flp,
@@ -2732,11 +2730,7 @@ int ip_route_output_flow(struct net *net, struct rtable **rp, struct flowi *flp,
2732 flp->fl4_src = (*rp)->rt_src; 2730 flp->fl4_src = (*rp)->rt_src;
2733 if (!flp->fl4_dst) 2731 if (!flp->fl4_dst)
2734 flp->fl4_dst = (*rp)->rt_dst; 2732 flp->fl4_dst = (*rp)->rt_dst;
2735 err = __xfrm_lookup(net, (struct dst_entry **)rp, flp, sk, 0); 2733 return xfrm_lookup(net, (struct dst_entry **)rp, flp, sk, 0);
2736 if (err == -EREMOTE)
2737 err = ipv4_dst_blackhole(net, rp, flp);
2738
2739 return err;
2740 } 2734 }
2741 2735
2742 return 0; 2736 return 0;
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 63aa88efdcef..5f0f058dc376 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -234,6 +234,7 @@ static struct xfrm_policy_afinfo xfrm4_policy_afinfo = {
234 .get_tos = xfrm4_get_tos, 234 .get_tos = xfrm4_get_tos,
235 .init_path = xfrm4_init_path, 235 .init_path = xfrm4_init_path,
236 .fill_dst = xfrm4_fill_dst, 236 .fill_dst = xfrm4_fill_dst,
237 .blackhole_route = ipv4_blackhole_route,
237}; 238};
238 239
239#ifdef CONFIG_SYSCTL 240#ifdef CONFIG_SYSCTL