709 Commits

Author SHA1 Message Date
glebius
fc9f312630 MFC 1.3:
Free private data when deleting hook.

  PR:		kern/93952
  Submitted by:	Antoine Brodin <antoine.brodin laposte.net>

Approved by:	re (mux)
2006-03-18 22:00:37 +00:00
jhb
025e3d0a95 MFC: Split struct ithd into struct intr_thread and intr_event and
associated changes.  More details below:

  Remove public declarations of variables that were forgotten when they were
  made static.

  Revision  Changes    Path
  1.31      +0 -1      src/sys/sys/interrupt.h

  Make sure the interrupt is masked before processing it, or bad things
  can happen.

  Revision  Changes    Path
  1.10      +3 -3      src/sys/arm/arm/intr.c

  Reorganize the interrupt handling code a bit to make a few things cleaner
  and increase flexibility to allow various different approaches to be tried
  in the future.
  - Split struct ithd up into two pieces.  struct intr_event holds the list
    of interrupt handlers associated with interrupt sources.
    struct intr_thread contains the data relative to an interrupt thread.
    Currently we still provide a 1:1 relationship of events to threads
    with the exception that events only have an associated thread if there
    is at least one threaded interrupt handler attached to the event.  This
    means that on x86 we no longer have 4 bazillion interrupt threads with
    no handlers.  It also means that interrupt events with only INTR_FAST
    handlers no longer have an associated thread either.
  - Renamed struct intrhand to struct intr_handler to follow the struct
    intr_foo naming convention.  This did require renaming the powerpc
    MD struct intr_handler to struct ppc_intr_handler.
  - INTR_FAST no longer implies INTR_EXCL on all architectures except for
    powerpc.  This means that multiple INTR_FAST handlers can attach to the
    same interrupt and that INTR_FAST and non-INTR_FAST handlers can attach
    to the same interrupt.  Sharing INTR_FAST handlers may not always be
    desirable, but having sio(4) and uhci(4) fight over an IRQ isn't fun
    either.  Drivers can always still use INTR_EXCL to ask for an interrupt
    exclusively.  The way this sharing works is that when an interrupt
    comes in, all the INTR_FAST handlers are executed first, and if any
    threaded handlers exist, the interrupt thread is scheduled afterwards.
    This type of layout also makes it possible to investigate using interrupt
    filters ala OS X where the filter determines whether or not its companion
    threaded handler should run.
  - Aside from the INTR_FAST changes above, the impact on MD interrupt code
    is mostly just 's/ithread/intr_event/'.
  - A new MI ddb command 'show intrs' walks the list of interrupt events
    dumping their state.  It also has a '/v' verbose switch which dumps
    info about all of the handlers attached to each event.
  - We currently don't destroy an interrupt thread when the last threaded
    handler is removed because it would suck for things like ppbus(8)'s
    braindead behavior.  The code is present, though, it is just under
    #if 0 for now.
  - Move the code to actually execute the threaded handlers for an interrrupt
    event into a separate function so that ithread_loop() becomes more
    readable.  Previously this code was all in the middle of ithread_loop()
    and indented halfway across the screen.
  - Made struct intr_thread private to kern_intr.c and replaced td_ithd
    with a thread private flag TDP_ITHREAD.
  - In statclock, check curthread against idlethread directly rather than
    curthread's proc against idlethread's proc. (Not really related to intr
    changes)

  Tested on:      alpha, amd64, i386, sparc64
  Tested on:      arm, ia64 (older version of patch by cognet and marcel)

  Revision  Changes    Path
  1.88      +43 -29    src/sys/alpha/alpha/interrupt.c
  1.38      +5 -5      src/sys/alpha/isa/isa.c
  1.16      +58 -52    src/sys/amd64/amd64/intr_machdep.c
  1.6       +1 -1      src/sys/amd64/include/intr_machdep.h
  1.16      +2 -2      src/sys/amd64/isa/atpic.c
  1.11      +28 -22    src/sys/arm/arm/intr.c
  1.462     +2 -2      src/sys/dev/sio/sio.c
  1.6       +1 -1      src/sys/dev/uart/uart_kbd_sun.c
  1.24      +2 -2      src/sys/dev/uart/uart_tty.c
  1.15      +58 -52    src/sys/i386/i386/intr_machdep.c
  1.8       +1 -1      src/sys/i386/include/intr_machdep.h
  1.21      +2 -2      src/sys/i386/isa/atpic.c
  1.52      +32 -25    src/sys/ia64/ia64/interrupt.c
  1.180     +3 -2      src/sys/kern/kern_clock.c
  1.127     +437 -270  src/sys/kern/kern_intr.c
  1.206     +0 -1      src/sys/kern/subr_witness.c
  1.6       +3 -3      src/sys/powerpc/include/intr_machdep.h
  1.7       +35 -32    src/sys/powerpc/powerpc/intr_machdep.c
  1.14      +1 -1      src/sys/sparc64/include/intr_machdep.h
  1.24      +43 -36    src/sys/sparc64/sparc64/intr_machdep.c
  1.32      +36 -36    src/sys/sys/interrupt.h
  1.440     +1 -3      src/sys/sys/proc.h

  Catch up with interrupt-thread changes.

  Revision  Changes    Path
  1.32      +1 -1      src/sys/dev/zs/zs.c

  Catch up with new interrupt handling code.

  Revision  Changes    Path
  1.16      +3 -3      src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c

  Catch up with new interrupt handling code.

  Revision  Changes    Path
  1.162     +2 -2      src/sys/dev/cy/cy.c
  1.101     +2 -2      src/sys/dev/rc/rc.c

  Catch up with new interrupt handling code.

  Revision  Changes    Path
  1.50      +2 -2      src/sys/dev/cx/if_cx.c
  1.41      +1 -1      src/sys/dev/sab/sab.c
  1.238     +2 -2      src/sys/pc98/cbus/sio.c

  Add a swi_remove() function to teardown software interrupt handlers.  For
  now it just calls intr_event_remove_handler(), but at some point it might
  also be responsible for tearing down interrupt events created via swi_add.

  Revision  Changes    Path
  1.128     +17 -0     src/sys/kern/kern_intr.c
  1.33      +1 -0      src/sys/sys/interrupt.h

  - Use swi_remove() to teardown swi handlers rather than
    intr_event_remove_handler().
  - Remove tty: prefix from a couple of swi handler names.

  Revision  Changes    Path
  1.51      +1 -1      src/sys/dev/cx/if_cx.c
  1.102     +2 -2      src/sys/dev/rc/rc.c
  1.42      +1 -1      src/sys/dev/sab/sab.c
  1.25      +1 -1      src/sys/dev/uart/uart_tty.c
  1.33      +1 -1      src/sys/dev/zs/zs.c
  1.17      +2 -2      src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c

  Remove a stray return statement in the interrupt dispatch function
  that caused a premature exit after calling a fast interrupt handler
  and bypassing a much needed critical_exit() and the scheduling of
  the interrupt thread for non-fast handlers. In short: unbreak :-)

  Revision  Changes    Path
  1.53      +0 -1      src/sys/ia64/ia64/interrupt.c

  If we get a stray interrupt, return after logging it.  In the extremely
  rare case of a stray interrupt to an unregistered source (such as a stray
  interrupt from the 8259As when using APIC), this could result in a page
  fault when it tried to walk the list of interrupt handlers to execute
  INTR_FAST handlers.  This bug was introduced with the intr_event changes,
  so it's not present in 5.x or 6.x.

  Submitted by:   Mark Tinguely tinguely at casselton dot net

  Revision  Changes    Path
  1.17      +1 -0      src/sys/amd64/amd64/intr_machdep.c
  1.16      +1 -0      src/sys/i386/i386/intr_machdep.c

Approved by:	re (scottl)
2006-03-10 19:37:35 +00:00
ru
0095d3270c MFC: 1.58: Clear csum_flags after reading from the socket buffer.
Approved by:	re (scottl)
2006-02-24 11:23:05 +00:00
ru
5787b49b31 MFC: Fix a bug that prevented passing IP fragments through a dummynet.
Approved by:	re (scottl)
2006-02-17 16:46:47 +00:00
glebius
719a451400 MFC 1.9:
- Increase maximum number of interfaces to 2048.
  - Regroup softc so that frequently used elements are
    grouped in the beginning, while the interfaces
    array is at the end.

Approved by:	re (kensmith)
2006-02-16 12:37:14 +00:00
ru
7b02bd77cd MFC: 1.36: Fix output byte and error counting.
Approved by:	re (scottl)
2006-02-14 06:21:47 +00:00
yar
25d6e2cc4f MFC:
Avoid creating (and subsequently using) fake opt_*.h files
when the modules are built with the kernel and hence actual
opt_*.h files are available in ${KERNBUILDDIR}.  Fix a few
small bugs that would prevent this from working.

At last the build options of the modules become consistent
with those of the kernel unless the MODULES_WITH_WORLD way
still is used.

Approved by:	re (kensmith, scottl)
Requested by:	ru
Tested on:	amd64 i386 sparc64
Tested by:	md5
2006-02-10 00:38:08 +00:00
ru
cc436d7bbf MFC: 1.35: Fix interface output queue handling.
Approved by:	re (scottl)
2006-02-09 16:59:37 +00:00
rik
4908bf7b86 MFC: -j 1.9 -j 1.10
----------------------------
	revision 1.10
	date: 2006/01/29 22:06:51;  author: rik;  state: Exp;  lines: +1 -0
	Fix module from panic.
	Pointy hat:	brooks
	MFC after:	3 days
2006-02-01 04:50:07 +00:00
glebius
5ce5257942 MFC 1.27:
Simplify ng_source_send() removing temporary queue and merging two
  cycles into one.
2006-01-31 15:39:05 +00:00
glebius
606be86649 Sync ng_pppoe with HEAD, merging:
- ktr(4) instead of printfs.
- D-Link compat mode.
- style(9) cleanup.
2006-01-31 15:36:11 +00:00
glebius
9e96610e5b MFC 1.26 - 1.29:
Fix several bugs found by Coverity.
2006-01-21 10:15:00 +00:00
glebius
8ee060690d MFC 1.25:
Initialize variable.

  Found with:     Coverity Prevent(tm)
2006-01-21 10:13:03 +00:00
glebius
3920cf9b74 MFC 1.25:
Remove dead code.

  Found with:     Coverity Prevent(tm)
2006-01-21 10:12:16 +00:00
glebius
6404be1e73 MFC 1.12:
Correct off-by-one errors.

  Found with:     Coverity Prevent(tm)
2006-01-21 10:11:01 +00:00
glebius
7a6a9a7a20 MFC 1.18:
When sending export datagram from interrupt thread, use NG_QUEUE
  in flags. When sending export datagram from expiry thread, then
  use default zero flags. This removes unpleasant contention of the
  interrupt thread on mutexes (usually ng_ksocket's socket buffer
  mutex).
2006-01-21 10:09:18 +00:00
glebius
3d78d7e213 MFC 1.58:
Do not force queueing on peer hooks. This was important only for
  5.0-CURRENT. And it looks like this didn't work before Julian's
  revamp of netgraph queue code.

  Reviewed by:    julian
2006-01-21 10:07:25 +00:00
glebius
a0d17dcfa1 MFC 1.8:
Mark appropriate commands with NGM_READONLY and NGM_HASREPLY and
  bump type cookie.

  This fixes flowctl(8) exiting without any output under high load on SMP.
2006-01-21 10:06:15 +00:00
glebius
098f73d3f4 Partial MFC of NGM_HASREPLY flag. The flag is introduced, but message
codes and netgraph cookie are not altered, to preserve ABI compatibility.
2006-01-21 10:04:40 +00:00
glebius
443e91f57b MFC 1.65:
Provide additional macros for sending netgraph items, which allow
  to use non-default flags for netgraph functions. Implement current
  macros via new ones.
2006-01-21 10:00:51 +00:00
glebius
94513f129b Sync with HEAD:
- Some whitespace and style(9) cleanup.
  - Add ktr(4) debugging.
2006-01-21 09:59:43 +00:00
glebius
65952b1976 MFC 1.11:
In ng_netflow_disconnect() check whether we are working with "iface"
  or with "out" hook, and clear the right pointer.

  Reported by:    Vitaliy Ovsyannikov <V.Ovsyannikov kr.ru>
2006-01-10 10:22:22 +00:00
glebius
801f2fea18 MFC:
Implement an upper limit for packets per second sent by node.
2006-01-10 10:11:48 +00:00
ru
9dbd13db82 MFC: Fix memory leak. 2005-12-09 07:13:06 +00:00
glebius
a95ec831a0 MFC 1.17:
- Update the flow sequence before converting count to
    network byte order.
  - Update the flow sequence in one atomic op instead of two.

  Reported by:    Denis Shaposhnikov <dsh vlink.ru>
  Reported by:    Daniil Kharoun <kdl chelcom.ru>
  PR:             kern/89417
2005-12-06 09:51:10 +00:00
glebius
d60eb7f43e MFC 1.70:
Fix several races between socket closure and node/hook
  destruction:
    - Backout 1.62, since it doesn't fix all possible
    problems.
    - Upon node creation, put an additional reference on node.
    - Add a mutex and refcounter to struct ngsock. Netgraph node,
      control socket and data socket all count as references.
    - Introduce ng_socket_free_priv() which removes one reference
      from ngsock, and frees it when all references has gone.
    - No direct pointers between pcbs and node, all pointing
      is done via struct ngsock and protected with mutex.
2005-11-25 14:26:40 +00:00
glebius
f85409be55 Sync with HEAD, merging the following:
revision 1.117
date: 2005/11/02 15:23:47;  author: glebius;  state: Exp;  lines: +47 -8
Fix two races which happen when netgraph is restructuring:
  - Introduce ng_topo_mtx, a mutex to protect topology changes.
  - In ng_destroy_node() protect with ng_topo_mtx the process
    of checking and pointing at ng_deadnode. [1]
  - In ng_con_part2() check that our peer is not a ng_deadnode,
    and protect the check with ng_topo_mtx.
  - Add KASSERTs to ng_acquire_read/write, to make more
    understandible synopsis in case if called on ng_deadnode.

Reported by:    Roselyn Lee [1]
----------------------------
revision 1.116
date: 2005/11/02 14:27:24;  author: glebius;  state: Exp;  lines: +106 -121
Rework the ng_item queueing on nodes:
  - Introduce a new flags NGQF_QREADER and NGQF_QWRITER,
    which tell how the item should be actually applied,
    overriding NGQF_READER/NGQF_WRITER flags.
  - Do not differ between pending reader or writer. Use only
    one flag that is raised, when there are pending items.
  - Schedule netgraph ISR in ng_queue_rw(), so that callers
    do not need to do this job.
  - Fix several comments.

Submitted by:   julian

As well as some lesser changes: ng_base.c 1.114, 1.113, 1.107, 1.118.
2005-11-25 14:23:27 +00:00
ru
b8108a4f96 MFC: 1.56: Make IFP2NG() usable as lvalue. 2005-11-16 10:33:53 +00:00
ru
539591f019 MFC: Use sparse initializers for "struct domain" and "struct protosw". 2005-11-16 10:31:23 +00:00
ru
693f92adc9 MFC: 1.34: Simplify setting the link-level address. 2005-11-16 10:14:25 +00:00
ru
f8684a4759 MFC: All recent fixes. 2005-11-16 10:13:34 +00:00
ru
f130d9a1f5 MFC: 1.55: Restore part of the code mistakenly dropped in rev. 1.25. 2005-11-16 10:09:51 +00:00
ru
af77f484ad MFC: Use variable-sized arrays where appropriate. 2005-11-16 10:08:02 +00:00
ru
40f4fd56fd MFC: 1.5: Make the cookie constant name canonical. 2005-11-16 10:01:27 +00:00
ru
4bcf743b75 MFC: 1.58: Fix up comment. 2005-11-16 07:36:51 +00:00
glebius
88bf054121 MFC ALTQ support for ng_iface(4). 2005-11-09 11:36:07 +00:00
glebius
9cf9c62adb MFC 1.115:
- 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-11-04 18:20:32 +00:00
thompsa
35a7273cfa MFC ng_ether support for if_bridge and cleanup of bridge hooks.
bridgestp.c; r1.8
 if_bridge.c; r1.25, 1.27
 if_bridgevar.h; r1.5
 if_ethersubr.c; r1.201, 1.202, 1.206
 ng_ether.c; r1.52 - 1.54

Approved by:	re (scottl)
2005-10-23 02:36:58 +00:00
tanimura
e04edc1b3f MFC 1.35: do not derefer NULL sc in ngt_input().
Approved by:	re (scottl)
2005-10-09 00:19:28 +00:00
glebius
be4f3d3a0f MFC typo fix from 1.75:
Dej'a vu of revision 1.35

  PR:		kern/86258
  Submitted by:	Hiroshi Oota <ghelp excite.co.jp>

Approved by:	re (kensmith)
2005-09-20 13:46:15 +00:00
glebius
2031716961 MFC 1.69:
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

Approved by:	re (kensmith)
2005-09-20 13:42:20 +00:00
glebius
93d4651ace Merge locking of ng_pptpgre node. See 1.38, 1.39 log for longer
description.

Approved by:	re (kensmith)
2005-09-20 13:40:55 +00:00
glebius
f3983d158a MFC 1.7:
Plug item leak in case when not all hooks are connected.

  Found by:	David Vos <david.vos gmail.com>

Approved by:	re (kensmith)
2005-09-13 12:44:19 +00:00
glebius
3a2f67e4e3 MFC 1.68 by obrien:
Fix missing '=' in structure initialization.

Approved by:	re (kensmith)
2005-09-13 12:43:15 +00:00
glebius
7b7ee804e9 MFC 1.26 by ru:
Fixed parsing of unsigned integers.

Approved by:	re (kensmith)
2005-09-13 12:41:05 +00:00
glebius
a9f4fdf4f8 MFC 1.112:
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

Approved by:	re (kensmith)
2005-09-12 14:46:19 +00:00
glebius
1cb55cc44f MFC 1.57 (see original revision for full description):
- 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

Approved by:	re (scottl)
2005-09-09 06:13:25 +00:00
glebius
0bc972befd MFC 1.109:
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

Approved by:	re (scottl)
2005-09-09 06:08:07 +00:00
glebius
4905127030 MFC 1.108, 1.110, 1.111:
Use non-debug macros inside debugging functions, to prevent
  important information from being rewritten.

  In INVARIANTS case also check that nodes do not pass queues of mbufs
  each other.

Approved by:	re (scottl)
2005-09-09 06:06:51 +00:00
emax
6e96afd69d MFC to RELENG 6
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>
Approved by:	re (scottl)
2005-09-03 03:34:23 +00:00