<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/netgraph/bluetooth/socket, branch releng/5.3</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=releng%2F5.3</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=releng%2F5.3'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2004-10-21T09:30:48Z</updated>
<entry>
<title>Merge kern_descrip.c:1.246, uipc_socket.c:1.214, uipc_usrreq.c:1.141,</title>
<updated>2004-10-21T09:30:48Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-10-21T09:30:48Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=689a28d6610af4c680f8bd5d9c5be33811a50754'/>
<id>urn:sha1:689a28d6610af4c680f8bd5d9c5be33811a50754</id>
<content type='text'>
raw_cb.c:1.30, raw_usrreq.c:1.35, ddp_pcb.c:1.45, atm_socket.c:1.21,
ng_btsocket_hci_raw.c:1.16, ng_btsocket_l2cap.c:1.14,
ng_btsocket_l2cap_raw.c:1.13, ng_btsocket_rfcomm.c:1.13, in_pcb.c:1.156,
tcp_subr.c:1.205, in6_pcb.c:1.61, ipx_pcb.c:1.29, ipx_usrreq.c:1.41,
natm.c:1.35, socketvar.h:1.135 from HEAD to RELENG_5_3:

  Push acquisition of the accept mutex out of sofree() into the caller
  (sorele()/sotryfree()):

  - This permits the caller to acquire the accept mutex before the socket
    mutex, avoiding sofree() having to drop the socket mutex and re-order,
    which could lead to races permitting more than one thread to enter
    sofree() after a socket is ready to be free'd.

  - This also covers clearing of the so_pcb weak socket reference from
    the protocol to the socket, preventing races in clearing and
    evaluation of the reference such that sofree() might be called more
    than once on the same socket.

  This appears to close a race I was able to easily trigger by repeatedly
  opening and resetting TCP connections to a host, in which the
  tcp_close() code called as a result of the RST raced with the close()
  of the accepted socket in the user process resulting in simultaneous
  attempts to de-allocate the same socket.  The new locking increases
  the overhead for operations that may potentially free the socket, so we
  will want to revise the synchronization strategy here as we normalize
  the reference counting model for sockets.  The use of the accept mutex
  in freeing of sockets that are not listen sockets is primarily
  motivated by the potential need to remove the socket from the
  incomplete connection queue on its parent (listen) socket, so cleaning
  up the reference model here may allow us to substantially weaken the
  synchronization requirements.

  RELENG_5_3 candidate.

  MFC after:      3 days
  Reviewed by:    dwhite
  Discussed with: gnn, dwhite, green
  Reported by:    Marc UBM Bocklet &lt;ubm at u-boot-man dot de&gt;
  Reported by:    Vlad &lt;marchenko at gmail dot com&gt;

Approved by:    re (scottl)
</content>
</entry>
<entry>
<title>Add '#include &lt;sys/mbuf.h&gt;' to fix the kernel build.</title>
<updated>2004-06-25T23:03:33Z</updated>
<author>
<name>Maksim Yevmenkin</name>
<email>emax@FreeBSD.org</email>
</author>
<published>2004-06-25T23:03:33Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=21da5727431ba999c628a55b8299e5f3ec55d028'/>
<id>urn:sha1:21da5727431ba999c628a55b8299e5f3ec55d028</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Correct merge-o: make sure to unlock symmetrically socket buffer</title>
<updated>2004-06-18T05:09:42Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-18T05:09:42Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=68548aa4c6fb3f51053217c682ca8e93237c4ad8'/>
<id>urn:sha1:68548aa4c6fb3f51053217c682ca8e93237c4ad8</id>
<content type='text'>
locks on bluetooth sockets when clearing upcall flags.

Submitted by:	emax
</content>
</entry>
<entry>
<title>Merge additional socket buffer locking from rwatson_netperf:</title>
<updated>2004-06-17T22:48:11Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-17T22:48:11Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=9535efc00de36129762534223a2f5782cc5fe472'/>
<id>urn:sha1:9535efc00de36129762534223a2f5782cc5fe472</id>
<content type='text'>
- Lock down low hanging fruit use of sb_flags with socket buffer
  lock.

- Lock down low hanging fruit use of so_state with socket lock.

- Lock down low hanging fruit use of so_options.

- Lock down low-hanging fruit use of sb_lowwat and sb_hiwat with
  socket buffer lock.

- Annotate situations in which we unlock the socket lock and then
  grab the receive socket buffer lock, which are currently actually
  the same lock.  Depending on how we want to play our cards, we
  may want to coallesce these lock uses to reduce overhead.

- Convert a if()-&gt;panic() into a KASSERT relating to so_state in
  soaccept().

- Remove a number of splnet()/splx() references.

More complex merging of socket and socket buffer locking to
follow.
</content>
</entry>
<entry>
<title>The socket field so_state is used to hold a variety of socket related</title>
<updated>2004-06-14T18:16:22Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-14T18:16:22Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c0b99ffa021c0be74d6ab90a6eccfe511be8bb19'/>
<id>urn:sha1:c0b99ffa021c0be74d6ab90a6eccfe511be8bb19</id>
<content type='text'>
flags relating to several aspects of socket functionality.  This change
breaks out several bits relating to send and receive operation into a
new per-socket buffer field, sb_state, in order to facilitate locking.
This is required because, in order to provide more granular locking of
sockets, different state fields have different locking properties.  The
following fields are moved to sb_state:

  SS_CANTRCVMORE            (so_state)
  SS_CANTSENDMORE           (so_state)
  SS_RCVATMARK              (so_state)

Rename respectively to:

  SBS_CANTRCVMORE           (so_rcv.sb_state)
  SBS_CANTSENDMORE          (so_snd.sb_state)
  SBS_RCVATMARK             (so_rcv.sb_state)

This facilitates locking by isolating fields to be located with other
identically locked fields, and permits greater granularity in socket
locking by avoiding storing fields with different locking semantics in
the same short (avoiding locking conflicts).  In the future, we may
wish to coallesce sb_state and sb_flags; for the time being I leave
them separate and there is no additional memory overhead due to the
packing/alignment of shorts in the socket buffer structure.
</content>
</entry>
<entry>
<title>Extend coverage of SOCK_LOCK(so) to include so_count, the socket</title>
<updated>2004-06-12T20:47:32Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-12T20:47:32Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=395a08c90416e029c757cb51721b87b83fd0194b'/>
<id>urn:sha1:395a08c90416e029c757cb51721b87b83fd0194b</id>
<content type='text'>
reference count:

- Assert SOCK_LOCK(so) macros that directly manipulate so_count:
  soref(), sorele().

- Assert SOCK_LOCK(so) in macros/functions that rely on the state of
  so_count: sofree(), sotryfree().

- Acquire SOCK_LOCK(so) before calling these functions or macros in
  various contexts in the stack, both at the socket and protocol
  layers.

- In some cases, perform soisdisconnected() before sotryfree(), as
  this could result in frobbing of a non-present socket if
  sotryfree() actually frees the socket.

- Note that sofree()/sotryfree() will release the socket lock even if
  they don't free the socket.

Submitted by:	sam
Sponsored by:	FreeBSD Foundation
Obtained from:	BSD/OS
</content>
</entry>
<entry>
<title>Integrate accept locking from rwatson_netperf, introducing a new</title>
<updated>2004-06-02T04:15:39Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-02T04:15:39Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=2658b3bb8e5e924aad1b62f71664458ef23e5f7b'/>
<id>urn:sha1:2658b3bb8e5e924aad1b62f71664458ef23e5f7b</id>
<content type='text'>
global mutex, accept_mtx, which serializes access to the following
fields across all sockets:

          so_qlen          so_incqlen         so_qstate
          so_comp          so_incomp          so_list
          so_head

While providing only coarse granularity, this approach avoids lock
order issues between sockets by avoiding ownership of the fields
by a specific socket and its per-socket mutexes.

While here, rewrite soclose(), sofree(), soaccept(), and
sonewconn() to add assertions, close additional races and  address
lock order concerns.  In particular:

- Reorganize the optimistic concurrency behavior in accept1() to
  always allocate a file descriptor with falloc() so that if we do
  find a socket, we don't have to encounter the "Oh, there wasn't
  a socket" race that can occur if falloc() sleeps in the current
  code, which broke inbound accept() ordering, not to mention
  requiring backing out socket state changes in a way that raced
  with the protocol level.  We may want to add a lockless read of
  the queue state if polling of empty queues proves to be important
  to optimize.

- In accept1(), soref() the socket while holding the accept lock
  so that the socket cannot be free'd in a race with the protocol
  layer.  Likewise in netgraph equivilents of the accept1() code.

- In sonewconn(), loop waiting for the queue to be small enough to
  insert our new socket once we've committed to inserting it, or
  races can occur that cause the incomplete socket queue to
  overfill.  In the previously implementation, it was sufficient
  to simply tested once since calling soabort() didn't release
  synchronization permitting another thread to insert a socket as
  we discard a previous one.

- In soclose()/sofree()/et al, it is the responsibility of the
  caller to remove a socket from the incomplete connection queue
  before calling soabort(), which prevents soabort() from having
  to walk into the accept socket to release the socket from its
  queue, and avoids races when releasing the accept mutex to enter
  soabort(), permitting soabort() to avoid lock ordering issues
  with the caller.

- Generally cluster accept queue related operations together
  throughout these functions in order to facilitate locking.

Annotate new locking in socketvar.h.
</content>
</entry>
<entry>
<title>The SS_COMP and SS_INCOMP flags in the so_state field indicate whether</title>
<updated>2004-06-01T02:42:56Z</updated>
<author>
<name>Robert Watson</name>
<email>rwatson@FreeBSD.org</email>
</author>
<published>2004-06-01T02:42:56Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=36568179e321497c431bd9c3baa9a4d2054e75d4'/>
<id>urn:sha1:36568179e321497c431bd9c3baa9a4d2054e75d4</id>
<content type='text'>
the socket is on an accept queue of a listen socket.  This change
renames the flags to SQ_COMP and SQ_INCOMP, and moves them to a new
state field on the socket, so_qstate, as the locking for these flags
is substantially different for the locking on the remainder of the
flags in so_state.
</content>
</entry>
<entry>
<title>Switch to using C99 sparse initialisers for the type methods array.</title>
<updated>2004-05-29T00:51:19Z</updated>
<author>
<name>Julian Elischer</name>
<email>julian@FreeBSD.org</email>
</author>
<published>2004-05-29T00:51:19Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=f8aae7776f85d2fa8aa93f73c37782cd9e1204c6'/>
<id>urn:sha1:f8aae7776f85d2fa8aa93f73c37782cd9e1204c6</id>
<content type='text'>
Should make no binary difference.

Submitted by:	Gleb Smirnoff &lt;glebius@cell.sick.ru&gt;
Reviewed by:	Harti Brandt &lt;harti@freebsd.org&gt;
MFC after:	1 week
</content>
</entry>
<entry>
<title>Address few style issues pointed out by bde</title>
<updated>2004-04-27T16:38:15Z</updated>
<author>
<name>Maksim Yevmenkin</name>
<email>emax@FreeBSD.org</email>
</author>
<published>2004-04-27T16:38:15Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b84b10f92fe9e702a9f39d4c6b5c4ce70669fa25'/>
<id>urn:sha1:b84b10f92fe9e702a9f39d4c6b5c4ce70669fa25</id>
<content type='text'>
Reviewed by:	bde, ru
</content>
</entry>
</feed>
