diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-13 12:55:28 -0700 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-13 23:10:33 +0300 |
commit | d97636980f6ba7344c8aa6fa349b9059c60ee478 (patch) | |
tree | 98b7196d4aad90206104796f16d42d6fd1d36056 /net | |
parent | 84b34d9867f826caecaab4444c86438935b7eb2b (diff) | |
download | lwn-d97636980f6ba7344c8aa6fa349b9059c60ee478.tar.gz lwn-d97636980f6ba7344c8aa6fa349b9059c60ee478.zip |
Bluetooth: Add support for per socket msg_name callback
This allows to add a per socket msg_name callback that can be used
for updating the msg_name information for recvmsg() system calls.
This feature is used by another patch to support address information
on L2CAP connectionless channels.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 9c7e4edc6504..f0aadeac4455 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -221,12 +221,12 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, if (flags & (MSG_OOB)) return -EOPNOTSUPP; - msg->msg_namelen = 0; - skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) { - if (sk->sk_shutdown & RCV_SHUTDOWN) + if (sk->sk_shutdown & RCV_SHUTDOWN) { + msg->msg_namelen = 0; return 0; + } return err; } @@ -238,9 +238,16 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, skb_reset_transport_header(skb); err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); - if (err == 0) + if (err == 0) { sock_recv_ts_and_drops(msg, sk, skb); + if (bt_sk(sk)->skb_msg_name) + bt_sk(sk)->skb_msg_name(skb, msg->msg_name, + &msg->msg_namelen); + else + msg->msg_namelen = 0; + } + skb_free_datagram(sk, skb); return err ? : copied; |