Commit Graph

1180 Commits

Author SHA1 Message Date
Marko Zec
8b615593fc Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit

Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.

Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().

Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).

All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).

(*) netipsec/keysock.c did not validate depending on compile time options.

Implemented by:	julian, bz, brooks, zec
Reviewed by:	julian, bz, brooks, kris, rwatson, ...
Approved by:	julian (mentor)
Obtained from:	//depot/projects/vimage-commit2/...
X-MFC after:	never
Sponsored by:	NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Ed Schouten
d3ce832719 Remove unit2minor() use from kernel code.
When I changed kern_conf.c three months ago I made device unit numbers
equal to (unneeded) device minor numbers. We used to require
bitshifting, because there were eight bits in the middle that were
reserved for a device major number. Not very long after I turned
dev2unit(), minor(), unit2minor() and minor2unit() into macro's.
The unit2minor() and minor2unit() macro's were no-ops.

We'd better not remove these four macro's from the kernel, because there
is a lot of (external) code that may still depend on them. For now it's
harmless to remove all invocations of unit2minor() and minor2unit().

Reviewed by:	kib
2008-09-26 14:19:52 +00:00
Andrew Thompson
89ac5af9c1 Add ng_rmnode_flags() so the caller can pass NG_QUEUE and have the node
destroyed asynchronously due to locking or other constraints.

Reviewed by:	julian
2008-09-22 19:28:18 +00:00
Marko Zec
3ac12c597e Fix error message content.
Approved by:	julian (mentor)
MFC after:	3 days
2008-09-21 07:33:33 +00:00
Alexander Motin
74c9119d4a We can't implicitly trust the hook on NGQF_FN/NGQF_FN2 processing in
ng_apply_item(). There are possible (and I have got one) use-after-free
class panics because of it.

If hook is specified, require it to be valid at the apply time. The only
exceptions are the internal ng_con_part2(), ng_con_part3() and
ng_rmhook_part2() functions which are specially made to work with invalid
hooks.
2008-09-13 09:17:02 +00:00
Julian Elischer
9c238a0ec4 Add Marko's pipe node.
This allows one to do flow modulation similar to dummynet
between arbitrary nodes.
2008-09-03 18:17:45 +00:00
Jung-uk Kim
37b5fe59b5 Make sure BPF program is not bigger than set maximum (net.bpf.maxinsns). 2008-08-29 15:49:40 +00:00
Julian Elischer
ac957cd271 A bunch of formatting fixes brough to light by, or created by the Vimage commit
a few days ago.
2008-08-20 01:05:56 +00:00
Bjoern A. Zeeb
603724d3ab Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).

This is the first in a series of commits over the course
of the next few weeks.

Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.

We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.

Obtained from:	//depot/projects/vimage-commit2/...
Reviewed by:	brooks, des, ed, mav, julian,
		jamie, kris, rwatson, zec, ...
		(various people I forgot, different versions)
		md5 (with a bit of help)
Sponsored by:	NLnet Foundation, The FreeBSD Foundation
X-MFC after:	never
V_Commit_Message_Reviewed_By:	more people than the patch
2008-08-17 23:27:27 +00:00
Maksim Yevmenkin
4fa708ef20 Implement ratelimiting for debug messages. For now, allow at most
one message per second. In the future might add a sysctl knob for
each socket family to fine tune this.

MFC after:	1 week
2008-08-01 00:36:43 +00:00
Maksim Yevmenkin
93f9b5b4aa Increase maximum input queue size limit for raw Bluetooth HCI sockets.
MFC after:	3 days
2008-08-01 00:16:40 +00:00
Maksim Yevmenkin
9b5b51671c Fix locking bug, i.e. lock "wildcard" matched pcb before return. 2008-08-01 00:13:32 +00:00
Maksim Yevmenkin
48698a834c Introduce support for Bluetooth SCO sockets. This is based on older
code that was revisted.

MFC after:	3 months
2008-07-30 22:41:23 +00:00
Maksim Yevmenkin
a4d05859e7 Simplify ubt_isoc_in_complete2(). Also should fix off by 1 bug.
MFC after:	3 months
2008-07-29 00:17:53 +00:00
Alexander Motin
280d6bd758 Don't use memcpy() to copy several bytes.
Store IDs is host order. It is not so important to bloat code for it.
Combine m_adj() and M_PREPEND() into single M_PREPEND().
2008-07-28 22:22:38 +00:00
Tom Rhodes
54d1e01094 Fill in the string portion of the bluetooth stack version sysctl.
Approved by:	emax
2008-07-14 13:45:05 +00:00
Maksim Yevmenkin
f0f78f3513 Dust off old code for support of USB isochronous transfers.
USB isochronous transfer support is required for Bluetooth SCO.
While i'm here change u_int to uint and update TODO.
This should produce no visible changes unless the device is
broken (or really old).

MFC after:	3 months
2008-07-11 17:13:43 +00:00
Maksim Yevmenkin
fb8bcdc044 Get in some basic infrastructure for Bluetooth SCO support.
MFC after:	3 months
2008-07-10 00:15:29 +00:00
Oleksandr Tymoshenko
1566e059bf Back out r180370. It was not discussed with subsystem maintainers. 2008-07-08 20:19:43 +00:00
Oleksandr Tymoshenko
7156132cd9 Queue decapsulated packed instead of performing direct dispatch. Some
execution pathes might hit stack limit under certain circumstances
(e.g. ng_mppc).

PR:                     kern/125314
Reported by:            Illya Klymov <ilia dot klimov at gmail dot com>
2008-07-08 18:21:44 +00:00
Robert Watson
59dd72d040 Remove NETISR_MPSAFE, which allows specific netisr handlers to be directly
dispatched without Giant, and add NETISR_FORCEQUEUE, which allows specific
netisr handlers to always be dispatched via a queue (deferred).  Mark the
usb and if_ppp netisr handlers as NETISR_FORCEQUEUE, and explicitly
acquire Giant in those handlers.

Previously, any netisr handler not marked NETISR_MPSAFE would necessarily
run deferred and with Giant acquired.  This change removes Giant
scaffolding from the netisr infrastructure, but NETISR_FORCEQUEUE allows
non-MPSAFE handlers to continue to force deferred dispatch so as to avoid
lock order reversals between their acqusition of Giant and any calling
context.

It is likely we will be able to remove NETISR_FORCEQUEUE once
IFF_NEEDSGIANT is removed, as non-MPSAFE usb and if_ppp drivers will no
longer be supported.

Reviewed by:	bz
MFC after:	1 month
X-MFC note:	We can't remove NETISR_MPSAFE from stable/7 for KPI reasons,
		but the rest can go back.
2008-07-04 00:21:38 +00:00
George V. Neville-Neil
a13c239b91 Make it simpler to build netgraph modules outside of the kernel source
tree.  This change follows similar ones in the device tree.

MFC after:	2 weeks
2008-06-24 18:49:49 +00:00
Alexander Motin
a9a13b54e9 Pass really available buffer size to libalias instead of MCLBYTES constant.
MCLBYTES constant were used with believe that m_megapullup() always moves
date into a fresh cluster that may become not so.
2008-06-01 15:13:32 +00:00
Robert Watson
e4372ceba0 Remove netatm from HEAD as it is not MPSAFE and relies on the now removed
NET_NEEDS_GIANT.  netatm has been disconnected from the build for ten
months in HEAD/RELENG_7.  Specifics:

- netatm include files
- netatm command line management tools
- libatm
- ATM parts in rescue and sysinstall
- sample configuration files and documents
- kernel support as a module or in NOTES
- netgraph wrapper nodes for netatm
- ctags data for netatm.
- netatm-specific device drivers.

MFC after:	3 weeks
Reviewed by:	bz
Discussed with:	bms, bz, harti
2008-05-25 22:11:40 +00:00
Julian Elischer
8b07e49a00 Add code to allow the system to handle multiple routing tables.
This particular implementation is designed to be fully backwards compatible
and to be MFC-able to 7.x (and 6.x)

Currently the only protocol that can make use of the multiple tables is IPv4
Similar functionality exists in OpenBSD and Linux.

From my notes:

-----

  One thing where FreeBSD has been falling behind, and which by chance I
  have some time to work on is "policy based routing", which allows
  different
  packet streams to be routed by more than just the destination address.

  Constraints:
  ------------

  I want to make some form of this available in the 6.x tree
  (and by extension 7.x) , but FreeBSD in general needs it so I might as
  well do it in -current and back port the portions I need.

  One of the ways that this can be done is to have the ability to
  instantiate multiple kernel routing tables (which I will now
  refer to as "Forwarding Information Bases" or "FIBs" for political
  correctness reasons). Which FIB a particular packet uses to make
  the next hop decision can be decided by a number of mechanisms.
  The policies these mechanisms implement are the "Policies" referred
  to in "Policy based routing".

  One of the constraints I have if I try to back port this work to
  6.x is that it must be implemented as a EXTENSION to the existing
  ABIs in 6.x so that third party applications do not need to be
  recompiled in timespan of the branch.

  This first version will not have some of the bells and whistles that
  will come with later versions. It will, for example, be limited to 16
  tables in the first commit.
  Implementation method, Compatible version. (part 1)
  -------------------------------
  For this reason I have implemented a "sufficient subset" of a
  multiple routing table solution in Perforce, and back-ported it
  to 6.x. (also in Perforce though not  always caught up with what I
  have done in -current/P4). The subset allows a number of FIBs
  to be defined at compile time (8 is sufficient for my purposes in 6.x)
  and implements the changes needed to allow IPV4 to use them. I have not
  done the changes for ipv6 simply because I do not need it, and I do not
  have enough knowledge of ipv6 (e.g. neighbor discovery) needed to do it.

  Other protocol families are left untouched and should there be
  users with proprietary protocol families, they should continue to work
  and be oblivious to the existence of the extra FIBs.

  To understand how this is done, one must know that the current FIB
  code starts everything off with a single dimensional array of
  pointers to FIB head structures (One per protocol family), each of
  which in turn points to the trie of routes available to that family.

  The basic change in the ABI compatible version of the change is to
  extent that array to be a 2 dimensional array, so that
  instead of protocol family X looking at rt_tables[X] for the
  table it needs, it looks at rt_tables[Y][X] when for all
  protocol families except ipv4 Y is always 0.
  Code that is unaware of the change always just sees the first row
  of the table, which of course looks just like the one dimensional
  array that existed before.

  The entry points rtrequest(), rtalloc(), rtalloc1(), rtalloc_ign()
  are all maintained, but refer only to the first row of the array,
  so that existing callers in proprietary protocols can continue to
  do the "right thing".
  Some new entry points are added, for the exclusive use of ipv4 code
  called in_rtrequest(), in_rtalloc(), in_rtalloc1() and in_rtalloc_ign(),
  which have an extra argument which refers the code to the correct row.

  In addition, there are some new entry points (currently called
  rtalloc_fib() and friends) that check the Address family being
  looked up and call either rtalloc() (and friends) if the protocol
  is not IPv4 forcing the action to row 0 or to the appropriate row
  if it IS IPv4 (and that info is available). These are for calling
  from code that is not specific to any particular protocol. The way
  these are implemented would change in the non ABI preserving code
  to be added later.

  One feature of the first version of the code is that for ipv4,
  the interface routes show up automatically on all the FIBs, so
  that no matter what FIB you select you always have the basic
  direct attached hosts available to you. (rtinit() does this
  automatically).

  You CAN delete an interface route from one FIB should you want
  to but by default it's there. ARP information is also available
  in each FIB. It's assumed that the same machine would have the
  same MAC address, regardless of which FIB you are using to get
  to it.

  This brings us as to how the correct FIB is selected for an outgoing
  IPV4 packet.

  Firstly, all packets have a FIB associated with them. if nothing
  has been done to change it, it will be FIB 0. The FIB is changed
  in the following ways.

  Packets fall into one of a number of classes.

  1/ locally generated packets, coming from a socket/PCB.
     Such packets select a FIB from a number associated with the
     socket/PCB. This in turn is inherited from the process,
     but can be changed by a socket option. The process in turn
     inherits it on fork. I have written a utility call setfib
     that acts a bit like nice..

         setfib -3 ping target.example.com # will use fib 3 for ping.

     It is an obvious extension to make it a property of a jail
     but I have not done so. It can be achieved by combining the setfib and
     jail commands.

  2/ packets received on an interface for forwarding.
     By default these packets would use table 0,
     (or possibly a number settable in a sysctl(not yet)).
     but prior to routing the firewall can inspect them (see below).
     (possibly in the future you may be able to associate a FIB
     with packets received on an interface..  An ifconfig arg, but not yet.)

  3/ packets inspected by a packet classifier, which can arbitrarily
     associate a fib with it on a packet by packet basis.
     A fib assigned to a packet by a packet classifier
     (such as ipfw) would over-ride a fib associated by
     a more default source. (such as cases 1 or 2).

  4/ a tcp listen socket associated with a fib will generate
     accept sockets that are associated with that same fib.

  5/ Packets generated in response to some other packet (e.g. reset
     or icmp packets). These should use the FIB associated with the
     packet being reponded to.

  6/ Packets generated during encapsulation.
     gif, tun and other tunnel interfaces will encapsulate using the FIB
     that was in effect withthe proces that set up the tunnel.
     thus setfib 1 ifconfig gif0 [tunnel instructions]
     will set the fib for the tunnel to use to be fib 1.

  Routing messages would be associated with their
  process, and thus select one FIB or another.
  messages from the kernel would be associated with the fib they
  refer to and would only be received by a routing socket associated
  with that fib. (not yet implemented)

  In addition Netstat has been edited to be able to cope with the
  fact that the array is now 2 dimensional. (It looks in system
  memory using libkvm (!)). Old versions of netstat see only the first FIB.

  In addition two sysctls are added to give:
  a) the number of FIBs compiled in (active)
  b) the default FIB of the calling process.

  Early testing experience:
  -------------------------

  Basically our (IronPort's) appliance does this functionality already
  using ipfw fwd but that method has some drawbacks.

  For example,
  It can't fully simulate a routing table because it can't influence the
  socket's choice of local address when a connect() is done.

  Testing during the generating of these changes has been
  remarkably smooth so far. Multiple tables have co-existed
  with no notable side effects, and packets have been routes
  accordingly.

  ipfw has grown 2 new keywords:

  setfib N ip from anay to any
  count ip from any to any fib N

  In pf there seems to be a requirement to be able to give symbolic names to the
  fibs but I do not have that capacity. I am not sure if it is required.

  SCTP has interestingly enough built in support for this, called VRFs
  in Cisco parlance. it will be interesting to see how that handles it
  when it suddenly actually does something.

  Where to next:
  --------------------

  After committing the ABI compatible version and MFCing it, I'd
  like to proceed in a forward direction in -current. this will
  result in some roto-tilling in the routing code.

  Firstly: the current code's idea of having a separate tree per
  protocol family, all of the same format, and pointed to by the
  1 dimensional array is a bit silly. Especially when one considers that
  there is code that makes assumptions about every protocol having the
  same internal structures there. Some protocols don't WANT that
  sort of structure. (for example the whole idea of a netmask is foreign
  to appletalk). This needs to be made opaque to the external code.

  My suggested first change is to add routing method pointers to the
  'domain' structure, along with information pointing the data.
  instead of having an array of pointers to uniform structures,
  there would be an array pointing to the 'domain' structures
  for each protocol address domain (protocol family),
  and the methods this reached would be called. The methods would have
  an argument that gives FIB number, but the protocol would be free
  to ignore it.

  When the ABI can be changed it raises the possibilty of the
  addition of a fib entry into the "struct route". Currently,
  the structure contains the sockaddr of the desination, and the resulting
  fib entry. To make this work fully, one could add a fib number
  so that given an address and a fib, one can find the third element, the
  fib entry.

  Interaction with the ARP layer/ LL layer would need to be
  revisited as well. Qing Li has been working on this already.

  This work was sponsored by Ironport Systems/Cisco

Reviewed by:    several including rwatson, bz and mlair (parts each)
Obtained from:  Ironport systems/Cisco
2008-05-09 23:03:00 +00:00
Alexander Motin
a04e98468d ng_address_hook() microoptimization. Use local variables as they should be.
It helps compiller to avoid some extra memory accesses.
2008-04-19 05:30:49 +00:00
Alexander Motin
6aa6d011e4 Use separate UMA zone for data items allocation. It is a partial
rev. 1.149 rework.
It allows to save several percents of CPU time on SMP by using UMA's
internal per-CPU allocation limits instead of own global variable
each time updated with atomics.

Tested with:    Netperf cluster
2008-04-16 19:52:29 +00:00
Kris Kennaway
c637bc9203 Replace callout_init(..., 1) with callout_init(..., CALLOUT_MPSAFE) for
better grep-compliance and to standardize with the rest of the kernel.

Reviewed by:	       jhb
MFC after:	       1 week
2008-04-16 16:47:14 +00:00
Alexander Motin
9852972bb5 Several changes breaking netgraph module ABI collected together:
- reorder structures fields (XX_refs) a bit to group fields modified
   same time together. According to my tests it gives up to 10%
   SMP performance benefit on real workload due to reduced inter-CPU
   cache trashing.
 - change q_flags from long to int as long is not really needed there and
   it's usage with atomics is argued by some people.
 - move NGF_WORKQ flag into the separate field q_flags2 as it protected by
   queue mutex instead of node writer protection used by the rest of flags.
 - move nd_work queue entry to ng_queue structure to which it is more
   related and make it STAILQ instead of TAILQ as now it is a classic FIFO.
 - remove q_node pointer from ng_queue structure as it is not really needed.
 - reimplement item queue using STAILQ instead of own equal implementation.
   As soon as BT subsystem has own item queues using ng_item.el_next update
   it also.
 - change depth field in ng_item from uintptr_t to u_int. It was made
   uintptr_t to keep ABI compatibility.

Reviewed by:	julian, emax
Tested with:	Netperf cluster
2008-04-15 21:15:32 +00:00
Alexander Motin
8f9ac44aa7 Add memory barriers to the node locking operations.
Add some comments.
2008-04-09 19:03:19 +00:00
Alexander Motin
394cb30a36 Rewrite node's r/w/q-lock semantics using only atomics instead of mutex
and atomics combination. Mutex is now used only for queue protection.
Also avoid unneded extra swi scheduling calls.
2008-04-06 15:26:32 +00:00
Alexander Motin
c77b232bb6 - Account all node stats at the shape mode.
- Do not check destination hook presence, it will be done by netgraph.
- Use u_int instead of int in some places to simplify type conversions.
- Use NG_SEND_DATA_ONLY() macro instead of selfmade equivalent.
2008-03-30 07:53:51 +00:00
Alexander Motin
018fe3d10e Use new atomic_fetchadd() primitive instead of looping atomic_cmpset(). 2008-03-30 00:27:48 +00:00
Alexander Motin
f573da1a0e There is no need to erase hook->hk_node before freing hook. 2008-03-29 22:53:58 +00:00
Alexander Motin
244586d6f1 Remove ng_setisr() call from ng_dequeue(). It is useless as we any way
will never exit ngintr(), while there is some ready requests on the queue.
It was made years ago with hope of parallel queue processing by several
net threads. But even if we have several threads sometimes, we have no
rights to process queue in parallel as it will break original requests
serialization that is critically important for some setups.
2008-03-27 23:02:30 +00:00
Alexander Motin
c86d865ec8 Switch from timeval to bintime, to use 1/(2^20) of seconds instead of
microseconds. It allows to use bit shifts instead of some heavy 64bit
mul/div math operations.
2008-03-27 20:04:20 +00:00
Alexander Motin
714f558be1 Some minor code and math optimizations. 2008-03-26 21:19:03 +00:00
Alexander Motin
489290e9e9 Rewrite node to support multiple hooks, alike to ng_l2tp, to use one pair
of pptpgre and ksocket nodes for all calls between two peers. This patch
modifies node's API by adding new "session_%04x" hook names support, while
keeping backward compatibility.

Together with appropriate user-level support (by latest mpd5) it gives
huge performance benefits for case of multiple active calls between
two peers because of avoiding data duplication and extra socket processing.
On my benchmarks I have got more then 10 times speedup for the 200
simultaneous PPTP calls between two peers.
In conclusion, it allows now to build effective "clients <=> PAC <=> PNS"
setups.
2008-03-24 22:55:22 +00:00
Alexander Motin
e81de8afb0 Remove impossible (hk_peer == NULL) check from ng_address_hook().
Valid hook can't have NULL peer. Even invalid one can't, as it is resets to
deadhook, but not NULL.
2008-03-16 23:12:17 +00:00
Alexander Motin
4e7597635f Add session ID hashing to speedup incoming packets dispatch in case
of many connections working via the same tunnel. For example, in case
of full "client <-> LAC <-> LNS" setup.
2008-03-16 21:33:12 +00:00
Alexander Motin
10e873189c Improve apply callback error reporting:
Before this patch callback returned result of the last finished call chain.
Now it returns last nonzero result from all call chain results in this request.

As soon as this improvement gives reliable error reporting, it is now possible
to remove dirty workaround in ng_socket, made to return ENOBUFS error statuses
of request-response operations. That workaround was responsible for returning
ENOBUFS errors to completely unrelated requests working at the same time
on socket.
2008-03-11 21:58:48 +00:00
Alexander Motin
395adfbe34 Addition to the previous commit. Release inproc in case of memory error. 2008-03-09 11:17:00 +00:00
Alexander Motin
af63939c67 To avoid control data losses do not acknowledge recieving of control packet
if netgraph reported error while delivering to destination.
Reset 'next send' counter to the last requested by peer on ack timeout
to resend all subsequest packets after lost one again without additional hints.
2008-03-08 23:55:29 +00:00
Alexander Motin
6e7ed93017 Send only one incoming notification at a time to reduce queue
trashing and improve performance.
Remove waitflag argument from ng_ksocket_incoming2(), it means nothing
as function call was queued by netgraph.
Remove node validity check, as node validity guarantied by netgraph.
Update comments.
2008-03-07 21:12:56 +00:00
Alexander Motin
ed75521f5b Increase default queue items allocation limit from 512 to 4096 items
to avoid terrible unpredicted effects for netgraph operation of their
exhaustion while allocating control messages.
Add separate configurable 512 items limit for data items allocation
for DoS/overload protection.

Discussed with:	julian
2008-03-05 22:12:34 +00:00
Alexander Motin
cfea3f8522 Implement 128 items node name hash for faster name search.
Increase node ID hash size from 32 to 128 items.
2008-03-04 18:22:18 +00:00
Alexander Motin
b7c649d811 Fix incorrect field name. 2008-03-04 11:10:54 +00:00
Alexander Motin
dda30f129e Use more compact LIST instead of TAILQ for session hash.
Add all listening hooks into LIST to simplify searches.
Use ng_findhook() instead of own equal implementation.
2008-03-03 19:36:03 +00:00
Alexander Motin
bd500dab7f Make session ID generator to use session ID hash.
Make session ID generator thread-safe.
2008-03-02 23:26:35 +00:00
Alexander Motin
fffba935e4 Add support for the libalias redirect functionality.
Submitted by:   Vadim Goncharov <vadim_nuclight@mail.ru>
2008-03-01 17:14:02 +00:00
Alexander Motin
db3408aed0 Fix incorrect constant used in rev. 1.146 that broke node writer locking. 2008-02-25 21:24:53 +00:00
Alexander Motin
510b772284 Fix shutdown bug made by previous commit. 2008-02-24 10:13:32 +00:00
Gleb Smirnoff
150c26cb34 Use rtalloc1() instead of rtalloc_ign(). It returns a locked
rtentry. We quickly copy the fields of interest, and then
RTFREE_LOCKED(). This should be faster then lock & unlock the
rtentry twice.
2008-02-07 11:10:17 +00:00
Alexander Motin
b4d0be220a Do not use bcmp() to compare two bytes with constants. 2008-02-06 20:37:34 +00:00
Alexander Motin
f50597f5f1 Cleanup and tune ng_snd_item() function as it is one of the
most busy netgraph functions.
Tune stack protection constants to avoid division operation.
2008-02-06 18:50:40 +00:00
Alexander Motin
193f57e2c0 Prepare hooks direct pointers on setup to avoid heavy ng_findhook() calls
during operarion.
2008-02-04 19:26:53 +00:00
Alexander Motin
e632000eed Move all possible node logic out of the rcvdata() function
to the newhook()/disconnect().
Unify function names with other nodes.
2008-02-03 18:55:45 +00:00
Alexander Motin
102fe25ee0 Revert previous commit.
glebius@ noticed that it was not a bug, but undocumented feature.
2008-02-03 10:30:45 +00:00
Dmitry Morozovsky
f9773372c3 Fix one more grammo.
Noticed by:	ru
2008-02-02 08:41:53 +00:00
Dmitry Morozovsky
942fe01f61 Reword recent comment a bit. 2008-02-01 17:35:46 +00:00
Alexander Motin
d4529f987a Add comments about stack protection mechanism. 2008-02-01 11:01:15 +00:00
Alexander Motin
b1a3358ba3 Tune the message for better informativity.
Print the hook pointer as other functions do.
2008-02-01 07:25:06 +00:00
Benno Rice
db2dabf87c Band-aid recent commit by mav by replacing a variable in a CTR statement with
the variable that appears as if it should've been there.

Pointy hat to:		mav
Not tested either by:	benno
2008-02-01 07:17:26 +00:00
Alexander Motin
b2b5279b25 Implement Session-ID hashing to improve receive performance scalability
for big number of concurrent sessions.
2008-01-31 22:42:37 +00:00
Alexander Motin
e72a98f4bf Some code reformat. 2008-01-31 10:13:04 +00:00
Alexander Motin
81a253a4ed Implement stack protection based on GET_STACK_USAGE() macro.
This fixes system panics possible with complicated netgraph setups
and allows to avoid unneded extra queueing for stack unwrapping.
2008-01-31 08:51:48 +00:00
Alexander Motin
f38b370376 Avoid data copying when it is possible.
bpf_filter() is able to work directly on mbuf chain.
2008-01-28 22:37:17 +00:00
Alexander Motin
57f2b25dfa Run expire even without export hook connected.
PR:	kern/119839
2008-01-27 15:01:16 +00:00
Alexander Motin
cfcb2a4c82 Fix memory leak when export hook is not connected. 2008-01-27 09:22:10 +00:00
Alexander Motin
f704a24b20 Remove one very strange unneded if. 2008-01-27 08:52:41 +00:00
Alexander Motin
f8e5127d49 Slightly simplify code. 2008-01-27 02:04:12 +00:00
Alexander Motin
5716b3f192 Improve multilink receive performance by netgraph item reuse. 2008-01-26 22:42:47 +00:00
Alexander Motin
f9ec69904b Improve multilink xmit performance by netgraph item reuse. 2008-01-26 22:41:14 +00:00
Alexander Motin
93caf2e299 Improve multilink receive performance with fragment headers preallocation. 2008-01-26 22:39:05 +00:00
Alexander Motin
9c10d11388 Fix bundle xmit octets stats for packet-split operation mode. 2008-01-23 11:47:09 +00:00
Jeff Roberson
397c19d175 Remove explicit locking of struct file.
- Introduce a finit() which is used to initailize the fields of struct file
   in such a way that the ops vector is only valid after the data, type,
   and flags are valid.
 - Protect f_flag and f_count with atomic operations.
 - Remove the global list of all files and associated accounting.
 - Rewrite the unp garbage collection such that it no longer requires
   the global list of all files and instead uses a list of all unp sockets.
 - Mark sockets in the accept queue so we don't incorrectly gc them.

Tested by:	kris, pho
2007-12-30 01:42:15 +00:00
Alexander Motin
098ff746f8 Add support for optional "AC-Name\Service-Name" syntax at NGM_PPPOE_CONNECT
argument. It allows ppp, mpd or any other node consumer to request
connection to specified access concentrator.

Proposed by:	Alexander A. Burylov <burylov@mail.ru>
2007-12-29 19:44:41 +00:00
Alexander Motin
97b4f83bb3 Fix incorrectly placed bracket in pppoe_find_svc(). 2007-12-26 19:33:53 +00:00
Alexander Motin
b06ccdeab3 Remove some prehistoric never used defines. 2007-12-26 19:15:07 +00:00
Robert Watson
3de213cc00 Add a new 'why' argument to kdb_enter(), and a set of constants to use
for that argument.  This will allow DDB to detect the broad category of
reason why the debugger has been entered, which it can use for the
purposes of deciding which DDB script to run.

Assign approximate why values to all current consumers of the
kdb_enter() interface.
2007-12-25 17:52:02 +00:00
Alexander Motin
673f5a8b44 Add option to set packets per second limits instead of default
bits per second ones.
2007-12-19 22:50:14 +00:00
Alexander Motin
52b9b77f78 Increase control channel xmit queue to 128 packets.
Previous value 16 was too small for real LAC as temporal activity
spike cound easily overflow queue demanding tunnel disconnection due
to possible state inconsistency.
2007-12-12 19:04:30 +00:00
Julian Elischer
182ff780b4 Add ipv6 to ng_cisco node. ipv6 wasn't a reality when I wrote it..
Submitted by: Marko Zec
2007-11-30 23:27:39 +00:00
Gleb Smirnoff
b332b91f74 - Merge all the ng_send_fn2* functions into one - ng_send_fn2(),
removing some copy&pasted code.
- Reduce copy and paste in ng_apply_item().
- Resurrect ng_send_fn() as a valid symbol, not a define.

Reviewed by:	mav, julian
2007-11-14 11:25:58 +00:00
Maksim Yevmenkin
b64b9bb278 Fix locking issue in ng_btsocket_l2cap_ctloutput()
Submitted by:	Heiko Wundram (Beenic) < wundram at beenic dot net >
MFC after:	3 days
2007-10-31 16:17:20 +00:00
Maksim Yevmenkin
a6f3c1e3f3 Allow RFCOMM servers to bind to a ''wildcard'' RFCOMM channel
zero (0). Actual RFCOMM channel will be assigned after listen(2)
call is done on a RFCOMM socket bound to a ''wildcard'' RFCOMM
channel zero (0).

Address locking issues in ng_btsocket_rfcomm_bind()

Submitted by:	Heiko Wundram (Beenic) < wundram at beenic dot net >
MFC after:	1 week
2007-10-29 19:06:47 +00:00
Alexander Motin
eb4687d223 Minor debug message fix. 2007-10-28 18:05:59 +00:00
Ruslan Ermilov
857304e6f1 Fix build with NETGRAPH_DEBUG. 2007-10-19 20:09:58 +00:00
Alexander Motin
e088dd4c44 Implement new apply callback mechanism to handle item forwarding.
When item forwarded refence counter is incremented, when item
processed, counter decremented. When counter reaches zero,
apply handler is getting called.
Now it allows to report right connect() call status from user-level
at the right time.
2007-10-19 15:04:17 +00:00
Alexander Motin
98e7b7536b Split ng_pppoe_rcvdata() function into three hook-specific ones
to simplify code and reduce stack usage.
2007-10-14 09:58:22 +00:00
Alexander Motin
8cfaad5f6a Remove ng_pppoe_sendpacket() function to simplify code as it is called
as much times as it has cases inside of it.
2007-10-14 09:51:19 +00:00
Alexander Motin
702f98951d Protect struct seq with mutex.
Approved by:	glebius (mentor)
2007-10-12 04:56:26 +00:00
Alexander Motin
058ef12167 Remove one unneded assertion. It is also checked in
ng_l2tp_seq_check().

Approved by:	glebius (mentor)
2007-10-12 04:54:43 +00:00
Alexander Motin
bf741e4d08 Replace single rcvdata with 3 distinct to simplify code and
reduce stack usage.

Approved by:	mentor (glebius)
2007-10-12 04:53:23 +00:00
Alexander Motin
40097c5d9f Remove duplicate variables. 2007-10-12 04:51:30 +00:00
Alexander Motin
661e502900 Dead code removal.
Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:25:55 +00:00
Alexander Motin
99f4de905c This is optimization of ether and debug hooks determination. It
simplifies code and should speedup pppoe_findsession() function which is
called for every incoming packet.

Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:24:08 +00:00
Alexander Motin
1e7d84b055 This patch fixes thread unsafe usage of global pkt_hdr
variable. Second part is not so important, but IMO is also good.

Approved by:	re (kensmith), glebius (mentor)
2007-09-21 08:16:33 +00:00
Alexander Motin
6d67c50b39 Fix typo which brokes VJ decompression
when VJC negotiated in only one direction.

Approved by:	re (bmah), glebius (mentor)
2007-09-15 16:55:44 +00:00
Maksim Yevmenkin
d46210e60d Return EADDRNOTAVAIL instead of EDESTADDRREQ error when
listen(2) is called on improperly bound socket.

Suggested by:	Iain Hibbert
Approved by:	re (kensmith)
MFC after:	3 days
2007-08-23 16:55:22 +00:00
Alexander Motin
3fb87c2411 Add ng_send_fn() error handeling inside ng_con_nodes().
Without it some errors may left unnoticed and unhandeled
that will lead to hooks left in half-connected state.

Reviewed by:	julian@
Approved by:	re (kensmith), glebius (mentor)
2007-08-18 11:59:17 +00:00
Maksim Yevmenkin
51713b2a7b Make ng_h4(4) MPSAFE. Use similar to ng_tty(4) locking strategy.
Reconnect ng_h(4) back to the build.

Reviewed by:	kensmith
Approved by:	re (kensmith)
MFC after:	1 month
2007-08-13 17:19:28 +00:00
Robert Watson
0bf686c125 Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, which
previously conditionally acquired Giant based on debug.mpsafenet.  As that
has now been removed, they are no longer required.  Removing them
significantly simplifies error-handling in the socket layer, eliminated
quite a bit of unwinding of locking in error cases.

While here clean up the now unneeded opt_net.h, which previously was used
for the NET_WITH_GIANT kernel option.  Clean up some related gotos for
consistency.

Reviewed by:	bz, csjp
Tested by:	kris
Approved by:	re (kensmith)
2007-08-06 14:26:03 +00:00
Alexander Motin
d6fe462ac1 Add 64bit statistic counters to the ng_ppp node.
64bit counters are needed to simplify traffic accounting and
reduce system load at the big PPP concentrators.

Approved by:	re (rwatson), glebius (mentor)
2007-08-01 20:49:35 +00:00
Alexander Motin
e89c150775 This patch improves fine-grained locking for the ng_ppp node.
Till now node's transmit path was completely unprotected
and so wasn't thread safe in multilink mode. It's receive path was
declared as WRITER as the simpliest protection method but it
reduces performance when compression or encryption enabled.

Approved by:	re (rwatson), glebius (mentor)
2007-08-01 20:38:37 +00:00
Robert Watson
c6b2899785 Replace references to NET_CALLOUT_MPSAFE with CALLOUT_MPSAFE, and remove
definition of NET_CALLOUT_MPSAFE, which is no longer required now that
debug.mpsafenet has been removed.

The once over:	bz
Approved by:	re (kensmith)
2007-07-28 07:31:30 +00:00
Alexander Motin
091193febe Reduce stack usage by 256 bytes per call. It helps to avoid kernel
stack overflow in complicated traffic filtering setups.

There can be minor performance degradation for the MHLEN < len <= 256 case
due to additional buffer allocation, but it is a rare case.

Approved by:	re (rwatson), glebius (mentor)
MFC after:	1 week
2007-07-26 18:15:02 +00:00
Gleb Smirnoff
bb5ba44f82 Honor the IFF_MONITOR flag.
PR:		kern/99500
Submitted by:	Craig Leres <leres ee.lbl.gov>
Approved by:	re (kensmith)
2007-07-26 10:54:33 +00:00
Maksim Yevmenkin
08b755600f Mark ng_h4(4) as not MPSAFE and disconnect it from the build for now.
Approved by:	re (rwatson)
2007-07-10 16:38:43 +00:00
Warner Losh
02fb1cf4b9 These modules depend on usb, make that explicit
Approved by: re@
2007-06-23 04:34:38 +00:00
Matt Jacob
2a9a64c6a2 Fix various compilation warnings for gcc-4.2.
Approved by:	re (bruce)
2007-06-23 00:02:20 +00:00
Maksim Yevmenkin
280c458af8 Replace sosend() with direct call to .pru_send method on the
L2CAP socket. This is to avoid LOR with sx(9) lock in sblock()
called from sosend_generic().

Approved by:	re (kensmith)
MFC after:	1 week
2007-06-21 19:55:49 +00:00
Xin LI
8dac5046be Fix build problem caused by a set of typos.
Reported by:	tinderbox
Approved by:	re (mux)
2007-06-19 14:56:35 +00:00
Warner Losh
38b00ba0cd Finish removing usb_port.h compat macros. 2007-06-18 22:23:20 +00:00
Ruslan Ermilov
77764a595a Remove two more instances of the USBDEV() macro. 2007-06-13 12:36:01 +00:00
Alexander Motin
df01e68922 Add missing ng_uncallout() on node shutdown.
Approved by:	glebius (mentor)
2007-06-13 11:01:17 +00:00
Maksim Yevmenkin
8004e6ecc8 Catch up with USB cleanups and fix the world 2007-06-13 00:32:00 +00:00
Warner Losh
4f9929e80f Eliminate usb_thread_t. 2007-06-12 17:30:54 +00:00
Warner Losh
645016c0e4 Expand USB_ATTACH_{ERROR,SUCCESS}_RETURN inline and eliminate from
usb_port.h.  They aren't needed, and are a legacy of this code's past.
2007-06-12 15:37:19 +00:00
Warner Losh
c7b8e2f50c Silence a gcc warning in a more canonical way (evl = NULL rather than &evl).
I saw warnings here at one point on the arm build.
2007-06-11 15:29:02 +00:00
Warner Losh
387ecc9396 Expand USB_ATTACH_SETUP inline.
Kill devinfo stuff.
2007-06-09 06:53:27 +00:00
David Malone
041b706b2f Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported.  In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.
2007-06-04 18:25:08 +00:00
Alexander Motin
c35e19c430 No need to update link queue stats when round-robin algorithm enabled.
Approved by:	glebius (mentor)
2007-06-04 13:50:09 +00:00
Gleb Smirnoff
2775748750 Partially back out rev. 1.127, to restore broken functionality. This
should be redesigned, but better enter RELENG_7 with a working ngctl(8).

Agreed by:	julian
2007-06-01 09:20:57 +00:00
Robert Watson
e1e8f51b85 Universally adopt most conventional spelling of acquire. 2007-05-27 20:50:23 +00:00
Alexander Motin
e842c54054 Add support for setmode and settarget messages.
Approved by:	glebius (mentor)
2007-05-22 12:23:39 +00:00
Alexander Motin
179f56e196 Allow node to bypass traffic while no alias address defined.
Approved by:	glebius (mentor)
2007-05-22 12:14:43 +00:00
Alexander Motin
06c51e6e74 Fix build with NETGRAPH_MPPC_COMPRESSION but without NETGRAPH_MPPC_ENCRYPTION.
Approved by:	glebius (mentor)
2007-05-18 15:28:01 +00:00
David Malone
34fa9e8a37 Help ng_fec deal with multicast addresses.
While ng_fec called the ioctl to let interfaces in the bundle know
the list of multicast addresses had changed, it never actually
updated that list on the interfaces in the bundle. Consequently,
the multicast filters could be programmed incorrectly.

if_lagg does this correctly, by maintaining a list of addresses
that it has added to interfaces in the bundle. This commit basically
takes the if_lagg code and adds it to ng_fec.

A version of this patch for RELENG_6 has fixed some problems with
IPv6 ND over ng_fec. This is probably the problem in PR 107523.

PR:		107523
Tested by:	Rob Gallagher <robert.gallagher@heanet.ie>
Obtained from:	if_lagg
MFC after:	3 weeks
2007-05-18 15:05:49 +00:00
Alexander Motin
b50ace7384 Fix small copy/paste mistake. 2007-05-17 13:33:38 +00:00
Alexander Motin
ae1be01f9e Style cleanup.
Approved by:	glebius (mentor)
2007-05-16 12:11:09 +00:00
Alexander Motin
c97bf8c3bd A node that implements various traffic shaping and rate limiting algorithms.
Approved by:	glebius (mentor)
2007-05-15 16:09:23 +00:00
Alexander Motin
ce52e8f411 Performance optimization of the "encryption without compression" case by
avoiding memory allocation and data copying.
Encrypting directly at the original mbuf chain.

Approved by:	glebius (mentor)
2007-05-11 14:36:02 +00:00
Robert Watson
54d642bbe5 Reduce network stack oddness: implement .pru_sockaddr and .pru_peeraddr
protocol entry points using functions named proto_getsockaddr and
proto_getpeeraddr rather than proto_setsockaddr and proto_setpeeraddr.
While it's true that sockaddrs are allocated and set, the net effect is
to retrieve (get) the socket address or peer address from a socket, not
set it, so align names to that intent.
2007-05-11 10:20:51 +00:00
Alexander Motin
6370fd6b05 Avoid extra rc4_init() when ng_mppc_updatekey() going to do it anyway.
Approved by:	glebius (mentor)
2007-05-04 16:20:47 +00:00
Alexander Motin
adecf751c3 Compact code a bit
Approved by:	glebius (mentor)
2007-05-04 16:12:54 +00:00
Alexander Motin
755bc28723 Make coherency counter 12bit as it should
Approved by:	glebius (mentor)
2007-05-04 16:05:58 +00:00
Alexander Motin
592009a347 Fix small mistake (sizeof(pad2) instead of sizeof(pad1))
Approved by:	glebius (mentor)
2007-05-04 15:44:22 +00:00
Alexander Motin
8239d414fa Remove unneded bzero().
SHA1Final() does not require clean buffer.

Approved by:	glebius (mentor)
2007-05-04 15:41:49 +00:00
Alexander Motin
206fa244b7 Avoid false assertion on transmit and delayed ack timeout with enabled invariants.
Replace callout_pending() by callout_active() to remove race window.

Reviewed by:	archie
Approved by:	glebius (mentor)
2007-04-24 10:50:25 +00:00
Alexander Motin
34d16c641d Global xmit stats calculation fix.
Approved by:	glebius (mentor)
2007-04-23 15:25:14 +00:00
Alexander Motin
e07c5170e1 Added m_tag_copy_chain() call to copy original outgoing packet tags to all of
it's fragments.

Reviewed by:	archie
Approved by:	glebius (mentor)
2007-04-20 08:44:40 +00:00
Alexander Motin
ccffcb5147 Optimized packet distribution plan for the equal links case. Do not
split packet on fragments smaller then MP_MIN_FRAG_LEN to reduce total
overhead.

Reviewed by:	archie
Approved by:	glebius (mentor)
2007-04-20 08:42:08 +00:00
Alexander Motin
8e8f114e62 - Changed sequence numbers processing to avoid incorrect timeout waiting
when one of links is inactive and have stale sequence number. To avoid
this sequence numbers of all links are getting updated on every
successful packet reassembling.
- ng_ppp_bump_mseq function created to simplify code.
- ng_ppp_frag_drop function separated from ng_ppp_frag_process to
simplify code.

Reviewed by:	archie
Approved by:	glebius (mentor)
2007-04-20 08:38:18 +00:00
Alexander Motin
fd58342c26 - Fixed mistakes in latency and xmitBytes calculation math
which lead to ineffective multilink packet distribution plans.
- Changed bytesInQueue calculation math to have more precise information
about links utilization.
- Taken rough account of the link overhead. Better way to do it could be to
get exact overhead from user-level, but I have not done it to keep
binary compatibility.

Reviewed by:	archie
Approved by:	glebius (mentor)
2007-04-20 08:22:57 +00:00
Wojciech A. Koszek
4abab3d593 We don't need spinning locks here. Change them to the adaptive mutexes. This
change should bring no performance decrease, as it did not in my tests.

Reviewed by:	julian, glebius
Approved by:	cognet (mentor)
2007-03-31 15:43:06 +00:00
Wojciech A. Koszek
2c8dda8d55 Instead of direct manipulation on queue and worklist mutexes, bring macros
for doing this job. This change will make it easy to migrate from using
spinning locks to adaptive ones.

Reviewed by:	glebius, julian
Approved by:	cognet (mentor)
2007-03-30 14:34:34 +00:00
Maksim Yevmenkin
4301b2519d Try to silence Coverity by adding (void) in front of function call.
Also add a comment, explaining why return value is not being checked.

Requested by:	netchild
MFC after:	1 week
2007-03-28 21:25:56 +00:00
Gleb Smirnoff
dc7359b8dd Bump maximum number of interface hooks to the maximum possible value.
This will increase the memory consumption for more than 1 Mb, but this
is required for operation on multiinterface access concentrators running
mpd.

Requested by:	Alexander Motin
2007-03-28 13:59:13 +00:00
Maxim Konovalov
2701afd004 o Update a comment: sonewconn() lives in uipc_socket.c now. 2007-03-26 18:17:57 +00:00
Bruce M Simpson
ec002fee99 Implement reference counting for ifmultiaddr, in_multi, and in6_multi
structures. Detect when ifnet instances are detached from the network
stack and perform appropriate cleanup to prevent memory leaks.

This has been implemented in such a way as to be backwards ABI compatible.
Kernel consumers are changed to use if_delmulti_ifma(); in_delmulti()
is unable to detect interface removal by design, as it performs searches
on structures which are removed with the interface.

With this architectural change, the panics FreeBSD users have experienced
with carp and pfsync should be resolved.

Obtained from:	p4 branch bms_netdev
Reviewed by:	andre
Sponsored by:	Garance A Drosehn
Idea from:	NetBSD
MFC after:	1 month
2007-03-20 00:36:10 +00:00
Robert Watson
64efc707cf Prefer more traditional spellings of some words in comments. 2007-03-18 16:49:50 +00:00
Julian Elischer
a54a69d7f9 oops committed the wrong patch.
try this one..
2007-03-10 01:02:40 +00:00
Julian Elischer
262dfd7fae ng_apply_item should be void. It is called from the interrupt source or
from whoever has dequeued the item from the queue. Generally they have
no interest in the result, and even if it is called by the queuer, it
should still pretend that it was queued. The queuer should be assuming
that the call was queued and giving them the false confidence that they
are getting status leads to hard to find bugs.

Make it a void and remove all the code that tried to return status through it.
2007-03-09 21:04:50 +00:00
Ruslan Ermilov
2eddfeaaf0 ng_send_fn() can return with an error, the function of interest
will never be called and OACTIVE will never be reset.  Fix this.

Submitted by:	Vsevolod Lobko
MFC after:	3 days
2007-03-08 21:10:53 +00:00
Ed Maste
ab2e868cc1 Ensure message passed to "settimestamp" and "setcounter" is the right
length.  Use NULL instead of 0.

Submitted by: glebius, ru
2007-03-02 14:36:19 +00:00
Ed Maste
577421ebc5 Add "setcounter" and "getcounter" messages, providing the the ability
to embed up to four counters in outgoing packets.  The message specifies
the offset at which the counter should be inserted as well as the
parameters of the counter.

Example usage:

  ngctl msg src0: setcounter \
    '{ index=0 offset=0x40 flags=1 width=4 increment=1 max_val=12345 }'

Sponsored by:   Sandvine Incorporated
2007-03-02 01:44:04 +00:00
Ed Maste
5f87dd698c Add "settimestamp" and "gettimestamp" messages, providing the the ability
to embed a timestamp (struct timeval) in outgoing packets.  The message
specifies the offset at which the timestamp should be inserted.

NG_SOURCE(4) gives an example usage that queues an ICMP packet.  Using that
example, the following command will insert a timestamp in the ICMP's data
payload:

  ngctl msg src0: settimestamp '{ offset=0x2a flags=1 }'

Sponsored by:	Sandvine Incorporated
2007-03-01 23:16:17 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
Bruce M Simpson
4ae54e2fad In the output path, mask off M_BCAST|M_MCAST so as to prevent incorrect
addressing if a packet is later re-encapsulated and sent to a
non-broadcast, non-multicast destination after being received on the
ng_ksocket input hook.

PR:		106999
Submitted by:	Kevin Lahey
MFC after:	4 weeks
2007-02-09 12:35:29 +00:00
Gleb Smirnoff
f8e159d658 Quoting Alexander:
Formulas described in RFC require high precision of floating point.
  Formulas of integer math implemented in ng_pptpgre give mistake in range
  of +0-7ms on RTT and +0-3ms on deviation. This leads to significant
  underestimation of real packet RTT.

  I have made a very simple patch to reduce mistake to +4-3ms on RTT and
  +2-1ms on deviation. Mistake in RTT is not good, but gets covered by
  deviation. To cover worst possible negative mistake in deviation I have
  added 2ms to it. Also this 2 ms cover the case when measured deviation
  is so small (about zero) that it can interfere with process scheduling
  delays or weather on Mars.

  My tests show decreasing of packet losses on 20ms RTT link from 2.5% to
  0.3% while speed increased un 1/3.

Reviewed by:	archie
2007-02-02 09:45:23 +00:00
Gleb Smirnoff
39c14742d9 - Create ng_ppp_bypass() function, that prepares a packet
with bypass header, to send it out to userland.
- Use ng_ppp_bypass() in ng_ppp_proto_recv().
- Use ng_ppp_bypass() in ng_ppp_comp_recv() and in
  ng_ppp_crypt_recv() if compression or encryption is
  disabled, respectively.
- Any LCP packet goes directly to ng_ppp_bypass(), instead
  of passing through PPP stack.
- Any non-LCP packet on disabled link is discarded. This
  is behavior defined in RFC.

Submitted by:	Alexander Motin <mav alkar.net>
2007-01-25 21:16:50 +00:00
Matt Jacob
33eb7cb0a9 A less draconian fix to the build. 2007-01-18 19:41:39 +00:00
David E. O'Brien
da1fa91ac0 Temporarily comment out the KASSERT that broke the kernel build. 2007-01-18 18:53:13 +00:00
Gleb Smirnoff
164b576e96 Revise the ng_ppp(4) node, so that code flow is more clear. All non-link
hooks get their per hook rcvdata methods, and all functions are organized
corresponding to protocol stack model.

Submitted by:	Alexander Motin <mav alkar.net>
Reviewed by:	archie, julian
2007-01-18 13:55:21 +00:00
Gleb Smirnoff
0d1513aa4b Whitespace cleanup.
Checked with:	cvs diff -b
2007-01-15 05:55:56 +00:00
Gleb Smirnoff
bc12a09303 Update ip and tcp pointers after m_pullup().
Submitted by:	Alexander Motin <mav alkar.net>
2007-01-15 05:01:31 +00:00
Gleb Smirnoff
833c4a01f5 Fix accounting of incoming octets.
Submitted by:	Alexander Motin <mav alkar.net>
2007-01-10 15:04:10 +00:00
John Baldwin
0dea849ae9 Various bpf(4) related fixes to catch places up to the new bpf(4)
semantics.
- Stop testing bpf pointers for NULL.  In some cases use
  bpf_peers_present() and then call the function directly inside the
  conditional block instead of the macro.
- For places where the entire conditional block is the macro, remove the
  test and make the macro unconditional.
- Use BPF_MTAP() in if_pfsync on FreeBSD instead of an expanded version of
  the old semantics.

Reviewed by:	csjp (older version)
2006-12-29 13:59:50 +00:00
Gleb Smirnoff
700218c77b A node that implements Predictor-1 compression for PPP.
Submitted by:	Alexander Motin <mav alkar.net>
2006-12-29 09:54:32 +00:00
Gleb Smirnoff
81ccbd956d A node that implements the Deflate sub-protocols of the Compression Control
Protocol (CCP).

Submitted by:	Alexander Motin <mav alkar.net>
2006-12-28 15:44:05 +00:00
Gleb Smirnoff
ccb07cc3db Before this commit, if the compression is enabled the, ng_ppp(4)
node would send every outgoing frame to the "compress" hook.
Packets received on the "compress" hook were expected to be
compressed and PROT_COMPD tag was put on them unconditionally.

After this commit an alternative compression mode can be set.
In this mode the node doesn't put the PROT_COMPD, the compressor
should put it itself. This is important for such kind of
compressors, that can submit uncompressed frames.

Before this commit, if the decompression is enabled, the ng_ppp(4)
node would send and incoming frame to the "decompress" hook
only if it has the PROT_COMPD proto tag on it.

After this commit an alternative decompression mode can be set.
In this mode the node sends all the incoming packets to the
decompression hook. This is important for such kind of compressors
that need uncompressed packets too, to keep their library in sync.

These new features will be used in new version of mpd4, and in new
compressor nodes.

Submitted by:	Alexander Motin <mav alkar.net>
2006-12-28 13:21:54 +00:00
Gleb Smirnoff
4b4ee018fa Return value PKT_ALIAS_FOUND_HEADER_FRAGMENT isn't an error case. The
packet shouldn't be dropped.

Submitted by:	Alexander Motin <mav alkar.net>
2006-12-21 10:26:01 +00:00
Gleb Smirnoff
e7bf470011 Correctly calculate length of IP header.
Submitted by:	Eugene Hartmann <eugene tpsb.com.ru>
2006-12-12 12:35:06 +00:00
Paolo Pisati
e876228edc Remove m_megapullup from ng_nat and put it under libalias.
Approved by: gleb
2006-12-01 16:27:11 +00:00
Robert Watson
acd3428b7d Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges.  These may
require some future tweaking.

Sponsored by:           nCircle Network Security, Inc.
Obtained from:          TrustedBSD Project
Discussed on:           arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
                        Alex Lyashkov <umka at sevcity dot net>,
                        Skip Ford <skip dot ford at verizon dot net>,
                        Antoine Brodin <antoine dot brodin at laposte dot net>
2006-11-06 13:42:10 +00:00
Andre Oppermann
5e20f43d31 Rename m_getm() to m_getm2() and rewrite it to allocate up to page sized
mbuf clusters.  Add a flags parameter to accept M_PKTHDR and M_EOR mbuf
chain flags.  Provide compatibility macro for m_getm() calling m_getm2()
with M_PKTHDR set.

Rewrite m_uiotombuf() to use m_getm2() for mbuf allocation and do the
uiomove() in a tight loop over the mbuf chain.  Add a flags parameter to
accept mbuf flags to be passed to m_getm2().  Adjust all callers for the
extra parameter.

Sponsored by:	TCP/IP Optimization Fundraise 2005
MFC after:	3 month
2006-11-02 17:37:22 +00:00
Gleb Smirnoff
e4c185db7a Check pointer before dereferencing.
Reported by:	Coverity
CID:		1556
2006-10-18 07:47:07 +00:00
Gleb Smirnoff
237af4af3f Some clenaup of ngs_rcvmsg():
- Inline ship_msg() into ngs_rcvmsg().
  - Plug memory leak in case if no control socket present.
  - Remove malloc() and allocate the sockaddr on stack.
  - style(9).
2006-10-17 16:52:09 +00:00
Gleb Smirnoff
dcaf468dcb Some cleanup and small changes:
- Use malloc() and free() instead of MALLOC() and FREE() macros.
  - Do not check malloc results if M_WAITOK was used.
  - Remove linked list of all netgraph sockets. It isn't needed.
  - Use ng_findhook() instead of searching the list ourselves.
  - Use NG_WAITOK in syscalls.
  - Remove unneeded includes.
  - style(9)
2006-10-17 12:21:48 +00:00
Gleb Smirnoff
81ba27c8d9 Make the sg_len and sg_family members of the sockaddr_ng the same type
as the corresponding values in sockaddr are.
2006-10-17 11:03:55 +00:00
Gleb Smirnoff
bb964e745b Make ng_ID_t fixed size, so that its maximum value is platform independent.
This will be important in future.
2006-10-17 11:01:20 +00:00
Gleb Smirnoff
c6964951c6 - ng_address_ID() has already freed the message, don't do double free.
- Get error from ng_address_ID().

Reported by:	Coverity via pjd
2006-10-17 10:59:39 +00:00
Gleb Smirnoff
b0dc008358 Fix result of some mechanical change that I did some time ago, when
writing this node.
2006-10-13 09:11:12 +00:00
Gleb Smirnoff
7801dc7cb3 Recognize 802.1q frames in Ethernet input and process them.
PR:		kern/101162
Submitted by:	CoolDavid (Tseng Guo-Fu) <cooldavid cdpa.nsysu.edu.tw>
2006-10-11 15:27:13 +00:00
Gleb Smirnoff
cf3254aac8 Do not leak hooks in ng_bypass().
Submitted by:	Alexander Motin <mav alkar.net>
2006-10-11 14:33:08 +00:00
Gleb Smirnoff
11e685579f Make it buildable. 2006-10-11 13:28:37 +00:00
Gleb Smirnoff
3b9c299730 Unbreak a short one.
Submitted by:	maxim
2006-10-11 12:39:21 +00:00
Gleb Smirnoff
006725ba9e Break long line. 2006-10-11 12:32:53 +00:00
Gleb Smirnoff
96a0326e14 Use hash functions with better distribution. Tested on live traffic.
Submitted by:	Alexander Motin <mav alkar.net>
2006-10-11 12:31:14 +00:00
Gleb Smirnoff
b7e405bd4a Use bitcount32() from sys/systm.h instead of my own. 2006-10-11 10:47:44 +00:00
Alexander Leidinger
63272d3036 Don't use data after free.
Found by:	Coverity Prevent
CID:		536
Submitted by:	harti (via vs)
2006-09-30 12:37:43 +00:00
Andre Oppermann
78ba57b9e1 Move ethernet VLAN tags from mtags to its own mbuf packet header field
m_pkthdr.ether_vlan.  The presence of the M_VLANTAG flag on the mbuf
signifies the presence and validity of its content.

Drivers that support hardware VLAN tag stripping fill in the received
VLAN tag (containing both vlan and priority information) into the
ether_vtag mbuf packet header field:

	m->m_pkthdr.ether_vtag = vlan_id;	/* ntohs()? */
	m->m_flags |= M_VLANTAG;

to mark the packet m with the specified VLAN tag.

On output the driver should check the mbuf for the M_VLANTAG flag to
see if a VLAN tag is present and valid:

	if (m->m_flags & M_VLANTAG) {
		... = m->m_pkthdr.ether_vtag;	/* htons()? */
		... pass tag to hardware ...
	}

VLAN tags are stored in host byte order.  Byte swapping may be necessary.

(Note: This driver conversion was mechanic and did not add or remove any
byte swapping in the drivers.)

Remove zone_mtag_vlan UMA zone and MTAG_VLAN definition.  No more tag
memory allocation have to be done.

Reviewed by:	thompsa, yar
Sponsored by:	TCP/IP Optimization Fundraise 2005
2006-09-17 13:33:30 +00:00
Ruslan Ermilov
85fcf1ba07 Fix input byte counting. Now the sum of the ipackets/ibytes counters
of individual interfaces should match the ipackets/ibytes counter of
the aggregate (FEC) interface.

PR:		kern/82189
Submitted by:	Stikheev Andrew <sand AT zunet DOT ru>
MFC after:	3 days
2006-09-15 20:17:45 +00:00
Ruslan Ermilov
7f01dc25c4 Make it possible to set a larger MTU by attempting to set MTUs on all
trunk ports first.  If that succeeds, and we're inside our own bounds,
so be it.

Still not ideal -- adding a port after changing an MTU doesn't change
port's MTU, but a step in the right direction.

PR:		kern/95417
Submitted by:	Vladimir Ivanov <wawa AT yandex-team DOT ru>
MFC after:	3 days

I've slightly edited a patch to make the conditional logic positive
and remove (what I think was) a redundant ng_fec_init() call.
2006-09-15 16:06:27 +00:00
Ruslan Ermilov
3d82b87057 SIOCSIFFLAGS doesn't require an argument in kernel land; instead, flags
are supposed to be set directly in ifnet already.  This change fixes a
panic when ng_eiface node is attached to ng_fec node and the latter is
shut down (ng_fec sets flags and then calls SIOCSIFFLAGS with a NULL
argument).

MFC after:	3 days
2006-09-15 15:53:09 +00:00
Maksim Yevmenkin
0ff5b678c3 s/USBDEVNAME/device_get_nameunit/g
s/USBBASEDEVICE/device_t/g
2006-09-07 23:38:09 +00:00
Matt Jacob
d8c1647f2f more usb fallout changes 2006-09-07 06:18:34 +00:00
Maksim Yevmenkin
7c3808562a - Catch up with ongoing rwatson's socket work;
- Fix a couple of LORs and panics;

- Temporarily remove the code that tries to cleanup sockets that stuck
  on accepting queues (both complete and incomplete). I'm taking an ostrich
  approach here until I find a better way to deal with sockets that were
  disconnected before accepting (i.e. while socket was on complete or
  incomplete accept queue).
2006-08-25 17:53:13 +00:00
Ruslan Ermilov
a819085b87 Fix another fallout from the IF_LLADDR() type change.
Spotted by:	mwlucas
2006-08-24 19:50:00 +00:00
Maksim Yevmenkin
231e95561a Define mtu as u_int16_t not as int. This should fix problem with rfcomm
on sparc64.

Reported by:	Andrew Belashov <bel at orel dot ru>
Tested by:	Andrew Belashov <bel at orel dot ru>
MFC after:	3 days
2006-08-24 16:51:02 +00:00
Gleb Smirnoff
f366efa96f Some perfectionizm against last revision.
Submitted by:	ru
2006-08-10 11:07:11 +00:00
Gleb Smirnoff
b1ba28df1d Fix ng_pppoe(4) after turning off "autosrc feature" on ng_ether(4).
- Store the Ethernet header in node softc.
- Initialize header with dst addr and ethertype in node
  constructor method.
- In node connect method send NGM_ETHER_GET_ENADDR message
  downwards.
- If received reply from ng_ether(4) store the src addr
  in softc.
- Add NGM_PPPOE_SETENDADDR message that allows user to
  override the address with whatever he/she wants.
2006-08-09 09:56:58 +00:00
Gleb Smirnoff
2e87c3cc4d - Use log(9) instead of printf(9).
- Print node ID, where possible.
- Prepend log messages with function name, or at least with "ng_pppoe".

Reviewed by:	julian
Tested by:	Joao Barros <joao.barros gmail.com>
2006-08-07 08:05:10 +00:00
Gleb Smirnoff
447a8026ec Turn off by default "feature" that overwrites MAC address
on output frames.

Many people were confused with not working CARP, ng_bridge(4)
and other subsystems, because ng_ether(4) overwritten source
MAC address.
2006-08-04 13:36:27 +00:00
Andrew Thompson
9674cf0e27 Remove the dependency of bridgestp.h on if_bridgevar.h by moving a couple of
private structures to if_bridge.c.
2006-07-27 21:01:48 +00:00
Tai-hwa Liang
87909ba75c Fixing compilation bustage: net/if_bridgevar.h depends on net/bridgestp.h. 2006-07-27 06:15:37 +00:00
Robert Watson
b0668f7151 soreceive_generic(), and sopoll_generic(). Add new functions sosend(),
soreceive(), and sopoll(), which are wrappers for pru_sosend,
pru_soreceive, and pru_sopoll, and are now used univerally by socket
consumers rather than either directly invoking the old so*() functions
or directly invoking the protocol switch method (about an even split
prior to this commit).

This completes an architectural change that was begun in 1996 to permit
protocols to provide substitute implementations, as now used by UDP.
Consumers now uniformly invoke sosend(), soreceive(), and sopoll() to
perform these operations on sockets -- in particular, distributed file
systems and socket system calls.

Architectural head nod:	sam, gnn, wollman
2006-07-24 15:20:08 +00:00
Robert Watson
a152f8a361 Change semantics of socket close and detach. Add a new protocol switch
function, pru_close, to notify protocols that the file descriptor or
other consumer of a socket is closing the socket.  pru_abort is now a
notification of close also, and no longer detaches.  pru_detach is no
longer used to notify of close, and will be called during socket
tear-down by sofree() when all references to a socket evaporate after
an earlier call to abort or close the socket.  This means detach is now
an unconditional teardown of a socket, whereas previously sockets could
persist after detach of the protocol retained a reference.

This faciliates sharing mutexes between layers of the network stack as
the mutex is required during the checking and removal of references at
the head of sofree().  With this change, pru_detach can now assume that
the mutex will no longer be required by the socket layer after
completion, whereas before this was not necessarily true.

Reviewed by:	gnn
2006-07-21 17:11:15 +00:00
Maksim Yevmenkin
df280cb596 Replace inb() and outb() with bus_space_read_1() and bus_space_write_1()
Submitted by:	marius
MFC after:	1 week
2006-07-05 17:18:47 +00:00
Gleb Smirnoff
d473c9d543 A netgraph node that can do different manipulations with
mbuf_tags(9) on packets.

Submitted by:		Vadim Goncharov <vadimnuclight tpu.ru>
mdoc(7) reviewed by:	ru
2006-06-27 12:45:28 +00:00
John Baldwin
edd32c2da2 Use kern_kldload() and kern_kldunload() to load and unload modules when
we intend for the user to be able to unload them later via kldunload(2)
instead of calling linker_load_module() and then directly adjusting the
ref count on the linker file structure.  This makes the resulting
consumer code simpler and cleaner and better hides the linker internals
making it possible to sanely lock the linker.
2006-06-13 21:36:23 +00:00
Gleb Smirnoff
b96baf0a65 When counting nodes second time, use the same criteria as for
the first time.

PR:		kern/98529
Submitted by:	Michael Heyman
2006-06-07 12:42:15 +00:00
Gleb Smirnoff
27e216594b Use NET_CALLOUT_MPSAFE for netgraph callout initializer. 2006-06-06 08:05:27 +00:00
Sam Leffler
ff046a6c6b add missed calls to bpf_peers_present 2006-06-02 23:14:40 +00:00
John Baldwin
b1e30c4c4e Conditionally acquire Giant in netgraph callouts to honor mpsafenet=0.
Reported by:	sekes <gexlie at gmail dot com>
MFC after:	1 week
2006-06-02 20:35:39 +00:00
Diomidis Spinellis
809f920d59 Replace the array initialization using the gcc-specific format
[constant] value
with the C99 format
[constant] = value
2006-06-02 09:08:51 +00:00
Maksim Yevmenkin
c4e3f62cc1 Add new SIOC_HCI_RAW_NODE_LIST_NAMES ioctl. User-space applications can
use this ioctl to obtain the list of HCI nodes. User-space application
is expected to preallocate 'ng_btsocket_hci_raw_node_list_names' structure
and set limit in 'num_nodes' field. The 'nodes' field should be allocated
as well and it should have space for at least 'num_nodes' elements.

The SIOC_HCI_RAW_NODE_LIST_NAMES should be issued on bound raw HCI socket.
It does not really really matter what HCI name the socket is bound to, as
long as it is not empty.

MFC after:	1 week
2006-05-17 00:13:07 +00:00
Gleb Smirnoff
441bc021a2 Remove unneeded check.
Coverity ID:	445
2006-05-16 11:49:26 +00:00
Gleb Smirnoff
00570db37b Do not leak kernel memory in case if userland has been compiled
against older NG_VERSION.

Coverity ID:	1131
2006-05-16 09:32:58 +00:00
Maxim Konovalov
7edf55d7ff o Replace disappeared URLs to Cisco docs by new ones, style.
No functional changes.
2006-04-25 20:01:50 +00:00
Maxim Konovalov
f17f823163 o Set to zero engine_type, engine_id and pad (cisco calls it
sampling_interval) fields in netflow v5 header.  We do not use
them but some netflow tools show garbage.

PR:		kern/96296
Submitted by:	David Duchscher
Approved by:	glebius
MFC after:	1 week
2006-04-25 19:56:53 +00:00
Robert Watson
c0a1b804a7 Correct assertion in ng_detach().
Submitted by:	tegge
MFC after:	3 months
2006-04-06 02:54:42 +00:00
Robert Watson
bc725eafc7 Chance protocol switch method pru_detach() so that it returns void
rather than an error.  Detaches do not "fail", they other occur or
the protocol flags SS_PROTOREF to take ownership of the socket.

soclose() no longer looks at so_pcb to see if it's NULL, relying
entirely on the protocol to decide whether it's time to free the
socket or not using SS_PROTOREF.  so_pcb is now entirely owned and
managed by the protocol code.  Likewise, no longer test so_pcb in
other socket functions, such as soreceive(), which have no business
digging into protocol internals.

Protocol detach routines no longer try to free the socket on detach,
this is performed in the socket code if the protocol permits it.

In rts_detach(), no longer test for rp != NULL in detach, and
likewise in other protocols that don't permit a NULL so_pcb, reduce
the incidence of testing for it during detach.

netinet and netinet6 are not fully updated to this change, which
will be in an upcoming commit.  In their current state they may leak
memory or panic.

MFC after:	3 months
2006-04-01 15:42:02 +00:00
Robert Watson
ac45e92ff2 Change protocol switch pru_abort() API so that it returns void rather
than an int, as an error here is not meaningful.  Modify soabort() to
unconditionally free the socket on the return of pru_abort(), and
modify most protocols to no longer conditionally free the socket,
since the caller will do this.

This commit likely leaves parts of netinet and netinet6 in a situation
where they may panic or leak memory, as they have not are not fully
updated by this commit.  This will be corrected shortly in followup
commits to these components.

MFC after:      3 months
2006-04-01 15:15:05 +00:00
Gleb Smirnoff
df7e759cc0 Free private data when deleting hook.
PR:		kern/93952
Submitted by:	Antoine Brodin <antoine.brodin laposte.net>
2006-03-15 15:41:36 +00:00
Ruslan Ermilov
aa00bc830f Clear csum_flags after reading data from socket buffer. Otherwise,
if ksocket is connected to an interface-type node somewhere later
in the graph (e.g., ng_eiface or ng_iface), the csum_data may be
applied to a wrong packet (if we encapsulate Ethernet or IP).

MFC after:	3 days
2006-02-21 13:04:39 +00:00
Gleb Smirnoff
ffbea430b8 Remove unused now field. 2006-02-17 09:42:49 +00:00
Ruslan Ermilov
e185ee8004 Unbreak this. 2006-02-14 15:22:24 +00:00
Ruslan Ermilov
fc07e4027a Don't count output bytes twice (the byte accouting is done
in if.c).  Count output errors.

MFC after:	3 days
2006-02-11 20:25:00 +00:00
Gleb Smirnoff
3bbbf02d3c - 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.
2006-02-09 11:42:17 +00:00
Ruslan Ermilov
e497d0cdba Two fixes:
- Run send queue down to completion, not just one packet.
  It has been observed to cause a stall queue otherwise.

- Prevent queueing multiple function calls to a node.

MFC after:	3 days
2006-02-06 14:30:21 +00:00
Roman Kurakin
439635c43e Fix module from panic.
Pointy hat:	brooks
MFC after:	3 days
2006-01-29 22:06:51 +00:00
Gleb Smirnoff
1c8aa594a8 o Introduce D-Link compat mode, that is default to off and can be set
by NGM_PPPOE_SETMODE message. When D-Link compat mode is on, we will
  broadcast PADI with empty Service-Name to all listening hooks.
o Rewrite the compatibility options. Before we had two modes - standard
  and non-standard (aka 3Com). Now we have standard mode and two compat
  flags, that can be combined.
o Be consistent and do s/STUPID/3COM/g. I don't say that 3Com mode isn't
  stupid, just want to make code easier to read.
2006-01-27 10:56:22 +00:00
Gleb Smirnoff
68b789b23f From the RFC2516 it is not clear, what is the correct behavior for a
PPPoE AC, servicing a specific Service-Name, when client sends a PADI
with an empty Service-Name. Should it reply with all available service
names or should it be silent? Our implementation had chosen the latter,
while some other had chosen the former (they say Linux and Cisco). Now
some PPPoE clients appear, that rely on the assumption that AC will
send all names in a PADO reply to a PADI with wildcard Service-Name.
These clients can't connect to FreeBSD AC.

I have requested comments from authors of RFC2516 via email, but
received no reply.

This change makes FreeBSD AC compatible with D-Link DI-614+ and
D-Link DI-624+ SOHO routers, and probably others.

Big thanks to D-Link's Russian office, namely Victor Platov, for
assistance and support in investigation and testing of this change.

Details:
  o Split pppoe_match_svc() into three different functions serving
    different purposes:
    - pppoe_match_svc() - match non-empty Service-Name tag from PADI
      against all available hooks in listening state.
    - pppoe_find_svc() - check that given Service-Name is not yet
      registered.
    - pppoe_broadcast_padi() - send a copy of PADI packet with empty
      Service-Name tag to all listening hooks.
  o For NGM_PPPOE_LISTEN message use pppoe_find_svc().
  o In ng_pppoe_rcvdata() in a PADI case use pppoe_match_svc() for
    a non-empty Service-Name tag, and pppoe_broadcast_padi() in
    either case.

A side effect from the above changes is that now pppoed(8) and mpd
will reply to a empty Service-Name PADI sending a PADO with two
Service-Name tags - an empty one and correct one. This is not fatal,
and will be corrected in pppoed(8) and mpd later. No need to update
node interface version.

Supported by:	D-Link
2006-01-26 13:06:49 +00:00
Gleb Smirnoff
205aefa363 Simplify ng_source_send() removing temporary queue and merging two
cycles into one.
2006-01-23 10:28:04 +00:00
Gleb Smirnoff
7762e8c630 - Remove debugging printfs.
- Add some ktr(4) debugging.
- Whitespaces at eols.
- Tidy up comments.
- u_intXX -> uintXX
2006-01-21 08:13:19 +00:00
Ruslan Ermilov
4006cd2b3f Fix two accesses to uninitialized variables that a revision 1.27
has introduced.

Found with:	Coverity Prevent(tm)
2006-01-18 16:09:00 +00:00
Gleb Smirnoff
929d59e2fe Initialize variable.
Found with:	Coverity Prevent(tm)
2006-01-14 21:49:31 +00:00
Gleb Smirnoff
efa3bacc86 Make code simplier fixing memory leak.
Found with:	Coverity Prevent(tm)
2006-01-14 21:28:30 +00:00
Gleb Smirnoff
6b5ac2b675 Remove dead code.
Found with:	Coverity Prevent(tm)
2006-01-14 14:17:27 +00:00
Gleb Smirnoff
f3d231b46b Correct off-by-one errors.
Found with:	Coverity Prevent(tm)
2006-01-14 12:26:32 +00:00
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