Commit Graph

2047 Commits

Author SHA1 Message Date
thorpej 0dd41b37de Make ip6 and icmp6 stats per-cpu. 2008-04-15 03:57:04 +00:00
cegger 856327cd56 make this build with BRIDGE_IPF and PFIL_HOOKS options 2008-04-12 09:26:45 +00:00
thorpej 7ff8d08aae Make IP, TCP, UDP, and ICMP statistics per-CPU. The stats are collated
when the user requests them via sysctl.
2008-04-12 05:58:22 +00:00
dyoung 18f5f53751 Add some assertions that will catch any exception to
ro->ro_sa == NULL implies ro->_ro_rt == NULL.
2008-04-10 18:12:02 +00:00
thorpej 3f466bce48 Change IPv6 stats from a structure to an array of uint64_t's.
Note: This is ABI-compatible with the old ip6stat structure; old netstat
binaries will continue to work properly.
2008-04-08 23:37:43 +00:00
thorpej 88d65e9212 Change IP stats from a structure to an array of uint64_t's.
Note: This is ABI-compatible with the old ipstat structure; old netstat
binaries will continue to work properly.
2008-04-07 06:31:27 +00:00
cegger cc658c528f use aprint_*_dev and device_xname 2008-04-05 13:49:36 +00:00
dyoung cdb2193bda Improve error handling. gre(4) is still broken, but it does not
any longer cause a page fault trap.
2008-04-03 21:40:59 +00:00
dyoung b674c86ad6 Fix one of two bugs introduced by the descriptor handling changes
(rev 1.125): correct the check for fd_getsock() failure in
gre_socreate().

The second bug is more complicated to fix.  Since rev 1.125,
gre_reconf() is using the file descriptor table of the current
process instead of the process 0's (the kernel's).
2008-04-03 07:19:32 +00:00
dyoung 0228252053 Cosmetic: use curlwp everywhere that it is appropriate, instead of
using a temporary variable.  Remove superflous curly braces.  Move
an assignment that shuts up a "variable may be used uninitialized"
warning.
2008-04-03 07:12:16 +00:00
yamt c585603ac5 route_intr: fill a correct member of sockproto. (sp_family -> sp_protocol) 2008-03-29 13:00:43 +00:00
ad be04ac4896 Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
2008-03-27 19:06:51 +00:00
ad 9591013005 Defer processing of routing messages to a soft interrupt. These can be
generated at IPL_VM and it's not safe to call directly into the socket
layer at that level. Reviewed by matt@.
2008-03-26 14:53:14 +00:00
christos f071da976a - put const back, no reason to modify the prototype.
1. Please don't cast function pointers to (void *), use the full function
   prototype cast; this is for archs where a function pointer is not a regular
   pointer.
2. Compare pointers to NULL not 0.
2008-03-26 02:21:52 +00:00
yamt 9a4b7dd279 merge yamt-lazymbuf branch. 2008-03-24 12:24:37 +00:00
yamt 9f194df082 agrport_monitor: map IFM_NONE to IFM_NONE|IFM_ETHER and add a comment. 2008-03-24 09:14:52 +00:00
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
rtr 6797804c6b whitespace '\t' -> ' ' 2008-03-15 11:45:18 +00:00
matt 45e0220f34 Make sure M_PROMISC isn't already set, before we need to see if we are going
to see if we need to set M_PROMISC.
Assume the interface is not CARP'ed.
2008-03-15 05:07:34 +00:00
dyoung 84f6ead420 Make some cosmetic changes:
Use fewer 'error = ...; break;' statements and more 'return
        ...;'

        Make the SIOCSIFFLAGS case more clear by using a switch
        statement instead of an if-else if-else chain.

        Shorten a staircase, and remove two unnecessary curly
        braces.
2008-03-12 18:22:24 +00:00
cube 44f2cef6db Split device_t/softc, and other related cosmetic changes. 2008-03-04 13:25:05 +00:00
rmind c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
dyoung 8a7761f76c Cosmetic: shorten staircases. Join some lines. 2008-02-29 21:23:55 +00:00
matt eefce21cf2 Revert change of char to int8_t. 2008-02-20 17:18:11 +00:00
matt 2b028087f5 s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
2008-02-20 17:05:52 +00:00
skrll 5bdccff36c CARP is Common *Address* Redundancy Protocol 2008-02-13 09:25:24 +00:00
dyoung df7679436b #include <sys/evcnt.h> for event counters. 2008-02-12 00:53:06 +00:00
dyoung b1480edbc5 Do not needlessly #include <sys/device.h>. 2008-02-11 22:32:48 +00:00
simonb 93469128b0 Don't look for <stdbool.h> if compiling _STANDALONE as well. 2008-02-11 04:47:21 +00:00
martin 035ac59527 Make it compile w/o INET6 2008-02-07 08:48:16 +00:00
xtraeme 4f2a32a138 Remove neticp (network info commpage) stuff that dyoung added
accidentally to make this build again.
2008-02-07 04:44:21 +00:00
dyoung 2ccede0a9c Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs.  This will ease extending the kernel and sharing of code
between drivers.

First steps:  Make the signature of ifioctl_common() match struct
ifinet->if_ioctl.  Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
2008-02-07 01:21:52 +00:00
dyoung d8e12ce795 Fix more fall-out from extracting ifioctl_common(): don't return
ENETRESET from ifioctl().
2008-01-23 16:51:19 +00:00
dyoung aa385448f5 Functional: return ENTRESET from ifioctl_common(), if SIOCSIFCAP
changed anything.

Cosmetic: shorten staircase.
2008-01-22 22:26:30 +00:00
dyoung 94e4ecb4ba Add missing break statement. 2008-01-22 22:09:59 +00:00
dyoung 81e0f3dc3d Take two steps toward adding and deleting link-layer addresses.
1 Extract subroutine if_dl_create() from if_alloc_sadl().
  if_dl_create() allocates a link-layer ifaddr.

2 Extract subroutine ifioctl_common() from ifioctl().  ifioctl_common()
  will be the basis for an ifnet "superclass" whose functions
  drivers may inherit.  Very simple drivers may set ifnet->if_ioctl
  = ifioctl_common.  More sophisticated drivers will set ifnet->if_ioctl
  = driver_ioctl.  driver_ioctl() will call ifioctl_common() to
  re-use the common code.
2008-01-22 16:25:15 +00:00
dyoung af289dd714 struct route is part of the kernel ABI (!!!), so move it back
outside of #ifdef _KERNEL.  #include stdbool.h if !_KERNEL.
2008-01-21 20:25:33 +00:00
dyoung 58eb3d1bbb Move struct route inside of #ifdef _KERNEL to protect userland from
it.
2008-01-21 20:04:37 +00:00
dyoung 14e6ca4ee4 In rtflushall(), do not clear a route cache by removing its rtentry
reference, but mark the cache 'invalid'.  Let the next user of the
route cache check to whether or not the cache is valid, and update
the rtentry reference if necessary.  In this way, avoid hairy
splnet()/splx() protection of route caches, which I never did trust.
2008-01-21 09:11:24 +00:00
dyoung ebc5b3612c Use C99 array initializers for bridge_control_table[]. 2008-01-19 23:17:47 +00:00
dyoung d338f6b0ba Add default handling of SIOCSIFMEDIA/SIOCGIFMEDIA. 2008-01-19 20:11:52 +00:00
dyoung 5624d2b7cd Use rtcache_validate() instead of rtcache_getrt(). Delete rtcache_getrt().
In rtcache_lookup2(), use the return values of rtcache_validate()
and _rtcache_init() instead of looking at _ro_rt.  Also, check the
return code of rtcache_setdst() for an error.
2008-01-14 05:00:18 +00:00
dyoung 1386ee4adf Good-bye, rtcache_check(). Call both rtcache_validate() and
rtcache_update(,1) instead of rtcache_check().
2008-01-12 02:58:58 +00:00
dyoung 5bf14fd932 _rtcache_init(): shorten this by getting out immediately if rtalloc1()
returns NULL.
rtcache_copy(): re-order operations a bit.  KASSERT() that we are
    not copying a route over itself.
2008-01-12 02:56:30 +00:00
dyoung a52afa8f89 Cosmetic: remove redundant 'not' from a comment, re-wrap lines. 2008-01-11 01:38:45 +00:00
dyoung ca874f52f7 Make many void rtcache_X() routines return struct rtentry *, so
that we can make many back-to-back rtcache_X();rtcache_getrt()
calls into one rtcache_X() call.
2008-01-10 08:03:22 +00:00
dyoung 72fea72bb2 Add a helper subroutine for ethernet drivers, ifmedia_change(). 2008-01-10 08:00:22 +00:00
dyoung f384d52f35 Delete an unnecessary cast. 2008-01-08 03:37:45 +00:00
dyoung a4455600d4 Replace rtcache_down() with rtcache_validate() and update rtcache_down()
uses.
2008-01-04 23:26:44 +00:00
ad 0664a0459b Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
2008-01-04 21:17:40 +00:00
christos ad809afe5c PR/37663: Guy Harris: bpf_validate rejects valid programs that use the multiply instruction 2008-01-02 15:58:01 +00:00
dyoung 60e2cd65a0 Fix XEN2_DOMU (and amd64?) builds: move ether_mediastatus(),
ether_mediachange() to their own module that we compile only if
the kernel configuration demands support for both MII buses and
ethernet.  Thanks to Tom Spindler for suggesting that these routines
move to dev/mii/.
2008-01-02 00:41:07 +00:00
dyoung aca36c0c26 Add media-handling code for several ethernet drivers with MII buses
to share.
2007-12-31 22:48:41 +00:00
he 32dafd4672 Convert to using if_set_sadl() instead of arc_storelladdr(), catching
an overlooked setting of ifnet->if_sadl.  This follows up the recent
change to net/if.h.
2007-12-25 23:31:26 +00:00
perry b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
dyoung 6f3852fab4 Constify struct ifnet->if_sadl and every use throughout the tree.
Add if_set_sadl() that both sets the link-layer address length and
replaces the current link-layer address with a new one, and use it
throughout the tree.
2007-12-20 21:08:17 +00:00
dyoung 72fa642a86 Poison struct route->ro_rt uses in the kernel by changing the name
to _ro_rt.  Use rtcache_getrt() to access a route cache's struct
rtentry *.

Introduce struct ifnet->if_dl that always points at the interface
identifier/link-layer address.  Make code that treated the first
ifaddr on struct ifnet->if_addrlist as the interface address use
if_dl, instead.

Remove stale debugging code from net/route.c.  Move the rtflush()
code into rtcache_clear() and delete rtflush().  Delete rtalloc(),
because nothing uses it any more.

Make ND6_HINT an inline, lowercase subroutine, nd6_hint.

I've done my best to convert IP Filter, the ISO stack, and the
AppleTalk stack to rtcache_getrt().  They compile, but I have not
tested them.  I have given the changes to PF, GRE, IPv4 and IPv6
stacks a lot of exercise.
2007-12-20 19:53:29 +00:00
dyoung a31aaaf8bb Use LIST_FOREACH(). 2007-12-20 18:13:26 +00:00
dyoung c669c33b43 Move more code in gre_clone_destroy() under splnet() protection,
in order to protect against gre_input() on a destroyed gre.
2007-12-20 18:12:11 +00:00
lukem 456279df8f use __KERNEL_RCSID() 2007-12-11 12:29:11 +00:00
ad 5e0c5eae3c Unbork 2007-12-08 15:04:29 +00:00
elad 51fe5bc63c Replace usage of p_cred in kauth(9) call with kauth_cred_get().
okay yamt@.
2007-12-08 13:31:03 +00:00
dyoung 9fd5916940 Fix a serious regression: insert new ifaddrs at the end of if_addrlist,
not at the front, because the first ifaddr on the list has special
significance (grrr).
2007-12-06 02:23:42 +00:00
dyoung 7a3c43874a Add ifa_insert() and ifa_remove() that add/remove an ifaddr to/from
an interface and increase/decrease its reference count.
2007-12-06 00:23:09 +00:00
dyoung b8f324fabd Extract common code, creating a subroutine if_purgeaddrs(ifp,
family, purgeaddr) which applies function `purgeaddr' to each
address on `ifp' belonging to `family'.
2007-12-05 23:47:17 +00:00
dyoung 498e382747 Use IFADDR_FIRST(), IFADDR_NEXT(). 2007-12-05 22:56:02 +00:00
dyoung adde197943 Use IFADDR_EMPTY(). 2007-12-05 22:51:01 +00:00
dyoung 67637efccc Add IFNET_FIRST(), IFNET_NEXT(), IFADDR_FIRST(), IFADDR_NEXT(),
IFADDR_EMPTY().

Call the IF{NET,ADDR}_FOREACH() macro arguments __ifp and __ifa
instead of ifp and ifa.
2007-12-05 18:07:21 +00:00
pooka 4e38160d4d Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
2007-12-05 17:19:46 +00:00
ad 6874e511b7 lockmgr -> mutex 2007-12-05 07:58:29 +00:00
dyoung 73b0c685df Use IFADDR_FOREACH(). 2007-12-04 10:31:14 +00:00
ad 4b293a84e1 Interrupt handling changes, in discussion since February:
- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
2007-12-03 15:33:00 +00:00
ad 57ab3d5998 Grab tty_lock in more places. Noted and tested by degroote@. 2007-11-28 21:44:11 +00:00
dyoung 453e5e8a7d Cosmetic: join two lines. 2007-11-28 02:40:21 +00:00
dyoung 42e892e3d8 Pass the mbuf type (e.g., MT_SONAME, MT_SOOPTS) as the second
argument to getsockmbuf().
2007-11-24 07:49:03 +00:00
dyoung 8fd9837dcc Fix a bunch of locking bugs ("Mutex error: lockdebug_barrier: spin
lock held"): only hold a mutex briefly at the top and bottom of
gre_ioctl().  Use splnet() to synchronize reconfiguration with
network interrupts.
2007-11-24 07:43:32 +00:00
dyoung 50906e3486 Delete state GRE_S_DOCONF, I no longer use it. 2007-11-23 22:58:54 +00:00
ad 9bf7522dd1 Call ttwakeup() with tty_lock held. 2007-11-12 14:20:40 +00:00
ad 0f8b0df960 Call ttyflush() with tty_lock held. 2007-11-10 18:29:36 +00:00
ad d37935697b Merge tty changes from the vmlocking branch. 2007-11-07 15:56:11 +00:00
ad efe07d555b Use the softint_* API. 2007-11-07 00:19:54 +00:00
dyoung 08fdf3b0de Change a few malloc(9) + memset(3) pairs to malloc(..., ...|M_ZERO). 2007-11-01 20:37:48 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
dyoung 462deb7ea8 In ifreq_setaddr(), use the right buffer sizes for compat v.
non-compat commands.
2007-10-11 20:47:27 +00:00
dyoung c54777285d Delete dead code. 2007-10-10 22:14:38 +00:00
ad 46ed8f7d77 Use the softint API. 2007-10-08 16:18:02 +00:00
ad 451aacda90 Merge file descriptor locking, cwdi locking and cross-call changes
from the vmlocking branch.
2007-10-08 15:12:05 +00:00
dyoung 1dc4f12dca Change some ints to bools. 2007-10-06 03:35:14 +00:00
dyoung 2c54ff5913 Good-bye, kernel thread, we don't need you any longer. 2007-10-06 03:30:25 +00:00
martin 38e2704180 Add missing include for definition of struct evcnt. 2007-10-05 08:05:37 +00:00
dyoung 32fddb3293 Cosmetic: KNF. Litter the code with fewer #if NBPFILTER > 0. 2007-10-05 05:15:58 +00:00
dyoung 944a024048 Remove a lot of dead code. Move gre_do_send() code into greintr(),
and move gre_do_recv() code into gre_receive().  Get rid of some
unused event counters.
2007-10-05 04:55:10 +00:00
dyoung 60149b1ce8 Work in progress: use a raw socket for GRE in IP encapsulation
instead of adding/subtracting our own IPv4 header.

There are many benefits:  gre(4) needn't grok the outer encapsulation
header any longer, so this simplifies the gre(4) code.  The IP
stack needn't grok GRE, so it is simplified, too.  gre(4) will
benefit from optimizations in the socket code.  Eventually, gre(4)
will gain an IPv6 encapsulation with very few new lines of code.

There is a small performance loss.  A 133 MHz, 486-class AMD Elan
sinks/sources a TCP stream over GRE with about 93% the throughput
of the old code.  TCP throughput on a 266 MHz, 586-class AMD Geode
is about 96% the throughput of the old code.  A 175-MHz ADM5120
(MIPS) only sinks a TCP stream over GRE at about 90% of the old
code; I am still investigating that.

I produced stripped-down versions of sosend() and soreceive() for
gre(4) to use.  They are guaranteed not to block, so they can be
called from a software interrupt and from a socket upcall,
respectively.

A kernel thread is no longer necessary for socket transmit/receive,
but I didn't get around to removing it, yet.

Thanks to Matt Thomas for suggesting the use of stripped-down socket
code and software interrupts, and to Andrew Doran for advice and
answers concerning software interrupts, threads, and performance.
2007-10-05 03:28:12 +00:00
scw 851609250e s/NPBFILTER/NBPFILTER/
Compile-tested only.
2007-09-29 18:44:51 +00:00
dyoung 43390716bc Constify sockaddr argument to ether_multiaddr(). Change struct
ifreq * arguments to ether_addmulti() and ether_delmulti() to const
struct sockaddr *, since ether_{add,del}multi() only ever read the
sockaddr ifreq member, ifr_addr.  Update uses in carp(4) and in
vlan(4).
2007-09-19 05:25:33 +00:00
dyoung 306b542543 Save some lines of code, use sockaddr_dup(), sockaddr_free(),
sockaddr_cmp().  No functional change intended.

Bug fix: pass M_WAITOK, not M_WAIT, to malloc(9).
2007-09-16 18:09:51 +00:00
dyoung 2d2c83df85 KNF: use tabs instead of spaces. 2007-09-16 02:23:29 +00:00
dyoung b0dad91e16 Use sockaddr_dup() and sockaddr_free(). 2007-09-16 02:19:44 +00:00
dyoung d34212ed04 Move the LIST_HEAD() definition below etherip_softc's definition.
Somehow having it above interfered with ctags(1) producing a tag
for etherip_softc.

Remove the sole member of the union etherip_softc.sc_scr; call it
sc_ro.  Delete the union.  Delete the #define for sc_ro.  The union
was a holdover from days before the route caches were unified.
2007-09-16 02:15:54 +00:00
gdt 2f4541505a Add a define for the ifru_space union member.
Copy the entire sockaddr to the buffer to be written to user space,
according to its length, not just the part that fits in struct
sockaddr.

This fixes the 'bad MAC address' problem in dhclient.
2007-09-13 18:54:57 +00:00
gdt aebe6f5793 Fix bug in SIOCGIFCONF where the wrong length was calculated for
sockaddrs bigger than struct sockaddr.  Tightly bind decrementing
available space and using it, avoiding incorrect accounting in an
error case.  Document invariants.  Document calling convention for
SIOCGIFCONF.  Simplify by removing code to handle sockaddrs that don't
fit in struct ifreq; with sockaddr_storage this can no longer occur.
Add several KASSERTs.

This commit resolves the problem with racoon failing to list
interfaces.

Proposed on tech-net@ with no objections.
2007-09-11 19:31:22 +00:00
cube c725329722 Remove 3rd clause and my name from all the licences which were only in my
name.
2007-09-10 10:35:51 +00:00
martin 90ef42f1bb Print the access concentrator name when a session is established.
This seems to be usefull to identify peers with known broken firmware
(e.g. that can only do IPv4 reliably).
2007-09-09 09:58:55 +00:00
dyoung 7cf94b5474 Rename gre_socreate1() -> gre_socreate(). 2007-09-08 04:34:02 +00:00
dyoung 88399b6877 We cannot sleep in a software interrupt, so do not sockaddr_dl_alloc(...,
M_WAITOK).  Instead, sockaddr_dl_init() a sockaddr_dl on the stack.
2007-09-02 19:42:21 +00:00
dyoung da055795a8 Delete unused variable. 2007-09-02 07:03:22 +00:00
dyoung c87aad4f08 Simplify code, add debug statements, and fix a bug that could
soclose() a UDP socket that a struct file still pointed at.
2007-09-02 07:01:41 +00:00
dyoung 76b1df3703 Get rid of struct oifreq/ifreq compat code, because ifioctl() has
taken care of this for us.
2007-09-02 01:50:58 +00:00
dyoung 0af5ef16d6 Be consistent: use the prefix sc_ for all members of the gre_softc. 2007-09-02 01:49:49 +00:00
dyoung 36a3794513 Protect userland from ifreq_getaddr() w/ #ifdef _KERNEL. 2007-09-02 00:24:18 +00:00
dyoung 064ec1416f token_addmulti and token_delmulti are never used in the kernel, so
delete them.
2007-09-01 07:41:22 +00:00
dyoung c66d2e7604 fddi_addmulti and fddi_delmulti are never used in the kernel, so
delete them.
2007-09-01 07:40:53 +00:00
dyoung 9bee2cd7f1 Fix compilation if !defined(INET6). Thanks, Geoff Wing, for the
bug report & patch.
2007-09-01 07:03:32 +00:00
dyoung 2fc102750d Use ifreq_setaddr(), ifreq_getaddr(), sockaddr_in_init(), and
sockaddr_copy().  Constify.  Compare pointers with NULL, not 0.
Don't "test truth" of pointers, but compare with NULL.
2007-09-01 04:32:50 +00:00
dyoung aade2db1a7 Use ifreq_getaddr(). Pass a sockaddr instead of ifreq where sockaddr
will suffice.
2007-09-01 03:07:24 +00:00
dyoung 7e6b3f4292 Per discussion in 30 May 2007 on tech-net, add accessors for
ifreq->ifr_addr, ifreq_getaddr() and ifreq_setaddr().
2007-08-31 21:02:15 +00:00
dyoung e44b703953 Move sc_fp & sc_newfp from struct gre_softc to struct gre_soparm. 2007-08-30 05:54:07 +00:00
dyoung 7ac92eed2a Remove out-of-date debug message and comment. 2007-08-30 05:14:32 +00:00
dyoung f562a76244 Cosmetic: remove an out-of-place comma in a comment. 2007-08-30 05:01:30 +00:00
dyoung 17038010cb Do not hold the mutex as much in gre_thread1(). Move initial mutex
acquisition and final release out into gre_thread().  This will
fix a locking bug that LOCKDEBUG exposed: holding a spinlock over
an sosend() call is a no-no.

Cosmetic: join some lines, remove some unnecessary curly braces.
2007-08-30 04:58:25 +00:00
dyoung a7ae782635 Make rtcache() and rtflush() block IPL_NET while they add/remove
a route from the cached routes list, so that the list won't change
out from under them.
2007-08-30 02:22:29 +00:00
dyoung b3fc296326 Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain.  Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size.  Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead.  Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 02:17:34 +00:00
dyoung b4ed197c2d LLADDR -> CLLADDR. 2007-08-27 14:59:11 +00:00
dyoung d93512cce5 Remove dead code. 2007-08-27 14:57:47 +00:00
dyoung ae7a571b06 Add a new routing message type, RTM_SETGATE. We can use an
RTM_SETGATE message to ask the link layer to fill in the link-layer
nexthop before we try to detect a duplicate route in a multipath-capable
kernel.
2007-08-27 00:34:01 +00:00
dyoung 5204966a96 Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).

Use sockaddr_dl_setaddr() in a few places.
2007-08-26 22:59:08 +00:00
dyoung e7e5e02759 Overhaul gre(4), especially the GRE in UDP bits:
* Create the kernel thread in gre_clone_create() instead of trying
  to create it in gre_ioctl().  (Thanks ad@ for suggesting it, and
  pointing out that I can't kthread_create while I hold a spin
  lock.)  Run the thread always, but put it to sleep while the
  gre(4) is not in UDP mode.

* Use sockaddr_in_init().

* Move some thread state off of the stack and into the softc.

* Extract subroutines gre_do_recv(), gre_do_send(), and gre_reconf()
  from gre_thread1(), making the code more readable.
2007-08-24 23:38:31 +00:00
skd d4509b0376 Clean up net compat ioctls, and clean up handling of wireless ioctls. 2007-08-20 04:49:40 +00:00
joerg b2dde09db1 Explicitly assert that the protocol out pr_ctloutput before calling it. 2007-08-14 16:03:48 +00:00
seanb 7a700a611e - Check IFF_RUNNING | IFF_UP in gre_output() correctly. 2007-08-14 13:36:50 +00:00
dyoung 3aa180f03a As a stopgap measure to avoid dependency on net/if.h, don't use
IFNAMSIZ.
2007-08-07 04:59:46 +00:00
dyoung 97ecf3fcfd Constify. bcopy -> memcpy. 2007-08-07 04:41:46 +00:00
dyoung 9ca94f6e09 Use satocsdl() instead of SDL(). 2007-08-07 04:41:15 +00:00
dyoung 846a5ed688 Use satocsdl() instead of SDL(). bcopy -> memcpy. 2007-08-07 04:39:34 +00:00
dyoung e3b7db6399 Constify. 2007-08-07 04:37:44 +00:00
dyoung 59d43281b6 Use sockaddr_dl_measure() and sockaddr_dl_init(). Erase unnecessary
cast.
2007-08-07 04:27:44 +00:00
dyoung 1cf606d23a In if_alloc_sadl(), use sockaddr_dl_init() and satocsdl(). Introduce
variable 'mask' for the netmask, and use it instead of assigning
to 'sdl' twice.

In ifa_ifwithnet(), use satocsdl().
2007-08-07 04:14:37 +00:00
dyoung 04d14f227e Lengthen sockaddr_dl so that a 16-byte FireWire address will fit
into sdl_data[].

Move the macro satocsdl() to net/if_dl.h, and introduce satosdl().

Add some helpers for initializing sockaddr_dl (sockaddr_dl_init),
for finding out the length to put in a sockaddr_dl's sdl_len member
(sockaddr_dl_measure), and for setting the link-layer address in
a sockaddr_dl to a new value (sockaddr_dl_setaddr).

Make sockaddr_copy() panic if the caller tries to copy a sockaddr
to a destination where it will not fit.
2007-08-07 04:06:20 +00:00
yamt cf51ee04a5 don't forget to maintain ama_addrs. reported by Coverity via Arnaud Lacombe. 2007-08-02 12:37:47 +00:00
yamt 5e1e651c3e agrport_mc_del_callback: s/SIOCADDMULTI/SIOCDELMULTI/ 2007-08-02 12:34:23 +00:00
dyoung edc2327d04 Cosmetic: remove superfluous parentheses. Compare pointers with
NULL instead of testing "truth."  Remove unnecessary casts to void*
in memset() calls.
2007-07-21 03:12:10 +00:00
dyoung 49412ed4f9 Use NULL instead of 0 for null pointers. 2007-07-21 02:24:11 +00:00
dyoung 08e6f22226 Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:

        Introduce rt_walktree() for walking the routing table and
        applying a function to each rtentry.  Replace most
        rn_walktree() calls with it.

        Use rt_getkey()/rt_setkey() to get/set a route's destination.
        Keep a pointer to the sockaddr key in the rtentry, so that
        rtentry users do not have to grovel in the radix_node for
        the key.

        Add a RTM_GET method to rtrequest.  Use that instead of
        radix_node lookups in, e.g., carp(4).

Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).

Cosmetic:

        Constify.  KNF.  Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
        et cetera.  Use NULL instead of 0 for null pointers.  Use
        __arraycount().  Reduce gratuitous parenthesization.

        Stop using variadic arguments for rip6_output(), it is
        unnecessary.

        Remove the unnecessary rtentry member rt_genmask and the
        code to maintain it, since nothing actually used it.

        Make rt_maskedcopy() easier to read by using meaningful variable
        names.

        Extract a subroutine intern_netmask() for looking up a netmask in
        the masks table.

        Start converting backslash-ridden IPv6 macros in
        sys/netinet6/in6_var.h into inline subroutines that one
        can read without special eyeglasses.

One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.

I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.

Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-19 20:48:52 +00:00
ad bba99c25aa Generic soft interrupts are mandatory. 2007-07-14 21:02:36 +00:00
dyoung 690f9353c0 Cosmetic: KNF. Shorten a staircase. 2007-07-12 04:28:59 +00:00
xtraeme 746fb9e8e8 Replace a simple lock with a mutex and make it static (as it's only used
on this file). Ok by ad@.
2007-07-11 21:26:53 +00:00
dyoung 911c7b0317 Cosmetic: KNF. 2007-07-11 00:53:14 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
scw 2346befecc If the underlying link's MTU is less than PP_MTU (e.g. PPPoE), set our
MRU to the link's MTU and initiate an MRU negotiation with the peer.

This is useful when the PPP session is bridged from Ethernet to ATM
by an ADSL modem (such as the Linksys AM200). Unless we negotiate the
lower MRU, the peer is unaware that 1500-byte packets will not make
it umolested across the link (the Linksys AM200 silently truncates them
to 1498 bytes, creating a nice PMTU blackhole).

Note that the PPP RFC says peers MUST accept 1500 byte packets,
regardless of the negotiated MRU, so most ISPs which use PPPoA will
probably still send 1500-byte packets. However, I persuaded my ISP
(Andrews and Arnold) to modify their software to generate an ICMP error
"fragment needed" for packets with IP.DF set which are larger than the
negotiated MRU. They will still forward non-IP.DF packets, with the
associated truncation, but at least my PMTU troubles have gone.
2007-06-23 08:45:25 +00:00
dyoung cb3da2abc3 Remove unnecessary __UNCONST(). 2007-06-13 05:08:02 +00:00
dyoung 95edb940c2 Get rid of radix_node_head.rnh_walktree, because it is only ever
set to rn_walktree.

Introduce rt_walktree(), which applies a subroutine to every route
in a particular address family.  Use it instead of rn_walktree()
virtually everywhere.  This helps to hide the routing table
implementation.
2007-06-09 03:07:21 +00:00
christos 89734304c6 - fix unused variable when none of the compat options are defined.
- remove debugging
2007-06-01 15:41:15 +00:00
enami 723ff30abc Fix some bugs in ifconf():
- maintain space left correctly.  the pointer is advanced by the size
  of struct ifreq when length of address is small.
- single sizeof operator is enough to take the size of struct.
- the type of `sz' must be singed type since it is/was compared against to
  the variable which may become negative.
- no need to traverse rest of interfaces once we got an error.  note that
  the latter `break' statement was inside inner loop.
2007-06-01 09:35:47 +00:00
christos f6ca3502bf provide the minimum ifreq size (when sockaddr is empty) 2007-05-31 02:56:50 +00:00
christos d81aadc176 Move the nasty ifdefs in one place. Requested by ad and dyoung. 2007-05-30 21:02:02 +00:00
christos 781021f65e fix unused variable. 2007-05-29 23:32:41 +00:00
xtraeme 967c5e0168 Initialize oifr to fix build with COMPAT_40. 2007-05-29 22:05:01 +00:00
christos 20bfd9898e Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
2007-05-29 21:32:27 +00:00
yamt a5e5b20e90 use mutex. 2007-05-20 07:57:03 +00:00
christos 885ed2ab13 return POLLERR instead of ENXIO since we are expecting an revents mask not
an errno.
2007-05-17 18:01:57 +00:00
dyoung 752b247e01 Cosmetic: make the macro 'equal' into an inline subroutine, bcmp
-> memcmp, bcopy -> memcpy, 0 -> NULL, shorten staircases, remove
needless cast to int.
2007-05-06 06:21:26 +00:00
dyoung d9b62cfaed Switch from spl(9) to mutex(9) and condvar(9).
Fix a defect in the locking of file descriptors as we delegate a
UDP socket from userland to the kernel.  Move sc_fp out of sc_soparm.
Synchronize access to sc_fp by gre_ioctl() and the kernel thread
using a condition variable.  For simplicity's sake, make it the
kernel helper thread's responsibility to close its UDP socket.
2007-05-06 02:47:52 +00:00
dyoung 680f00f8b5 Factor rtcache_lookup2() out of rtcache_lookup1(), for re-use in
the IPv6 stack.  rtcache_lookup2() takes an int * argument that it
writes with 1 if we had a cache 'hit', 0 if there was a cache
'miss'.
2007-05-06 02:17:54 +00:00
dyoung f650cb5d03 Free the route cache after detaching the interface w/ if_detach()
instead of before, because if_detach() may cause the cache to be
reloaded.  (I already fixed this in both etherip(4) and gre(4).
Ewww, rampant code duplication.)
2007-05-06 02:15:34 +00:00
yamt 3c8e37e03e agrether_hashmbuf: feed ipv6 flowlabel to hash calculation. 2007-05-05 18:23:23 +00:00
dyoung 72f0a6dfb0 Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing.  Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously.  Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs.  I have
  introduced routines for allocating, copying, and duplicating,
  and freeing sockaddrs:

        struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
        struct sockaddr *sockaddr_copy(struct sockaddr *dst,
                                       const struct sockaddr *src);
        struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
        void sockaddr_free(struct sockaddr *sa);

  sockaddr_alloc() returns either a sockaddr from the pool belonging
  to the specified family, or NULL if the pool is exhausted.  The
  returned sockaddr has the right size for that family; sa_family
  and sa_len fields are initialized to the family and sockaddr
  length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
  sockaddr_in).  sockaddr_free() puts the given sockaddr back into
  its family's pool.

  sockaddr_dup() and sockaddr_copy() work analogously to strdup()
  and strcpy(), respectively.  sockaddr_copy() KASSERTs that the
  family of the destination and source sockaddrs are alike.

  The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
  passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
  family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
  etc.  They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more.  All protocol families
  use struct route.  I have changed the route cache, 'struct route',
  so that it does not contain storage space for a sockaddr.  Instead,
  struct route points to a sockaddr coming from the pool the sockaddr
  belongs to.  I added a new method to struct route, rtcache_setdst(),
  for setting the cache destination:

        int rtcache_setdst(struct route *, const struct sockaddr *);

  rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
  available to create the sockaddr storage.

  It is now possible for rtcache_getdst() to return NULL if, say,
  rtcache_setdst() failed.  I check the return value for NULL
  everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
  caches, dom_rtcache.  rtflushall(sa_family_t af) looks up the
  domain indicated by 'af', walks the domain's list of route caches
  and invalidates each one.
2007-05-02 20:40:22 +00:00
dyoung 7ff356f18d Free route cache after detaching an etherip(4) instance. 2007-04-23 05:05:03 +00:00
xtraeme df40909241 rtcache_clear is defined as static void in route.c, but it's used
in netinet/in_route.c. Move the prototype into route.h to fix
the build.
2007-04-22 13:05:21 +00:00
dyoung 3ce5c94b0e In gre_clone_destroy(), free the route cache after calling if_detach(),
because if_detach() may cause us to transmit a packet, which
ordinarily entails reloading the route cache.  This fixes a bug
where the kernel would panic later in rtflush().  Thanks Michael
Earnhart for reporting the bug.

In gre_output(), do not leak mbufs.
2007-04-14 22:41:42 +00:00
martin de3603e82a caddr_t fallout (only visible with options PPPOE_SERVER) 2007-03-31 11:00:23 +00:00
ad 9982390dd6 lwp::l_acflag is no longer used. 2007-03-29 16:51:21 +00:00
dyoung be7bb25d74 Make all debug messages use GRE_DPRINTF(). Get rid of a redundant
if_ierrors++.  Change (type *)0 to NULL.  Get rid of unnecessary
casts to void *.
2007-03-21 03:18:08 +00:00
dyoung 271d77fa58 If we do not recognize the protocol of a received packet, then
increase ifi_noproto.  If the GRE header contains routing options,
increase the input-error count, ifi_ierrors.

While I am here, make some cosmetic changes: remove unnecessary
'proto' argument from gre_input3().  Shorten some staircases.
2007-03-21 01:56:05 +00:00
dyoung cafee584b5 KNF: compare pointers with NULL instead of 0, and do not "test
truth" of either integers or pointers, so that it's clear
     what's going on.  Remove superfluous () from return statements.
     bcmp -> memcmp, bcopy -> memcpy.

Misc. cosmetic: join some lines, remove a few empty lines, remove
spaces from type casts.  Don't open-code IFNET_FOREACH().  Shorten
some staircases.
2007-03-18 20:59:38 +00:00
dyoung 912b6eb53e The departure of IPv6 interfaces does not agree with pf. The pfil
hooks that signal the interface's departure run before IPv6 sends
messages to indicate that it is leaving its multicast groups; when
pf filters the departure messages, it does not recognize the output
interface, so it complains at the departure of gre65, for example:

pf_test6: kif == NULL, if_xname gre65

I have changed if_detach() so that it calls pr_usrreq(PRU_PURGEIF)
before pfil_run_hooks(PFIL_IFNET_DETACH), instead of the other way
around.  That quiets the pf_test6: messages.
2007-03-18 20:05:52 +00:00
dyoung 72d41408ef bcopy -> memcpy, bcmp -> memcmp.
Don't open-code LIST_FOREACH().
2007-03-17 06:36:05 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
drochner 814e248430 don't use DVUNIT_ANY as unit number to attach pseudo devices,
use FSTATE_STAR and cf_unit=0 like normal devices.
Thanks to Arnaud Degroote for the bug report and testing.
2007-03-09 18:42:22 +00:00
liamjfoy 8aa640dadd Add IPv6 Fast Forward - the IPv4 counterpart:
If ip6_forward successfully forwards a packet, a cache, in this case a
ip6flow struct entry, will be created. ether_input and friends will
then be able to call ip6flow_fastforward with the packet which will then
be passed to if_output (unless an issue is found - in that case the packet
is passed back to ip6_input).

ok matt@ christos@ dyoung@ and joerg@
2007-03-07 22:20:04 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
cube f361d6e858 Remove unnecessary output and reduce verbosity in dmesg(8) output. That
makes the output consistent with etherip(4).

Suggested by Nino Dehne on current-users@.
2007-02-26 23:52:18 +00:00
dyoung 6a5d57a4de In gif_clone_destroy(), free the cached route before freeing the
interface.
2007-02-23 06:15:31 +00:00
dyoung 2bc5758505 Cosmetic: remove gratuitous () from return statements. 2007-02-23 06:13:24 +00:00
dyoung 6917e4364d If we enter gre_output() without a route in the cache, call
rtcache_init() to try to fill the cache.  rtcache_check() was not
sufficient.
2007-02-23 06:10:40 +00:00
dyoung 9020519740 Destroy route cache before destroying the interface. 2007-02-23 04:20:02 +00:00
dyoung fea99925e4 Cosmetic: use TAILQ_EMPTY, TAILQ_FOREACH. 2007-02-22 09:23:38 +00:00
thorpej 7cc07e11dc TRUE -> true, FALSE -> false 2007-02-22 06:16:03 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
dyoung 58cb526fa7 Use __arraycount(). 2007-02-21 02:24:14 +00:00
dyoung af8be3e751 Remove extraneous parentheses. bcopy -> memcpy. 2007-02-20 08:55:54 +00:00
dyoung 818fe8ed7b Remove unused #define SIN.
Constify.
2007-02-20 08:32:14 +00:00
dyoung b700519db9 Remove unused #define SIN(). From he@. 2007-02-19 21:18:23 +00:00
dyoung ba2aee81a0 Fix fallout from if_output constification. Thanks, Havard Eidnes,
for reporting the problem and testing my patch.
2007-02-19 21:17:03 +00:00
matt 58aa85753d Initialize routeswitch with structure initializers. 2007-02-18 22:46:32 +00:00
dyoung 3365b046ad Use satocsin to cast to const struct sockaddr_in *. 2007-02-18 07:17:48 +00:00
dogcow 27a0c93811 constify struct sockaddr. 2007-02-18 06:20:10 +00:00
dyoung 5493f188c7 KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
   in6_src.c, avoid casts by changing several route_in6 pointers
   to struct route pointers.  Remove unnecessary casts to caddr_t
   elsewhere.

Pave the way for eliminating address family-specific route caches:
   soon, struct route will not embed a sockaddr, but it will hold
   a reference to an external sockaddr, instead.  We will set the
   destination sockaddr using rtcache_setdst().  (I created a stub
   for it, but it isn't used anywhere, yet.)  rtcache_free() will
   free the sockaddr.  I have extracted from rtcache_free() a helper
   subroutine, rtcache_clear().  rtcache_clear() will "forget" a
   cached route, but it will not forget the destination by releasing
   the sockaddr.  I use rtcache_clear() instead of rtcache_free()
   in rtcache_update(), because rtcache_update() is not supposed
   to forget the destination.

Constify:

   1 Introduce const accessor for route->ro_dst, rtcache_getdst().

   2 Constify the 'dst' argument to ifnet->if_output().  This
     led me to constify a lot of code called by output routines.

   3 Constify the sockaddr argument to protosw->pr_ctlinput.  This
     led me to constify a lot of code called by ctlinput routines.

   4 Introduce const macros for converting from a generic sockaddr
     to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
     satocsin, et cetera.
2007-02-17 22:34:07 +00:00
dyoung 3267be0b29 Cosmetic: don't open-code LIST_FOREACH(). Remove extraneous
parentheses.  Bzero -> memset.  Shorten staircase in rt_timer_add().
2007-02-17 07:50:49 +00:00
dyoung 7cfeb3c2ed Clean this code up some.
Extract subroutine rn_delete1() to ease RADIX_MPATH integration,
should we ever do that.

Remove RN_DEBUG code that does not compile.

Join some lines of the type

        type var1;
        type var2;
        type var3;

making

        type var1, var2, var3.

Break lines of the type if (expr) stmt1; else stmt2; so that normal
people can read them.
2007-02-17 07:46:38 +00:00
bouyer 53bfe8e81c Drop M_PROMISC before passing the packet to a carp device, for the same
reason it's dropped before passing to bridge: when a vlan interface is
in promisc mode, it will loop the packet back to ether_input() with
M_PROMISC set, and when carp calls ether_input again the flag is still
there and the packet is dropped. If the carp interface doesn't take
the packet M_PROMISC is set just after is needed anyway.
Tested on a box with multiple carp on vlans, no comments about this patch
on tech-net@
2007-01-29 22:13:14 +00:00
cbiere bcfa6c3c08 Use be16dec() and be32dec() instead of reimplementing them. 2007-01-27 07:16:01 +00:00
cbiere 6b77c2af74 Use a plain memcpy() instead of alignment- and endian-specific hacks. 2007-01-27 07:12:16 +00:00
dyoung 2115f7da2f Fix the check for a routing loop. 2007-01-26 19:32:32 +00:00
dyoung 832c31b2c6 Mark some shared variables as volatile. 2007-01-26 03:01:32 +00:00
isaki 7525ed1e40 Install <net/if_pflog.h>. 2007-01-13 14:13:53 +00:00
mouse 8fb29141e0 Hook srt into the rest of the kernel build machinery, so it works to
just uncomment the pseudo-device line (which arguably should go into
other ports' GENERICs too, and at some point may).

OKed by perry.
2007-01-11 05:36:29 +00:00
bouyer 9403f4d239 Don't define dropanyway: label unless ISO or NETATALK is defined. Fix
kern/35364 by Gene ENonymous
2007-01-06 20:38:14 +00:00
joerg 8632294e2e Add a debug option for the route cache to help tracing down issues
like PR 35272 and 35318. When the kernel is compiled with
-DRTCACHE_DEBUG, all rtcache entries are logged to a list with the place
they got initialised. This allows overwrites, double inits and other
manual messing to be detected.
2007-01-05 16:40:08 +00:00
mouse 9707fdff94 Add workarounds for include-file bugs exposed by this file. (Ideal, of
course, would be to fix the include-file bugs; that may follow later.)
2007-01-05 06:32:48 +00:00
elad b2eb9a5389 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 19:07:03 +00:00
wiz 0b5301abc7 Add RCS Id. 2006-12-29 10:39:59 +00:00
mouse ebc746c114 Very first import of the source-address-based routing pseudo-device,
before any cleanup at all, per discussion with perry@.
2006-12-29 04:20:14 +00:00
joerg eb04733c4e Introduce new helper functions to abstract the route caching.
rtcache_init and rtcache_init_noclone lookup ro_dst and store
the result in ro_rt, taking care of the reference counting and
calling the domain specific route cache.
rtcache_free checks if a route was cashed and frees the reference.
rtcache_copy copies ro_dst of the given struct route, checking that
enough space is available and incrementing the reference count of the
cached rtentry if necessary.
rtcache_check validates that the cached route is still up. If it isn't,
it tries to look it up again. Afterwards ro_rt is either a valid again
or NULL.
rtcache_copy is used internally.

Adjust to callers of rtalloc/rtflush in the tree to check the sanity of
ro_dst first (if necessary). If it doesn't fit the expectations, free
the cache, otherwise check if the cached route is still valid. After
that combination, a single check for ro_rt == NULL is enough to decide
whether a new lookup needs to be done with a different ro_dst.
Make the route checking in gre stricter by repeating the loop check
after revalidation.
Remove some unused RADIX_MPATH code in in6_src.c. The logic is slightly
changed here to first validate the route and check RTF_GATEWAY
afterwards. This is sementically equivalent though.
etherip doesn't need sc_route_expire similiar to the gif changes from
dyoung@ earlier.

Based on the earlier patch from dyoung@, reviewed and discussed with
him.
2006-12-15 21:18:52 +00:00
christos 5abf774808 initialize error, cause gcc3 says so. 2006-12-10 23:12:37 +00:00
is dc12fff4c3 Explain XID magic constants, correcting the format ID 2006-12-10 14:52:29 +00:00
is 8812d0414b oops, forgot lan_hdr_len length offset 2006-12-10 14:49:43 +00:00
is e80820a117 oops, forgot the m_adj 2006-12-10 14:47:40 +00:00
is 9c9b34873f was wrong magic constant. no functional change. 2006-12-10 14:45:09 +00:00
is d227658f6b Avoid overlapping struct assignment, like in the Ethernet and FDDI cases. 2006-12-10 14:39:03 +00:00
is 60ee96c865 Explain llc XID magic constants, correcting the XID header format tag. 2006-12-10 14:21:32 +00:00
is 74a405e314 Avoid overlapping struct assignment for FDDI. Should fix netiso like in the
Ethernet case.
2006-12-10 12:34:42 +00:00
is 287d53b453 explain XID constants, and fix a wrong one 2006-12-10 11:39:43 +00:00
is 1f15d00952 define some more magic LLC constants 2006-12-10 11:35:36 +00:00
is 29b0f75d10 comment on llc class 2006-12-10 10:51:11 +00:00
dyoung cf7bb443ac Straggler from last: convert to rtflush(). 2006-12-09 06:32:58 +00:00
dyoung c308b1c661 Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route).  Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).

Stale IPv6 and ISO route caches will be treated by separate patches.

Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.

Here are the details:

Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.

Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.

Chain together all IPv4 route caches where ro_rt != NULL.  Provide
in_rtcache() for adding a route to the chain.  Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches.  In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain.  In in_rtflushall(), walk the chain and remove every route
cache.

In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.

In gif(4), discard the workaround for stale caches that involves
expiring them every so often.

Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).

Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.

Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.

In domain initializers, use .dom_xxx tags.

KNF here and there.
2006-12-09 05:33:04 +00:00
joerg b49bdf49d7 Deinline rt_get_ifa. Keep it in route.c as it is part of the routing
API, even though rtsock.c is the only user right now.
2006-12-07 19:37:08 +00:00
joerg d87b42b41f Deinline rt_replace_ifa and move rt_set_ifa and rt_set_ifa1 to
route.c as they are not used outside that file.
2006-12-07 19:20:14 +00:00
dyoung 627864e36f Per discussion on tech-net@, discard the address-munging hack that
let one create a tunnel with equal inner and outer destination IP
numbers.  Update gre(4) documentation for this change.

Extract subroutine  gre_update_route() from gre_compute_route(),
and always call it in gre_output() to freshen the route for
tunnel-encapsulated packets.
2006-12-04 02:40:15 +00:00
dyoung 31730224f4 In gre_clone_destroy,
1 use splnet() to synchronize gre clone destruction with interrupts,
  and
2 wait to call if_detach() until after joining the gre kernel
  thread.
2006-12-04 01:49:47 +00:00
dyoung e45f67b8b4 Extract subroutines rn_walkfirst() and rn_walknext() from rn_walktree().
No functional change intended.

Add some new diagnostic code, bracketed by #ifdef RN_DEBUG, that
uses the two new subroutines to walk and print a tree.

XXX The format of the diagnostic print-outs needs improvement.
2006-12-04 01:45:50 +00:00
dyoung 7e5a475027 Replace the temporary variable ndst with rt_key(rt). This will
simplify the application of RADIX_MPATH patches.

No functional change intended.
2006-12-04 00:56:44 +00:00
dyoung 8a5a3d2d66 Paranoid protection against use after free: in rtfree(), set rt_ifa
and rt_ifp to NULL.
2006-12-04 00:52:47 +00:00
dyoung b0520122af Cosmetic: remove extra empty line. 2006-12-04 00:48:59 +00:00
dyoung 626b8f05e2 Fix spelling, s/straglers/stragglers/. 2006-12-03 19:17:41 +00:00
dyoung 7b85ed030b In if_rt_walktree(), make absolutely certain not to leave a dangling
pointer, rt_ifp, from an rtentry to an interface that we are going
to destroy.
2006-12-02 20:48:13 +00:00
is 07e04d08c3 Remove an overlapping struct copy from ether_input, which caused address
corruption for incoming netiso packets with recent (at least NetBSD-3 and
later) compilers. This is done in a way that the copy is avoided totally.
Code path tested with tcp+udp/ipv4+ipv6, arp and ISO cltp/clnp.
Visually ok'd by Christos@.
2006-12-01 18:43:40 +00:00
wiz fa34b615d2 Correct spelling of "immediate(ly)". From Zafer. 2006-11-24 21:23:07 +00:00
rpaulo bc3d08297a The change I committed to etherip was wrong. ether_snprintf doesn't make
sense when chaning the MAC address of the virtual interface as pointed
out by Hans himself.
So, introduce ether_nonstatic_aton() and make etherip(4) and tap(4) use it.
2006-11-24 01:04:30 +00:00
yamt 809ec70bcf implement ipv6 TSO.
partly from Matthias Scheler.  tested by him.
2006-11-23 19:41:58 +00:00
rpaulo 74b7608af9 Remove extra prototype. 2006-11-23 04:20:54 +00:00
rpaulo 5423539f94 New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld.
Notable changes:
	* Fixes PR 34268.
	* Separates the code from gif(4) (which is more cleaner).
	* Allows the usage of STP (Spanning Tree Protocol).
	* Removed EtherIP implementation from gif(4)/tap(4).

Some input from Christos.
2006-11-23 04:07:07 +00:00
dyoung 43778cd2ec "Reform" TAILQ usage:
Obey the TAILQ abstraction while removing ifaddrs from an interface
in if_detach; just restart the loop after removing one or more
ifaddrs from the interface.

Convert a bunch of for (ifa = TAILQ_FIRST(); ifa; ifa = TAILQ_NEXT())
loops to TAILQ_FOREACH().

Remove some superfluous parentheses while I am here.
2006-11-20 04:09:25 +00:00
dyoung 33f672908d Correct the length of the TTL argument to setsockopt(IPPROTO_IP,
IP_TTL).
2006-11-16 22:58:00 +00:00
dyoung 51a6c2e769 Cosmetic: s/g_proto/sc_proto/.
(Straggler from last commit affecting net/if_gre.c, netinet/ip_gre.c.)
2006-11-16 22:32:38 +00:00
dyoung 641edc65f1 Cosmetic: s/g_proto/sc_proto/. Remove superfluous parentheses and
curly braces.
2006-11-16 22:26:35 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
dyoung 2ed50f892c make the routing socket report the right source address in RTM_GET
responses when a source-address selection policy is in use.
2006-11-13 19:16:01 +00:00
dyoung 00aa0b8d95 Fix bugs in rt_get_ifa() and put aside the sequence number stuff,
which isn't ready for primetime yet.
2006-11-13 19:14:30 +00:00
dyoung e362cfc96f In rtalloc(), release our reference to the prior rtentry before
referencing a new rtentry.
2006-11-13 17:51:02 +00:00