Skip to content

Commit

Permalink
Phonet: hook resource routing to userspace via ioctl()'s
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rémi Denis-Courmont authored and David S. Miller committed Sep 16, 2010
1 parent 4e3d16c commit 7417fa8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/phonet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

/* ioctls */
#define SIOCPNGETOBJECT (SIOCPROTOPRIVATE + 0)
#define SIOCPNADDRESOURCE (SIOCPROTOPRIVATE + 14)
#define SIOCPNDELRESOURCE (SIOCPROTOPRIVATE + 15)

/* Phonet protocol header */
struct phonethdr {
Expand Down
13 changes: 13 additions & 0 deletions net/phonet/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions net/phonet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7417fa8

Please sign in to comment.