aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorMartin KaFai Lau <kafai@fb.com>2014-10-20 16:42:45 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-24 00:14:39 -0400
commit367efcb932c1cfc134d5b1fd9db8665ae5e6a251 (patch)
tree81a13422d8797e22e2009d5e445f3dc30237db02 /net/ipv6
parent94c77bb41d871deb848e5011aacb5d7c24358ddd (diff)
ipv6: Avoid redoing fib6_lookup() with reachable = 0 by saving fn
This patch save the fn before doing rt6_backtrack. Hence, without redo-ing the fib6_lookup(), saved_fn can be used to redo rt6_select() with RT6_LOOKUP_F_REACHABLE off. Some minor changes I think make sense to review as a single patch: * Remove the 'out:' goto label. * Remove the 'reachable' variable. Only use the 'strict' variable instead. After this patch, "failing ip6_ins_rt()" should be the only case that requires a redo of fib6_lookup(). Cc: David Miller <davem@davemloft.net> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-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++;