Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66626
b: refs/heads/master
c: 768f359
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Oct 10, 2007
1 parent 971c194 commit 033b3d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1a348ccc1047a00507e554826775a3d81f7f3437
refs/heads/master: 768f3591e2b1cc309fd6f10d6579b216026d7817
14 changes: 14 additions & 0 deletions trunk/include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,20 @@ static inline void list_splice_init_rcu(struct list_head *list,
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

/**
* list_for_each_entry_continue_reverse - iterate backwards from the given point
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*
* Start to iterate over list of given type backwards, continuing after
* the current position.
*/
#define list_for_each_entry_continue_reverse(pos, head, member) \
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
prefetch(pos->member.prev), &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))

/**
* list_for_each_entry_from - iterate over list of given type from the current point
* @pos: the type * to use as a loop cursor.
Expand Down
12 changes: 4 additions & 8 deletions trunk/net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static void net_free(struct net *net)
static void cleanup_net(struct work_struct *work)
{
struct pernet_operations *ops;
struct list_head *ptr;
struct net *net;

net = container_of(work, struct net, work);
Expand All @@ -69,8 +68,7 @@ static void cleanup_net(struct work_struct *work)
net_unlock();

/* Run all of the network namespace exit methods */
list_for_each_prev(ptr, &pernet_list) {
ops = list_entry(ptr, struct pernet_operations, list);
list_for_each_entry_reverse(ops, &pernet_list, list) {
if (ops->exit)
ops->exit(net);
}
Expand Down Expand Up @@ -102,16 +100,14 @@ static int setup_net(struct net *net)
{
/* Must be called with net_mutex held */
struct pernet_operations *ops;
struct list_head *ptr;
int error;

memset(net, 0, sizeof(struct net));
atomic_set(&net->count, 1);
atomic_set(&net->use_count, 0);

error = 0;
list_for_each(ptr, &pernet_list) {
ops = list_entry(ptr, struct pernet_operations, list);
list_for_each_entry(ops, &pernet_list, list) {
if (ops->init) {
error = ops->init(net);
if (error < 0)
Expand All @@ -120,12 +116,12 @@ static int setup_net(struct net *net)
}
out:
return error;

out_undo:
/* Walk through the list backwards calling the exit functions
* for the pernet modules whose init functions did not fail.
*/
for (ptr = ptr->prev; ptr != &pernet_list; ptr = ptr->prev) {
ops = list_entry(ptr, struct pernet_operations, list);
list_for_each_entry_continue_reverse(ops, &pernet_list, list) {
if (ops->exit)
ops->exit(net);
}
Expand Down

0 comments on commit 033b3d7

Please sign in to comment.