diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-12-02 09:02:03 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-12-05 10:05:34 -0500 |
commit | 64b4f8dc763d5c26dea0f483d6e475540eaf9759 (patch) | |
tree | 916bea4e6211ad9b3a510e7b4272150d3b735b98 /net | |
parent | 0cd75f7ed740a8c605fe55ac71a9b5162c612422 (diff) |
Bluetooth: Limit L2CAP_OPTIONS socket option usage with LE
Most of the values in L2CAP_OPTIONS are not applicable for LE and those
that are have different semantics. It makes therefore sense to
completely block this socket option for LE and add (in a separate patch)
a new socket option for tweaking the values that do make sense (mainly
the send and receive MTU). Legacy user space ATT code still depends on
getsockopt for L2CAP_OPTIONS though so we need to plug a hole for that
for backwards compatibility.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 61e25bafdf43..a20fcc3ddcd9 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -370,6 +370,16 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, | |||
370 | 370 | ||
371 | switch (optname) { | 371 | switch (optname) { |
372 | case L2CAP_OPTIONS: | 372 | case L2CAP_OPTIONS: |
373 | /* LE sockets should use BT_SNDMTU/BT_RCVMTU, but since | ||
374 | * legacy ATT code depends on getsockopt for | ||
375 | * L2CAP_OPTIONS we need to let this pass. | ||
376 | */ | ||
377 | if (bdaddr_type_is_le(chan->src_type) && | ||
378 | chan->scid != L2CAP_CID_ATT) { | ||
379 | err = -EINVAL; | ||
380 | break; | ||
381 | } | ||
382 | |||
373 | memset(&opts, 0, sizeof(opts)); | 383 | memset(&opts, 0, sizeof(opts)); |
374 | opts.imtu = chan->imtu; | 384 | opts.imtu = chan->imtu; |
375 | opts.omtu = chan->omtu; | 385 | opts.omtu = chan->omtu; |
@@ -564,6 +574,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, | |||
564 | 574 | ||
565 | switch (optname) { | 575 | switch (optname) { |
566 | case L2CAP_OPTIONS: | 576 | case L2CAP_OPTIONS: |
577 | if (bdaddr_type_is_le(chan->src_type)) { | ||
578 | err = -EINVAL; | ||
579 | break; | ||
580 | } | ||
581 | |||
567 | if (sk->sk_state == BT_CONNECTED) { | 582 | if (sk->sk_state == BT_CONNECTED) { |
568 | err = -EINVAL; | 583 | err = -EINVAL; |
569 | break; | 584 | break; |