]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - net/ipv4/route.c
net: ipv4: Fix NULL pointer dereference in route lookup
[thirdparty/kernel/stable.git] / net / ipv4 / route.c
index 16259ea9df54973e6f5290afd1a415e7de71d5e1..e3ac458b5d8be26af72a313225bcf1cef00fb605 100644 (file)
@@ -887,13 +887,15 @@ void ip_rt_send_redirect(struct sk_buff *skb)
        /* No redirected packets during ip_rt_redirect_silence;
         * reset the algorithm.
         */
-       if (time_after(jiffies, peer->rate_last + ip_rt_redirect_silence))
+       if (time_after(jiffies, peer->rate_last + ip_rt_redirect_silence)) {
                peer->rate_tokens = 0;
+               peer->n_redirects = 0;
+       }
 
        /* Too many ignored redirects; do not send anything
         * set dst.rate_last to the last seen redirected packet.
         */
-       if (peer->rate_tokens >= ip_rt_redirect_number) {
+       if (peer->n_redirects >= ip_rt_redirect_number) {
                peer->rate_last = jiffies;
                goto out_put_peer;
        }
@@ -910,6 +912,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
                icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, gw);
                peer->rate_last = jiffies;
                ++peer->rate_tokens;
+               ++peer->n_redirects;
 #ifdef CONFIG_IP_ROUTE_VERBOSE
                if (log_martians &&
                    peer->rate_tokens == ip_rt_redirect_number)
@@ -1817,6 +1820,7 @@ out:
 int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
                       const struct sk_buff *skb, struct flow_keys *flkeys)
 {
+       u32 multipath_hash = fl4 ? fl4->flowi4_multipath_hash : 0;
        struct flow_keys hash_keys;
        u32 mhash;
 
@@ -1867,6 +1871,9 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
        }
        mhash = flow_hash_from_keys(&hash_keys);
 
+       if (multipath_hash)
+               mhash = jhash_2words(mhash, multipath_hash, 0);
+
        return mhash >> 1;
 }
 #endif /* CONFIG_IP_ROUTE_MULTIPATH */