diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-06-08 05:22:28 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-03 11:42:42 -0400 |
commit | d9fbd02be5c201c1659ee0d79c0820bb68d95c8c (patch) | |
tree | b2f7aa9fa77a90c45e5e5eeda0d47e16ef452c4c | |
parent | 0775899158d0e1436316f3bf451d78bf34b88d17 (diff) |
Bluetooth: Use explicit header and body length for L2CAP SKB allocation
When allocating the L2CAP SKB for transmission, provide the upper layers
with a clear distinction on what is the header and what is the body
portion of the SKB.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/l2cap.h | 1 | ||||
-rw-r--r-- | net/bluetooth/a2mp.c | 3 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 10 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 3 |
4 files changed, 10 insertions, 7 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 18f4f27e0f74..92511034d1d4 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -600,6 +600,7 @@ struct l2cap_ops { | |||
600 | void (*set_shutdown) (struct l2cap_chan *chan); | 600 | void (*set_shutdown) (struct l2cap_chan *chan); |
601 | long (*get_sndtimeo) (struct l2cap_chan *chan); | 601 | long (*get_sndtimeo) (struct l2cap_chan *chan); |
602 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | 602 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, |
603 | unsigned long hdr_len, | ||
603 | unsigned long len, int nb); | 604 | unsigned long len, int nb); |
604 | }; | 605 | }; |
605 | 606 | ||
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 1a5b1eb96d1a..0fd8d1dda709 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -693,11 +693,12 @@ static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state, | |||
693 | } | 693 | } |
694 | 694 | ||
695 | static struct sk_buff *a2mp_chan_alloc_skb_cb(struct l2cap_chan *chan, | 695 | static struct sk_buff *a2mp_chan_alloc_skb_cb(struct l2cap_chan *chan, |
696 | unsigned long hdr_len, | ||
696 | unsigned long len, int nb) | 697 | unsigned long len, int nb) |
697 | { | 698 | { |
698 | struct sk_buff *skb; | 699 | struct sk_buff *skb; |
699 | 700 | ||
700 | skb = bt_skb_alloc(len, GFP_KERNEL); | 701 | skb = bt_skb_alloc(hdr_len + len, GFP_KERNEL); |
701 | if (!skb) | 702 | if (!skb) |
702 | return ERR_PTR(-ENOMEM); | 703 | return ERR_PTR(-ENOMEM); |
703 | 704 | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 3dca28246cbe..ac2461442f21 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -2131,7 +2131,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, | |||
2131 | 2131 | ||
2132 | count = min_t(unsigned int, conn->mtu, len); | 2132 | count = min_t(unsigned int, conn->mtu, len); |
2133 | 2133 | ||
2134 | tmp = chan->ops->alloc_skb(chan, count, | 2134 | tmp = chan->ops->alloc_skb(chan, 0, count, |
2135 | msg->msg_flags & MSG_DONTWAIT); | 2135 | msg->msg_flags & MSG_DONTWAIT); |
2136 | if (IS_ERR(tmp)) | 2136 | if (IS_ERR(tmp)) |
2137 | return PTR_ERR(tmp); | 2137 | return PTR_ERR(tmp); |
@@ -2166,7 +2166,7 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, | |||
2166 | 2166 | ||
2167 | count = min_t(unsigned int, (conn->mtu - hlen), len); | 2167 | count = min_t(unsigned int, (conn->mtu - hlen), len); |
2168 | 2168 | ||
2169 | skb = chan->ops->alloc_skb(chan, count + hlen, | 2169 | skb = chan->ops->alloc_skb(chan, hlen, count, |
2170 | msg->msg_flags & MSG_DONTWAIT); | 2170 | msg->msg_flags & MSG_DONTWAIT); |
2171 | if (IS_ERR(skb)) | 2171 | if (IS_ERR(skb)) |
2172 | return skb; | 2172 | return skb; |
@@ -2197,7 +2197,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, | |||
2197 | 2197 | ||
2198 | count = min_t(unsigned int, (conn->mtu - L2CAP_HDR_SIZE), len); | 2198 | count = min_t(unsigned int, (conn->mtu - L2CAP_HDR_SIZE), len); |
2199 | 2199 | ||
2200 | skb = chan->ops->alloc_skb(chan, count + L2CAP_HDR_SIZE, | 2200 | skb = chan->ops->alloc_skb(chan, L2CAP_HDR_SIZE, count, |
2201 | msg->msg_flags & MSG_DONTWAIT); | 2201 | msg->msg_flags & MSG_DONTWAIT); |
2202 | if (IS_ERR(skb)) | 2202 | if (IS_ERR(skb)) |
2203 | return skb; | 2203 | return skb; |
@@ -2239,7 +2239,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, | |||
2239 | 2239 | ||
2240 | count = min_t(unsigned int, (conn->mtu - hlen), len); | 2240 | count = min_t(unsigned int, (conn->mtu - hlen), len); |
2241 | 2241 | ||
2242 | skb = chan->ops->alloc_skb(chan, count + hlen, | 2242 | skb = chan->ops->alloc_skb(chan, hlen, count, |
2243 | msg->msg_flags & MSG_DONTWAIT); | 2243 | msg->msg_flags & MSG_DONTWAIT); |
2244 | if (IS_ERR(skb)) | 2244 | if (IS_ERR(skb)) |
2245 | return skb; | 2245 | return skb; |
@@ -2360,7 +2360,7 @@ static struct sk_buff *l2cap_create_le_flowctl_pdu(struct l2cap_chan *chan, | |||
2360 | 2360 | ||
2361 | count = min_t(unsigned int, (conn->mtu - hlen), len); | 2361 | count = min_t(unsigned int, (conn->mtu - hlen), len); |
2362 | 2362 | ||
2363 | skb = chan->ops->alloc_skb(chan, count + hlen, | 2363 | skb = chan->ops->alloc_skb(chan, hlen, count, |
2364 | msg->msg_flags & MSG_DONTWAIT); | 2364 | msg->msg_flags & MSG_DONTWAIT); |
2365 | if (IS_ERR(skb)) | 2365 | if (IS_ERR(skb)) |
2366 | return skb; | 2366 | return skb; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index d95964c9f91e..55215ebf6547 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -1292,6 +1292,7 @@ static void l2cap_sock_state_change_cb(struct l2cap_chan *chan, int state, | |||
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, | 1294 | static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, |
1295 | unsigned long hdr_len, | ||
1295 | unsigned long len, int nb) | 1296 | unsigned long len, int nb) |
1296 | { | 1297 | { |
1297 | struct sock *sk = chan->data; | 1298 | struct sock *sk = chan->data; |
@@ -1299,7 +1300,7 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, | |||
1299 | int err; | 1300 | int err; |
1300 | 1301 | ||
1301 | l2cap_chan_unlock(chan); | 1302 | l2cap_chan_unlock(chan); |
1302 | skb = bt_skb_send_alloc(sk, len, nb, &err); | 1303 | skb = bt_skb_send_alloc(sk, hdr_len + len, nb, &err); |
1303 | l2cap_chan_lock(chan); | 1304 | l2cap_chan_lock(chan); |
1304 | 1305 | ||
1305 | if (!skb) | 1306 | if (!skb) |