Commit Graph

209 Commits

Author SHA1 Message Date
Brian Somers
9088fa05ae If an attempt is made to LISTEN for a service tag that's already being
LISTENed for, return EEXISTS.

Only match the magic "*" service tag if no other LISTEN service tags
match.

Require an explicit LISTEN for an empty service tag in order to match
empty service requests.

Approved by:	julian
MFC after:	3 days
2001-07-25 03:34:07 +00:00
Brooks Davis
bb5c977fbd General cleanup providing better style(9) conformance and generally
improved readability.  The two real functional changes are that
netgraph now sees this as the "split" node type rather then the
"ng_split" node type and that meta data is passed through without
processing rather then being dropped.

Reviewed by:	jhb, julian
MFC after:	7 weeks
2001-07-24 23:33:06 +00:00
Julian Elischer
c31b4a5381 Add an external function to unlink a netgraph type from the types list. 2001-07-23 21:14:57 +00:00
Julian Elischer
8b68f82f72 remember to set the return address in a message when
sending it along a hook.

PR: 27906
Submitted by: Harti Brandt <brandt@fokus.gmd.de>

no MFC as code is different in 4.x
2001-07-14 05:51:33 +00:00
Peter Wemm
bc66c1fd1f Fix warning: (int/long mixup in printf)
475: warning: unsigned int format, long unsigned int arg (arg 3)
2001-06-15 07:35:25 +00:00
John Polstra
a514569e9a Fix a range checking bug in ng_int32_parse which affected 64-bit
machines.  The code formerly read:

    long val;
    if (val < (long)-0x80000000 || ...)
            return EINVAL;

The constant 0x80000000 has type unsigned int.  The unary `-'
operator does not change the type (or the value, in this case).
Therefore the promotion to long is done by 0-extension, giving
0x0000000080000000 instead of the desired 0xffffffff80000000.  I
got rid of the `-' and changed the cast to (int32_t) to give proper
sign-extension on all architectures and to better reflect the fact
that we are range-checking a 32-bit value.

This commit also makes the analogous changes to ng_int{8,16}_parse
for consistency.

MFC after:	3 days
2001-05-19 19:36:32 +00:00
John Baldwin
f5d325c599 Remove unneeded includes in the i386 case. 2001-05-15 23:16:18 +00:00
Archie Cobbs
422c727634 Don't reference a node after we dropped a reference to it
(same as in previous checkin, but in a different function).
2001-04-11 22:04:47 +00:00
John Baldwin
f34fa851e0 Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
2001-03-28 09:17:56 +00:00
Julian Elischer
5951069a87 netgraph.h:
Change a prototype.
  Add a function version of ng_ref_node() when debugging so
  a breakpoint can be set on it.
ng_base.c:
  add 'node' as an argument to ng_apply_item so that it is up
  to the caller to take over and release the item's reference on
  the node. If the release reports back that the node went away
  due to the reference going to 0, the caller should cease referencing
  the now defunct node. (e.g. the item was a 'kill node' message).
  Alter ng_unref_node to report back the residual references as a result.
ng_pptpgre.c:
  Don't reference a node after we dropped a reference to it.
  (What if it was the last?)
Fixes a node leak reported by Harti Brandt <brandt@fokus.gmd.de>
 which was due to an incorrect earlier attempt to fix the
 "accessing node after dropping the last reference" problem.
2001-03-10 16:31:00 +00:00
Archie Cobbs
22dfb9bdb7 Fix potential crash caused by packets with bogus ACK's.
Reported by:	Fabien THOMAS <fabient@netasq.com>
2001-03-08 20:10:02 +00:00
Julian Elischer
8714210340 Cleanups to Macros for sending data between netgraph nodes. 2001-03-03 05:52:49 +00:00
Julian Elischer
e7af56e53e Add parenthesis to a macro.
This took me 2 whole days to track down. (bleah)
2001-03-03 05:50:47 +00:00
Julian Elischer
a96dcd84d2 Shuffle netgraph mutexes a bit and hold a reference on a node
from the function that is calling the destructor.
2001-02-28 18:49:09 +00:00
Julian Elischer
e08d3e3c33 Allow a changed MAC address to show up in ifconfig by changing it
in the ifaddr list as well. Also change an error return in the base system.
2001-02-26 09:31:54 +00:00
Julian Elischer
950809d7ac slight cleanups during testing. 2001-02-25 16:49:04 +00:00
Julian Elischer
2b2c95c996 Add a node that looks to all the word like an ethernet but delivers its
ehternet frames to a netgraph  hook.

Submitted by: "Vitaly V. Belekhov" <vitaly@riss-telecom.ru>
translated to 5.0 by me. man page not yet written.

This node still needs a little work.. don't use yet. Not yet linked into
the build.
2001-02-25 05:46:52 +00:00
Julian Elischer
e519ede348 Make the sample netgraph node compileable again.
Makes it easier for people if they can start with something
that actually compiles.
2001-02-25 05:36:25 +00:00
Julian Elischer
33338e7370 Add knowledge of the netgraph spinlocks into the Witness code.
Well, at least I think that's how it's done.
2001-02-24 14:29:47 +00:00
Julian Elischer
bfa7e882d1 Shuffle sysctls a bit (thankyou whoever made them dynamic for modules)
and add a sysctl to pppoe to activate non standard ethertypes
so that idiot ISPs (apparently in France) who use
equipment from idiot suppliers (rumour says 3com)
who use nonstandard ethertypes can still connect.

 "yep, sure we do pppoe, we use a different identifier to that dictated in
 the standard, but sure it's pppoe!"

sysctl -w net.graph.stupid_isp=1 enables the changeover.
2001-02-23 16:34:22 +00:00
Julian Elischer
cdee49f986 Add a 'splitter' node to separate a bidirectional
packet flow into two unidirectional flows.

Part of a suite of nodes developed for packet flow control.
More to follow as I have time to port them to 5.x or
as others do so. The ipfw node will be the hardest..

Submitted by:	"Vitaly V. Belekhov" <vitaly@riss-telecom.ru>
2001-02-22 17:14:36 +00:00
Jeroen Ruigrok van der Werven
d7d97eb0aa Preceed/preceeding are not english words. Use precede and preceding. 2001-02-18 10:43:53 +00:00
Archie Cobbs
93caaaa74b Fix an erroneous comment and two style(9) bugs. 2001-02-16 17:37:31 +00:00
Bosko Milekic
9ed346bab0 Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:

mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)

similarily, for releasing a lock, we now have:

mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.

The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.

Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:

MTX_QUIET and MTX_NOSWITCH

The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:

mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.

Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.

Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.

Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.

Finally, caught up to the interface changes in all sys code.

Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +00:00
Julian Elischer
0402c7ce1d Add a dummy disconnect function so that the socket code doesn't leap into
space when it calls the disconnect PRU function without checking that it
there.
2001-02-05 20:48:04 +00:00
Julian Elischer
9d72a7a3f8 Make netgraph modules refuse to link with modules of a different ABI version.
also try implement teh documented behaviour in socket nodes
so that when there is only one hook, an unaddressed write/send
will DTRT and send the data to that hook.
2001-02-05 18:57:11 +00:00
Julian Elischer
f7109125e1 Change the kernel internal ABI number as the HOOK structure has changed.
Forgotten by: me
2001-02-01 21:25:06 +00:00
Julian Elischer
b57a79658b Clean up reference counting with relation to queued packets and the worklist,
and while I'm there, clean up the worklist insertion and removal.

Inspired by: Harti Brandt <brandt@fokus.gmd.de>
2001-02-01 20:51:23 +00:00
Julian Elischer
c4b5eea4e2 Add the ability to declare ore-ride methods on a per-hook basis
for the rcvdata() and rcvmsg() methods.

Also bring the man page up to sync with my last commit. (and this one)
2001-01-31 20:46:00 +00:00
Julian Elischer
1acb27c64a Implement direct support for semipersistant nodes.
(e.g. ethernet nodes are persistent until you rip out the hardware)
Use this support in the ethernet and sample nodes.
Add some more abstraction on the 'item's so that  node and
hook reference counting can be checked easier.
Slight man page correction.
Make pppoe type dependent on ethernet type.
Clean up node shutdown a little.
Move a mutex from MTX_SPIN to MTX_DEF (oops)
Fix small ref-counting bug.
remove warning on one2many type.
2001-01-30 20:51:52 +00:00
Julian Elischer
d2a57575f1 Fix cut and paste error in a comment.
Submitted by: Peter Wemm <peter@freebsd.org>
2001-01-30 07:58:30 +00:00
Julian Elischer
d30293b3ff Add a new distribution algorythm to the 'one2many' node type.
The new method is 'flood' (in addition to the old round-robin)
in which incoming packets are sent to more than one outgoing hook.
(I'm not sure what Rogier is using this for but it seems generally useful
and isn't much extra)

Submitted by:   Rogier R. Mulhuijzen (drwilco@drwilco.net )
2001-01-28 15:37:06 +00:00
Julian Elischer
0633aaefef Swap egress hooks for packets entering from the monitor hooks. 2001-01-26 11:35:36 +00:00
Julian Elischer
34f9ca0908 Only clear the 'free' bit if we were successful in getting a queue item off the free list.
Found by: Harti Brandt (address unknown)
2001-01-25 19:48:57 +00:00
Julian Elischer
c73b94a276 Don't crash the kernel if the user tries to load a netgraph
module with the wrong version number.
2001-01-24 21:29:57 +00:00
Julian Elischer
95012d3829 Add MTX_SPIN to an mtx_init( 2001-01-22 17:51:48 +00:00
Julian Elischer
0f150d0411 remove stupid braino (recursive mutex)
tripped over by: PHK
2001-01-21 23:32:00 +00:00
Julian Elischer
6b79597012 Add a generic "queued function callin" mechanism
Use it to implement (hopefully) SMP safe node/hook addition
and removal.
Fix some debug stuff.
2001-01-14 23:25:54 +00:00
Julian Elischer
52fa355626 remove debug sysctl
slight tweek to hook removal. (or is that tweak?)
2001-01-11 23:05:34 +00:00
Julian Elischer
3e4084c88a Make hook deletion SMP safe. 2001-01-11 22:22:52 +00:00
Julian Elischer
954c4772dd Add an exported function ng_rmhook_self() that removes a hook
from a node, but does it via the locking queue, thus ensuring that the
node is locked when it's hook is removed.

Add 'deadnode' and 'deadhook' structures for when a node or hook is
invalidated but not yet freed. (not yet freed)
2001-01-11 19:27:54 +00:00
Julian Elischer
cdbfe12417 Another brian fix, luckily not in live code. 2001-01-11 15:44:41 +00:00
Julian Elischer
0069b9cb86 Fix uninitialised pointer.
Found by: Brian Sommers
2001-01-11 15:42:22 +00:00
Archie Cobbs
ce5e5f9953 Unbreak compilation. 2001-01-11 04:13:46 +00:00
Julian Elischer
f585602984 Only free items that are not already free or passed to other nodes.
Clever work by: Brian Sommers (Brian@freeBSD.org)
2001-01-10 23:49:03 +00:00
Julian Elischer
70de87f2ef Changes to stop zombie nodes showing up in active node lists.
Also some changes resulting from debug work done earlier.
2001-01-10 23:19:32 +00:00
Julian Elischer
9c8c302fd0 Fix some memory leaks
Add memory leak detection assitance.
2001-01-10 07:13:58 +00:00
Julian Elischer
584af70a85 Missing FREE(). 2001-01-09 00:49:31 +00:00
Julian Elischer
12574a02a6 Bad julian.. forgot to destroy mutex before freeing the
structure it was part of!
2001-01-08 06:28:30 +00:00
Julian Elischer
30400f03aa Part 2 of the netgraph rewrite.
This is mostly cosmetic changes, (though I caught a bug or two while
makeing them)
Reviewed by:	archie@freebsd.org
2001-01-08 05:34:06 +00:00