Bluetooth: Assign L2CAP socket priority when allocating SKB
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 5 Jun 2014 13:22:51 +0000 (15:22 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 3 Jul 2014 15:42:41 +0000 (17:42 +0200)
The SKB for L2CAP sockets are all allocated in a central callback
in the socket support. Instead of having to pass around the socket
priority all the time, assign it to skb->priority when actually
allocating the SKB.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/l2cap.h
net/bluetooth/a2mp.c
net/bluetooth/l2cap_core.c
net/bluetooth/l2cap_sock.c

index cf67420616e5d111b2031087dcf3276594f3b357..18f4f27e0f74f8e64eb1c84d4ae8eb9c98826d3b 100644 (file)
@@ -872,8 +872,7 @@ struct l2cap_chan *l2cap_chan_create(void);
 void l2cap_chan_close(struct l2cap_chan *chan, int reason);
 int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
                       bdaddr_t *dst, u8 dst_type);
-int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
-                                                               u32 priority);
+int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
 void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
 int l2cap_chan_check_security(struct l2cap_chan *chan);
 void l2cap_chan_set_defaults(struct l2cap_chan *chan);
index 1996b4c4dfd5caa3618e534edd8767eb890d4d33..1a5b1eb96d1a59a88f7dbb4982b1f571b132c767 100644 (file)
@@ -63,7 +63,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
        msg.msg_iov = (struct iovec *) &iv;
        msg.msg_iovlen = 1;
 
-       l2cap_chan_send(chan, &msg, total_len, 0);
+       l2cap_chan_send(chan, &msg, total_len);
 
        kfree(cmd);
 }
index 323f23cd2c37c4a9b95f3c195c48d170d9e73404..3dca28246cbee537e87f69335a9371b9a342c13d 100644 (file)
@@ -2141,8 +2141,6 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
                if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count))
                        return -EFAULT;
 
-               (*frag)->priority = skb->priority;
-
                sent += count;
                len  -= count;
 
@@ -2156,16 +2154,15 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
 }
 
 static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan,
-                                                struct msghdr *msg, size_t len,
-                                                u32 priority)
+                                                struct msghdr *msg, size_t len)
 {
        struct l2cap_conn *conn = chan->conn;
        struct sk_buff *skb;
        int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE;
        struct l2cap_hdr *lh;
 
-       BT_DBG("chan %p psm 0x%2.2x len %zu priority %u", chan,
-              __le16_to_cpu(chan->psm), len, priority);
+       BT_DBG("chan %p psm 0x%2.2x len %zu", chan,
+              __le16_to_cpu(chan->psm), len);
 
        count = min_t(unsigned int, (conn->mtu - hlen), len);
 
@@ -2174,8 +2171,6 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan,
        if (IS_ERR(skb))
                return skb;
 
-       skb->priority = priority;
-
        /* Create L2CAP header */
        lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
        lh->cid = cpu_to_le16(chan->dcid);
@@ -2191,8 +2186,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan,
 }
 
 static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan,
-                                             struct msghdr *msg, size_t len,
-                                             u32 priority)
+                                             struct msghdr *msg, size_t len)
 {
        struct l2cap_conn *conn = chan->conn;
        struct sk_buff *skb;
@@ -2208,8 +2202,6 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan,
        if (IS_ERR(skb))
                return skb;
 
-       skb->priority = priority;
-
        /* Create L2CAP header */
        lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
        lh->cid = cpu_to_le16(chan->dcid);
@@ -2430,8 +2422,7 @@ static int l2cap_segment_le_sdu(struct l2cap_chan *chan,
        return 0;
 }
 
-int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
-                   u32 priority)
+int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
 {
        struct sk_buff *skb;
        int err;
@@ -2442,7 +2433,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
 
        /* Connectionless channel */
        if (chan->chan_type == L2CAP_CHAN_CONN_LESS) {
-               skb = l2cap_create_connless_pdu(chan, msg, len, priority);
+               skb = l2cap_create_connless_pdu(chan, msg, len);
                if (IS_ERR(skb))
                        return PTR_ERR(skb);
 
@@ -2499,7 +2490,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
                        return -EMSGSIZE;
 
                /* Create a basic PDU */
-               skb = l2cap_create_basic_pdu(chan, msg, len, priority);
+               skb = l2cap_create_basic_pdu(chan, msg, len);
                if (IS_ERR(skb))
                        return PTR_ERR(skb);
 
index 11e2207717b62f4350c8ff1102fa66bf4837f758..d95964c9f91eaa455f4f8edd139fc6c1c7697217 100644 (file)
@@ -964,7 +964,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
                return err;
 
        l2cap_chan_lock(chan);
-       err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
+       err = l2cap_chan_send(chan, msg, len);
        l2cap_chan_unlock(chan);
 
        return err;
@@ -1305,6 +1305,8 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
        if (!skb)
                return ERR_PTR(err);
 
+       skb->priority = sk->sk_priority;
+
        bt_cb(skb)->chan = chan;
 
        return skb;