linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / decnet / dn_table.c
index e926c95..6f8b565 100644 (file)
@@ -12,6 +12,7 @@
  * Changes:
  *
  */
+#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/net.h>
 #include <linux/socket.h>
@@ -45,7 +46,7 @@ struct dn_zone
        u32                     dz_hashmask;
 #define DZ_HASHMASK(dz)        ((dz)->dz_hashmask)
        int                     dz_order;
-       __le16                  dz_mask;
+       u16                     dz_mask;
 #define DZ_MASK(dz)    ((dz)->dz_mask)
 };
 
@@ -83,14 +84,14 @@ static int dn_fib_hash_zombies;
 
 static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz)
 {
-       u16 h = dn_ntohs(key.datum)>>(16 - dz->dz_order);
+       u16 h = ntohs(key.datum)>>(16 - dz->dz_order);
        h ^= (h >> 10);
        h ^= (h >> 6);
        h &= DZ_HASHMASK(dz);
        return *(dn_fib_idx_t *)&h;
 }
 
-static inline dn_fib_key_t dz_key(__le16 dst, struct dn_zone *dz)
+static inline dn_fib_key_t dz_key(u16 dst, struct dn_zone *dz)
 {
        dn_fib_key_t k;
        k.datum = dst & DZ_MASK(dz);
@@ -158,10 +159,12 @@ static void dn_rehash_zone(struct dn_zone *dz)
                        break;
        }
 
-       ht = kcalloc(new_divisor, sizeof(struct dn_fib_node*), GFP_KERNEL);
+       ht = kmalloc(new_divisor*sizeof(struct dn_fib_node*), GFP_KERNEL);
+
        if (ht == NULL)
                return;
 
+       memset(ht, 0, new_divisor*sizeof(struct dn_fib_node *));
        write_lock_bh(&dn_fib_tables_lock);
        old_ht = dz->dz_hash;
        dz->dz_hash = ht;
@@ -182,10 +185,11 @@ static void dn_free_node(struct dn_fib_node *f)
 static struct dn_zone *dn_new_zone(struct dn_hash *table, int z)
 {
        int i;
-       struct dn_zone *dz = kzalloc(sizeof(struct dn_zone), GFP_KERNEL);
+       struct dn_zone *dz = kmalloc(sizeof(struct dn_zone), GFP_KERNEL);
        if (!dz)
                return NULL;
 
+       memset(dz, 0, sizeof(struct dn_zone));
        if (z) {
                dz->dz_divisor = 16;
                dz->dz_hashmask = 0x0F;
@@ -194,12 +198,14 @@ static struct dn_zone *dn_new_zone(struct dn_hash *table, int z)
                dz->dz_hashmask = 0;
        }
 
-       dz->dz_hash = kcalloc(dz->dz_divisor, sizeof(struct dn_fib_node *), GFP_KERNEL);
+       dz->dz_hash = kmalloc(dz->dz_divisor*sizeof(struct dn_fib_node *), GFP_KERNEL);
+
        if (!dz->dz_hash) {
                kfree(dz);
                return NULL;
        }
 
+       memset(dz->dz_hash, 0, dz->dz_divisor*sizeof(struct dn_fib_node*));
        dz->dz_order = z;
        dz->dz_mask = dnet_make_mask(z);
 
@@ -244,7 +250,7 @@ static int dn_fib_nh_match(struct rtmsg *r, struct nlmsghdr *nlh, struct dn_kern
 
        for_nexthops(fi) {
                int attrlen = nhlen - sizeof(struct rtnexthop);
-               __le16 gw;
+               dn_address gw;
 
                if (attrlen < 0 || (nhlen -= nhp->rtnh_len) < 0)
                        return -EINVAL;
@@ -451,7 +457,7 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
 
        dz_key_0(key);
        if (rta->rta_dst) {
-               __le16 dst;
+               dn_address dst;
                memcpy(&dst, rta->rta_dst, 2);
                if (dst & ~DZ_MASK(dz))
                        return -EINVAL;
@@ -587,7 +593,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
 
        dz_key_0(key);
        if (rta->rta_dst) {
-               __le16 dst;
+               dn_address dst;
                memcpy(&dst, rta->rta_dst, 2);
                if (dst & ~DZ_MASK(dz))
                        return -EINVAL;