Commit 5c45fd0f authored by David S. Miller's avatar David S. Miller

[IPV4]: Use list.h facilities for fib_info_list.

Do not use a by-hand list implementation.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2546ee7a
...@@ -62,8 +62,7 @@ struct fib_nh ...@@ -62,8 +62,7 @@ struct fib_nh
struct fib_info struct fib_info
{ {
struct fib_info *fib_next; struct list_head fib_list;
struct fib_info *fib_prev;
int fib_treeref; int fib_treeref;
atomic_t fib_clntref; atomic_t fib_clntref;
int fib_dead; int fib_dead;
......
...@@ -45,12 +45,12 @@ ...@@ -45,12 +45,12 @@
#define FSprintk(a...) #define FSprintk(a...)
static struct fib_info *fib_info_list; static struct list_head fib_info_list = LIST_HEAD_INIT(fib_info_list);
static rwlock_t fib_info_lock = RW_LOCK_UNLOCKED; static rwlock_t fib_info_lock = RW_LOCK_UNLOCKED;
int fib_info_cnt; int fib_info_cnt;
#define for_fib_info() { struct fib_info *fi; \ #define for_fib_info() { struct fib_info *fi; \
for (fi = fib_info_list; fi; fi = fi->fib_next) list_for_each_entry(fi, &fib_info_list, fib_list)
#define endfor_fib_info() } #define endfor_fib_info() }
...@@ -156,12 +156,7 @@ void fib_release_info(struct fib_info *fi) ...@@ -156,12 +156,7 @@ void fib_release_info(struct fib_info *fi)
{ {
write_lock(&fib_info_lock); write_lock(&fib_info_lock);
if (fi && --fi->fib_treeref == 0) { if (fi && --fi->fib_treeref == 0) {
if (fi->fib_next) list_del(&fi->fib_list);
fi->fib_next->fib_prev = fi->fib_prev;
if (fi->fib_prev)
fi->fib_prev->fib_next = fi->fib_next;
if (fi == fib_info_list)
fib_info_list = fi->fib_next;
fi->fib_dead = 1; fi->fib_dead = 1;
fib_info_put(fi); fib_info_put(fi);
} }
...@@ -581,11 +576,7 @@ fib_create_info(const struct rtmsg *r, struct kern_rta *rta, ...@@ -581,11 +576,7 @@ fib_create_info(const struct rtmsg *r, struct kern_rta *rta,
fi->fib_treeref++; fi->fib_treeref++;
atomic_inc(&fi->fib_clntref); atomic_inc(&fi->fib_clntref);
write_lock(&fib_info_lock); write_lock(&fib_info_lock);
fi->fib_next = fib_info_list; list_add(&fi->fib_list, &fib_info_list);
fi->fib_prev = NULL;
if (fib_info_list)
fib_info_list->fib_prev = fi;
fib_info_list = fi;
write_unlock(&fib_info_lock); write_unlock(&fib_info_lock);
return fi; return fi;
......
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