Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256010
b: refs/heads/master
c: 4e985ad
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Graf authored and David S. Miller committed Jul 1, 2011
1 parent 65b8387 commit ba387c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e77aeb71f04ed236fffe5f347e208c8b0e92d48a
refs/heads/master: 4e985adaa504c1c1a05c8e013777ea0791a17b4d
1 change: 1 addition & 0 deletions trunk/include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct net {
struct list_head dev_base_head;
struct hlist_head *dev_name_head;
struct hlist_head *dev_index_head;
unsigned int dev_base_seq; /* protected by rtnl_mutex */

/* core fib_rules */
struct list_head rules_ops;
Expand Down
10 changes: 10 additions & 0 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ static struct list_head ptype_all __read_mostly; /* Taps */
DEFINE_RWLOCK(dev_base_lock);
EXPORT_SYMBOL(dev_base_lock);

static inline void dev_base_seq_inc(struct net *net)
{
while (++net->dev_base_seq == 0);
}

static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
{
unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
Expand Down Expand Up @@ -237,6 +242,9 @@ static int list_netdevice(struct net_device *dev)
hlist_add_head_rcu(&dev->index_hlist,
dev_index_hash(net, dev->ifindex));
write_unlock_bh(&dev_base_lock);

dev_base_seq_inc(net);

return 0;
}

Expand All @@ -253,6 +261,8 @@ static void unlist_netdevice(struct net_device *dev)
hlist_del_rcu(&dev->name_hlist);
hlist_del_rcu(&dev->index_hlist);
write_unlock_bh(&dev_base_lock);

dev_base_seq_inc(dev_net(dev));
}

/*
Expand Down
1 change: 1 addition & 0 deletions trunk/net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static __net_init int setup_net(struct net *net)

atomic_set(&net->count, 1);
atomic_set(&net->passive, 1);
net->dev_base_seq = 1;

#ifdef NETNS_REFCNT_DEBUG
atomic_set(&net->use_count, 0);
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
s_idx = cb->args[1];

rcu_read_lock();
cb->seq = net->dev_base_seq;

for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
idx = 0;
head = &net->dev_index_head[h];
Expand All @@ -1043,6 +1045,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
cb->nlh->nlmsg_seq, 0,
NLM_F_MULTI) <= 0)
goto out;

nl_dump_check_consistent(cb, nlmsg_hdr(skb));
cont:
idx++;
}
Expand Down

0 comments on commit ba387c2

Please sign in to comment.