I can't get Bluetooth working. Setting up the netgraph nodes with ngctl works, but trying to send a command with hccontrol fails with "Message too long" (EMSGSIZE). I've bisected this to r275326, a merge from the projects/sendfile branch. I guess some of the socket changes don't work 100% reliably with the netgraph/Bluetooth code. I can reproduce this with a recent snapshot on a Thinkpad T420 with Bluetooth from Broadcom. I can send more info if needed.
Yes, please provide the all sequence of commands to reproduce the problem.
I've run "sh -x /etc/rc.d/bluetooth start ubt0" to debug the bluetooth startup script and it runs these commands: ngctl mkpeer ubt0: hci hook drv ngctl name ubt0:hook ubt0hci ngctl msg ubt0hci: set_debug 3 ngctl mkpeer ubt0hci: l2cap acl hci ngctl name ubt0hci:acl ubt0l2cap ngctl msg ubt0l2cap: set_debug 3 ngctl connect ubt0hci: btsock_hci_raw: raw ubt0raw ngctl connect ubt0l2cap: btsock_l2c_raw: ctl ubt0ctl ngctl connect ubt0l2cap: btsock_l2c: l2c ubt0l2c /usr/sbin/hccontrol -n ubt0hci reset It fails at the hccontrol command with a "Message too long" error. The ngctl commands work fine. I'll reboot into the snapshot again and see if there is anything unusual in dmesg or /var/log/messages.
Can you please do: # kldload dtraceall # dtrace -n 'fbt:ng_btsocket::return / execname == "hccontrol" && arg1 == 40 / { stack(); }' Then in another window try to reproduce the problem again. I'm interested whether dtrace would catch anything.
This Dtrace command didn't catch anything, sadly.
How many probes did it match?
It did match 123 probes. If I leave out "arg1 == 40", stuff gets printed when I run hccontrol, but not when I leave it in.
Can you please run: # dtrace -n 'syscall:::return / execname == "hccontrol" && arg1 == -1 / { printf("ret %d\n", arg1); stack(); }'
There are only some lstat/access/readlink/stat syscalls that return ENOENT.
Ok. I will update my Thinkpad X1 to recent head and try it myself. Never used bluetooth on it before.
I've just noticed that hccontrol sets EMSGSIZE itself in two places. I'll check if this is the source of the error.
I did some printf debugging of hccontrol, and it looks like recv in hci_recv in send_recv.c returns 0 and not at least sizeof(ng_hci_event_pkt_t). Then errno is set to EMSGSIZE. The socket was created by a call to socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI). I've tried to call recv in a loop, but then hci_recv just runs into the timeout.
btw, have you tried head after 275968?
(In reply to Gleb Smirnoff from comment #12) > btw, have you tried head after 275968? I`ve seen exactly the same problem with r276028 and reverting to r275326 also helped to solve it. I`ve tracked it to line 77 of /usr/src/usr.sbin/bluetooth/hccontrol/send_recv.c like Jan did
Created attachment 150848 [details] Proposed patch. Can you please test this patch?
With this patch, at least "hccontrol -n ubt0hci reset" and "hccontrol -n ubt0hci inquiry" work, and "service bluetooth start ubt0" works as before, i.e. the first time there is an error but the second time it works. The hccontrol inquiry command correctly detects my phone. Starting the hcsecd daemon with "hcsecd -d" also seems to work fine. However, trying to send/receive files fails. "obexapp -a XX:XX:XX:XX:XX:XX -C OPUSH" prints "obexapp: Could not obtain RFCOMM channel: No message of desired type" after maybe 10 seconds. Usually this command causes a confirmation dialog to pop up on the phone and then goes into a ftp-like interface where one can upload files to the phone.
Created attachment 150851 [details] another patch Please try this one, backing out the previous one.
Thanks, this patch works! Sending and receiving files is possible again.
A commit references this bug: Author: glebius Date: Mon Dec 22 15:39:25 UTC 2014 New revision: 276058 URL: https://svnweb.freebsd.org/changeset/base/276058 Log: In sbappend*() family of functions clear M_PROTO flags of incoming mbufs. sbappendstream() already does this in m_demote(). PR: 196174 Sponsored by: Nginx, Inc. Changes: head/sys/kern/uipc_sockbuf.c
I`m also able to use my bt keyboard now. Thank you.