Commit Graph

421 Commits

Author SHA1 Message Date
Robert Watson
68548aa4c6 Correct merge-o: make sure to unlock symmetrically socket buffer
locks on bluetooth sockets when clearing upcall flags.

Submitted by:	emax
2004-06-18 05:09:42 +00:00
Robert Watson
9535efc00d Merge additional socket buffer locking from rwatson_netperf:
- 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()->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.
2004-06-17 22:48:11 +00:00
Poul-Henning Kamp
f3732fd15b Second half of the dev_t cleanup.
The big lines are:
	NODEV -> NULL
	NOUDEV -> NODEV
	udev_t -> dev_t
	udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.
2004-06-17 17:16:53 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Robert Watson
c0b99ffa02 The socket field so_state is used to hold a variety of socket related
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.
2004-06-14 18:16:22 +00:00
Julian Elischer
a974ba0b70 Add the capacity for the rfc1490 node to handle cisco style encasulation
which is often used alongside rfc1490 in frame relay links.

Submitted by:	Gleb Smirnoff <glebius@cell.sick.ru>
2004-06-13 15:44:00 +00:00
Robert Watson
395a08c904 Extend coverage of SOCK_LOCK(so) to include so_count, the socket
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
2004-06-12 20:47:32 +00:00
Julian Elischer
a65d0dc8f2 Now that mbufs are allocated using uma,
don't check for accidental usage of mbuf 'how' flags as
they are the same thing.
2004-06-07 22:11:12 +00:00
Robert Watson
2658b3bb8e Integrate accept locking from rwatson_netperf, introducing a new
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.
2004-06-02 04:15:39 +00:00
Ruslan Ermilov
58acf05ade Removed a leftover from the previous change.
Submitted by:	Gleb Smirnoff
2004-06-01 13:15:32 +00:00
Robert Watson
36568179e3 The SS_COMP and SS_INCOMP flags in the so_state field indicate whether
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.
2004-06-01 02:42:56 +00:00
Poul-Henning Kamp
5dba30f15a add missing #include <sys/module.h> 2004-05-30 20:27:19 +00:00
Julian Elischer
991fc65a92 Add a new netgraph method to allow restoration of some
behaviour lost in the change from 4.x style netgraph tee nodes.
Alter the tee node to use the new method. Document the behaviour.

Step the ABI version number... old netgraph klds will refuse to load.
Better than just crashing.

Submitted by:	Gleb Smirnoff <glebius@cell.sick.ru>
2004-05-29 07:21:46 +00:00
Julian Elischer
3eb483729e Missed these in the last commit.
Change to C99 structure initialisation for the type method structure.
2004-05-29 07:16:49 +00:00
Julian Elischer
f8aae7776f Switch to using C99 sparse initialisers for the type methods array.
Should make no binary difference.

Submitted by:	Gleb Smirnoff <glebius@cell.sick.ru>
Reviewed by:	Harti Brandt <harti@freebsd.org>
MFC after:	1 week
2004-05-29 00:51:19 +00:00
Warner Losh
dba6dd177b Move to generating pccarddevs.h on the fly, both for the kernel and
the modules.

Also generate usbdevs.h automatically now, but a non-kernel file is
stopping that at the moment.
2004-05-26 00:53:10 +00:00
Julian Elischer
bac74dea2f Use NG_HOOKSIZ instead of the deprecated (NG_HOOKLEN + 1) 2004-05-24 20:41:40 +00:00
Ruslan Ermilov
9573c7e9cf Whitespace nit. 2004-05-19 11:35:03 +00:00
Ruslan Ermilov
171e08dc7f Maintain statistics about the received frames. 2004-05-19 11:26:33 +00:00
Archie Cobbs
1a292b8015 Allow ng_ether "lower" and "orphans" hooks to be connected at the same time.
Reviewed by:	julian
PR:		kern/63317
2004-05-16 19:31:35 +00:00
Maksim Yevmenkin
73a4a9a759 Mode few Bluetooth defines into system include files
Reviewed by:	imp
2004-05-10 02:24:56 +00:00
John Polstra
0a4a8041ba Fix a memory leak in ng_get_string_token. A dynamically-allocated
buffer wasn't freed if the function failed.

MFC after:	3 days
2004-04-29 01:37:11 +00:00
Maksim Yevmenkin
b84b10f92f Address few style issues pointed out by bde
Reviewed by:	bde, ru
2004-04-27 16:38:15 +00:00
Archie Cobbs
922ee196d9 Add 'enableWindowing' configuration knob to the ng_pptpgre(4) netgraph node.
Submitted by:	Michael Bretterklieber <mbretter@a-quadrat.at>
MFC after:	2 weeks
2004-04-26 14:26:54 +00:00
Maksim Yevmenkin
48bd0712bc Make sure RFCOMM multiplexor channel does not hang in DISCONNECTING
state. Apparently it happens when both devices try to disconnect RFCOMM
multiplexor channel at the same time.

The scenario is as follows:

- local device initiates RFCOMM connection to the remote device. This
  creates both RFCOMM multiplexor channel and data channel;

- remote device terminates RFCOMM data channel (inactivity timeout);

- local device acknowledges RFCOMM data channel termination. Because
  there is no more active data channels and local device has initiated
  connection it terminates RFCOMM multiplexor channel;

- remote device does not acknowledges RFCOMM multiplexor channel
  termination. Instead it sends its own request to terminate RFCOMM
  multiplexor channel. Even though local device acknowledges RFCOMM
  multiplexor channel termination the remote device still keeps
  L2CAP connection open.

Because of hanging RFCOMM multiplexor channel subsequent RFCOMM
connections between local and remote devices will fail.

Reported by:	Johann Hugo <jhugo@icomtek.csir.co.za>
2004-04-23 20:21:17 +00:00
Luigi Rizzo
212b6d5244 + rename and document an unused field in struct arpcom (field is still
there so there are no ABI changes);
+ replace 5 redefinitions of the IPF2AC macro with one in if_arp.h

Eventually (but before freezing the ABI) we need to get rid of
struct arpcom (initially with the help of some smart #defines
to avoid having to touch each and every driver, see below).

Apart from the struct ifnet, struct arpcom now only stores a copy
of the MAC address (ac_enaddr, but we already have another copy in
the struct ifnet -- if_addrhead), and a netgraph-specific field
which is _always_ accessed through the ifp, so it might well go
into the struct ifnet too (where, besides, there is already an entry
for AF_NETGRAPH data...)

Too bad ac_enaddr is widely referenced by all drivers. But
this can be fixed as follows:

#define ac_enaddr       ac_if.the_original_ac_enaddr_in_struct_ifnet

(note that the right hand side would likely be a pointer rather than
the base address of an array.)
2004-04-18 01:15:32 +00:00
Ruslan Ermilov
dfa515f294 Don't give up if sending to one link fails, continue.
Suggested by:	jmallett
2004-04-17 23:52:57 +00:00
Ruslan Ermilov
b462702f94 A simple packet distribution node type that acts like an Ethernet hub. 2004-04-17 12:42:17 +00:00
Luigi Rizzo
7affdebea2 Consistently use ifaddr_byindex() to access the link-level address
of an interface. No functional change.

On passing, comment an useless invocation of TAILQ_INIT(&ifp->if_addrhead)
which could probably be removed in the interest of clarity.
2004-04-16 08:15:37 +00:00
Maksim Yevmenkin
4ae439a316 Make sure Bluetooth stuff can be compiled on amd64
Submitted by:	ps
2004-04-09 23:01:42 +00:00
Archie Cobbs
2c9027fcba Rename internal structure to fix cut & paste error.
Submitted by:	Bjoern A. Zeeb <bzeeb+freebsd@zabbadoz.net>
MFC After:	3 days
2004-04-04 21:33:09 +00:00
Roman Kurakin
8b96678536 sppp (4) to netgraph (4) node. As always: I'l connect it to the
system after extra check.

Approved by:	imp (mentor)
Approved by:	julian (in general)
2004-03-24 17:24:01 +00:00
Julian Elischer
ba9c6c61b2 Don't duplicate a packet, just to throw it away when we discover the
duplicat hook is not connected.
2004-03-24 08:53:45 +00:00
Julian Elischer
0598ef01ee Dont count bytes being sent to a disconnected hook.
MFC after:	3 days
2004-03-22 01:15:28 +00:00
David Malone
f6fee71d57 Make the vaule of PTT_RELAY_SID match the RFC. This should help PPPoE
users that are working with relayed PPPoE.

Submitted by:	Bodo Rüskamp <jordbaer@mac.com>
PR:		44936
Approved by:	julian
MFC after:	1 week
2004-03-18 12:34:14 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Benno Rice
bde778e9f2 Add a netgraph node to handle ATM LLC encapsulation. This currently handles
ethernet (tested) and FDDI (not tested).  The main use for this is on ADSL (or
other ATM) connections where bridged ethernet is used, PPPoE being a prime
example.

There is no manual page as yet, I will write one shortly.

Reviewed by:	harti
2004-03-08 10:54:35 +00:00
Ruslan Ermilov
1164db57e4 Implemented the "getifindex" control message.
PR:		kern/63864
Submitted by:	Gleb Smirnoff
2004-03-07 23:00:44 +00:00
Ruslan Ermilov
407ea29095 Netgraph node type for IEEE 802.1Q VLAN tagging. 2004-03-01 17:22:16 +00:00
Robert Watson
746e5bf09b Rename dup_sockaddr() to sodupsockaddr() for consistency with other
functions in kern_socket.c.

Rename the "canwait" field to "mflags" and pass M_WAITOK and M_NOWAIT
in from the caller context rather than "1" or "0".

Correct mflags pass into mac_init_socket() from previous commit to not
include M_ZERO.

Submitted by:	sam
2004-03-01 03:14:23 +00:00
Poul-Henning Kamp
917a7daac3 Unconst. Somebody didn't compile LINT. 2004-02-24 22:16:40 +00:00
Colin Percival
3f54070bd2 Check that a pointer is non-NULL before dereferencing it, not after.
Reported by:	"Ted Unangst" <tedu@coverity.com>
Approved by:	rwatson (mentor)
2004-02-24 18:01:43 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Pawel Jakub Dawidek
3c976c3f95 Backout previous change, it breaks build and it is not needed
layering violation. As pointed out, there is much better way to do this.
Sorry guys, I need to find a better way to force reviews.

Requested by:	harti, julian, scottl (mentor)
Pointy hat to:	pjd
2004-02-20 08:26:27 +00:00
Pawel Jakub Dawidek
51e9da0539 Add new failure detection algorithm.
It works as follows:
In every 'interval' seconds defined links are checked.
If they are non-active they will not be used by to data transfer.

No response from:	julian, archie
Silent on:		net@
Approved by:		scottl (mentor)
2004-02-19 17:04:23 +00:00
Pawel Jakub Dawidek
d592e95ba7 Export private structure owned by ng_ether(4) module outside.
It'll is required by new failure detection algorithm for ng_one2many(4).

No response from:	julian, archie
Silent on:		net@
Approved by:		scottl (mentor)
2004-02-19 16:58:01 +00:00
Hartmut Brandt
a1adb510b2 Use the official ng_timeout function to trigger sending. This means,
that we can get rid of of all the spl*() calls, because ng_timeout
handles the locking issues.
2004-01-30 15:34:57 +00:00
Ruslan Ermilov
4296e6f8b8 Correct the description of the net.graph.recvspace sysctl. 2004-01-27 22:02:01 +00:00
Hartmut Brandt
4e0dea9a30 Don't confuse NULL and 0, use 0 where an integer is expected. 2004-01-27 10:46:33 +00:00