aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet/socket.c
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2008-12-03 18:42:56 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-03 18:42:56 -0500
commit52404881984e2d447f920a23e3bb63262dfc77f3 (patch)
tree531b4ac50fe372d26bf950c77d31f2ddcb40153c /net/phonet/socket.c
parentd81d228567f55af517796638075dbbce9b40d7af (diff)
Phonet: basic net namespace support
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet/socket.c')
-rw-r--r--net/phonet/socket.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index d81740187fb4..c75aa5cdead5 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -57,7 +57,7 @@ static struct {
57 * Find address based on socket address, match only certain fields. 57 * Find address based on socket address, match only certain fields.
58 * Also grab sock if it was found. Remember to sock_put it later. 58 * Also grab sock if it was found. Remember to sock_put it later.
59 */ 59 */
60struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *spn) 60struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *spn)
61{ 61{
62 struct hlist_node *node; 62 struct hlist_node *node;
63 struct sock *sknode; 63 struct sock *sknode;
@@ -71,6 +71,8 @@ struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *spn)
71 struct pn_sock *pn = pn_sk(sknode); 71 struct pn_sock *pn = pn_sk(sknode);
72 BUG_ON(!pn->sobject); /* unbound socket */ 72 BUG_ON(!pn->sobject); /* unbound socket */
73 73
74 if (!net_eq(sock_net(sknode), net))
75 continue;
74 if (pn_port(obj)) { 76 if (pn_port(obj)) {
75 /* Look up socket by port */ 77 /* Look up socket by port */
76 if (pn_port(pn->sobject) != pn_port(obj)) 78 if (pn_port(pn->sobject) != pn_port(obj))
@@ -130,7 +132,7 @@ static int pn_socket_bind(struct socket *sock, struct sockaddr *addr, int len)
130 132
131 handle = pn_sockaddr_get_object((struct sockaddr_pn *)addr); 133 handle = pn_sockaddr_get_object((struct sockaddr_pn *)addr);
132 saddr = pn_addr(handle); 134 saddr = pn_addr(handle);
133 if (saddr && phonet_address_lookup(saddr)) 135 if (saddr && phonet_address_lookup(sock_net(sk), saddr))
134 return -EADDRNOTAVAIL; 136 return -EADDRNOTAVAIL;
135 137
136 lock_sock(sk); 138 lock_sock(sk);
@@ -361,6 +363,7 @@ static DEFINE_MUTEX(port_mutex);
361int pn_sock_get_port(struct sock *sk, unsigned short sport) 363int pn_sock_get_port(struct sock *sk, unsigned short sport)
362{ 364{
363 static int port_cur; 365 static int port_cur;
366 struct net *net = sock_net(sk);
364 struct pn_sock *pn = pn_sk(sk); 367 struct pn_sock *pn = pn_sk(sk);
365 struct sockaddr_pn try_sa; 368 struct sockaddr_pn try_sa;
366 struct sock *tmpsk; 369 struct sock *tmpsk;
@@ -381,7 +384,7 @@ int pn_sock_get_port(struct sock *sk, unsigned short sport)
381 port_cur = pmin; 384 port_cur = pmin;
382 385
383 pn_sockaddr_set_port(&try_sa, port_cur); 386 pn_sockaddr_set_port(&try_sa, port_cur);
384 tmpsk = pn_find_sock_by_sa(&try_sa); 387 tmpsk = pn_find_sock_by_sa(net, &try_sa);
385 if (tmpsk == NULL) { 388 if (tmpsk == NULL) {
386 sport = port_cur; 389 sport = port_cur;
387 goto found; 390 goto found;
@@ -391,7 +394,7 @@ int pn_sock_get_port(struct sock *sk, unsigned short sport)
391 } else { 394 } else {
392 /* try to find specific port */ 395 /* try to find specific port */
393 pn_sockaddr_set_port(&try_sa, sport); 396 pn_sockaddr_set_port(&try_sa, sport);
394 tmpsk = pn_find_sock_by_sa(&try_sa); 397 tmpsk = pn_find_sock_by_sa(net, &try_sa);
395 if (tmpsk == NULL) 398 if (tmpsk == NULL)
396 /* No sock there! We can use that port... */ 399 /* No sock there! We can use that port... */
397 goto found; 400 goto found;