aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2010-09-15 12:30:12 +0000
committerJonas ABERG <jonas.aberg@stericsson.com>2011-01-24 10:46:41 +0100
commit12ac42fec0b7ab5e9b46eee2d5ff3020191dd3ed (patch)
tree86ba1524432b2a626e1023026ea6c9100b0327ea /net
parent17620df4e25cc979b390f781620b60d8ccccac8a (diff)
Phonet: hook resource routing to userspace via ioctl()'s
I wish we could use something cleaner, such as bind(). But that would not work since resource subscription is orthogonal/in addition to the normal object ID allocated via bind(). This is similar to multicasting which also uses ioctl()'s. Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net> Change-Id: Ia77be1a96e55ff2db13d9bfbbe653e3171fd6d03 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/13153 Reviewed-by: QATOOLS Reviewed-by: B Sampath KUMAR <sampath.kumar@stericsson.com> Tested-by: B Sampath KUMAR <sampath.kumar@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'net')
-rw-r--r--net/phonet/datagram.c13
-rw-r--r--net/phonet/socket.c1
2 files changed, 14 insertions, 0 deletions
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
index 1bd38db4fe1..2f032381bd4 100644
--- a/net/phonet/datagram.c
+++ b/net/phonet/datagram.c
@@ -52,6 +52,19 @@ static int pn_ioctl(struct sock *sk, int cmd, unsigned long arg)
answ = skb ? skb->len : 0;
release_sock(sk);
return put_user(answ, (int __user *)arg);
+
+ case SIOCPNADDRESOURCE:
+ case SIOCPNDELRESOURCE: {
+ u32 res;
+ if (get_user(res, (u32 __user *)arg))
+ return -EFAULT;
+ if (res >= 256)
+ return -EINVAL;
+ if (cmd == SIOCPNADDRESOURCE)
+ return pn_sock_bind_res(sk, res);
+ else
+ return pn_sock_unbind_res(sk, res);
+ }
}
return -ENOIOCTLCMD;
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 4c29a23e900..d4f41afc058 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -158,6 +158,7 @@ void pn_sock_unhash(struct sock *sk)
spin_lock_bh(&pnsocks.lock);
sk_del_node_init(sk);
spin_unlock_bh(&pnsocks.lock);
+ pn_sock_unbind_all_res(sk);
}
EXPORT_SYMBOL(pn_sock_unhash);