Commit Graph

697 Commits

Author SHA1 Message Date
Gleb Smirnoff
eb2405dde8 - When flushing node input queue, check whether item has a callback. If
it does, then call it suppling ENOENT as error value.
- Add assert, that helped to catch the above error.
2005-10-13 11:55:50 +00:00
Andrew Thompson
9cff52f7f6 Clean up the if_bridge hooks a bit in if_ethersubr.c and ng_ether.c, move
the broadcast/multicast test to bridge_input().

Requested by:	glebius
2005-10-13 09:43:30 +00:00
Gleb Smirnoff
32b33288f7 After rev. 1.103 the oitem and ierror are no longer needed, remove them. 2005-10-12 10:18:44 +00:00
Gleb Smirnoff
714fb86548 Fix a regression introduced in rev. 1.107. If an item once had a writer
semantics, and then was reused for next node, it still would be applied
as writer again.
  To fix the regression the decision is made never to alter item->el_flags
after the item has been allocated. This requires checking for overrides
both in ng_dequeue() and in ng_snd_item().

  Details:
  - Caller of the ng_apply_item() knows what is the current access to
    node and specifies it to ng_apply_item(). The latter drops the
    given access after item has beem applied.
  - ng_dequeue() needs to be supplied with int pointer, where it stores
    the obtained access on node.
  - Check for node/hook access overrides in ng_dequeue().
2005-10-11 13:48:38 +00:00
Gleb Smirnoff
547faba51c Style and other fixes for the last commit.
Submitted by:	ru
2005-10-11 09:11:57 +00:00
Gleb Smirnoff
376e05d113 ALTQ support for ng_iface(4). Before turning on please consult manual page. 2005-10-10 15:12:59 +00:00
Seigo Tanimura
314378233c In ngt_input(), do not derefer sc (= (sc_p) tp->t_lsc) before making
sure sc != NULL.
2005-10-08 11:03:29 +00:00
Gleb Smirnoff
6512768b89 A deja vu of:
http://lists.freebsd.org/pipermail/cvs-src/2004-October/033496.html

The same problem applies to if_bridge(4), too.

- Copy-and-paste the if_bridge(4) related block from
  if_ethersubr.c to ng_ether.c
- Add XXXs, so that copy-and-paste would be noticed by
  any future editors of this code.
- Also add XXXs near if_bridge(4) declarations.

Silence from:	thompsa
2005-10-07 14:14:47 +00:00
Max Laier
b6de9e91bd Remove bridge(4) from the tree. if_bridge(4) is a full functional
replacement and has additional features which make it superior.

Discussed on:	-arch
Reviewed by:	thompsa
X-MFC-after:	never (RELENG_6 as transition period)
2005-09-27 18:10:43 +00:00
Maksim Yevmenkin
a4cb050617 Fix comment 2005-09-22 19:15:33 +00:00
Warner Losh
0837eb061f Finish last commit: actually remove compat methods from bt3c_pccard_methods 2005-09-22 05:51:07 +00:00
Warner Losh
55b6280fd1 Remove broken OLDCARD compat shims.
"PC Card" is the correct spelling.  "PC-Card" isn't, per the PCMCIA
standard.
2005-09-22 05:47:04 +00:00
Gleb Smirnoff
f795fd004d Dej'a vu of revision 1.35
PR:		kern/86258
Submitted by:	Hiroshi Oota <ghelp excite.co.jp>
2005-09-19 11:49:54 +00:00
Gleb Smirnoff
723359f73a When message can't fit into socket receive buffer return ENOBUFS
to userland program instead of letting it wait until end of days.

PR:	kern/85907
2005-09-12 14:11:11 +00:00
Gleb Smirnoff
fb3eb9dace Remove ng_callout_init_mtx() macro. Mutexed callouts are incompatible
with netgraph(4).
2005-09-12 07:41:31 +00:00
Gleb Smirnoff
1bf8e0faed Fix an item leak, that happens when some node calls ng_callout() two
times consequently, without checking whether callout has been serviced
or not. (ng_pptpgre and ng_ppp were catched in this behavior).

  - In ng_callout() save old item before calling callout_reset(). If the
    latter has returned 1, then free this item.
  - In ng_uncallout() clear c->c_arg.

Problem reported by:	Alexandre Kardanev
2005-09-08 14:32:19 +00:00
Gleb Smirnoff
83beeed993 Rework locking, that I have introduced recently, since it was incorrect:
First, mutexed callouts are incompatible with netgraph nodes, because
  netgraph(4) can guarantee that the function will be called with mutex
  held.

  Second, nodes should not send data to their neighbor holding their
  mutex. A node does not know what stack can it enter sending data in
  some direction. May be executing will encounter a place to sleep.

New locking:

  - ng_pptpgre_recv() and ng_pptpgre_xmit() must be entered with mutex held.
  - ng_pptpgre_recv() and ng_pptpgre_xmit() unlock mutex before
    sending data and then return unlocked.
  - callout routines acquire mutex themselves.
2005-09-08 14:26:23 +00:00
Gleb Smirnoff
ba5b359aef Fix build. 2005-09-06 20:36:38 +00:00
Gleb Smirnoff
e71fefbe21 When we read data from socket buffer using soreceive() the socket layer
does not clear m_nextpkt for us. The mbufs are sent into netgraph and
then, if they contain a TCP packet delivered locally, they will enter
socket code again. They can pass the first assert in sbappendstream()
because m_nextpkt may be set not in the first mbuf, but deeper in the
chain. So the problem will trigger much later, when local program
reads the data from socket, and an mbuf with m_nextpkt becomes a
first one.

This bug was demasked by revision 1.54, when I made upcall queueable.
Before revision 1.54 there was a very small probability to have 2
mbufs in GRE socket buffer, because ng_ksocket_incoming2() dequeued
the first one immediately.

 - in ng_ksocket_incoming2() clear m_nextpkt on all mbufs
   read from socket.
 - restore rev. 1.54 change in ng_ksocket_incoming().

PR:			kern/84952
PR:			kern/82413
In collaboration with:	rwatson
2005-09-06 17:15:42 +00:00
Gleb Smirnoff
b32cfb3228 In INVARIANTS case also check that nodes do not pass queues of mbufs
each other.
2005-09-06 17:02:13 +00:00
Gleb Smirnoff
c6118fcc1c Raise one more bit in READER_MASK. I believe that before this change
it was possible to have 1 reader and 1 writer thread working on
a node simultaneously.

Reviewed by:	julian
2005-09-06 16:58:25 +00:00
Gleb Smirnoff
6064e568ec Use non-debug macros inside debugging functions, to prevent
important information from being rewritten.
2005-09-02 19:52:54 +00:00
Maksim Yevmenkin
82e1becc5f Fix dangling callout problem in the Bluetooth L2CAP code that leads to
panic. The panic happens when outgoing L2CAP connection descriptor is
deleted with the L2CAP command(s) pending in the queue. In this case when
the last L2CAP command is deleted (due to cleanup) and reference counter
for the L2CAP connection goes down to zero the auto disconnect timeout
is incorrectly set. pjd gets credit for tracking this down and committing
bandaid.

Reported by:	Jonatan B <onatan at gmail dot com>
MFC after:	3 days
2005-08-31 18:13:23 +00:00
Gleb Smirnoff
f2ba84d72d Lock down PPTP node, since it has many data structures, that won't survive
parallel ng_pptp_rcvdata():

- Add a per-node mutex.
- Acquire mutex during all ng_pptp_rcvdata() method.
- Make callouts protected by mutex. Now callouts count as
  netgraph writers, but there are plans to allow reader callouts
  for nodes, that have internal locking.
- Acquire mutex in ng_pptp_reset(), which can be triggered
  by a message or node shutdown.

PR:		kern/80035
Tested by:	Deomid Ryabkov <myself rojer.pp.ru>
Reviewed by:	Deomid Ryabkov <myself rojer.pp.ru>
2005-08-30 09:51:54 +00:00
Gleb Smirnoff
5e067d612f Add ng_callout_ini_mtx() macro. 2005-08-30 09:44:54 +00:00
Gleb Smirnoff
3ff2ed9e6d Plug item leak in case when not all hooks are connected.
Found by:	David Vos <david.vos gmail.com>
2005-08-29 13:47:08 +00:00
Gleb Smirnoff
6f683eeed2 Cleanup the reader/writer policy in netgraph(4). Assign
either reader or writer flag on item in the function, that
allocates the item. Do not modify these flags when item is
applied or queued.
  The only exceptions are node and hook overrides - they can
change item flags to writer.
2005-08-26 15:14:33 +00:00
Maksim Yevmenkin
f41317de66 Make sure ng_fec_init() uses the same calling convention as the rest of
the code, i.e. ng_fec_init() is called with the ifp->if_softc pointer and
NOT with the ifp pointer.

PR:		kern/85239
Reviewed by:	brooks
MFC after:	1 day
2005-08-25 17:00:02 +00:00
Gleb Smirnoff
d7f56eabab Backout revision 1.54, because it exposes a worse problem, than
it fixes. I believe the problem lives somewhere outside ng_ksocket,
but until it is found, let the node be working.

PR:		kern/84952
PR:		kern/82413
MFC after:	3 days
2005-08-25 07:21:15 +00:00
Maksim Yevmenkin
db37c09a49 Fix multiple typos in the mutex names. This fixes false positive (and pretty
strange looking too) LORs I have seen on my system. Pointy hat to goes to me.

MFC after:	1 day
2005-08-23 00:50:59 +00:00
Gleb Smirnoff
03b25f5ddc In ng_callout() assert that supplied arguments are non-NULL. 2005-08-21 19:48:51 +00:00
Pawel Jakub Dawidek
1ec75877dc Stop callout before freeing memory, so it won't panic from softclock.
Reported by:	Jonatan B <onatan@gmail.com>
MFC after:	3 days
2005-08-21 19:16:27 +00:00
Pawel Jakub Dawidek
e5cd9375e4 Before freeing memory, assert that there is no pending callout.
MFC after:	3 days
2005-08-21 19:15:14 +00:00
David E. O'Brien
7e2b43eeb3 Use the ISO standard function variable vs. a GCC'ism. 2005-08-10 06:25:41 +00:00
Robert Watson
13f4c340ae Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags.  Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags.  This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by:	pjd, bz
MFC after:	7 days
2005-08-09 10:20:02 +00:00
Julian Elischer
9722b2db99 reorder a couple of cases of void __inline to __inline void
to silence warnings from compilig with -W

Submitted by:	sandvine inc
MFC after:	1 week
2005-08-08 20:08:44 +00:00
Ruslan Ermilov
0515d4fd73 Fix up the comment. 2005-08-02 20:06:48 +00:00
Ruslan Ermilov
91b756f435 Fixed parsing of unsigned integers. 2005-08-02 20:05:37 +00:00
Maksim Yevmenkin
89a4a8b5f3 Fix typo and check correct (rsp) pointer against the NULL value.
Submitted by:	Oliver < urnenfel at tiscali dot es >
MFC after:	1 day
2005-07-29 14:44:17 +00:00
Maksim Yevmenkin
d6279c101e Address minor locking issues. Use taskqueue_swi instead of taskqueue_swi_giant.
MFC after:	1 month
2005-07-28 17:43:20 +00:00
David E. O'Brien
d3a46d1253 Fix missing '=' in structure initialization. 2005-07-23 19:28:51 +00:00
Gleb Smirnoff
5bc15201f4 Fix cut-n-paste error, introduced in rev. 1.103. 2005-07-21 22:15:37 +00:00
Gleb Smirnoff
e58d779daa Catch up with netgraph.h rev. 1.57 and fix build. 2005-07-21 20:34:40 +00:00
Gleb Smirnoff
59087d62e7 Bump NG_ABI_VERSION. A number of ABI breakeges had been done since
RELENG_5 fork.
2005-07-21 12:32:52 +00:00
Gleb Smirnoff
25f8b7d9c3 Enhance struct ng_hook - add hk_type field. This field will describe
data link type of the hook. It will be used to ease autoconfiguration
of netgraph and also to print warning messages, when incompatoble nodes
are connected together.
2005-07-21 12:31:42 +00:00
Gleb Smirnoff
f912c0f77c Problem description:
At the end of ng_snd_item(), node queue is processed. In certain
netgraph setups deep recursive calls can occur.
  For example this happens, when two nodes are connected and can send
items to each other in both directions. If, for some reason, both nodes
have a lot of items in their queues, then the processing thread will
recurse between these two nodes, delivering items left and right, going
deeper in the stack. Other setups can suffer from deep recursion, too.
The following factors can influence risk of deep netgraph call:
 - periodical write-access events on node
 - combination of slow link and fast one in one graph
 - net.inet.ip.fastforwarding

Changes made:

 - In ng_acquire_{read,write}() do not dequeue another item. Instead,
   call ng_setisr() for this node.
 - At the end of ng_snd_item(), do not process queue. Call ng_setisr(),
   if there are any dequeueable items on node queue.
 - In ng_setisr() narrow worklist mutex holding.
 - In ng_setisr() assert queue mutex.

Theoretically, the first two changes should negatively affect performance.
To check this, some profiling was made:

1) In general real tasks, no noticable performance difference was found.

2) The following test was made: two multithreaded nodes and one
single-threaded were connected into a ring. A large queues of packets
were sent around this ring. Time to pass the ring N times was measured.
This is a very vacuous test: no items/mbufs are allocated, no upcalls or
downcalls outside of netgraph. It doesn't represent a real load, it is
a stress test for ng_acquire_{read,write}() and item queueing functions.
Surprisingly, the performance impact was positive! New code is 13% faster
on UP and 17% faster on SMP, in this particular test.

The problem was originally found, described, analyzed and original patch
was written by Roselyn Lee from Vernier Networks. Thanks!

Submitted by:		Roselyn Lee <rosel verniernetworks com>
2005-07-21 12:08:37 +00:00
Maksim Yevmenkin
17d0bf1250 Ignore AVM BlueFRITZ! USB Bluetooth Adapter v1.0 (product ID 0x2200).
It does not work with ng_ubt(4) and require special driver and firmware.

Obtained from:	Marcel Holtmann < marcel at holtmann dot org >
Submitted by:	Rainer Goellner < rainer at jabbe dot de >
MFC after:	3 days
2005-07-19 00:33:37 +00:00
Maksim Yevmenkin
384792133f Add support for AVM BlueFRITZ! USB Bluetooth Adapter v2.0. It appears that
there are at least two versions of the adapter. Version 1 (product ID 0x2200)
of the adapter does not work with ng_ubt(4) and require special driver and
firmware. Version 2 (product ID 0x3800) seems to work just fine, except it
does not have bDeviceClass, bDeviceSubClass and bDeviceProtocol set to required
(by specification) values. This change forces ng_ubt(4) to attach to the
version 2 adapter.

Obtained from:	Marcel Holtmann <marcel at holtmann dot org>
Submitted by:	Rainer Goellner <rainer at jabbe dot de>
2005-07-18 16:34:49 +00:00
Gleb Smirnoff
ed2fc9673b Check that we have first fragment before pulling up TCP/UDP header. 2005-07-17 08:09:59 +00:00
Gleb Smirnoff
ae1ff8e34f Remove obsoleted sysctl interface for switching between standard and 3Com
PPPoE modes. The interface was declared obsoleted before 5.3-RELEASE.

When running as access concentrator ng_pppoe(4) supports both modes
simultanously. When running as client mode can be swicthed in ppp(8)
configuration.

Approved by:	re (scottl)
2005-07-05 17:51:02 +00:00