aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-09-27 01:20:01 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-28 21:01:11 -0400
commitb6e80c6c8b2de8b581e7521af3e118ea379260f1 (patch)
treeb4e71679677889a1f1ee270ca24bf94c760825ad /net/ipv4
parent80e856e16a145d7f44f613d9f3d903bf459510ca (diff)
[IPV4]: trivial fib_hash.c annotations
hash key and stored netmask are net-endian Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/fib_hash.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 88133b383dc5..107bb6cbb0b3 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -51,7 +51,7 @@ static kmem_cache_t *fn_alias_kmem __read_mostly;
51struct fib_node { 51struct fib_node {
52 struct hlist_node fn_hash; 52 struct hlist_node fn_hash;
53 struct list_head fn_alias; 53 struct list_head fn_alias;
54 u32 fn_key; 54 __be32 fn_key;
55}; 55};
56 56
57struct fn_zone { 57struct fn_zone {
@@ -64,7 +64,7 @@ struct fn_zone {
64#define FZ_HASHMASK(fz) ((fz)->fz_hashmask) 64#define FZ_HASHMASK(fz) ((fz)->fz_hashmask)
65 65
66 int fz_order; /* Zone order */ 66 int fz_order; /* Zone order */
67 u32 fz_mask; 67 __be32 fz_mask;
68#define FZ_MASK(fz) ((fz)->fz_mask) 68#define FZ_MASK(fz) ((fz)->fz_mask)
69}; 69};
70 70
@@ -77,7 +77,7 @@ struct fn_hash {
77 struct fn_zone *fn_zone_list; 77 struct fn_zone *fn_zone_list;
78}; 78};
79 79
80static inline u32 fn_hash(u32 key, struct fn_zone *fz) 80static inline u32 fn_hash(__be32 key, struct fn_zone *fz)
81{ 81{
82 u32 h = ntohl(key)>>(32 - fz->fz_order); 82 u32 h = ntohl(key)>>(32 - fz->fz_order);
83 h ^= (h>>20); 83 h ^= (h>>20);
@@ -87,7 +87,7 @@ static inline u32 fn_hash(u32 key, struct fn_zone *fz)
87 return h; 87 return h;
88} 88}
89 89
90static inline u32 fz_key(u32 dst, struct fn_zone *fz) 90static inline __be32 fz_key(__be32 dst, struct fn_zone *fz)
91{ 91{
92 return dst & FZ_MASK(fz); 92 return dst & FZ_MASK(fz);
93} 93}
@@ -254,7 +254,7 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
254 struct hlist_head *head; 254 struct hlist_head *head;
255 struct hlist_node *node; 255 struct hlist_node *node;
256 struct fib_node *f; 256 struct fib_node *f;
257 u32 k = fz_key(flp->fl4_dst, fz); 257 __be32 k = fz_key(flp->fl4_dst, fz);
258 258
259 head = &fz->fz_hash[fn_hash(k, fz)]; 259 head = &fz->fz_hash[fn_hash(k, fz)];
260 hlist_for_each_entry(f, node, head, fn_hash) { 260 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} 365}
366 366
367/* Return the node in FZ matching KEY. */ 367/* Return the node in FZ matching KEY. */
368static struct fib_node *fib_find_node(struct fn_zone *fz, u32 key) 368static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key)
369{ 369{
370 struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)]; 370 struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)];
371 struct hlist_node *node; 371 struct hlist_node *node;
@@ -387,7 +387,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
387 struct fn_zone *fz; 387 struct fn_zone *fz;
388 struct fib_info *fi; 388 struct fib_info *fi;
389 u8 tos = cfg->fc_tos; 389 u8 tos = cfg->fc_tos;
390 u32 key; 390 __be32 key;
391 int err; 391 int err;
392 392
393 if (cfg->fc_dst_len > 32) 393 if (cfg->fc_dst_len > 32)
@@ -541,7 +541,7 @@ static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg)
541 struct fib_node *f; 541 struct fib_node *f;
542 struct fib_alias *fa, *fa_to_delete; 542 struct fib_alias *fa, *fa_to_delete;
543 struct fn_zone *fz; 543 struct fn_zone *fz;
544 u32 key; 544 __be32 key;
545 545
546 if (cfg->fc_dst_len > 32) 546 if (cfg->fc_dst_len > 32)
547 return -EINVAL; 547 return -EINVAL;
@@ -966,7 +966,7 @@ static void fib_seq_stop(struct seq_file *seq, void *v)
966 read_unlock(&fib_hash_lock); 966 read_unlock(&fib_hash_lock);
967} 967}
968 968
969static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) 969static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
970{ 970{
971 static const unsigned type2flags[RTN_MAX + 1] = { 971 static const unsigned type2flags[RTN_MAX + 1] = {
972 [7] = RTF_REJECT, [8] = RTF_REJECT, 972 [7] = RTF_REJECT, [8] = RTF_REJECT,
@@ -975,7 +975,7 @@ static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi)
975 975
976 if (fi && fi->fib_nh->nh_gw) 976 if (fi && fi->fib_nh->nh_gw)
977 flags |= RTF_GATEWAY; 977 flags |= RTF_GATEWAY;
978 if (mask == 0xFFFFFFFF) 978 if (mask == htonl(0xFFFFFFFF))
979 flags |= RTF_HOST; 979 flags |= RTF_HOST;
980 flags |= RTF_UP; 980 flags |= RTF_UP;
981 return flags; 981 return flags;
@@ -991,7 +991,7 @@ static int fib_seq_show(struct seq_file *seq, void *v)
991{ 991{
992 struct fib_iter_state *iter; 992 struct fib_iter_state *iter;
993 char bf[128]; 993 char bf[128];
994 u32 prefix, mask; 994 __be32 prefix, mask;
995 unsigned flags; 995 unsigned flags;
996 struct fib_node *f; 996 struct fib_node *f;
997 struct fib_alias *fa; 997 struct fib_alias *fa;