Date: Sat, 7 Nov 2015 12:15:03 +0000 (UTC) From: Takanori Watanabe <takawata@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290491 - in head/sys/netgraph/bluetooth: hci socket Message-ID: <201511071215.tA7CF3vm026280@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: takawata Date: Sat Nov 7 12:15:02 2015 New Revision: 290491 URL: https://svnweb.freebsd.org/changeset/base/290491 Log: Fix encryption error handling. Close l2cap connection on encryption error. Modified: head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c Modified: head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c ============================================================================== --- head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c Sat Nov 7 12:11:17 2015 (r290490) +++ head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c Sat Nov 7 12:15:02 2015 (r290491) @@ -913,17 +913,17 @@ encryption_change(ng_hci_unit_p unit, st ng_hci_encryption_change_ep *ep = NULL; ng_hci_unit_con_p con = NULL; int error = 0; + u_int16_t h; NG_HCI_M_PULLUP(event, sizeof(*ep)); if (event == NULL) return (ENOBUFS); ep = mtod(event, ng_hci_encryption_change_ep *); + h = NG_HCI_CON_HANDLE(le16toh(ep->con_handle)); + con = ng_hci_con_by_handle(unit, h); if (ep->status == 0) { - u_int16_t h = NG_HCI_CON_HANDLE(le16toh(ep->con_handle)); - - con = ng_hci_con_by_handle(unit, h); if (con == NULL) { NG_HCI_ALERT( "%s: %s - invalid connection handle=%d\n", @@ -940,12 +940,14 @@ encryption_change(ng_hci_unit_p unit, st con->encryption_mode = NG_HCI_ENCRYPTION_MODE_P2P; else con->encryption_mode = NG_HCI_ENCRYPTION_MODE_NONE; - ng_hci_lp_enc_change(con, ep->encryption_enable); } else NG_HCI_ERR( "%s: %s - failed to change encryption mode, status=%d\n", __func__, NG_NODE_NAME(unit->node), ep->status); + /*Anyway, propagete encryption status to upper layer*/ + ng_hci_lp_enc_change(con, con->encryption_mode); + NG_FREE_M(event); return (error); Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c ============================================================================== --- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c Sat Nov 7 12:11:17 2015 (r290490) +++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c Sat Nov 7 12:15:02 2015 (r290491) @@ -467,6 +467,7 @@ ng_btsocket_l2cap_process_l2ca_con_req_r (pcb->idtype == NG_L2CAP_L2CA_IDTYPE_SMP)){ pcb->encryption = op->encryption; pcb->cid = op->lcid; if(pcb->need_encrypt && !(pcb->encryption)){ + ng_btsocket_l2cap_timeout(pcb); pcb->state = NG_BTSOCKET_L2CAP_W4_ENC_CHANGE; }else{ pcb->state = NG_BTSOCKET_L2CAP_OPEN; @@ -713,6 +714,7 @@ static int ng_btsocket_l2cap_process_l2c pcb->encryption = op->result; if(pcb->need_encrypt){ + ng_btsocket_l2cap_untimeout(pcb); if(pcb->state != NG_BTSOCKET_L2CAP_W4_ENC_CHANGE){ NG_BTSOCKET_L2CAP_WARN("%s: Invalid pcb status %d", __func__, pcb->state); @@ -721,6 +723,7 @@ static int ng_btsocket_l2cap_process_l2c soisconnected(pcb->so); }else{ pcb->so->so_error = EPERM; + ng_btsocket_l2cap_send_l2ca_discon_req(0, pcb); pcb->state = NG_BTSOCKET_L2CAP_CLOSED; soisdisconnected(pcb->so); } @@ -2844,6 +2847,7 @@ ng_btsocket_l2cap_process_timeout(void * switch (pcb->state) { case NG_BTSOCKET_L2CAP_CONNECTING: case NG_BTSOCKET_L2CAP_CONFIGURING: + case NG_BTSOCKET_L2CAP_W4_ENC_CHANGE: /* Send disconnect request with "zero" token */ if (pcb->cid != 0) ng_btsocket_l2cap_send_l2ca_discon_req(0, pcb);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511071215.tA7CF3vm026280>