Merge branch 'for-3.18-consistent-ops' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / net / ipv4 / route.c
index 7d6f4e021846e63862e782f45ba2b313d8552ae2..2d4ae469b471a4fff941e0dd13d014dfd222f6a8 100644 (file)
@@ -596,12 +596,12 @@ static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash)
 
 static inline u32 fnhe_hashfun(__be32 daddr)
 {
+       static u32 fnhe_hashrnd __read_mostly;
        u32 hval;
 
-       hval = (__force u32) daddr;
-       hval ^= (hval >> 11) ^ (hval >> 22);
-
-       return hval & (FNHE_HASH_SIZE - 1);
+       net_get_random_once(&fnhe_hashrnd, sizeof(fnhe_hashrnd));
+       hval = jhash_1word((__force u32) daddr, fnhe_hashrnd);
+       return hash_32(hval, FNHE_HASH_SHIFT);
 }
 
 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe)
@@ -628,12 +628,12 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 
        spin_lock_bh(&fnhe_lock);
 
-       hash = nh->nh_exceptions;
+       hash = rcu_dereference(nh->nh_exceptions);
        if (!hash) {
                hash = kzalloc(FNHE_HASH_SIZE * sizeof(*hash), GFP_ATOMIC);
                if (!hash)
                        goto out_unlock;
-               nh->nh_exceptions = hash;
+               rcu_assign_pointer(nh->nh_exceptions, hash);
        }
 
        hash += hval;
@@ -746,7 +746,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
        }
 
        n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
-       if (n) {
+       if (!IS_ERR(n)) {
                if (!(n->nud_state & NUD_VALID)) {
                        neigh_event_send(n, NULL);
                } else {
@@ -1242,7 +1242,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
 
 static struct fib_nh_exception *find_exception(struct fib_nh *nh, __be32 daddr)
 {
-       struct fnhe_hash_bucket *hash = nh->nh_exceptions;
+       struct fnhe_hash_bucket *hash = rcu_dereference(nh->nh_exceptions);
        struct fib_nh_exception *fnhe;
        u32 hval;
 
@@ -2265,9 +2265,9 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
                return rt;
 
        if (flp4->flowi4_proto)
-               rt = (struct rtable *) xfrm_lookup(net, &rt->dst,
-                                                  flowi4_to_flowi(flp4),
-                                                  sk, 0);
+               rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst,
+                                                       flowi4_to_flowi(flp4),
+                                                       sk, 0);
 
        return rt;
 }