]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - net/ipv4/udp.c
net: Infrastructure for checksum unnecessary conversions
[mirror_ubuntu-zesty-kernel.git] / net / ipv4 / udp.c
index f57c0e4c2326fd1a7d4b85cbdb4304657e5660f8..3549c21fe5f737a3744b6322ea1be33ab9aa46b3 100644 (file)
@@ -99,6 +99,7 @@
 #include <linux/slab.h>
 #include <net/tcp_states.h>
 #include <linux/skbuff.h>
+#include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <net/net_namespace.h>
@@ -224,7 +225,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
                remaining = (high - low) + 1;
 
                rand = prandom_u32();
-               first = (((u64)rand * remaining) >> 32) + low;
+               first = reciprocal_scale(rand, remaining) + low;
                /*
                 * force rand to be an odd multiple of UDP_HTABLE_SIZE
                 */
@@ -448,7 +449,7 @@ begin:
                        }
                } else if (score == badness && reuseport) {
                        matches++;
-                       if (((u64)hash * matches) >> 32 == 0)
+                       if (reciprocal_scale(hash, matches) == 0)
                                result = sk;
                        hash = next_pseudo_random32(hash);
                }
@@ -529,7 +530,7 @@ begin:
                        }
                } else if (score == badness && reuseport) {
                        matches++;
-                       if (((u64)hash * matches) >> 32 == 0)
+                       if (reciprocal_scale(hash, matches) == 0)
                                result = sk;
                        hash = next_pseudo_random32(hash);
                }