1. 26 10月, 2015 6 次提交
    • M
      Bluetooth: Rename bt_cb()->req into bt_cb()->hci · 242c0ebd
      Marcel Holtmann 提交于
      The SKB context buffer for HCI request is really not just for requests,
      information in their are preserved for the whole HCI layer. So it makes
      more sense to actually rename it into bt_cb()->hci and also call it then
      struct hci_ctrl.
      
      In addition that allows moving the decoded opcode for outgoing packets
      into that struct. So far it was just consuming valuable space from the
      main shared items. And opcode are not valid for L2CAP packets.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      242c0ebd
    • M
      Bluetooth: Remove unneeded parenthesis around MSG_OOB · d94a6104
      Marcel Holtmann 提交于
      There are two checks that are still using (MSG_OOB) instead of just
      MSG_OOB and so lets just fix them.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      d94a6104
    • K
      Bluetooth: Fix locking issue during fast SCO reconnection. · 1da5537e
      Kuba Pawlak 提交于
      When SCO connection is requested and disconnected fast, there is a change
      that sco_sock_shutdown is going to preempt thread started in sco_connect_cfm.
      When this happens struct sock sk may be removed but a pointer to it is still
      held in sco_conn_ready, where embedded spinlock is used. If it is used, but
      struct sock has been removed, it will crash.
      
      Block connection object, which will prevent struct sock from being removed
      and give connection process chance to finish.
      
      BUG: spinlock bad magic on CPU#0, kworker/u:2H/319
       lock: 0xe3e99434, .magic: f3000000, .owner: (���/0, .owner_cpu: -203804160
      Pid: 319, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      Call Trace:
       [<c1155659>] ? do_raw_spin_lock+0x19/0xe9
       [<fb75354f>] ? sco_connect_cfm+0x92/0x236 [bluetooth]
       [<fb731dbc>] ? hci_sync_conn_complete_evt.clone.101+0x18b/0x1cb [bluetooth]
       [<fb734ee7>] ? hci_event_packet+0x1acd/0x21a6 [bluetooth]
       [<c1041095>] ? finish_task_switch+0x50/0x89
       [<c1349a2e>] ? __schedule+0x638/0x6b8
       [<fb727918>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
       [<c103760a>] ? queue_delayed_work_on+0x21/0x2a
       [<c1035df9>] ? process_one_work+0x157/0x21b
       [<fb72785f>] ? hci_cmd_work+0xef/0xef [bluetooth]
       [<c1036217>] ? worker_thread+0x16e/0x20a
       [<c10360a9>] ? manage_workers+0x1cf/0x1cf
       [<c103a0ef>] ? kthread+0x8d/0x92
       [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
       [<c103a062>] ? __init_kthread_worker+0x24/0x24
      BUG: unable to handle kernel NULL pointer dereference at   (null)
      IP: [<  (null)>]   (null)
      *pdpt = 00000000244e1001 *pde = 0000000000000000
      Oops: 0010 [#1] PREEMPT SMP
      Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) cdc_acm btintel(O) bluetooth(O) arc4 uinput hid_multitouch usbhid hid iwlmvm(O)e
      Pid: 319, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      EIP: 0060:[<00000000>] EFLAGS: 00010246 CPU: 0
      EIP is at 0x0
      EAX: e3e99400 EBX: e3e99400 ECX: 00000100 EDX: 00000000
      ESI: e3e99434 EDI: fb763ce0 EBP: e49b9e44 ESP: e49b9e14
       DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      CR0: 8005003b CR2: 00000000 CR3: 24444000 CR4: 001007f0
      DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      DR6: ffff0ff0 DR7: 00000400
      Process kworker/u:2H (pid: 319, ti=e49b8000 task=e4ab9030 task.ti=e49b8000)
      Stack:
       fb75355b 00000246 fb763900 22222222 22222222 22222222 e3f94460 e3ca7c0a
       e49b9e4c e3f34c00 e3ca7c0a fb763ce0 e49b9e6c fb731dbc 02000246 e4cec85c
       e4cec008 00000000 e3f34c00 e4cec000 e3c2ce00 0000002c e49b9ed0 fb734ee7
      Call Trace:
       [<fb75355b>] ? sco_connect_cfm+0x9e/0x236 [bluetooth]
       [<fb731dbc>] ? hci_sync_conn_complete_evt.clone.101+0x18b/0x1cb [bluetooth]
       [<fb734ee7>] ? hci_event_packet+0x1acd/0x21a6 [bluetooth]
       [<c1041095>] ? finish_task_switch+0x50/0x89
       [<c1349a2e>] ? __schedule+0x638/0x6b8
       [<fb727918>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
       [<c103760a>] ? queue_delayed_work_on+0x21/0x2a
       [<c1035df9>] ? process_one_work+0x157/0x21b
       [<fb72785f>] ? hci_cmd_work+0xef/0xef [bluetooth]
       [<c1036217>] ? worker_thread+0x16e/0x20a
       [<c10360a9>] ? manage_workers+0x1cf/0x1cf
       [<c103a0ef>] ? kthread+0x8d/0x92
       [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
       [<c103a062>] ? __init_kthread_worker+0x24/0x24
      Code:  Bad EIP value.
      EIP: [<00000000>] 0x0 SS:ESP 0068:e49b9e14
      CR2: 0000000000000000
      ---[ end trace 942a6577c0abd725 ]---
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1da5537e
    • K
      Bluetooth: Fix locking issue on SCO disconnection · 435c5133
      Kuba Pawlak 提交于
      Thread handling SCO disconnection may get preempted in '__sco_sock_close'
      after dropping a reference to hci_conn but before marking this as NULL
      in associated struct sco_conn. When execution returs to this thread,
      this connection will possibly be released, resulting in kernel crash
      
      Lock connection before this point.
      
      BUG: unable to handle kernel NULL pointer dereference at   (null)
      IP: [<fb770ab9>] __sco_sock_close+0x194/0x1ff [bluetooth]
      *pdpt = 0000000023da6001 *pde = 0000000000000000
      Oops: 0002 [#1] PREEMPT SMP
      Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) cdc_acm btintel(O) bluetooth(O) arc4 uinput hid_multitouch usbhid iwlmvm(O) hide
      Pid: 984, comm: bluetooth Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      EIP: 0060:[<fb770ab9>] EFLAGS: 00010282 CPU: 2
      EIP is at __sco_sock_close+0x194/0x1ff [bluetooth]
      EAX: 00000000 EBX: e49d7600 ECX: ef1ec3c2 EDX: 000000c3
      ESI: e4c12000 EDI: 00000000 EBP: ef1edf5c ESP: ef1edf4c
       DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      CR0: 80050033 CR2: 00000000 CR3: 23da7000 CR4: 001007f0
      DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      DR6: ffff0ff0 DR7: 00000400
      Process bluetooth (pid: 984, ti=ef1ec000 task=e47f2550 task.ti=ef1ec000)
      Stack:
       e4c120d0 e49d7600 00000000 08421a40 ef1edf70 fb770b7a 00000002 e8a4cc80
       08421a40 ef1ec000 c12966b1 00000001 00000000 0000000b 084954c8 c1296b6c
       0000001b 00000002 0000001b 00000002 00000000 00000002 b2524880 00000046
      Call Trace:
       [<fb770b7a>] ? sco_sock_shutdown+0x56/0x95 [bluetooth]
       [<c12966b1>] ? sys_shutdown+0x37/0x53
       [<c1296b6c>] ? sys_socketcall+0x12e/0x1be
       [<c134ae7e>] ? sysenter_do_call+0x12/0x26
       [<c1340000>] ? ip_vs_control_net_cleanup+0x46/0xb1
      Code: e8 90 6b 8c c5 f6 05 72 5d 78 fb 04 74 17 8b 46 08 50 56 68 0a fd 77 fb 68 60 5d 78 fb e8 68 95 9e c5 83 c4 10 8b 83 fc 01 00 00 <c7> 00 00 00 00 00 eb 32 ba 68 00 00 0b
      EIP: [<fb770ab9>] __sco_sock_close+0x194/0x1ff [bluetooth] SS:ESP 0068:ef1edf4c
      CR2: 0000000000000000
      ---[ end trace 47fa2f55a9544e69 ]---
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      435c5133
    • K
      Bluetooth: Fix crash on SCO disconnect · 75e34f5c
      Kuba Pawlak 提交于
      When disconnecting audio from the phone's side, it may happen, that
      a thread handling HCI message 'disconnection complete' will get preempted
      in 'sco_conn_del' before calling 'sco_sock_kill', still holding a pointer
      to struct sock sk. Interrupting thread started in 'sco_sock_shutdown' will
      carry on releasing resources and will eventually release struct sock.
      When execution goes back to first thread it will call sco_sock_kill using
      now invalid pointer to already destroyed socket.
      
      Fix is to grab a reference to the socket a release it after calling
      'sco_sock_kill'.
      
      [  166.358213] BUG: unable to handle kernel paging request at 7541203a
      [  166.365228] IP: [<fb6e8bfb>] bt_sock_unlink+0x1a/0x38 [bluetooth]
      [  166.372068] *pdpt = 0000000024b19001 *pde = 0000000000000000
      [  166.378483] Oops: 0002 [#1] PREEMPT SMP
      [  166.382871] Modules linked in: evdev ecb rfcomm(O) libcomposite usb2380 udc_core bnep(O) btusb(O) btbcm(O) btintel(O) cdc_acm bluetooth(O) arc4 uinput hid_multitouch iwlmvm(O) usbhid hide
      [  166.424233] Pid: 338, comm: kworker/u:2H Tainted: G           O 3.8.0-115.1-plk-adaptation-byt-ivi-brd #1
      [  166.435112] EIP: 0060:[<fb6e8bfb>] EFLAGS: 00010206 CPU: 0
      [  166.441259] EIP is at bt_sock_unlink+0x1a/0x38 [bluetooth]
      [  166.447382] EAX: 632e6563 EBX: e4bfc600 ECX: e466d4d3 EDX: 7541203a
      [  166.454369] ESI: fb7278ac EDI: e4d52000 EBP: e4669e20 ESP: e4669e0c
      [  166.461366]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      [  166.467391] CR0: 8005003b CR2: 7541203a CR3: 24aba000 CR4: 001007f0
      [  166.474387] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      [  166.481375] DR6: ffff0ff0 DR7: 00000400
      [  166.485654] Process kworker/u:2H (pid: 338, ti=e4668000 task=e466e030 task.ti=e4668000)
      [  166.494591] Stack:
      [  166.496830]  e4bfc600 e4bfc600 fb715c28 e4717ee0 e4d52000 e4669e3c fb715cf3 e4bfc634
      [  166.505518]  00000068 e4d52000 e4c32000 fb7277c0 e4669e6c fb6f2019 0000004a 00000216
      [  166.514205]  e4660101 e4c32008 02000001 00000013 e4d52000 e4c32000 e3dc9240 00000005
      [  166.522891] Call Trace:
      [  166.525654]  [<fb715c28>] ? sco_sock_kill+0x73/0x9a [bluetooth]
      [  166.532295]  [<fb715cf3>] ? sco_conn_del+0xa4/0xbf [bluetooth]
      [  166.538836]  [<fb6f2019>] ? hci_disconn_complete_evt.clone.55+0x1bd/0x205 [bluetooth]
      [  166.547609]  [<fb6f73d3>] ? hci_event_packet+0x297/0x223c [bluetooth]
      [  166.554805]  [<c10416da>] ? dequeue_task+0xaf/0xb7
      [  166.560154]  [<c1041095>] ? finish_task_switch+0x50/0x89
      [  166.566086]  [<c1349a2e>] ? __schedule+0x638/0x6b8
      [  166.571460]  [<fb6eb906>] ? hci_rx_work+0xb9/0x2b8 [bluetooth]
      [  166.577975]  [<c1035df9>] ? process_one_work+0x157/0x21b
      [  166.583933]  [<fb6eb84d>] ? hci_cmd_work+0xef/0xef [bluetooth]
      [  166.590448]  [<c1036217>] ? worker_thread+0x16e/0x20a
      [  166.596088]  [<c10360a9>] ? manage_workers+0x1cf/0x1cf
      [  166.601826]  [<c103a0ef>] ? kthread+0x8d/0x92
      [  166.606691]  [<c134adf7>] ? ret_from_kernel_thread+0x1b/0x28
      [  166.613010]  [<c103a062>] ? __init_kthread_worker+0x24/0x24
      [  166.619230] Code: 85 63 ff ff ff 31 db 8d 65 f4 89 d8 5b 5e 5f 5d c3 56 8d 70 04 53 89 f0 89 d3 e8 7e 17 c6 c5 8b 53 28 85 d2 74 1a 8b 43 24 85 c0 <89> 02 74 03 89 50 04 c7 43 28 00 00 00
      [  166.640501] EIP: [<fb6e8bfb>] bt_sock_unlink+0x1a/0x38 [bluetooth] SS:ESP 0068:e4669e0c
      [  166.649474] CR2: 000000007541203a
      [  166.653420] ---[ end trace 0181ff2c9e42d51e ]---
      [  166.658609] note: kworker/u:2H[338] exited with preempt_count 1
      Signed-off-by: NKuba Pawlak <kubax.t.pawlak@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      75e34f5c
    • J
      Bluetooth: btmrvl: add missing of_node_put · c0859e2f
      Julia Lawall 提交于
      for_each_compatible_node performs an of_node_get on each iteration, so
      a break out of the loop requires an of_node_put.
      
      A simplified version of the semantic patch that fixes this problem is as
      follows (http://coccinelle.lip6.fr):
      
      // <smpl>
      @@
      expression e;
      local idexpression n;
      @@
      
       for_each_compatible_node(n, ...) {
         ... when != of_node_put(n)
             when != e = n
      (
         return n;
      |
      +  of_node_put(n);
      ?  return ...;
      )
         ...
       }
      // </smpl>
      Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c0859e2f
  2. 22 10月, 2015 16 次提交
  3. 21 10月, 2015 18 次提交
    • J
      Bluetooth: Fix missing hdev locking for LE scan cleanup · 8ce783dc
      Johan Hedberg 提交于
      The hci_conn objects don't have a dedicated lock themselves but rely
      on the caller to hold the hci_dev lock for most types of access. The
      hci_conn_timeout() function has so far sent certain HCI commands based
      on the hci_conn state which has been possible without holding the
      hci_dev lock.
      
      The recent changes to do LE scanning before connect attempts added
      even more operations to hci_conn and hci_dev from hci_conn_timeout,
      thereby exposing potential race conditions with the hci_dev and
      hci_conn states.
      
      As an example of such a race, here there's a timeout but an
      l2cap_sock_connect() call manages to race with the cleanup routine:
      
      [Oct21 08:14] l2cap_chan_timeout: chan ee4b12c0 state BT_CONNECT
      [  +0.000004] l2cap_chan_close: chan ee4b12c0 state BT_CONNECT
      [  +0.000002] l2cap_chan_del: chan ee4b12c0, conn f3141580, err 111, state BT_CONNECT
      [  +0.000002] l2cap_sock_teardown_cb: chan ee4b12c0 state BT_CONNECT
      [  +0.000005] l2cap_chan_put: chan ee4b12c0 orig refcnt 4
      [  +0.000010] hci_conn_drop: hcon f53d56e0 orig refcnt 1
      [  +0.000013] l2cap_chan_put: chan ee4b12c0 orig refcnt 3
      [  +0.000063] hci_conn_timeout: hcon f53d56e0 state BT_CONNECT
      [  +0.000049] hci_conn_params_del: addr ee:0d:30:09:53:1f (type 1)
      [  +0.000002] hci_chan_list_flush: hcon f53d56e0
      [  +0.000001] hci_chan_del: hci0 hcon f53d56e0 chan f4e7ccc0
      [  +0.004528] l2cap_sock_create: sock e708fc00
      [  +0.000023] l2cap_chan_create: chan ee4b1770
      [  +0.000001] l2cap_chan_hold: chan ee4b1770 orig refcnt 1
      [  +0.000002] l2cap_sock_init: sk ee4b3390
      [  +0.000029] l2cap_sock_bind: sk ee4b3390
      [  +0.000010] l2cap_sock_setsockopt: sk ee4b3390
      [  +0.000037] l2cap_sock_connect: sk ee4b3390
      [  +0.000002] l2cap_chan_connect: 00:02:72:d9:e5:8b -> ee:0d:30:09:53:1f (type 2) psm 0x00
      [  +0.000002] hci_get_route: 00:02:72:d9:e5:8b -> ee:0d:30:09:53:1f
      [  +0.000001] hci_dev_hold: hci0 orig refcnt 8
      [  +0.000003] hci_conn_hold: hcon f53d56e0 orig refcnt 0
      
      Above the l2cap_chan_connect() shouldn't have been able to reach the
      hci_conn f53d56e0 anymore but since hci_conn_timeout didn't do proper
      locking that's not the case. The end result is a reference to hci_conn
      that's not in the conn_hash list, resulting in list corruption when
      trying to remove it later:
      
      [Oct21 08:15] l2cap_chan_timeout: chan ee4b1770 state BT_CONNECT
      [  +0.000004] l2cap_chan_close: chan ee4b1770 state BT_CONNECT
      [  +0.000003] l2cap_chan_del: chan ee4b1770, conn f3141580, err 111, state BT_CONNECT
      [  +0.000001] l2cap_sock_teardown_cb: chan ee4b1770 state BT_CONNECT
      [  +0.000005] l2cap_chan_put: chan ee4b1770 orig refcnt 4
      [  +0.000002] hci_conn_drop: hcon f53d56e0 orig refcnt 1
      [  +0.000015] l2cap_chan_put: chan ee4b1770 orig refcnt 3
      [  +0.000038] hci_conn_timeout: hcon f53d56e0 state BT_CONNECT
      [  +0.000003] hci_chan_list_flush: hcon f53d56e0
      [  +0.000002] hci_conn_hash_del: hci0 hcon f53d56e0
      [  +0.000001] ------------[ cut here ]------------
      [  +0.000461] WARNING: CPU: 0 PID: 1782 at lib/list_debug.c:56 __list_del_entry+0x3f/0x71()
      [  +0.000839] list_del corruption, f53d56e0->prev is LIST_POISON2 (00000200)
      
      The necessary fix is unfortunately more complicated than just adding
      hci_dev_lock/unlock calls to the hci_conn_timeout() call path.
      Particularly, the hci_conn_del() API, which expects the hci_dev lock to
      be held, performs a cancel_delayed_work_sync(&hcon->disc_work) which
      would lead to a deadlock if the hci_conn_timeout() call path tries to
      acquire the same lock.
      
      This patch solves the problem by deferring the cleanup work to a
      separate work callback. To protect against the hci_dev or hci_conn
      going away meanwhile temporary references are taken with the help of
      hci_dev_hold() and hci_conn_get().
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Cc: stable@vger.kernel.org # 4.3
      8ce783dc
    • M
      Bluetooth: btintel: Enable extra Intel vendor events · 213445b2
      Marcel Holtmann 提交于
      The Intel Bluetooth controllers can emit extra vendor specific events in
      error conditions or for debugging purposes. To make the life easier for
      engineers, enable them by default. When the vendor_diag options has been
      enabled, then additional debug events are also enabled.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      213445b2
    • M
      Bluetooth: btusb: Set manufacturer for Intel bootloader devices · e4c534bb
      Marcel Holtmann 提交于
      For Intel bootloader devices, set the manufacturer information so that
      it becomes possible to decode the boot process.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      e4c534bb
    • M
      Bluetooth: Introduce driver specific post init callback · 98a63aaf
      Marcel Holtmann 提交于
      Some drivers might have to restore certain settings after the init
      procedure has been completed. This driver callback allows them to hook
      into that stage. This callback is run just before the controller is
      declared as powered up.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      98a63aaf
    • M
      Bluetooth: hci_uart: Provide initial manufacturer information · aee61f7a
      Marcel Holtmann 提交于
      Provide an early indication about the manufacturer information so that
      it can be forwarded into monitor channel.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      aee61f7a
    • D
      Bluetooth: l2cap_disconnection_req priority over shutdown · 9f7378a9
      Dean Jenkins 提交于
      There is a L2CAP protocol race between the local peer and
      the remote peer demanding disconnection of the L2CAP link.
      
      When L2CAP ERTM is used, l2cap_sock_shutdown() can be called
      from userland to disconnect L2CAP. However, there can be a
      delay introduced by waiting for ACKs. During this waiting
      period, the remote peer may have sent a Disconnection Request.
      Therefore, recheck the shutdown status of the socket
      after waiting for ACKs because there is no need to do
      further processing if the connection has gone.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NHarish Jenny K N <harish_kandiga@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9f7378a9
    • D
      Bluetooth: Reorganize mutex lock in l2cap_sock_shutdown() · 04ba72e6
      Dean Jenkins 提交于
      This commit reorganizes the mutex lock and is now
      only protecting l2cap_chan_close(). This is now consistent
      with other places where l2cap_chan_close() is called.
      
      If a conn connection exists, call
      mutex_lock(&conn->chan_lock) before calling l2cap_chan_close()
      to ensure other L2CAP protocol operations do not interfere.
      
      Note that the conn structure has to be protected from being
      freed as it is possible for the connection to be disconnected
      whilst the locks are not held. This solution allows the mutex
      lock to be used even when the connection has just been
      disconnected.
      
      This commit also reduces the scope of chan locking.
      
      The only place where chan locking is needed is the call to
      l2cap_chan_close(chan, 0) which if necessary closes the channel.
      Therefore, move the l2cap_chan_lock(chan) and
      l2cap_chan_lock(chan) locking calls to around
      l2cap_chan_close(chan, 0).
      
      This allows __l2cap_wait_ack(sk, chan) to be called with no
      chan locks being held so L2CAP messaging over the ACL link
      can be done unimpaired.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NHarish Jenny K N <harish_kandiga@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      04ba72e6
    • D
      Bluetooth: Unwind l2cap_sock_shutdown() · e7456437
      Dean Jenkins 提交于
      l2cap_sock_shutdown() is designed to only action shutdown
      of the channel when shutdown is not already in progress.
      Therefore, reorganise the code flow by adding a goto
      to jump to the end of function handling when shutdown is
      already being actioned. This removes one level of code
      indentation and make the code more readable.
      Signed-off-by: NDean Jenkins <Dean_Jenkins@mentor.com>
      Signed-off-by: NHarish Jenny K N <harish_kandiga@mentor.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      e7456437
    • A
      6lowpan: put mcast compression in an own function · 09bf420f
      Alexander Aring 提交于
      This patch moves the mcast compression algorithmn to an own function
      like all other compression/decompression methods in iphc.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      09bf420f
    • A
      6lowpan: rework tc and flow label handling · b5af9bdb
      Alexander Aring 提交于
      This patch reworks the handling of compression/decompression of traffic
      class and flow label handling. The current method is hard to understand,
      also doesn't checks if we can read the buffer from skb length.
      
      I tried to put the shifting operations into static inline functions and
      comment each steps which I did there to make it hopefully somewhat more
      readable. The big mess to deal with that is the that the ipv6 header
      bring the order "DSCP + ECN" but iphc uses "ECN + DSCP". Additional the
      DCSP + ECN bits are splitted in ipv6_hdr inside the priority and
      flow_lbl[0] fields.
      
      I tested these compressions by using fakelb 802.15.4 driver and
      manipulate the tc and flow label fields manually in function
      "__ip6_local_out" before the skb will be send to lower layers. Then I
      looked up the tc and flow label fields in wireshark on a wpan and lowpan
      interface.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      b5af9bdb
    • A
      6lowpan: iphc: change define values · c8a3e7eb
      Alexander Aring 提交于
      This patch has the main goal to delete shift operations. Instead we
      doing masks and equals afterwards. E.g. for the SAM evaluation we
      masking only the SAM value which fits in iphc1 byte, then comparing with
      all possible SAM values over a switch case statement. We will not
      shifting the SAM value to somewhat readable anymore.
      Additional this patch slighty change the naming style like RFC 6282,
      e.g. TTL to HLIM and we will drop an errno now if CID flag is set,
      because we don't support it.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c8a3e7eb
    • A
      6lowpan: remove lowpan_is_addr_broadcast · 028b2a8c
      Alexander Aring 提交于
      This macro is used at 802.15.4 6LoWPAN only and can be replaced by
      memcmp with the interface broadcast address.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      028b2a8c
    • A
      6lowpan: move IPHC functionality defines · 6350047e
      Alexander Aring 提交于
      This patch removes the IPHC related defines for doing bit manipulation
      from global 6lowpan header to the iphc file which should the only one
      implementation which use these defines.
      
      Also move next header compression defines to their nhc implementation.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6350047e
    • A
      6lowpan: nhc: move iphc manipulation out of nhc · 607b0bd3
      Alexander Aring 提交于
      This patch moves the iphc setting of next header commpression bit inside
      iphc functionality. Setting of IPHC bits should be happen at iphc.c file
      only.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      607b0bd3
    • A
      6lowpan: remove lowpan_fetch_skb_u8 · 478208e3
      Alexander Aring 提交于
      This patch removes the lowpan_fetch_skb_u8 function for getting the iphc
      bytes. Instead we using the generic which has a len parameter to tell
      the amount of bytes to fetch.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      478208e3
    • A
      6lowpan: cleanup lowpan_header_decompress · 8911d774
      Alexander Aring 提交于
      This patch changes the lowpan_header_decompress function by removing
      inklayer related information from parameters. This is currently for
      supporting short and extended address for iphc handling in 802154.
      We don't support short address handling anyway right now, but there
      exists already code for handling short addresses in
      lowpan_header_decompress.
      
      The address parameters are also changed to a void pointer, so 6LoWPAN
      linklayer specific code can put complex structures as these parameters
      and cast it again inside the generic code by evaluating linklayer type
      before. The order is also changed by destination address at first and
      then source address, which is the same like all others functions where
      destination is always the first, memcpy, dev_hard_header,
      lowpan_header_compress, etc.
      
      This patch also moves the fetching of iphc values from 6LoWPAN linklayer
      specific code into the generic branch.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      8911d774
    • A
      6lowpan: cleanup lowpan_header_compress · a6f77389
      Alexander Aring 提交于
      This patch changes the lowpan_header_compress function by removing
      unused parameters like "len" and drop static value parameters of
      protocol type. Instead we really check the protocol type inside inside
      the skb structure. Also we drop the use of IEEE802154_ADDR_LEN which is
      link-layer specific. Instead we using EUI64_ADDR_LEN which should always
      the default case for now.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a6f77389
    • A
      6lowpan: introduce LOWPAN_IPHC_MAX_HC_BUF_LEN · bf513fd6
      Alexander Aring 提交于
      This patch introduces the LOWPAN_IPHC_MAX_HC_BUF_LEN define which
      represent the worst-case supported IPHC buffer length. It's used to
      allocate the stack buffer space for creating the IPHC header.
      Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
      Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      bf513fd6