]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/multipath_wrandom.c
[SK_BUFF] ipmr: Missed one conversion to skb_network_header()
[linux-2.6-omap-h63xx.git] / net / ipv4 / multipath_wrandom.c
index d25ec4ae09e55ca2d9e0eb6d8dbc38de10b7849c..57c50369453934bb238cc5c98ccd873fd40362df 100644 (file)
@@ -15,7 +15,6 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <linux/types.h>
-#include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
@@ -33,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/mroute.h>
 #include <linux/init.h>
+#include <linux/random.h>
 #include <net/ip.h>
 #include <net/protocol.h>
 #include <linux/skbuff.h>
@@ -60,8 +60,8 @@ struct multipath_dest {
        struct list_head        list;
 
        const struct fib_nh     *nh_info;
-       __u32                   netmask;
-       __u32                   network;
+       __be32                  netmask;
+       __be32                  network;
        unsigned char           prefixlen;
 
        struct rcu_head         rcu;
@@ -76,7 +76,7 @@ struct multipath_route {
        struct list_head        list;
 
        int                     oif;
-       __u32                   gw;
+       __be32                  gw;
        struct list_head        dests;
 
        struct rcu_head         rcu;
@@ -85,18 +85,6 @@ struct multipath_route {
 /* state: primarily weight per route information */
 static struct multipath_bucket state[MULTIPATH_STATE_SIZE];
 
-/* interface to random number generation */
-static unsigned int RANDOM_SEED = 93186752;
-
-static inline unsigned int random(unsigned int ubound)
-{
-       static unsigned int a = 1588635695,
-               q = 2,
-               r = 1117695901;
-       RANDOM_SEED = a*(RANDOM_SEED % q) - r*(RANDOM_SEED / q);
-       return RANDOM_SEED % ubound;
-}
-
 static unsigned char __multipath_lookup_weight(const struct flowi *fl,
                                               const struct rtable *rt)
 {
@@ -128,8 +116,8 @@ static unsigned char __multipath_lookup_weight(const struct flowi *fl,
 
        /* find state entry for destination */
        list_for_each_entry_rcu(d, &target_route->dests, list) {
-               __u32 targetnetwork = fl->fl4_dst & 
-                       (0xFFFFFFFF >> (32 - d->prefixlen));
+               __be32 targetnetwork = fl->fl4_dst &
+                       inet_make_mask(d->prefixlen);
 
                if ((targetnetwork & d->netmask) == d->network) {
                        weight = d->nh_info->nh_weight;
@@ -142,7 +130,7 @@ out:
        return weight;
 }
 
-static void wrandom_init_state(void) 
+static void wrandom_init_state(void)
 {
        int i;
 
@@ -167,7 +155,7 @@ static void wrandom_select_route(const struct flowi *flp,
 
        /* collect all candidates and identify their weights */
        for (rt = rcu_dereference(first); rt;
-            rt = rcu_dereference(rt->u.rt_next)) {
+            rt = rcu_dereference(rt->u.dst.rt_next)) {
                if ((rt->u.dst.flags & DST_BALANCED) != 0 &&
                    multipath_comparekeys(&rt->fl, flp)) {
                        struct multipath_candidate* mpc =
@@ -194,7 +182,7 @@ static void wrandom_select_route(const struct flowi *flp,
 
        /* choose a weighted random candidate */
        decision = first;
-       selector = random(power);
+       selector = random32() % power;
        last_power = 0;
 
        /* select candidate, adjust GC data and cleanup local state */
@@ -217,8 +205,8 @@ static void wrandom_select_route(const struct flowi *flp,
        *rp = decision;
 }
 
-static void wrandom_set_nhinfo(__u32 network,
-                              __u32 netmask,
+static void wrandom_set_nhinfo(__be32 network,
+                              __be32 netmask,
                               unsigned char prefixlen,
                               const struct fib_nh *nh)
 {
@@ -287,7 +275,7 @@ static void __multipath_free(struct rcu_head *head)
 
 static void __multipath_free_dst(struct rcu_head *head)
 {
-       struct multipath_dest *dst = container_of(head,
+       struct multipath_dest *dst = container_of(head,
                                                  struct multipath_dest,
                                                  rcu);
        kfree(dst);