aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-04-22 17:30:21 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-24 00:35:14 -0400
commit658cb354edf0f16cc5a2a2bda3ec5be1bba25e6d (patch)
tree4751e0b4b17af814646503492e195890e1e9ce59 /net/netlink/af_netlink.c
parent38ba0a65faf451dd46c7860b4fade84c0b8e444f (diff)
af_netlink: cleanups
netlink_destroy_callback() move to avoid forward reference CodingStyle cleanups Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r--net/netlink/af_netlink.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index da8721443503..85d27f9f0e67 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -104,27 +104,27 @@ static inline int netlink_is_kernel(struct sock *sk)
104} 104}
105 105
106struct nl_pid_hash { 106struct nl_pid_hash {
107 struct hlist_head *table; 107 struct hlist_head *table;
108 unsigned long rehash_time; 108 unsigned long rehash_time;
109 109
110 unsigned int mask; 110 unsigned int mask;
111 unsigned int shift; 111 unsigned int shift;
112 112
113 unsigned int entries; 113 unsigned int entries;
114 unsigned int max_shift; 114 unsigned int max_shift;
115 115
116 u32 rnd; 116 u32 rnd;
117}; 117};
118 118
119struct netlink_table { 119struct netlink_table {
120 struct nl_pid_hash hash; 120 struct nl_pid_hash hash;
121 struct hlist_head mc_list; 121 struct hlist_head mc_list;
122 struct listeners __rcu *listeners; 122 struct listeners __rcu *listeners;
123 unsigned int nl_nonroot; 123 unsigned int nl_nonroot;
124 unsigned int groups; 124 unsigned int groups;
125 struct mutex *cb_mutex; 125 struct mutex *cb_mutex;
126 struct module *module; 126 struct module *module;
127 int registered; 127 int registered;
128}; 128};
129 129
130static struct netlink_table *nl_table; 130static struct netlink_table *nl_table;
@@ -132,7 +132,6 @@ static struct netlink_table *nl_table;
132static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); 132static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
133 133
134static int netlink_dump(struct sock *sk); 134static int netlink_dump(struct sock *sk);
135static void netlink_destroy_callback(struct netlink_callback *cb);
136 135
137static DEFINE_RWLOCK(nl_table_lock); 136static DEFINE_RWLOCK(nl_table_lock);
138static atomic_t nl_table_users = ATOMIC_INIT(0); 137static atomic_t nl_table_users = ATOMIC_INIT(0);
@@ -149,6 +148,12 @@ static inline struct hlist_head *nl_pid_hashfn(struct nl_pid_hash *hash, u32 pid
149 return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask]; 148 return &hash->table[jhash_1word(pid, hash->rnd) & hash->mask];
150} 149}
151 150
151static void netlink_destroy_callback(struct netlink_callback *cb)
152{
153 kfree_skb(cb->skb);
154 kfree(cb);
155}
156
152static void netlink_sock_destruct(struct sock *sk) 157static void netlink_sock_destruct(struct sock *sk)
153{ 158{
154 struct netlink_sock *nlk = nlk_sk(sk); 159 struct netlink_sock *nlk = nlk_sk(sk);
@@ -414,9 +419,9 @@ static int __netlink_create(struct net *net, struct socket *sock,
414 sock_init_data(sock, sk); 419 sock_init_data(sock, sk);
415 420
416 nlk = nlk_sk(sk); 421 nlk = nlk_sk(sk);
417 if (cb_mutex) 422 if (cb_mutex) {
418 nlk->cb_mutex = cb_mutex; 423 nlk->cb_mutex = cb_mutex;
419 else { 424 } else {
420 nlk->cb_mutex = &nlk->cb_def_mutex; 425 nlk->cb_mutex = &nlk->cb_def_mutex;
421 mutex_init(nlk->cb_mutex); 426 mutex_init(nlk->cb_mutex);
422 } 427 }
@@ -522,8 +527,9 @@ static int netlink_release(struct socket *sock)
522 nl_table[sk->sk_protocol].module = NULL; 527 nl_table[sk->sk_protocol].module = NULL;
523 nl_table[sk->sk_protocol].registered = 0; 528 nl_table[sk->sk_protocol].registered = 0;
524 } 529 }
525 } else if (nlk->subscriptions) 530 } else if (nlk->subscriptions) {
526 netlink_update_listeners(sk); 531 netlink_update_listeners(sk);
532 }
527 netlink_table_ungrab(); 533 netlink_table_ungrab();
528 534
529 kfree(nlk->groups); 535 kfree(nlk->groups);
@@ -1086,8 +1092,8 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 pid,
1086 if (info.delivery_failure) { 1092 if (info.delivery_failure) {
1087 kfree_skb(info.skb2); 1093 kfree_skb(info.skb2);
1088 return -ENOBUFS; 1094 return -ENOBUFS;
1089 } else 1095 }
1090 consume_skb(info.skb2); 1096 consume_skb(info.skb2);
1091 1097
1092 if (info.delivered) { 1098 if (info.delivered) {
1093 if (info.congested && (allocation & __GFP_WAIT)) 1099 if (info.congested && (allocation & __GFP_WAIT))
@@ -1240,8 +1246,9 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
1240 nlk->flags |= NETLINK_RECV_NO_ENOBUFS; 1246 nlk->flags |= NETLINK_RECV_NO_ENOBUFS;
1241 clear_bit(0, &nlk->state); 1247 clear_bit(0, &nlk->state);
1242 wake_up_interruptible(&nlk->wait); 1248 wake_up_interruptible(&nlk->wait);
1243 } else 1249 } else {
1244 nlk->flags &= ~NETLINK_RECV_NO_ENOBUFS; 1250 nlk->flags &= ~NETLINK_RECV_NO_ENOBUFS;
1251 }
1245 err = 0; 1252 err = 0;
1246 break; 1253 break;
1247 default: 1254 default:
@@ -1645,12 +1652,6 @@ void netlink_set_nonroot(int protocol, unsigned int flags)
1645} 1652}
1646EXPORT_SYMBOL(netlink_set_nonroot); 1653EXPORT_SYMBOL(netlink_set_nonroot);
1647 1654
1648static void netlink_destroy_callback(struct netlink_callback *cb)
1649{
1650 kfree_skb(cb->skb);
1651 kfree(cb);
1652}
1653
1654struct nlmsghdr * 1655struct nlmsghdr *
1655__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) 1656__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
1656{ 1657{
@@ -1996,11 +1997,11 @@ static void netlink_seq_stop(struct seq_file *seq, void *v)
1996 1997
1997static int netlink_seq_show(struct seq_file *seq, void *v) 1998static int netlink_seq_show(struct seq_file *seq, void *v)
1998{ 1999{
1999 if (v == SEQ_START_TOKEN) 2000 if (v == SEQ_START_TOKEN) {
2000 seq_puts(seq, 2001 seq_puts(seq,
2001 "sk Eth Pid Groups " 2002 "sk Eth Pid Groups "
2002 "Rmem Wmem Dump Locks Drops Inode\n"); 2003 "Rmem Wmem Dump Locks Drops Inode\n");
2003 else { 2004 } else {
2004 struct sock *s = v; 2005 struct sock *s = v;
2005 struct netlink_sock *nlk = nlk_sk(s); 2006 struct netlink_sock *nlk = nlk_sk(s);
2006 2007