Skip to content

Commit

Permalink
netlink: Make NETLINK_USERSOCK work again.
Browse files Browse the repository at this point in the history
Once we started enforcing the a nl_table[] entry exist for
a protocol, NETLINK_USERSOCK stopped working.  Add a dummy
table entry so that it works again.

Reported-by: Thomas Voegtle <[email protected]>
Tested-by: Thomas Voegtle <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Aug 31, 2010
1 parent 628e300 commit b963ea8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,26 @@ static void __net_exit netlink_net_exit(struct net *net)
#endif
}

static void __init netlink_add_usersock_entry(void)
{
unsigned long *listeners;
int groups = 32;

listeners = kzalloc(NLGRPSZ(groups) + sizeof(struct listeners_rcu_head),
GFP_KERNEL);
if (!listeners)
panic("netlink_add_usersock_entry: Cannot allocate listneres\n");

netlink_table_grab();

nl_table[NETLINK_USERSOCK].groups = groups;
nl_table[NETLINK_USERSOCK].listeners = listeners;
nl_table[NETLINK_USERSOCK].module = THIS_MODULE;
nl_table[NETLINK_USERSOCK].registered = 1;

netlink_table_ungrab();
}

static struct pernet_operations __net_initdata netlink_net_ops = {
.init = netlink_net_init,
.exit = netlink_net_exit,
Expand Down Expand Up @@ -2150,6 +2170,8 @@ static int __init netlink_proto_init(void)
hash->rehash_time = jiffies;
}

netlink_add_usersock_entry();

sock_register(&netlink_family_ops);
register_pernet_subsys(&netlink_net_ops);
/* The netlink device handler may be needed early. */
Expand Down

0 comments on commit b963ea8

Please sign in to comment.