Commit Graph

787 Commits

Author SHA1 Message Date
Gleb Smirnoff
222c1141ea Fix two memory leakages.
Found with:	Coverity Prevent(tm)
2006-01-14 12:16:39 +00:00
Gleb Smirnoff
73189791f2 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-12 22:48:12 +00:00
Gleb Smirnoff
7383c92c9f 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-12 22:44:04 +00:00
Gleb Smirnoff
2955ee1802 - Print also node ID in ktr(9) messages. [1]
- Use fixed length for function name, making ktrdump(8) output
  easier to read.

Suggested by:	julian [1]
2006-01-12 22:41:32 +00:00
Gleb Smirnoff
04b3fa1623 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-12 21:09:12 +00:00
Gleb Smirnoff
22b286280c Remove old debugging leftover.
Reviewed by:	julian
2006-01-12 21:03:09 +00:00
Gleb Smirnoff
3d9dddcd0f Mark appropriate commands with NGM_READONLY and NGM_HASREPLY and
bump type cookie.
2006-01-12 19:16:08 +00:00
Gleb Smirnoff
2df050ad10 In the splnet(9) times netgraph(4) was synchronous and if a message
had been replied, the reply was always delivered to the originator
synchronously.

With introduction of netgraph item callbacks and a wait channel with
mutex in ng_socket(4), we have fixed the problem with ngctl(8) returning
earlier than the command has been proceeded by target node. But still
ngctl(8) can return prior to the reply has arrived to its node.

To fix this:
 - Introduce a new flag for netgraph(4) messages - NGM_HASREPLY.
   This flag is or'ed with message like NGM_READONLY.
 - In netgraph userland library if we have sent a message with
   NGM_HASREPLY flag, then select(2) until reply comes.
 - Mark appropriate generic commands with NGM_HASREPLY flag,
   gathering them into one enum {}. Bump generic cookie.
2006-01-12 19:14:40 +00:00
Gleb Smirnoff
1be0418cbc Fix wording in last commit.
Submitted by:	julian
2006-01-12 10:15:51 +00:00
Gleb Smirnoff
3b33fbe7d4 Add ktr(9) hooks to easier tracing of the netgraph item flow through
netgraph.
2006-01-11 15:29:48 +00:00
Gleb Smirnoff
747cdba40e 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>
2005-12-28 12:56:59 +00:00
Gleb Smirnoff
7223585771 Implement an upper limit for packets per second sent by node. 2005-12-23 19:14:38 +00:00
Ruslan Ermilov
1fb27d4388 Fix memory leak.
PR:		kern/90113
Submitted by:	Antoine Brodin
2005-12-09 07:09:44 +00:00
Jung-uk Kim
ae2cb97e54 Fix build without BPF_JITTER option. 2005-12-07 21:41:45 +00:00
Jung-uk Kim
848c454cc1 Add BPF Just-In-Time compiler support for ng_bpf(4).
The sysctl is changed from net.bpf.jitter.enable to net.bpf_jitter.enable
and this controls both bpf(4) and ng_bpf(4) now.
2005-12-07 21:30:47 +00:00
Ruslan Ermilov
3238c6bd33 Fix -Wundef from compiling the amd64 LINT. 2005-12-04 10:06:06 +00:00
Ruslan Ermilov
c7e7950d2d Use __LP64__ to check for the 64-bit pointer type, and fix -Wundef. 2005-12-04 00:25:03 +00:00
Gleb Smirnoff
14379bfbba - 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-11-27 02:43:08 +00:00
Gleb Smirnoff
4c9b591060 Some whitespace and style cleanup. 2005-11-15 10:54:20 +00:00
Ruslan Ermilov
4a0d6638b3 - Store pointer to the link-level address right in "struct ifnet"
rather than in ifindex_table[]; all (except one) accesses are
  through ifp anyway.  IF_LLADDR() works faster, and all (except
  one) ifaddr_byindex() users were converted to use ifp->if_addr.

- Stop storing a (pointer to) Ethernet address in "struct arpcom",
  and drop the IFP2ENADDR() macro; all users have been converted
  to use IF_LLADDR() instead.
2005-11-11 16:04:59 +00:00
Ruslan Ermilov
5240dcdb07 Make IFP2NG() usable as an lvalue. 2005-11-09 13:34:43 +00:00
Ruslan Ermilov
303989a2f3 Use sparse initializers for "struct domain" and "struct protosw",
so they are easier to follow for the human being.
2005-11-09 13:29:16 +00:00
Ruslan Ermilov
7af425cdee Simplify setting the link-level address. 2005-11-08 09:03:06 +00:00
Ruslan Ermilov
393109a1a2 Use if_setlladdr() to reprogram the link-level addresses; it causes
a synchronous reprogramming of hardware MAC filters if the physical
interface are up and running.  Previously, MAC filters would be
reconfigured only when the fec interface was brought up.
2005-11-04 16:29:51 +00:00
Ruslan Ermilov
6ea00fe048 Bring some level of stability to this driver:
- Disallow bundle reconfiguration when virtual
  interface is running; otherwise, removing a
  port from a running configuration will cause
  a panic in the start() method on the next packet
  on an assumption that a bundle has an even
  number of ports (2 or 4).

- Disallow bringing of virtual interface to a
  running state when a bundle size is 0; otherwise,
  adding and then removing the port will similarly
  cause a panic.

- Add missing initialization of fec_ifstat when
  adding a new port and fix media status reporting
  when virtual interface isn't yet up (check for
  fec_status of 1 rather than != 0).
2005-11-04 15:42:01 +00:00
Ruslan Ermilov
ca5d5ced13 - Fix another fallout from the if_alloc() conversion:
previously, ifp->if_type was set to IFT_ETHER by
  ether_ifattach(), now it's done by if_alloc() so
  an assignment of if_type to IFT_PROPVIRTUAL after
  if_alloc() but before ether_ifattach() broke it.
  This makes arp(8) and friends happy about the fec
  interfaces, and will allow us to use if_setlladdr()
  on the fec interface.

- Set/reset IFF_DRV_RUNNING/IFF_DRV_OACTIVE in init()
  and stop() methods rather than in ioctl(), like the
  rest of the drivers do.  This fixes a bug when an
  "ifconfig fec0 ipv4_address" would not have made
  the interface running, didn't launch the ticker
  function to track media status of bundled ports,
  etc.
2005-11-04 13:50:38 +00:00
Ruslan Ermilov
c60c00bce1 Restore part of the code dropped in rev. 1.25 that makes sure ether_demux()
will receive an mbuf chain with Ethernet header in the data portion of the
first mbuf.
2005-11-03 07:46:04 +00:00
Gleb Smirnoff
1928437497 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-02 15:34:42 +00:00
Gleb Smirnoff
ac5dd14182 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]
2005-11-02 15:23:47 +00:00
Gleb Smirnoff
4be5933577 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
2005-11-02 14:27:24 +00:00
Robert Watson
5bb84bc84b Normalize a significant number of kernel malloc type names:
- Prefer '_' to ' ', as it results in more easily parsed results in
  memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
  as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
  memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
  attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion.  Similar changes are required for UMA zone names.
2005-10-31 15:41:29 +00:00
Robert Watson
d374e81efd Push the assignment of a new or updated so_qlimit from solisten()
following the protocol pru_listen() call to solisten_proto(), so
that it occurs under the socket lock acquisition that also sets
SO_ACCEPTCONN.  This requires passing the new backlog parameter
to the protocol, which also allows the protocol to be aware of
changes in queue limit should it wish to do something about the
new queue limit.  This continues a move towards the socket layer
acting as a library for the protocol.

Bump __FreeBSD_version due to a change in the in-kernel protocol
interface.  This change has been tested with IPv4 and UNIX domain
sockets, but not other protocols.
2005-10-30 19:44:40 +00:00
Ruslan Ermilov
d56ace0997 Use variable-sized arrays where appropriate. 2005-10-28 14:41:28 +00:00
Maksim Yevmenkin
9460540740 Do not manually allocate/free device's softc structure.
Pointed by:	jhb
Reviewed by:	imp, jhb
2005-10-26 23:13:51 +00:00
John Baldwin
284b6708c4 - Use swi_remove() to teardown swi handlers rather than
intr_event_remove_handler().
- Remove tty: prefix from a couple of swi handler names.
2005-10-26 15:52:16 +00:00
Ruslan Ermilov
e110f39bf3 Catch up with new interrupt handling code. 2005-10-26 06:17:27 +00:00
Ruslan Ermilov
27b67627c4 Make the cookie constant name canonical. 2005-10-25 20:56:12 +00:00
Poul-Henning Kamp
2cccccddd4 Use new (inline) functions for calls into driver. 2005-10-16 20:44:18 +00:00
Yaroslav Tykhiy
10d645b7e5 In preparation for making the modules actually use opt_*.h files
provided in the kernel build directory, fix modules that were
failing to build this way due to not quite correct kernel option
usage.  In particular:

ng_mppc.c uses two complementary options, both of which are listed
in sys/conf/files.  Ideally, there should be a separate option for
including ng_mppc.c in kernel build, but now only
NETGRAPH_MPPC_ENCRYPTION is usable anyway, the other one requires
proprietary files.

nwfs and smbfs were trying to ensure they were built with proper
network components, but the check was rather questionable.

Discussed with:	ru
2005-10-14 23:17:45 +00:00
Andrew Thompson
fd6238a659 Further clean up the bridge hooks in if_ethersubr.c and ng_ether.c
- move the function pointer definitions to if_bridgevar.h
- move most of the logic to the new BRIDGE_INPUT and BRIDGE_OUTPUT macros
- remove unneeded functions from if_bridgevar.h and sort a little.
2005-10-14 02:38:47 +00:00
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
Gleb Smirnoff
8afe16d57b In the splnet times, netgraph was functional and synchronous. Nowadays,
an item may be queued and processed later. While this is OK for mbufs,
this is a problem for control messages.

In the framework:
- Add optional callback function pointer to an item. When item gets
  applied the callback is executed from ng_apply_item().
- Add new flag NG_PROGRESS. If this flag is supplied, then return
  EINPROGRESS instead of 0 in case if item failed to deliver
  synchronously and was queued.
- Honor NG_PROGRESS in ng_snd_item().

In ng_socket:
- When userland sends control message add callback to the item.
- If ng_snd_item() returns EINPROGRESS, then sleep.

This change fixes possible races in ngctl(8) scripts.

Reviewed by:	julian
Approved by:	re (scottl)
2005-07-05 17:35:20 +00:00
Gleb Smirnoff
3a48a9fac9 - After LibAlias processing check for TCP packet with th_x2 field
set. If found, then recalculate its checksum.
- Remove debugging printfs.
- Slightly rearrange code in ng_nat_rcvdata().

Approved by:	re (scottl)
2005-06-27 07:39:13 +00:00
David Malone
01399f34a5 Fix some long standing bugs in writing to the BPF device attached to
a DLT_NULL interface. In particular:

        1) Consistently use type u_int32_t for the header of a
           DLT_NULL device - it continues to represent the address
           family as always.
        2) In the DLT_NULL case get bpf_movein to store the u_int32_t
           in a sockaddr rather than in the mbuf, to be consistent
           with all the DLT types.
        3) Consequently fix a bug in bpf_movein/bpfwrite which
           only permitted packets up to 4 bytes less than the MTU
           to be written.
        4) Fix all DLT_NULL devices to have the code required to
           allow writing to their bpf devices.
        5) Move the code to allow writing to if_lo from if_simloop
           to looutput, because it only applies to DLT_NULL devices
           but was being applied to other devices that use if_simloop
           possibly incorrectly.

PR:		82157
Submitted by:	Matthew Luckie <mjl@luckie.org.nz>
Approved by:	re (scottl)
2005-06-26 18:11:11 +00:00
Warner Losh
ab581af779 Eliminate unused argument in PCMCIA_CARD macro.
Provide a backwards compatible way to have the extra macro by defining
PCCARD_API_LEVEL 5 before including pccarddevs for driver writers that
want/need to have the same driver on 5 and 6 with pccard attachments.

Approved by: re (dwhite)
2005-06-24 14:36:54 +00:00
Brooks Davis
fc74a9f93a Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
 - Struct arpcom is no longer referenced in normal interface code.
   Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
   To enforce this ac_enaddr has been renamed to _ac_enaddr.
 - The second argument to ether_ifattach is now always the mac address
   from driver private storage rather than sometimes being ac_enaddr.

Reviewed by:	sobomax, sam
2005-06-10 16:49:24 +00:00
Gleb Smirnoff
e6da342b6c - Remove redundant parenthesis in M_CHECK macro.
- Do not edit pullup_len outside M_CHECK macro.
- Do not reimplement NG_FWD_NEW_DATA().
- Remove redundant check for item being not NULL.

Submitted by:	ru
2005-06-10 12:44:21 +00:00
Gleb Smirnoff
adf284a2ac Add ng_tcpmss node, which alters MSS options of TCP packets. Useful to
hack MSS of packets outgoing via interface with small MTU, to workaround
path MTU discovery problems.

Written by Alexey Popov, with some cleanups from me. There are also plans
to improve mpd port, so that it uses this node, instead of doing MSS
hacking in userland, when 'enable tcpmssfix' option is on.

Submitted by:   Alexey Popov <lollypop@flexuser.ru>
2005-06-10 08:02:34 +00:00
Ruslan Ermilov
fc1f92b532 Refer to the mbuf header length field via the official method. 2005-06-09 10:27:27 +00:00
Gleb Smirnoff
f4b580b1dd Update statistics only in case if delivery was successfull. 2005-06-07 12:22:13 +00:00
Gleb Smirnoff
2f07580bf6 MPPC node is not thread safe.
PR:		kern/79990
Reported by:	Arcadiy Ivanov
Reported by:	atckoe.zlo @ gmail.com
MFC after:	1 week
2005-06-03 09:06:00 +00:00