Commit ca15febf authored by Gao feng's avatar Gao feng Committed by David S. Miller

netlink: make compare exist all the time

Commit da12c90e
"netlink: Add compare function for netlink_table"
only set compare at the time we create kernel netlink,
and reset compare to NULL at the time we finially
release netlink socket, but netlink_lookup wants
the compare exist always.

So we should set compare after we allocate nl_table,
and never reset it. make comapre exist all the time.
Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e3d73bce
...@@ -1174,7 +1174,6 @@ static int netlink_release(struct socket *sock) ...@@ -1174,7 +1174,6 @@ static int netlink_release(struct socket *sock)
kfree_rcu(old, rcu); kfree_rcu(old, rcu);
nl_table[sk->sk_protocol].module = NULL; nl_table[sk->sk_protocol].module = NULL;
nl_table[sk->sk_protocol].bind = NULL; nl_table[sk->sk_protocol].bind = NULL;
nl_table[sk->sk_protocol].compare = NULL;
nl_table[sk->sk_protocol].flags = 0; nl_table[sk->sk_protocol].flags = 0;
nl_table[sk->sk_protocol].registered = 0; nl_table[sk->sk_protocol].registered = 0;
} }
...@@ -2326,7 +2325,6 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module, ...@@ -2326,7 +2325,6 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
rcu_assign_pointer(nl_table[unit].listeners, listeners); rcu_assign_pointer(nl_table[unit].listeners, listeners);
nl_table[unit].cb_mutex = cb_mutex; nl_table[unit].cb_mutex = cb_mutex;
nl_table[unit].module = module; nl_table[unit].module = module;
nl_table[unit].compare = netlink_compare;
if (cfg) { if (cfg) {
nl_table[unit].bind = cfg->bind; nl_table[unit].bind = cfg->bind;
nl_table[unit].flags = cfg->flags; nl_table[unit].flags = cfg->flags;
...@@ -2973,6 +2971,8 @@ static int __init netlink_proto_init(void) ...@@ -2973,6 +2971,8 @@ static int __init netlink_proto_init(void)
hash->shift = 0; hash->shift = 0;
hash->mask = 0; hash->mask = 0;
hash->rehash_time = jiffies; hash->rehash_time = jiffies;
nl_table[i].compare = netlink_compare;
} }
netlink_add_usersock_entry(); netlink_add_usersock_entry();
......
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