Commit graph

203 commits

Author SHA1 Message Date
Julian Elischer 453b556583 oops that commit included a local hack... take it out.. 2000-12-12 18:59:09 +00:00
Julian Elischer 859a4d166c Reviewed by: Archie@freebsd.org
This clears out my outstanding netgraph changes.
There is a netgraph change of design in the offing and this is to some
extent a superset of soem of the new functionality and some of the old
functionality that may be removed.

This code works as before, but allows some new features that I want to
work with and evaluate. It is the basis for a version of netgraph
with integral locking for SMP use.

This is running on my test machine with no new problems :-)
2000-12-12 18:52:14 +00:00
Archie Cobbs 3d48aa2a7c Fix a bug where if the interface was in promiscuous mode when the
last hook was disconnected, the interface would not get reset to
non-promiscuous mode.

Reported by:	jdp
2000-12-11 03:36:26 +00:00
Julian Elischer e8a49db233 Add splhigh()s to protect against a race condition
that shows up when running with ethernet bridging
at high speed.

Submitted by: Chris Csanady <ccsanady@iastate.edu>
(and extended by me)
2000-12-02 13:27:58 +00:00
Jonathan Lemon fe96e26dd0 Fix another callout_init() that I missed. 2000-11-26 21:59:30 +00:00
David Malone 99cdf4ccb2 Add the use of M_ZERO to netgraph.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
Submitted by:	archie
Approved by:	archie
2000-11-18 15:17:43 +00:00
Brian Somers 27121ab1a4 Go back to using data_len in struct ngpppoe_init_data after discussions
with Julian and Archie.

Implement a new ``sizedstring'' parse type for dealing with field pairs
consisting of a uint16_t followed by a data field of that size, and use
this to deal with the data_len and data fields.

Written by:		Archie with some input by me
Agreed in principle by:	julian
2000-11-16 23:14:53 +00:00
Archie Cobbs 6e8d625628 New netgraph node type ng_one2many(4). 2000-11-16 05:58:33 +00:00
Kirk McKusick 5f90cac7f1 In preparation for deprecating CIRCLEQ macros in favor of TAILQ
macros which provide the same functionality and are a bit more
efficient, convert use of CIRCLEQ's in netgraph PPP code to TAILQ's.

Reviewed by:	Archie Cobbs <archie@dellroad.org>
2000-11-15 19:40:34 +00:00
Julian Elischer 7ccbb17bb3 Swap the order of two tags in the pppoe PADI and PADS packets
as there are apparently some buggy switches that need them in that order.
(I hope there aren't any that require them in the old order!)
2000-10-31 14:40:23 +00:00
Brian Somers 76a70671fc Change the format of ngpppoe_init_data so that the provider is NUL
terminated and the data_len field is no longer necessary.

Add ASCII2BINARY and BINARY2ASCII capabilities.

The old format is still understood and dealt with, but can't do
the ASCII2BINARY and BINARY2ASCII stuff.

Approved by: archie
2000-10-31 02:45:24 +00:00
Poul-Henning Kamp cf9fa8e725 Move suser() and suser_xxx() prototypes and a related #define from
<sys/proc.h> to <sys/systm.h>.

Correctly document the #includes needed in the manpage.

Add one now needed #include of <sys/systm.h>.
Remove the consequent 48 unused #includes of <sys/proc.h>.
2000-10-29 16:06:56 +00:00
Julian Elischer cc3bbd68c5 Since neither archie nor I work at Whistle any more, change our email
addresses to be the more usefu @freebsd.org ones
so we can keep getting bug-reports.
- man pages to follow..
2000-10-24 17:32:45 +00:00
Poul-Henning Kamp db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Archie Cobbs 034d9dac34 Calling untimeout(9) leads to a race window where memory could be leaked.
Close this window by simply not calling untimeout(9).
2000-10-11 20:29:12 +00:00
Archie Cobbs be731c30f3 Fix memory leak.
Submitted by:	Christopher N. Harrell <cnh@ivmg.net>
2000-10-11 19:04:34 +00:00
Archie Cobbs a89effcde1 Fix typo in NETGRAPH_INIT() macro. 2000-10-09 18:37:11 +00:00
Archie Cobbs 6f16db8137 More complete fix for multi-link sequence number handling bugs.
Add a new control message for querying the sequence number state.
2000-10-06 23:42:02 +00:00
Archie Cobbs 1cd643640f Fix bug in handling of multi-link sequence numbers.
Reported by:	Becca Anderson <becca@worldint.com>
2000-10-06 20:36:17 +00:00
Archie Cobbs 763fcb92c5 Use m_dup() instead of m_copypacket() for the time being. Not all
of the code in the kernel properly checks for read-onlyness before
writing into an mbuf data area. When that code is fixed, the m_dup()
can go back to being m_copypacket().

Requested by:	nsayer
2000-09-23 23:22:27 +00:00
Archie Cobbs ee79f58e34 Remove unnecessary #include's as reported by phk's script. 2000-09-22 16:51:14 +00:00
Archie Cobbs 65b9a0da90 Allocate all memory (including within node constructors) with M_NOWAIT
instead of M_WAITOK, to allow for maximum flexibility.
2000-09-21 18:01:23 +00:00
Archie Cobbs 840f71272d Allocate memory with M_NOWAIT instead of M_WAITOK because we could
be called in an interrupt context.
2000-09-21 17:33:33 +00:00
Julian Elischer a62b20c4a1 When sending a packet back to a network interface to simulate an arrived
packet, make sure that the packet has the interface marked in the first mbuf,
the same a truely arrived packets would have.
2000-09-19 08:35:44 +00:00
Archie Cobbs 2b9cf2f709 Rename "struct session" to "struct sess_con" to avoid conflict with
upcoming "struct session" in proc.h.

Requested by:	jasone
2000-09-19 03:22:06 +00:00
Jason Evans 0384fff8c5 Major update to the way synchronization is done in the kernel. Highlights
include:

* Mutual exclusion is used instead of spl*().  See mutex(9).  (Note: The
  alpha port is still in transition and currently uses both.)

* Per-CPU idle processes.

* Interrupts are run in their own separate kernel threads and can be
  preempted (i386 only).

Partially contributed by:	BSDi (BSD/OS)
Submissions by (at least):	cp, dfr, dillon, grog, jake, jhb, sheldonh
2000-09-07 01:33:02 +00:00
Archie Cobbs ed2dbd316a New netgraph node type for Ethernet bridging.
No ipfw support yet.
2000-09-01 01:37:13 +00:00
Archie Cobbs 7f98dc0449 Fix wrong offset bug in ng_enaddr_unparse(). 2000-09-01 00:28:03 +00:00
Archie Cobbs d99b0733c7 Avoid free'ing a NULL pointer. 2000-08-31 23:08:52 +00:00
Archie Cobbs f30a8c449f Export ng_ether_enaddr_type for other nodes that want to use it. 2000-08-30 18:39:29 +00:00
Archie Cobbs 56045c6673 Add three more control messages to complement their opposites:
NGM_ETHER_SET_ENADDR, NGM_ETHER_GET_PROMISC, and NGM_ETHER_GET_AUTOSRC.
Alter parsing algorithm so the EN address really looks like one.
2000-08-15 01:05:50 +00:00
Archie Cobbs a604c8808e Oops, previous commit fixed a bug that was already fixed before.
Back it out.
2000-08-10 23:04:46 +00:00
Archie Cobbs 0521578550 Add new control message to atomically get and clear statistics. 2000-08-10 22:52:40 +00:00
Archie Cobbs a8f6d55e95 Increase the maximum allowable datagram length. 2000-08-10 22:51:57 +00:00
Archie Cobbs cac2a7de76 "u_int32_t" should have been "int32_t". 2000-08-10 22:51:26 +00:00
Archie Cobbs 7133ac27ef Use a bigger buffer for NGM_BINARY2ASCII conversion, to handle really
long ASCII control messages.
2000-08-10 22:50:38 +00:00
Archie Cobbs 656485a2c6 - Add new control message NGM_VJC_GET_CONFIG
- Implement control message ASCII'fication for all control messages
2000-08-10 22:48:03 +00:00
Archie Cobbs 57b57be3ec Take advantage of the new unsigned and hex integer types. 2000-08-10 22:45:54 +00:00
Archie Cobbs 8fccb7e954 - Make statistics unsigned.
- Add new control message to atomically get and clear statistics.
2000-08-10 22:44:41 +00:00
Archie Cobbs 7b3bf3f9aa - Add new unsigned and hex integer parse types
- Fix bug in commented example code
2000-08-10 22:43:38 +00:00
Archie Cobbs 8db3c6cd29 - Add new unsigned and hex integer parse types; this allows simplifying
the bytearray parse type.
- Allocate (larger) temporary work buffer dynamically instead of on the
  stack when comparing to the default value.
2000-08-10 22:42:25 +00:00
Archie Cobbs 7b38c4e4d9 RFC 1661 requires that all LCP packets are sent with no address and
control field compression. The ng_ppp(4) node correctly follows this
rule. However, PPPoE is an exception: when doing PPPoE *all* frames
are sent with address and control field compression.

Alter this node's behavior so that when an outgoing frame is received,
any leading address and control field bytes are removed. This makes
this node compatible with ng_ppp(4).
2000-08-10 20:05:12 +00:00
Archie Cobbs 1baeddb81b In a struct sockaddr, sa->sa_len can be zero if uninitialized.
Make sure that this doesn't cause a problem when parsing.
2000-08-09 23:57:44 +00:00
Archie Cobbs 3b49655c07 Fix bug where bundle-level receive statistics were not getting updated. 2000-08-09 01:43:21 +00:00
Archie Cobbs 8a660c773a Fix a bug where we were accessing already free'd memory during node shutdown.
Detected via:	0xdeadc0de
2000-08-07 22:41:12 +00:00
Archie Cobbs 4b39c3c7b3 Add three new control messages to the ng_ether(4) netgraph node type:
NGM_ETHER_GET_ENADDR:	Get the device's Ethernet address
    NGM_ETHER_SET_PROMISC:	Enable/disable promiscuous mode
    NGM_ETHER_SET_AUTOSRC:	Enable/disable packet source address override
2000-08-07 18:52:26 +00:00
Archie Cobbs 9dcab5306e Fix misspelling. 2000-08-05 20:17:04 +00:00
Archie Cobbs da010626df Followup to previous commit..
- It's worthwhile to use untimeout(9), even though we must still protect
  against "false" timeouts, because most of the time it saves having to
  handle a dummy timeout event.
- Slight tweaks to the delayed ACK algorithm paramters.
2000-07-25 18:57:20 +00:00
Archie Cobbs 678f9e335e Several fixes:
- Fix slowness when operating over fast connections, where the timeout(9)
  granularity is on the same order of magnitude as the round trip time.
  timeout(9) can happen up to 1 tick early, which was causing receive
  ack timeouts to happen too early, causing bogus "lost" packets.
- Increase the local time counter to 64 bits to avoid roll-over.
- Keep statistics on memory allocation failures.
- Add a new option to always include the ack when sending data packets.
  Might be useful in high packet loss situations. Might not.
2000-07-25 00:23:19 +00:00
Archie Cobbs d2ea40c23f Allocate memory with M_NOWAIT instead of M_WAITOK, because it's possible
for these routines to be called from an interrupt context.

PR:		kern/20057
2000-07-20 17:23:49 +00:00
Archie Cobbs 7c24617ca0 Remove node's name reference when the interface is detached;
otherwise, the ng_ether.ko KLD will never be unloadable after
all Ethernet interfaces are detached, as it should be, because
of the lingering extra reference.

Submitted by:	"Yevmenkin, Maksim N, CSCIO" <myevmenkin@att.com>
2000-07-19 17:33:53 +00:00
Archie Cobbs 840e97785b Set NG_INVALID flag when destroying node. 2000-07-14 22:35:13 +00:00
Jeroen Ruigrok van der Werven 514baf3f99 Fix typo, teh -> the. 2000-07-14 11:17:16 +00:00
Archie Cobbs 051fbf7d66 Fix race condition caused by using NG_SEND_DATAQ() where we meant
to use ng_queue_data().

Reported by:	Udo Erdelhoff <ue@nathan.ruhr.de>
2000-07-12 23:55:07 +00:00
Julian Elischer 561e4fb9f6 Don't forget to set our MAC address into packets we wre sending out via
netgraph. Eventually we may need to have a separate hook for packets
that already have a source AMC address but for now just drop it in.
Should fix PPPoE.
2000-07-06 15:35:59 +00:00
Poul-Henning Kamp 7095e0970e Experiemntal ascii based device configuration mechanism.
This may or may not survive, decision will be made well before 5.0-R
2000-07-03 13:34:18 +00:00
Archie Cobbs e962a82308 Fix incorrectly implemented receive ACK timeout algorithm:
instead of bumping the recvAck counter by one, pretend that
all outstanding xmit packets are acknowleged, and restart
transmitting anew, with an empty (but halved) transmit window.

Put a lower bound on the adaptive timeout value.
2000-06-28 19:43:34 +00:00
Archie Cobbs e1e1452d61 Make the ng_ether(4) node type dynamically loadable like the rest.
This means 'options NETGRAPH' is no longer necessary in order to get
netgraph-enabled Ethernet interfaces. This supports loading/unloading
the ng_ether.ko and attaching/detaching the Ethernet interface in any
order.

Add two new hooks 'upper' and 'lower' to allow access to the protocol
demux engine and the raw device, respectively. This enables bridging
to be defined as a netgraph node, if so desired.

Reviewed by:	freebsd-net@freebsd.org
2000-06-26 23:34:54 +00:00
Archie Cobbs 3cd7db2297 - Start sequence numbers at zero instead of one; the rest of the
world seems to interpret the spec this way
- Initialize transmit window to two instead of one; helps get things
  going initially when the first packet may get dropped
- Really fix the shutdown + timeout race condition this time
2000-06-26 19:43:24 +00:00
Archie Cobbs b4c44c30d8 Fix bug where receive statistics for the bundle were not getting updated. 2000-06-01 01:29:49 +00:00
Jake Burkholder e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder 740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Archie Cobbs b715c697bf Add hook for IPv6. 2000-05-10 16:54:00 +00:00
Archie Cobbs 9bee7adfa8 Fix a couple of bugs:
- Properly handle 32 bit sequence numbers when they wrap around
- Don't drop GRE packets with stale ACK numbers, just ignore the ACK
- Close race between node being shutdown and timer going off
Also add support for lots of statistics, and control message ASCIIfication
2000-05-05 01:11:39 +00:00
Archie Cobbs 1bdebe4d45 Don't assume *lasthook is initialized in ng_path2node(). 2000-05-02 17:09:46 +00:00
Archie Cobbs a9b3dca54d Fix broken multi-link fragment reassembly algorithm.
Add hook for IPv6. Misc cleanups.

PR:		kern/16335
2000-05-02 00:09:18 +00:00
Archie Cobbs dce9390ed0 Macro call to ng_send_dataq() should have been to ng_send_data() instead. 2000-05-01 23:34:15 +00:00
Archie Cobbs a096e45ab9 Use 'type_name' structure field instead of 'typename', which is
a C++ reserved work.

Add a ng_copy_meta() function.
2000-05-01 23:29:19 +00:00
Peter Wemm cc3daab531 A temporary band-aid for ng_base. It works for some people, a better
fix will follow.

Submitted by:   Gary Jennejohn <garyj@muc.de>
2000-05-01 21:26:50 +00:00
Peter Wemm 99ff81767f Minimal tweak to make the ng_XXX modules depend on netgraph so that they
see its symbols and link ok.
2000-04-29 13:36:07 +00:00
Julian Elischer a4ec03cfa8 Two simple changes to the kernel internal API for netgraph modules,
to support future work in flow-control and 'packet reject/replace'
processing modes.

reviewed by: phk, archie
2000-04-28 17:09:00 +00:00
Poul-Henning Kamp 3389ae9350 Remove ~25 unneeded #include <sys/conf.h>
Remove ~60 unneeded #include <sys/malloc.h>
2000-04-19 14:58:28 +00:00
Archie Cobbs 52ec4a0370 Fix uninitialized variable.
PR:		kern/17911
Submitted by:	Tom Pavel <pavel@alum.mit.edu>
2000-04-12 17:29:33 +00:00
Archie Cobbs af7ab18437 A netgraph node that implements Microsoft Point-to-Point compression
(MPPC) and Microsoft Point-to-Point encryption (MPPE) protocols.

Note: the MPPC part is disabled as it requires proprietary files.

Obtained from:	Whistle source tree
2000-04-09 21:04:55 +00:00
Archie Cobbs 382379f8a8 Call bpfdetach() before going away. 2000-03-21 01:42:56 +00:00
Poul-Henning Kamp 63909a9015 Newer ciscos have become more picky, and will not accept the MULTICAST bit
being set for unicast packets.
2000-03-17 17:06:33 +00:00
Archie Cobbs 15ba31b9ad Updates to the ng_iface(8) netgraph node type:
- Make iface nodes removable on shutdown since FreeBSD now supports
    removable interfaces
  - Simplify supporting new protocols using family_enqueue(); add a
    few new ones including IPv6
  - Add support for configurable interface mode using new
    NGM_IFACE_POINT2POINT and NGM_IFACE_BROADCAST control messages
  - Remove NGM_IFACE_GET_IFADDRS control message; it just duplicates
    the functionality of SIOCGIFCONF
2000-03-13 19:18:10 +00:00
Archie Cobbs 9a9a26fd5a Some minor prototype tweaks. 2000-03-13 19:05:11 +00:00
Archie Cobbs af207f2160 Use snprintf() instead of sprintf(). 2000-03-13 18:54:10 +00:00
Archie Cobbs c1b9e5f25b Fix typo: "ng_parse_fixedsstring_info" -> "ng_parse_fixedstring_info" 2000-03-13 18:50:38 +00:00
Archie Cobbs 5c63f81fd4 Add control message ASCII conversion for this node type. 2000-01-27 01:32:53 +00:00
Archie Cobbs 4c641908e9 Fix a few obscure memory leaks. 2000-01-05 20:36:07 +00:00
Archie Cobbs 4164c44770 Fix race condition caused by missing splnet()'s. 2000-01-04 22:06:08 +00:00
Peter Wemm 664a31e496 Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot).  This is consistant with the other
BSD's who made this change quite some time ago.  More commits to come.
1999-12-29 04:46:21 +00:00
Archie Cobbs 1e7a9f724c Fix bugs in the MP fragment reassembly code that can cause a panic. 1999-12-17 23:29:04 +00:00
Archie Cobbs add85a1d6e New netgraph node type 'pptpgre': this performs GRE encapsulation
for the PPTP protocol as specified in RFC 2637.
1999-12-08 18:55:39 +00:00
Julian Elischer 647b86df6e Remove a bunch of un-needed includes.
Submitted by: phk@freebsd.org
1999-12-07 05:50:48 +00:00
Archie Cobbs ab0d3c94db Change definition of NG_BPF_HOOKPROG_SIZE() so as not to require
a structure pointer, just the number of BPF instructions.
1999-12-06 18:43:32 +00:00
Archie Cobbs 92a3e5521f New netgraph node type, ng_bpf(8). This node type allows you to
apply bpf(4) filters to data travelling through a netgraph network.
1999-12-03 21:21:49 +00:00
Archie Cobbs 899e9c4e44 Add a new function ng_findhook() for finding a node's hook;
if the node type provides a more efficient implementation than
the normal linear scan, use it.

Reviewed by:	julian
1999-12-03 21:17:30 +00:00
Archie Cobbs 2076235ada Fix bug parsing 32 bit integers on machines where sizeof(long) == 4. 1999-12-03 20:27:33 +00:00
Archie Cobbs 3fae25a8a6 Use m_dup() instead of m_copypacket() to duplicate the mbuf chain.
This fixes a bug where if the original packet was modified downstream
of the tee node, then the copy could get modified too.
1999-12-01 23:11:58 +00:00
Archie Cobbs 63e2ac54d1 Add more comments describing how to use parse types and how they work. 1999-12-01 19:41:15 +00:00
Archie Cobbs fa200997c8 Show how to supply a struct ng_cmdlist for (de)asciification
of control messages.

Suggested by:	julian
1999-12-01 19:40:37 +00:00
Julian Elischer d0fef8084f change intial timeout for session negotiation from 1 to 2 seconds.
One second was being hit too many times in normal situations.
1999-12-01 08:05:56 +00:00
Archie Cobbs f8307e1233 Add two new generic control messages, NGM_ASCII2BINARY and
NGM_BINARY2ASCII, which convert control messages to ASCII and back.
This allows control messages to be sent and received in ASCII form
using ngctl(8), which makes ngctl a lot more useful.

This also allows all the type-specific debugging code in libnetgraph
to go away -- instead, we just ask the node itself to do the ASCII
translation for us.

Currently, all generic control messages are supported, as well as
messages associated with the following node types: async, cisco,
ksocket, and ppp.

See /usr/share/examples/netgraph/ngctl for an example of using this.

Also give ngctl(8) the ability to print out incoming data and
control messages at any time.  Eventually nghook(8) may be subsumed.

Several other misc. bug fixes.

Reviewed by:	julian
1999-11-30 02:45:32 +00:00
Archie Cobbs 25792ef324 Change the prototype of the strto* routines to make the second
parameter a char ** instead of a const char **.  This make these
kernel routines consistent with the corresponding libc userland
routines.

Which is actually 'correct' is debatable, but consistency and
following the spec was deemed more important in this case.

Reviewed by (in concept):	phk, bde
1999-11-24 01:03:08 +00:00
Julian Elischer aa548c6abe oops cut-n-paste error 1999-11-21 23:11:52 +00:00
Julian Elischer cae912fcc8 It's time to only allow root to manipulate netgraph nodes.
(I meant to do this before checking in to FreeBSD and forgot)
1999-11-21 23:06:30 +00:00
Julian Elischer 490ccf9c5a Hopefully the last patch from Brian to get server side PPPoE working.
remove a 'free' that is no longer needed.
1999-11-21 22:18:54 +00:00