linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC 1/2] Bluetooth: make use of MSG_DONTROUTE flag in L2CAP sockets
Date: Tue, 10 Jan 2012 15:26:27 +0200	[thread overview]
Message-ID: <1326201988-17651-1-git-send-email-luiz.dentz@gmail.com> (raw)

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This use MSG_DONTROUTE to send a single message with highest possible
priority without having to rely on socket options.

This is useful for RFCOMM which relies on socket interface to send frames
to L2CAP, but since some of this frames are actual commands that can
timeout they should be sent as soon as possible.

For userspace this also offer the convenience of not having to use
setsockopt several times when only a single/some messages needs to be
prioritize.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/l2cap_sock.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index c57027f..133c1f2 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -699,6 +699,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
 	struct sock *sk = sock->sk;
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	int err;
+	u32 priority;
 
 	BT_DBG("sock %p, sk %p", sock, sk);
 
@@ -711,12 +712,18 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
 
 	lock_sock(sk);
 
+	priority = sk->sk_priority;
+
+	/* MSG_DONTROUTE send message at maximum possible priority */
+	if ((msg->msg_flags & MSG_DONTROUTE) && priority < HCI_PRIO_MAX - 1)
+		priority = HCI_PRIO_MAX - 1;
+
 	if (sk->sk_state != BT_CONNECTED) {
 		release_sock(sk);
 		return -ENOTCONN;
 	}
 
-	err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
+	err = l2cap_chan_send(chan, msg, len, priority);
 
 	release_sock(sk);
 	return err;
-- 
1.7.7.5


             reply	other threads:[~2012-01-10 13:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-10 13:26 Luiz Augusto von Dentz [this message]
2012-01-10 13:26 ` [RFC 2/2] Bluetooth: Fix possible timeouts while sending RFCOMM commands Luiz Augusto von Dentz
2012-01-10 16:50 ` [RFC 1/2] Bluetooth: make use of MSG_DONTROUTE flag in L2CAP sockets Marcel Holtmann
2012-01-11 10:07   ` Luiz Augusto von Dentz
2012-01-11 10:27     ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326201988-17651-1-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).