aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv6/route.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 98c523f4a3c3..c91083156edb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -917,31 +917,40 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort,
917static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif, 917static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif,
918 struct flowi6 *fl6, int flags) 918 struct flowi6 *fl6, int flags)
919{ 919{
920 struct fib6_node *fn; 920 struct fib6_node *fn, *saved_fn;
921 struct rt6_info *rt, *nrt; 921 struct rt6_info *rt, *nrt;
922 int strict = 0; 922 int strict = 0;
923 int attempts = 3; 923 int attempts = 3;
924 int err; 924 int err;
925 int reachable = net->ipv6.devconf_all->forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
926 925
927 strict |= flags & RT6_LOOKUP_F_IFACE; 926 strict |= flags & RT6_LOOKUP_F_IFACE;
927 if (net->ipv6.devconf_all->forwarding == 0)
928 strict |= RT6_LOOKUP_F_REACHABLE;
928 929
929redo_fib6_lookup_lock: 930redo_fib6_lookup_lock:
930 read_lock_bh(&table->tb6_lock); 931 read_lock_bh(&table->tb6_lock);
931 932
932redo_fib6_lookup:
933 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); 933 fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
934 saved_fn = fn;
934 935
935redo_rt6_select: 936redo_rt6_select:
936 rt = rt6_select(fn, oif, strict | reachable); 937 rt = rt6_select(fn, oif, strict);
937 if (rt->rt6i_nsiblings) 938 if (rt->rt6i_nsiblings)
938 rt = rt6_multipath_select(rt, fl6, oif, strict | reachable); 939 rt = rt6_multipath_select(rt, fl6, oif, strict);
939 if (rt == net->ipv6.ip6_null_entry) { 940 if (rt == net->ipv6.ip6_null_entry) {
940 fn = fib6_backtrack(fn, &fl6->saddr); 941 fn = fib6_backtrack(fn, &fl6->saddr);
941 if (fn) 942 if (fn)
942 goto redo_rt6_select; 943 goto redo_rt6_select;
943 else 944 else if (strict & RT6_LOOKUP_F_REACHABLE) {
944 goto out; 945 /* also consider unreachable route */
946 strict &= ~RT6_LOOKUP_F_REACHABLE;
947 fn = saved_fn;
948 goto redo_rt6_select;
949 } else {
950 dst_hold(&rt->dst);
951 read_unlock_bh(&table->tb6_lock);
952 goto out2;
953 }
945 } 954 }
946 955
947 dst_hold(&rt->dst); 956 dst_hold(&rt->dst);
@@ -977,13 +986,6 @@ redo_rt6_select:
977 ip6_rt_put(rt); 986 ip6_rt_put(rt);
978 goto redo_fib6_lookup_lock; 987 goto redo_fib6_lookup_lock;
979 988
980out:
981 if (reachable) {
982 reachable = 0;
983 goto redo_fib6_lookup;
984 }
985 dst_hold(&rt->dst);
986 read_unlock_bh(&table->tb6_lock);
987out2: 989out2:
988 rt->dst.lastuse = jiffies; 990 rt->dst.lastuse = jiffies;
989 rt->dst.__use++; 991 rt->dst.__use++;