Commit b6e80c6c authored by Al Viro's avatar Al Viro Committed by David S. Miller

[IPV4]: trivial fib_hash.c annotations

hash key and stored netmask are net-endian
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 80e856e1
...@@ -51,7 +51,7 @@ static kmem_cache_t *fn_alias_kmem __read_mostly; ...@@ -51,7 +51,7 @@ static kmem_cache_t *fn_alias_kmem __read_mostly;
struct fib_node { struct fib_node {
struct hlist_node fn_hash; struct hlist_node fn_hash;
struct list_head fn_alias; struct list_head fn_alias;
u32 fn_key; __be32 fn_key;
}; };
struct fn_zone { struct fn_zone {
...@@ -64,7 +64,7 @@ struct fn_zone { ...@@ -64,7 +64,7 @@ struct fn_zone {
#define FZ_HASHMASK(fz) ((fz)->fz_hashmask) #define FZ_HASHMASK(fz) ((fz)->fz_hashmask)
int fz_order; /* Zone order */ int fz_order; /* Zone order */
u32 fz_mask; __be32 fz_mask;
#define FZ_MASK(fz) ((fz)->fz_mask) #define FZ_MASK(fz) ((fz)->fz_mask)
}; };
...@@ -77,7 +77,7 @@ struct fn_hash { ...@@ -77,7 +77,7 @@ struct fn_hash {
struct fn_zone *fn_zone_list; struct fn_zone *fn_zone_list;
}; };
static inline u32 fn_hash(u32 key, struct fn_zone *fz) static inline u32 fn_hash(__be32 key, struct fn_zone *fz)
{ {
u32 h = ntohl(key)>>(32 - fz->fz_order); u32 h = ntohl(key)>>(32 - fz->fz_order);
h ^= (h>>20); h ^= (h>>20);
...@@ -87,7 +87,7 @@ static inline u32 fn_hash(u32 key, struct fn_zone *fz) ...@@ -87,7 +87,7 @@ static inline u32 fn_hash(u32 key, struct fn_zone *fz)
return h; return h;
} }
static inline u32 fz_key(u32 dst, struct fn_zone *fz) static inline __be32 fz_key(__be32 dst, struct fn_zone *fz)
{ {
return dst & FZ_MASK(fz); return dst & FZ_MASK(fz);
} }
...@@ -254,7 +254,7 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result ...@@ -254,7 +254,7 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
struct hlist_head *head; struct hlist_head *head;
struct hlist_node *node; struct hlist_node *node;
struct fib_node *f; struct fib_node *f;
u32 k = fz_key(flp->fl4_dst, fz); __be32 k = fz_key(flp->fl4_dst, fz);
head = &fz->fz_hash[fn_hash(k, fz)]; head = &fz->fz_hash[fn_hash(k, fz)];
hlist_for_each_entry(f, node, head, fn_hash) { hlist_for_each_entry(f, node, head, fn_hash) {
...@@ -365,7 +365,7 @@ static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f) ...@@ -365,7 +365,7 @@ static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f)
} }
/* Return the node in FZ matching KEY. */ /* Return the node in FZ matching KEY. */
static struct fib_node *fib_find_node(struct fn_zone *fz, u32 key) static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key)
{ {
struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)]; struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)];
struct hlist_node *node; struct hlist_node *node;
...@@ -387,7 +387,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -387,7 +387,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
struct fn_zone *fz; struct fn_zone *fz;
struct fib_info *fi; struct fib_info *fi;
u8 tos = cfg->fc_tos; u8 tos = cfg->fc_tos;
u32 key; __be32 key;
int err; int err;
if (cfg->fc_dst_len > 32) if (cfg->fc_dst_len > 32)
...@@ -541,7 +541,7 @@ static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg) ...@@ -541,7 +541,7 @@ static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg)
struct fib_node *f; struct fib_node *f;
struct fib_alias *fa, *fa_to_delete; struct fib_alias *fa, *fa_to_delete;
struct fn_zone *fz; struct fn_zone *fz;
u32 key; __be32 key;
if (cfg->fc_dst_len > 32) if (cfg->fc_dst_len > 32)
return -EINVAL; return -EINVAL;
...@@ -966,7 +966,7 @@ static void fib_seq_stop(struct seq_file *seq, void *v) ...@@ -966,7 +966,7 @@ static void fib_seq_stop(struct seq_file *seq, void *v)
read_unlock(&fib_hash_lock); read_unlock(&fib_hash_lock);
} }
static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
{ {
static const unsigned type2flags[RTN_MAX + 1] = { static const unsigned type2flags[RTN_MAX + 1] = {
[7] = RTF_REJECT, [8] = RTF_REJECT, [7] = RTF_REJECT, [8] = RTF_REJECT,
...@@ -975,7 +975,7 @@ static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) ...@@ -975,7 +975,7 @@ static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi)
if (fi && fi->fib_nh->nh_gw) if (fi && fi->fib_nh->nh_gw)
flags |= RTF_GATEWAY; flags |= RTF_GATEWAY;
if (mask == 0xFFFFFFFF) if (mask == htonl(0xFFFFFFFF))
flags |= RTF_HOST; flags |= RTF_HOST;
flags |= RTF_UP; flags |= RTF_UP;
return flags; return flags;
...@@ -991,7 +991,7 @@ static int fib_seq_show(struct seq_file *seq, void *v) ...@@ -991,7 +991,7 @@ static int fib_seq_show(struct seq_file *seq, void *v)
{ {
struct fib_iter_state *iter; struct fib_iter_state *iter;
char bf[128]; char bf[128];
u32 prefix, mask; __be32 prefix, mask;
unsigned flags; unsigned flags;
struct fib_node *f; struct fib_node *f;
struct fib_alias *fa; struct fib_alias *fa;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment