Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66603
b: refs/heads/master
c: 30d97d3
h: refs/heads/master
i:
  66601: d98337c
  66599: e64c3ed
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Oct 10, 2007
1 parent fc142f4 commit 21440b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 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: ad7379d49458a863c520a73a3c36441c572f850e
refs/heads/master: 30d97d35851f40fd1c108d1b8904aca3c38d0126
41 changes: 24 additions & 17 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4268,32 +4268,39 @@ int netdev_compute_features(unsigned long all, unsigned long one)
}
EXPORT_SYMBOL(netdev_compute_features);

static struct hlist_head *netdev_create_hash(void)
{
int i;
struct hlist_head *hash;

hash = kmalloc(sizeof(*hash) * NETDEV_HASHENTRIES, GFP_KERNEL);
if (hash != NULL)
for (i = 0; i < NETDEV_HASHENTRIES; i++)
INIT_HLIST_HEAD(&hash[i]);

return hash;
}

/* Initialize per network namespace state */
static int netdev_init(struct net *net)
{
int i;
INIT_LIST_HEAD(&net->dev_base_head);
rwlock_init(&dev_base_lock);

net->dev_name_head = kmalloc(
sizeof(*net->dev_name_head)*NETDEV_HASHENTRIES, GFP_KERNEL);
if (!net->dev_name_head)
return -ENOMEM;

net->dev_index_head = kmalloc(
sizeof(*net->dev_index_head)*NETDEV_HASHENTRIES, GFP_KERNEL);
if (!net->dev_index_head) {
kfree(net->dev_name_head);
return -ENOMEM;
}
net->dev_name_head = netdev_create_hash();
if (net->dev_name_head == NULL)
goto err_name;

for (i = 0; i < NETDEV_HASHENTRIES; i++)
INIT_HLIST_HEAD(&net->dev_name_head[i]);

for (i = 0; i < NETDEV_HASHENTRIES; i++)
INIT_HLIST_HEAD(&net->dev_index_head[i]);
net->dev_index_head = netdev_create_hash();
if (net->dev_index_head == NULL)
goto err_idx;

return 0;

err_idx:
kfree(net->dev_name_head);
err_name:
return -ENOMEM;
}

static void netdev_exit(struct net *net)
Expand Down

0 comments on commit 21440b6

Please sign in to comment.