aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r--net/netlink/af_netlink.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f29b63fad932..84ea76ca3f1f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1141,8 +1141,8 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol,
1141 struct module *module = NULL; 1141 struct module *module = NULL;
1142 struct mutex *cb_mutex; 1142 struct mutex *cb_mutex;
1143 struct netlink_sock *nlk; 1143 struct netlink_sock *nlk;
1144 int (*bind)(int group); 1144 int (*bind)(struct net *net, int group);
1145 void (*unbind)(int group); 1145 void (*unbind)(struct net *net, int group);
1146 int err = 0; 1146 int err = 0;
1147 1147
1148 sock->state = SS_UNCONNECTED; 1148 sock->state = SS_UNCONNECTED;
@@ -1251,7 +1251,7 @@ static int netlink_release(struct socket *sock)
1251 1251
1252 for (i = 0; i < nlk->ngroups; i++) 1252 for (i = 0; i < nlk->ngroups; i++)
1253 if (test_bit(i, nlk->groups)) 1253 if (test_bit(i, nlk->groups))
1254 nlk->netlink_unbind(i + 1); 1254 nlk->netlink_unbind(sock_net(sk), i + 1);
1255 } 1255 }
1256 kfree(nlk->groups); 1256 kfree(nlk->groups);
1257 nlk->groups = NULL; 1257 nlk->groups = NULL;
@@ -1418,8 +1418,9 @@ static int netlink_realloc_groups(struct sock *sk)
1418} 1418}
1419 1419
1420static void netlink_undo_bind(int group, long unsigned int groups, 1420static void netlink_undo_bind(int group, long unsigned int groups,
1421 struct netlink_sock *nlk) 1421 struct sock *sk)
1422{ 1422{
1423 struct netlink_sock *nlk = nlk_sk(sk);
1423 int undo; 1424 int undo;
1424 1425
1425 if (!nlk->netlink_unbind) 1426 if (!nlk->netlink_unbind)
@@ -1427,7 +1428,7 @@ static void netlink_undo_bind(int group, long unsigned int groups,
1427 1428
1428 for (undo = 0; undo < group; undo++) 1429 for (undo = 0; undo < group; undo++)
1429 if (test_bit(undo, &groups)) 1430 if (test_bit(undo, &groups))
1430 nlk->netlink_unbind(undo); 1431 nlk->netlink_unbind(sock_net(sk), undo);
1431} 1432}
1432 1433
1433static int netlink_bind(struct socket *sock, struct sockaddr *addr, 1434static int netlink_bind(struct socket *sock, struct sockaddr *addr,
@@ -1465,10 +1466,10 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1465 for (group = 0; group < nlk->ngroups; group++) { 1466 for (group = 0; group < nlk->ngroups; group++) {
1466 if (!test_bit(group, &groups)) 1467 if (!test_bit(group, &groups))
1467 continue; 1468 continue;
1468 err = nlk->netlink_bind(group); 1469 err = nlk->netlink_bind(net, group);
1469 if (!err) 1470 if (!err)
1470 continue; 1471 continue;
1471 netlink_undo_bind(group, groups, nlk); 1472 netlink_undo_bind(group, groups, sk);
1472 return err; 1473 return err;
1473 } 1474 }
1474 } 1475 }
@@ -1478,7 +1479,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1478 netlink_insert(sk, net, nladdr->nl_pid) : 1479 netlink_insert(sk, net, nladdr->nl_pid) :
1479 netlink_autobind(sock); 1480 netlink_autobind(sock);
1480 if (err) { 1481 if (err) {
1481 netlink_undo_bind(nlk->ngroups, groups, nlk); 1482 netlink_undo_bind(nlk->ngroups, groups, sk);
1482 return err; 1483 return err;
1483 } 1484 }
1484 } 1485 }
@@ -2129,7 +2130,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
2129 if (!val || val - 1 >= nlk->ngroups) 2130 if (!val || val - 1 >= nlk->ngroups)
2130 return -EINVAL; 2131 return -EINVAL;
2131 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) { 2132 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) {
2132 err = nlk->netlink_bind(val); 2133 err = nlk->netlink_bind(sock_net(sk), val);
2133 if (err) 2134 if (err)
2134 return err; 2135 return err;
2135 } 2136 }
@@ -2138,7 +2139,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
2138 optname == NETLINK_ADD_MEMBERSHIP); 2139 optname == NETLINK_ADD_MEMBERSHIP);
2139 netlink_table_ungrab(); 2140 netlink_table_ungrab();
2140 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind) 2141 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind)
2141 nlk->netlink_unbind(val); 2142 nlk->netlink_unbind(sock_net(sk), val);
2142 2143
2143 err = 0; 2144 err = 0;
2144 break; 2145 break;