Home | History | Annotate | Download | only in netbt
History log of /src/sys/netbt/rfcomm_upper.c
RevisionDateAuthorComments
 1.24  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.23  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.22  16-Nov-2014  plunky branches: 1.22.18; 1.22.20;
since rfcomm_attach_pcb may be called from (soft) interrupt context
(for incoming connections), use kmem_intr_()
 1.21  08-Aug-2014  rtr branches: 1.21.2;
split PRU_RCVD function out of pr_generic() usrreq switches and put into
separate functions

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_RCVD with calls to
pr_rcvd()
 1.20  05-Aug-2014  rtr split PRU_SEND function out of pr_generic() usrreq switches and put into
separate functions

xxx_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *, struct lwp *)

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_SEND with calls to
pr_send()

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_send() PRUs

- l2cap_send() -> l2cap_send_pcb()
- sco_send() -> sco_send_pcb()
- rfcomm_send() -> rfcomm_send_pcb()

patch reviewed by rmind
 1.19  31-Jul-2014  rtr split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions

xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)

- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively

rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().

- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()

patch reviewed by rmind
 1.18  30-Jul-2014  rtr split PRU_CONNECT function out of pr_generic() usrreq switches and put
into seaparate functions

xxx_listen(struct socket *, struct mbuf *)

- always KASSERT(solocked(so)) and KASSERT(nam != NULL)
- replace calls to pr_generic() with req = PRU_CONNECT with
pr_connect()
- rename existin {l2cap,sco,rfcomm}_connect() to
{l2cap,sco,rfcomm}_connect_pcb() respectively to permit
naming consistency with other protocols functions.
- drop struct lwp * parameter from unp_connect() and at_pcbconnect()
and use curlwp instead where appropriate.

patch reviewed by rmind
 1.17  24-Jul-2014  rtr split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreq
switches and put into separate functions
xxx_bind(struct socket *, struct mbuf *)
xxx_listen(struct socket *)

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_BIND with call to
pr_bind()

- replace calls to pr_generic() with req = PRU_LISTEN with call to
pr_listen()

- drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and
unp_bind() and always use curlwp.

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_{bind,listen}() PRUs

- l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb()
- sco_{bind,listen}() -> sco_{bind,listen}_pcb()
- rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb()

patch reviewed by rmind

welcome to netbsd 6.99.48
 1.16  09-Jul-2014  rtr * split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).

- KASSERT(solocked(so)) always in new functions even if request
is not implemented

- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.

* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()

- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.

* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).

- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()

* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).

- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()

note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.

patch reviewed by rmind

welcome to 6.99.47
 1.15  20-May-2014  rmind netbt: rename some attach/detach functions to have _pcb suffix, so
we could use standard attach/detach naming for pr_usrreq functions.
No functional change.
 1.14  19-May-2014  rmind - Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.
 1.13  04-Jan-2010  plunky branches: 1.13.22; 1.13.26; 1.13.36;
prevent local socket address from being changed after socket is
in use (connect or listen)
 1.12  22-Nov-2009  mbalmer more s/the the/the/
 1.11  06-Aug-2008  plunky Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
 1.10  20-Nov-2007  plunky branches: 1.10.14; 1.10.18; 1.10.20; 1.10.24;
allow listening to channel RFCOMM_CHANNEL_ANY, which means that
we should allocate the first available channel at the given
device address.
 1.9  20-Nov-2007  plunky when listening, don't attach to the 'any' address unless
we wanted to listen to the 'any' address.
 1.8  03-Nov-2007  plunky branches: 1.8.2;
"struct callout" -> callout_t
don't use callout_reset()
do use callout_destroy()
 1.7  09-Jul-2007  ad branches: 1.7.6; 1.7.8; 1.7.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6  21-Apr-2007  plunky Add 'service level' security for L2CAP and RFCOMM connections, following
the Linux (BlueZ) API.

- L2CAP or RFCOMM connections can require the baseband radio link
mode be any of:
authenticated (devices are paired)
encrypted (implies authentication)
secured (encryption, plus generate new link key)

- for sockets, the mode is set using setsockopt(2) and the socket
connection will be aborted if the mode change fails.

- mode settings will be applied during connection establishment, and
for safety, we enter a wait state and will only proceed when the mode
settings are successfuly set.

- It is possible to change the mode on already open connections, but
not possible to guarantee that data already queued (from either end)
will not be delivered. (this is a feature, not a bug)

- bthidev(4) and rfcomm_sppd(1) support "auth", "encrypt" and
"secure" options

- btdevctl(8) by default enables "auth" for HIDs, and "encrypt" for
keyboards (which are required to support it)
 1.5  06-Apr-2007  plunky rework ordering of error conditions for setopt, prefer to return EINVAL
rather than EBUSY.
 1.4  30-Mar-2007  plunky be more explicit and consistent in use of KASSERT with pointers,
test against NULL
 1.3  06-Mar-2007  plunky branches: 1.3.2; 1.3.4;
don't reset MTU when invalid value is given
 1.2  05-Mar-2007  plunky return ENOPROTOOPT when protocol options are not known
 1.1  19-Jun-2006  gdamore branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.18; 1.1.20; 1.1.24;
Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.
 1.1.24.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.20.3  07-May-2007  yamt sync with head.
 1.1.20.2  15-Apr-2007  yamt sync with head.
 1.1.20.1  12-Mar-2007  rmind Sync with HEAD.
 1.1.18.1  19-Jul-2007  liamjfoy Pull up following revision(s) (requested by plunky in ticket #744):
sys/netbt/l2cap_lower.c: revision 1.6
sys/dev/bluetooth/btdev.h: revision 1.6
sys/netbt/sco_socket.c: revision 1.9
sys/netbt/rfcomm_upper.c: revision 1.3
sys/netbt/l2cap_socket.c: revision 1.7
sys/netbt/rfcomm_upper.c: revision 1.5
lib/libusbhid/usbhid.h: revision 1.5
sys/netbt/rfcomm_upper.c: revision 1.6
usr.sbin/btdevctl/btdevctl.c: revision 1.4
usr.sbin/btdevctl/btdevctl.h: revision 1.3
usr.sbin/btdevctl/btdevctl.8: revision 1.4
sys/netbt/rfcomm_session.c: revision 1.5
sys/netbt/hci.h: revision 1.10
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.6
sys/netbt/hci_link.c: revision 1.11
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.7
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.8
sys/dev/bluetooth/btsco.c: revision 1.14
sys/netbt/rfcomm_session.c: revision 1.9
usr.sbin/btdevctl/sdp.c: revision 1.2
share/man/man9/bluetooth.9: revision 1.2
usr.sbin/btdevctl/sdp.c: revision 1.3
sys/dev/bluetooth/bthidev.c: revision 1.8
sys/netbt/l2cap.h: revision 1.4
sys/netbt/rfcomm.h: revision 1.3
sys/netbt/l2cap.h: revision 1.5
sys/netbt/l2cap_misc.c: revision 1.3
share/man/man4/bluetooth.4: revision 1.5
lib/libusbhid/usbhid.3: revision 1.11
sys/netbt/bluetooth.h: revision 1.5
share/man/man4/bthidev.4: revision 1.8
sys/netbt/rfcomm_dlc.c: revision 1.3
usr.sbin/btdevctl/print.c: revision 1.8
sys/netbt/rfcomm_socket.c: revision 1.7
sys/netbt/l2cap_signal.c: revision 1.4
sys/netbt/l2cap_signal.c: revision 1.5
sys/netbt/l2cap_signal.c: revision 1.7
sys/netbt/hci_event.c: revision 1.6
usr.bin/rfcomm_sppd/rfcomm_sppd.1: revision 1.5
sys/netbt/l2cap_upper.c: revision 1.3
sys/netbt/l2cap_lower.c: revision 1.2
usr.sbin/btdevctl/db.c: revision 1.3
sys/netbt/l2cap_upper.c: revision 1.6
lib/libusbhid/descr.c: revision 1.5
sys/netbt/l2cap_upper.c: revision 1.7
sys/netbt/l2cap_lower.c: revision 1.4
Add 'service level' security for L2CAP and RFCOMM connections, following
the Linux (BlueZ) API.
- L2CAP or RFCOMM connections can require the baseband radio link
mode be any of:
authenticated (devices are paired)
encrypted (implies authentication)
secured (encryption, plus generate new link key)
- for sockets, the mode is set using setsockopt(2) and the socket
connection will be aborted if the mode change fails.
- mode settings will be applied during connection establishment, and
for safety, we enter a wait state and will only proceed when the mode
settings are successfuly set.
- It is possible to change the mode on already open connections, but
not possible to guarantee that data already queued (from either end)
will not be delivered. (this is a feature, not a bug)
- bthidev(4) and rfcomm_sppd(1) support "auth", "encrypt" and
"secure" options
- btdevctl(8) by default enables "auth" for HIDs, and "encrypt" for
keyboards (which are required to support it)
- ALSO INCLUDES OTHER MINOR FIXES
 1.1.14.2  09-Sep-2006  rpaulo sync with head
 1.1.14.1  19-Jun-2006  rpaulo file rfcomm_upper.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:58:39 +0000
 1.1.8.2  13-Jul-2006  gdamore Merge from HEAD.
 1.1.8.1  19-Jun-2006  gdamore file rfcomm_upper.c was added on branch gdamore-uart on 2006-07-13 17:49:58 +0000
 1.1.6.2  26-Jun-2006  yamt sync with head.
 1.1.6.1  19-Jun-2006  yamt file rfcomm_upper.c was added on branch yamt-pdpolicy on 2006-06-26 12:53:57 +0000
 1.1.4.2  22-Jun-2006  chap Complete a sync sys/ with head.
 1.1.4.1  19-Jun-2006  chap file rfcomm_upper.c was added on branch chap-midi on 2006-06-22 03:39:50 +0000
 1.1.2.5  07-Dec-2007  yamt sync with head
 1.1.2.4  15-Nov-2007  yamt sync with head.
 1.1.2.3  03-Sep-2007  yamt sync with head.
 1.1.2.2  21-Jun-2006  yamt sync with head.
 1.1.2.1  19-Jun-2006  yamt file rfcomm_upper.c was added on branch yamt-lazymbuf on 2006-06-21 15:10:51 +0000
 1.3.4.1  11-Jul-2007  mjf Sync with head.
 1.3.2.3  01-Jul-2007  ad Adapt to callout API change.
 1.3.2.2  08-Jun-2007  ad Sync with head.
 1.3.2.1  10-Apr-2007  ad Sync with head.
 1.7.12.2  21-Nov-2007  bouyer Sync with HEAD
 1.7.12.1  13-Nov-2007  bouyer Sync with HEAD
 1.7.8.2  09-Jan-2008  matt sync with HEAD
 1.7.8.1  06-Nov-2007  matt sync with HEAD
 1.7.6.2  21-Nov-2007  joerg Sync with HEAD.
 1.7.6.1  04-Nov-2007  jmcneill Sync with HEAD.
 1.8.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.10.24.1  19-Oct-2008  haad Sync with HEAD.
 1.10.20.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.18.2  11-Mar-2010  yamt sync with head
 1.10.18.1  04-May-2009  yamt sync with head.
 1.10.14.1  28-Sep-2008  mjf Sync with HEAD.
 1.13.36.1  10-Aug-2014  tls Rebase.
 1.13.26.1  28-Aug-2013  rmind Checkpoint work in progress:
- Initial split of the protocol user-request method into the following
methods: pr_attach, pr_detach and pr_generic for old the pr_usrreq.
- Adjust socreate(9) and sonewconn(9) to call pr_attach without the
socket lock held (as a preparation for the locking scheme adjustment).
- Adjust all pr_attach routines to assert that PCB is not set.
- Sprinkle various comments, document some routines and their locking.
- Remove M_PCB, replace with kmem(9).
- Fix few bugs spotted on the way.
 1.13.22.2  03-Dec-2017  jdolecek update from HEAD
 1.13.22.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1  18-Nov-2014  snj Pull up following revision(s) (requested by plunky in ticket #248):
sys/netbt/rfcomm_upper.c: revision 1.22
since rfcomm_attach_pcb may be called from (soft) interrupt context
(for incoming connections), use kmem_intr_()
 1.22.20.1  10-Jun-2019  christos Sync with HEAD
 1.22.18.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)

RSS XML Feed