diff options
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 8097b4f3ead4..1e3fd5bfcd86 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -248,11 +248,10 @@ static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid) | |||
248 | struct nl_portid_hash *hash = &nl_table[protocol].hash; | 248 | struct nl_portid_hash *hash = &nl_table[protocol].hash; |
249 | struct hlist_head *head; | 249 | struct hlist_head *head; |
250 | struct sock *sk; | 250 | struct sock *sk; |
251 | struct hlist_node *node; | ||
252 | 251 | ||
253 | read_lock(&nl_table_lock); | 252 | read_lock(&nl_table_lock); |
254 | head = nl_portid_hashfn(hash, portid); | 253 | head = nl_portid_hashfn(hash, portid); |
255 | sk_for_each(sk, node, head) { | 254 | sk_for_each(sk, head) { |
256 | if (net_eq(sock_net(sk), net) && (nlk_sk(sk)->portid == portid)) { | 255 | if (net_eq(sock_net(sk), net) && (nlk_sk(sk)->portid == portid)) { |
257 | sock_hold(sk); | 256 | sock_hold(sk); |
258 | goto found; | 257 | goto found; |
@@ -312,9 +311,9 @@ static int nl_portid_hash_rehash(struct nl_portid_hash *hash, int grow) | |||
312 | 311 | ||
313 | for (i = 0; i <= omask; i++) { | 312 | for (i = 0; i <= omask; i++) { |
314 | struct sock *sk; | 313 | struct sock *sk; |
315 | struct hlist_node *node, *tmp; | 314 | struct hlist_node *tmp; |
316 | 315 | ||
317 | sk_for_each_safe(sk, node, tmp, &otable[i]) | 316 | sk_for_each_safe(sk, tmp, &otable[i]) |
318 | __sk_add_node(sk, nl_portid_hashfn(hash, nlk_sk(sk)->portid)); | 317 | __sk_add_node(sk, nl_portid_hashfn(hash, nlk_sk(sk)->portid)); |
319 | } | 318 | } |
320 | 319 | ||
@@ -344,7 +343,6 @@ static void | |||
344 | netlink_update_listeners(struct sock *sk) | 343 | netlink_update_listeners(struct sock *sk) |
345 | { | 344 | { |
346 | struct netlink_table *tbl = &nl_table[sk->sk_protocol]; | 345 | struct netlink_table *tbl = &nl_table[sk->sk_protocol]; |
347 | struct hlist_node *node; | ||
348 | unsigned long mask; | 346 | unsigned long mask; |
349 | unsigned int i; | 347 | unsigned int i; |
350 | struct listeners *listeners; | 348 | struct listeners *listeners; |
@@ -355,7 +353,7 @@ netlink_update_listeners(struct sock *sk) | |||
355 | 353 | ||
356 | for (i = 0; i < NLGRPLONGS(tbl->groups); i++) { | 354 | for (i = 0; i < NLGRPLONGS(tbl->groups); i++) { |
357 | mask = 0; | 355 | mask = 0; |
358 | sk_for_each_bound(sk, node, &tbl->mc_list) { | 356 | sk_for_each_bound(sk, &tbl->mc_list) { |
359 | if (i < NLGRPLONGS(nlk_sk(sk)->ngroups)) | 357 | if (i < NLGRPLONGS(nlk_sk(sk)->ngroups)) |
360 | mask |= nlk_sk(sk)->groups[i]; | 358 | mask |= nlk_sk(sk)->groups[i]; |
361 | } | 359 | } |
@@ -371,18 +369,17 @@ static int netlink_insert(struct sock *sk, struct net *net, u32 portid) | |||
371 | struct hlist_head *head; | 369 | struct hlist_head *head; |
372 | int err = -EADDRINUSE; | 370 | int err = -EADDRINUSE; |
373 | struct sock *osk; | 371 | struct sock *osk; |
374 | struct hlist_node *node; | ||
375 | int len; | 372 | int len; |
376 | 373 | ||
377 | netlink_table_grab(); | 374 | netlink_table_grab(); |
378 | head = nl_portid_hashfn(hash, portid); | 375 | head = nl_portid_hashfn(hash, portid); |
379 | len = 0; | 376 | len = 0; |
380 | sk_for_each(osk, node, head) { | 377 | sk_for_each(osk, head) { |
381 | if (net_eq(sock_net(osk), net) && (nlk_sk(osk)->portid == portid)) | 378 | if (net_eq(sock_net(osk), net) && (nlk_sk(osk)->portid == portid)) |
382 | break; | 379 | break; |
383 | len++; | 380 | len++; |
384 | } | 381 | } |
385 | if (node) | 382 | if (osk) |
386 | goto err; | 383 | goto err; |
387 | 384 | ||
388 | err = -EBUSY; | 385 | err = -EBUSY; |
@@ -575,7 +572,6 @@ static int netlink_autobind(struct socket *sock) | |||
575 | struct nl_portid_hash *hash = &nl_table[sk->sk_protocol].hash; | 572 | struct nl_portid_hash *hash = &nl_table[sk->sk_protocol].hash; |
576 | struct hlist_head *head; | 573 | struct hlist_head *head; |
577 | struct sock *osk; | 574 | struct sock *osk; |
578 | struct hlist_node *node; | ||
579 | s32 portid = task_tgid_vnr(current); | 575 | s32 portid = task_tgid_vnr(current); |
580 | int err; | 576 | int err; |
581 | static s32 rover = -4097; | 577 | static s32 rover = -4097; |
@@ -584,7 +580,7 @@ retry: | |||
584 | cond_resched(); | 580 | cond_resched(); |
585 | netlink_table_grab(); | 581 | netlink_table_grab(); |
586 | head = nl_portid_hashfn(hash, portid); | 582 | head = nl_portid_hashfn(hash, portid); |
587 | sk_for_each(osk, node, head) { | 583 | sk_for_each(osk, head) { |
588 | if (!net_eq(sock_net(osk), net)) | 584 | if (!net_eq(sock_net(osk), net)) |
589 | continue; | 585 | continue; |
590 | if (nlk_sk(osk)->portid == portid) { | 586 | if (nlk_sk(osk)->portid == portid) { |
@@ -1101,7 +1097,6 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid | |||
1101 | { | 1097 | { |
1102 | struct net *net = sock_net(ssk); | 1098 | struct net *net = sock_net(ssk); |
1103 | struct netlink_broadcast_data info; | 1099 | struct netlink_broadcast_data info; |
1104 | struct hlist_node *node; | ||
1105 | struct sock *sk; | 1100 | struct sock *sk; |
1106 | 1101 | ||
1107 | skb = netlink_trim(skb, allocation); | 1102 | skb = netlink_trim(skb, allocation); |
@@ -1124,7 +1119,7 @@ int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid | |||
1124 | 1119 | ||
1125 | netlink_lock_table(); | 1120 | netlink_lock_table(); |
1126 | 1121 | ||
1127 | sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list) | 1122 | sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list) |
1128 | do_one_broadcast(sk, &info); | 1123 | do_one_broadcast(sk, &info); |
1129 | 1124 | ||
1130 | consume_skb(skb); | 1125 | consume_skb(skb); |
@@ -1200,7 +1195,6 @@ out: | |||
1200 | int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) | 1195 | int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) |
1201 | { | 1196 | { |
1202 | struct netlink_set_err_data info; | 1197 | struct netlink_set_err_data info; |
1203 | struct hlist_node *node; | ||
1204 | struct sock *sk; | 1198 | struct sock *sk; |
1205 | int ret = 0; | 1199 | int ret = 0; |
1206 | 1200 | ||
@@ -1212,7 +1206,7 @@ int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) | |||
1212 | 1206 | ||
1213 | read_lock(&nl_table_lock); | 1207 | read_lock(&nl_table_lock); |
1214 | 1208 | ||
1215 | sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list) | 1209 | sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list) |
1216 | ret += do_one_set_err(sk, &info); | 1210 | ret += do_one_set_err(sk, &info); |
1217 | 1211 | ||
1218 | read_unlock(&nl_table_lock); | 1212 | read_unlock(&nl_table_lock); |
@@ -1676,10 +1670,9 @@ int netlink_change_ngroups(struct sock *sk, unsigned int groups) | |||
1676 | void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group) | 1670 | void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group) |
1677 | { | 1671 | { |
1678 | struct sock *sk; | 1672 | struct sock *sk; |
1679 | struct hlist_node *node; | ||
1680 | struct netlink_table *tbl = &nl_table[ksk->sk_protocol]; | 1673 | struct netlink_table *tbl = &nl_table[ksk->sk_protocol]; |
1681 | 1674 | ||
1682 | sk_for_each_bound(sk, node, &tbl->mc_list) | 1675 | sk_for_each_bound(sk, &tbl->mc_list) |
1683 | netlink_update_socket_mc(nlk_sk(sk), group, 0); | 1676 | netlink_update_socket_mc(nlk_sk(sk), group, 0); |
1684 | } | 1677 | } |
1685 | 1678 | ||
@@ -1974,14 +1967,13 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos) | |||
1974 | struct nl_seq_iter *iter = seq->private; | 1967 | struct nl_seq_iter *iter = seq->private; |
1975 | int i, j; | 1968 | int i, j; |
1976 | struct sock *s; | 1969 | struct sock *s; |
1977 | struct hlist_node *node; | ||
1978 | loff_t off = 0; | 1970 | loff_t off = 0; |
1979 | 1971 | ||
1980 | for (i = 0; i < MAX_LINKS; i++) { | 1972 | for (i = 0; i < MAX_LINKS; i++) { |
1981 | struct nl_portid_hash *hash = &nl_table[i].hash; | 1973 | struct nl_portid_hash *hash = &nl_table[i].hash; |
1982 | 1974 | ||
1983 | for (j = 0; j <= hash->mask; j++) { | 1975 | for (j = 0; j <= hash->mask; j++) { |
1984 | sk_for_each(s, node, &hash->table[j]) { | 1976 | sk_for_each(s, &hash->table[j]) { |
1985 | if (sock_net(s) != seq_file_net(seq)) | 1977 | if (sock_net(s) != seq_file_net(seq)) |
1986 | continue; | 1978 | continue; |
1987 | if (off == pos) { | 1979 | if (off == pos) { |