Home | History | Annotate | Download | only in net
History log of /src/sys/net/if_gre.c
RevisionDateAuthorComments
 1.187  16-Jul-2025  kre Kernel part of O_CLOFORK implementation (plus kernel revbump)

This is Ricardo Branco's implementation of O_CLOFORK (and
associated fcntl, etc) for NetBSD (with a few minor changes
by me).

For now, the header file symbols that should be exposed to
userland are hidden inside temporary #ifdef _KERNEL blocks,
just to avoid random userland apps, or config scripts, from
seeing any of this before it is better tested.

Userland parts of this will follow soon.

This also bumps the kernel version to 10.99.15 (changes to
data structs, and the signature of fd_dup()).
 1.186  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.185  03-Feb-2024  jdolecek branches: 1.185.2;
fix PIPE_SOCKETPAIR variant of pipe1() to apply correctly the 'flags'
passed when called via pipe2(2), fixing repeatable process hang during
compilation with 'gcc -pipe'

refactor fsocreate() to return the new socket and file pointers,
expect the caller to call fd_affix() once initialization is fully complete

use the new fsocreate() to replace the duplicate open-coded 'flags' handling
in makesocket() used for socketpair(2), and in the PIPE_SOCKETPAIR pipe1()

this also fixes lib/libc/sys/t_pipe2 pipe2_cloexec test to succeed
on PIPE_SOCKETPAIR kernel

fixes PR kern/55690
 1.184  03-Sep-2022  thorpej branches: 1.184.4;
Garbage-collect the remaining vestiges of netisr.
 1.183  03-Sep-2022  thorpej Convert MPLS from a legacy netisr to pktqueue.
 1.182  03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.181  21-Sep-2021  christos don't opencode kauth_cred_get()
 1.180  14-Feb-2021  roy if_gre: Remove alignment checks in favour copying to stack

Makes the code a lot simpler, idea from dyoung@
 1.179  13-Feb-2021  roy Prior alignment fixes should not use an offset
 1.178  12-Feb-2021  roy if_gre: Ensure that gre_h is aligned
 1.177  29-Jan-2020  thorpej branches: 1.177.6;
Adopt <net/if_stats.h>.
 1.176  16-Oct-2019  knakahara branches: 1.176.2;
Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.175  26-Apr-2019  pgoyette branches: 1.175.2;
Some more empty-string --> NULL conversions for module dependencies
 1.174  17-Apr-2019  msaitoh Remove unused inclusion.
 1.173  26-Jun-2018  msaitoh branches: 1.173.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.172  16-Jan-2018  maxv branches: 1.172.2;
style
 1.171  02-Oct-2016  christos MFREE -> m_free
 1.170  07-Aug-2016  christos modularize some more drivers and merge the module glue
 1.169  10-Jun-2016  ozaki-r branches: 1.169.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.168  28-Apr-2016  ozaki-r Constify rtentry of if_output

We no longer need to change rtentry below if_output.

The change makes it clear where rtentries are changed (or not)
and helps forthcoming locking (os psrefing) rtentries.
 1.167  24-Aug-2015  pooka sprinkle _KERNEL_OPT
 1.166  20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.165  02-May-2015  rtr make connect syscall use sockaddr_big and modify pr_{send,connect}
nam parameter type from buf * to sockaddr *.

final commit for parameter type changes to protocol user requests

* bump kernel version to 7.99.15 for parameter type changes to pr_{send,connect}
 1.164  24-Apr-2015  rtr make accept, getsockname and getpeername syscalls use sockaddr_big and modify
pr_{accept,sockname,peername} nam parameter type from mbuf * to sockaddr *.

* retained use of mbuftypes[MT_SONAME] for now.
* bump to netbsd version 7.99.12 for parameter type change.

patch posted to tech-net@ 2015/04/19
 1.163  20-Apr-2015  roy Introduce p2p_rtrequest() so that IFF_POINTOPOINT interfaces can work
with RTF_LOCAL.
Fixes PR kern/49829.
 1.162  03-Apr-2015  rtr * change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
 1.161  05-Sep-2014  matt branches: 1.161.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.160  18-Aug-2014  riastradh Don't leak in gre_clone_create error branch.

Noted by maxv@, compile-tested for amd64.
 1.159  08-Aug-2014  rtr branches: 1.159.2;
split PRU_RCVD function out of pr_generic() usrreq switches and put into
separate functions

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_RCVD with calls to
pr_rcvd()
 1.158  05-Aug-2014  rtr split PRU_SEND function out of pr_generic() usrreq switches and put into
separate functions

xxx_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *, struct lwp *)

- always KASSERT(solocked(so)) even if not implemented

- replace calls to pr_generic() with req = PRU_SEND with calls to
pr_send()

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_send() PRUs

- l2cap_send() -> l2cap_send_pcb()
- sco_send() -> sco_send_pcb()
- rfcomm_send() -> rfcomm_send_pcb()

patch reviewed by rmind
 1.157  09-Jul-2014  rtr * split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).

- KASSERT(solocked(so)) always in new functions even if request
is not implemented

- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.

* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()

- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.

* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).

- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()

* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).

- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()

note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.

patch reviewed by rmind

welcome to 6.99.47
 1.156  05-Jun-2014  rmind - Implement pktqueue interface for lockless IP input queue.
- Replace ipintrq and ip6intrq with the pktqueue mechanism.
- Eliminate kernel-lock from ipintr() and ip6intr().
- Some preparation work to push softnet_lock out of ipintr().

Discussed on tech-net.
 1.155  18-May-2014  rmind Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!
 1.154  17-May-2014  rmind - fsocreate: set SS_NBIO before the file descriptor is affixed as there is
a theoretical race condition (hard to trigger, though); remove the LWP
parameter and clean up the code a little.
- Sprinkle few comments.
- Remove M_SOOPTS while here.
 1.153  07-Nov-2013  christos branches: 1.153.2;
eliminate unused variable
 1.152  13-Sep-2013  martin Remove unused variable
 1.151  29-Aug-2013  rmind Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.
 1.150  09-Nov-2011  christos branches: 1.150.6; 1.150.10; 1.150.12; 1.150.14; 1.150.20;
cosmetic, no functional change:
- sizeof(*var) instead of sizeof(type)
- sort the event counters in the discard the same as alloc for readability
 1.149  02-Nov-2011  dyoung branches: 1.149.2;
For simplicity's sake, use pcq(9) instead of my own circular-queue
implementation. Saves 45 lines of code.
 1.148  28-Oct-2011  dyoung Don't kauth-orize SIOCDIFPHYADDR, SIOCSIFFLAGS, SIOCSIFMTU, or
SIOCSLIFPHYADDR, in gif_ioctl() or in gre_ioctl(), because those
operations are ordinarily kauth-orized already in ifioctl().

Kauth-orizing SIOCSIFFLAGS in gre_ioctl() caused a panic ("panic:
bpf_detachd: ifpromisc failed: 1") when tcpdump(8) was interrupted.
Somehow bpf(4) enables promiscuous mode using different credentials than
it uses to disable promiscuous mode, hence the ifpromisc failure. This
may have something to do with privilege-separation in tcpdump(8). I.e.,
an LWP with SIOCSIFFLAGS privilege opens /dev/bpf, but an LWP without
SIOCSIFFLAGS privilege closes it.
 1.147  27-Oct-2011  dyoung Fix gif(4)/gre(4) operation over interfaces such as wm(4) that do IPv4
checksum-offload. Note well: it really is necessary to clear the
csum_data.

While I'm here, remove the do-nothing case for SIOCSIFDSTADDR and let
ifioctl_common() or the protocol handle it.
 1.146  19-Oct-2011  dyoung Get rid of gre's deadlock-prone, one-off ifioctl locking. The standard
ifioctl locking will do.
 1.145  24-May-2011  joerg Use proper format string
 1.144  26-Jun-2010  kefren branches: 1.144.2;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33
 1.143  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.142  19-Jan-2010  pooka branches: 1.142.2; 1.142.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.141  02-Sep-2009  tls Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.
 1.140  28-Apr-2009  dyoung Let this build even if 'no options INET'.
 1.139  07-Nov-2008  dyoung branches: 1.139.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.138  06-Aug-2008  plunky branches: 1.138.2;
Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
 1.137  24-Jun-2008  ad branches: 1.137.2;
Replace references to getsock/getvnode.
 1.136  15-Jun-2008  christos - add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD)
- kill memsets where M_ZERO can be used.
 1.135  02-Jun-2008  dyoung branches: 1.135.2;
Destroy condition variable sc_fp_condvar.
 1.134  15-May-2008  dyoung Note both my contribution and NSF funding.
 1.133  15-May-2008  dyoung Get rid of gre_sosend()'s lwp argument.
 1.132  09-May-2008  dyoung Make gre(4) work in the New File Descriptor / Socket Locking Order.

Move the function+line printing into GRE_DPRINTF().

Retire gre_closef(). Retire gre_join(). Constify gre_reconf(),
and don't pass it an LWP any longer.

Make this work in the new file descriptor regime. Add a kernel
thread per gre(4) instance whose purpose is to install the socket
into proc0's file descriptor table. Add gre_fp_send() and
gre_fp_recv() for passing file_t pointers to proc0.

Fix locking: don't solock() in the socket upcall, where it is
already held. Do solock() before calling soconnect().

Simplify reconfiguration.

Update a comment that mentions finding a less specific route, since
we don't do that any more.
 1.131  28-Apr-2008  martin branches: 1.131.2;
Remove clause 3 and 4 from TNF licenses
 1.130  24-Apr-2008  ad branches: 1.130.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
 1.129  03-Apr-2008  dyoung branches: 1.129.2;
Improve error handling. gre(4) is still broken, but it does not
any longer cause a page fault trap.
 1.128  03-Apr-2008  dyoung 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).
 1.127  03-Apr-2008  dyoung 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.
 1.126  27-Mar-2008  ad 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.
 1.125  21-Mar-2008  ad Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.124  20-Feb-2008  matt branches: 1.124.6;
s/u_\(int[0-9]*_t\)/u\1/g
(change u_int*_t to uint*_t)
 1.123  07-Feb-2008  dyoung 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.
 1.122  20-Dec-2007  dyoung Move more code in gre_clone_destroy() under splnet() protection,
in order to protect against gre_input() on a destroyed gre.
 1.121  28-Nov-2007  dyoung branches: 1.121.2; 1.121.6;
Cosmetic: join two lines.
 1.120  24-Nov-2007  dyoung Pass the mbuf type (e.g., MT_SONAME, MT_SOOPTS) as the second
argument to getsockmbuf().
 1.119  24-Nov-2007  dyoung 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.
 1.118  07-Nov-2007  ad Use the softint_* API.
 1.117  19-Oct-2007  ad branches: 1.117.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.116  08-Oct-2007  ad branches: 1.116.2;
Merge file descriptor locking, cwdi locking and cross-call changes
from the vmlocking branch.
 1.115  06-Oct-2007  dyoung Change some ints to bools.
 1.114  06-Oct-2007  dyoung Good-bye, kernel thread, we don't need you any longer.
 1.113  05-Oct-2007  dyoung Cosmetic: KNF. Litter the code with fewer #if NBPFILTER > 0.
 1.112  05-Oct-2007  dyoung 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.
 1.111  05-Oct-2007  dyoung 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.
 1.110  08-Sep-2007  dyoung branches: 1.110.2;
Rename gre_socreate1() -> gre_socreate().
 1.109  02-Sep-2007  dyoung Delete unused variable.
 1.108  02-Sep-2007  dyoung Simplify code, add debug statements, and fix a bug that could
soclose() a UDP socket that a struct file still pointed at.
 1.107  02-Sep-2007  dyoung Get rid of struct oifreq/ifreq compat code, because ifioctl() has
taken care of this for us.
 1.106  02-Sep-2007  dyoung Be consistent: use the prefix sc_ for all members of the gre_softc.
 1.105  30-Aug-2007  dyoung Move sc_fp & sc_newfp from struct gre_softc to struct gre_soparm.
 1.104  30-Aug-2007  dyoung Remove out-of-date debug message and comment.
 1.103  30-Aug-2007  dyoung 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.
 1.102  24-Aug-2007  dyoung branches: 1.102.2;
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.
 1.101  20-Aug-2007  skd Clean up net compat ioctls, and clean up handling of wireless ioctls.
 1.100  14-Aug-2007  joerg Explicitly assert that the protocol out pr_ctloutput before calling it.
 1.99  14-Aug-2007  seanb - Check IFF_RUNNING | IFF_UP in gre_output() correctly.
 1.98  09-Jul-2007  ad branches: 1.98.2; 1.98.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.97  30-May-2007  christos Move the nasty ifdefs in one place. Requested by ad and dyoung.
 1.96  29-May-2007  christos fix unused variable.
 1.95  29-May-2007  xtraeme Initialize oifr to fix build with COMPAT_40.
 1.94  29-May-2007  christos 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.
 1.93  06-May-2007  dyoung 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.
 1.92  02-May-2007  dyoung 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.
 1.91  14-Apr-2007  dyoung 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.
 1.90  21-Mar-2007  dyoung 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 *.
 1.89  21-Mar-2007  dyoung 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.
 1.88  04-Mar-2007  christos branches: 1.88.2; 1.88.4; 1.88.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.87  23-Feb-2007  dyoung Cosmetic: remove gratuitous () from return statements.
 1.86  23-Feb-2007  dyoung 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.
 1.85  23-Feb-2007  dyoung Destroy route cache before destroying the interface.
 1.84  17-Feb-2007  dyoung 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.
 1.83  26-Jan-2007  dyoung branches: 1.83.2;
Fix the check for a routing loop.
 1.82  26-Jan-2007  dyoung Mark some shared variables as volatile.
 1.81  15-Dec-2006  joerg 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.
 1.80  10-Dec-2006  christos initialize error, cause gcc3 says so.
 1.79  09-Dec-2006  dyoung Straggler from last: convert to rtflush().
 1.78  04-Dec-2006  dyoung 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.
 1.77  04-Dec-2006  dyoung 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.
 1.76  16-Nov-2006  dyoung branches: 1.76.2;
Correct the length of the TTL argument to setsockopt(IPPROTO_IP,
IP_TTL).
 1.75  16-Nov-2006  dyoung Cosmetic: s/g_proto/sc_proto/. Remove superfluous parentheses and
curly braces.
 1.74  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.73  04-Nov-2006  dyoung Change lengthy ((struct sockaddr_in *)x) to satosin(x).
 1.72  04-Nov-2006  dyoung Remove unused variables.
 1.71  04-Nov-2006  dyoung Expand the comment concerning gre_kick().

Shorten the code in gre_compute_route() that flips the least
significant bit of the tunnel address. No functional change.
 1.70  25-Oct-2006  elad Kill some KAUTH_GENERIC_ISSUSER uses.
 1.69  15-Oct-2006  dyoung Two bug fixes:

If gre_socreate1() cannot find out the socket's address, exit with
an error. Before, it could exit *without* an error.

If gre_thread1() finds that it is without a valid socket (i.e., so
== NULL) but the configuration is "unchanged" (in initial state),
force reconfiguration. This prevents a crash when we try to bring
up a GRE over UDP interface whose UDP endpoints have never been
specified.
 1.68  15-Oct-2006  dyoung Cosmetic: join lines to conserve vertical space.
 1.67  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.66  09-Oct-2006  dyoung Bug fix: do not try to destroy a NULL socket. Stops the kernel
from crashing when a GRE over UDP instance of gre(4) is destroyed
before its socket is created/delegated.
 1.65  07-Sep-2006  dogcow branches: 1.65.2; 1.65.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.64  03-Sep-2006  dyoung Don't use IFQ_ macros on an ifqueue. Fixes a compilation error
reported by christos.
 1.63  01-Sep-2006  dyoung Rename gre_softc member sc_sp to sc_soparm to fix NetBSD/alpha
compiles, where some other system header #defines sc_sp.

In gre_ioctl, GREDSOCK case, do not try to delete sc_fp if it is
NULL.

Move GREDSOCK and GRESSOCK definitions to where the other GRE ioctls
are defined.

Remove #ifdef GRESSOCK, it's unnecessary now that the feature is
complete.
 1.62  31-Aug-2006  dyoung Add a mode to gre(4) that sends GRE tunnel packets in UDP datagrams.
Fix MOBILE encapsulation. Add many debugging printfs (mainly
concerning UDP mode). Clean up the gre(4) code a bit. Add the
capability to setup UDP tunnels to ifconfig. Update documentation.

In UDP mode, gre(4) puts a GRE header onto transmitted packets,
and hands them to a UDP socket for transmission. That is, the
encapsulation looks like this: IP+UDP+GRE+encapsulated packet.

There are two ways to set up a UDP tunnel. One way is to tell the
source and destination IP+port to gre(4), and let gre(4) create
the socket. The other way to create a UDP tunnel is for userland
to "delegate" a UDP socket to the kernel.
 1.61  23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.60  14-May-2006  elad integrate kauth.
 1.59  11-Dec-2005  thorpej branches: 1.59.4; 1.59.6; 1.59.8; 1.59.10; 1.59.12;
ANSI function decls and application of static.
 1.58  11-Dec-2005  christos merge ktrace-lwp.
 1.57  20-May-2005  christos branches: 1.57.2;
PR/30285: Mile Nordin: incorrect permission check joining/leaving multicast
groups.
 1.56  30-Mar-2005  is Add IPv6 over GRE (contributed by Gert Doering in PR 29150).
 1.55  26-Feb-2005  perry branches: 1.55.2;
nuke trailing whitespace
 1.54  06-Dec-2004  christos branches: 1.54.4; 1.54.6;
Sprinkle #ifdef INET to make a GENERIC kernel compile with INET undefined.
 1.53  04-Dec-2004  peter Change ifc_destroy to return an int instead of void, so that it
can pass back errors to ifconfig.
 1.52  19-Aug-2004  christos Factor out the hand-crafting of mbufs from the interface files. Reviewed by
gimpy. XXX: I could have used bpf_mtap2 on some of the new functions, but I
chose not to, because I just wanted to do what amounts to a code move.
 1.51  13-May-2004  tron Mark gre(4) interfaces as IFT_TUNNEL (Encapsulation interface).
 1.50  21-Apr-2004  itojun kill sprintf, use snprintf
 1.49  11-Dec-2003  itojun branches: 1.49.2;
gi_len is ip_len, so it has to be network byteorder. markus friedl
 1.48  05-Sep-2003  itojun u_short -> u_int16_t
 1.47  22-Aug-2003  itojun change the additional arg to be passed to ip{,6}_output to struct socket *.

this fixes KAME policy lookup which was broken by the previous commit.
 1.46  15-Aug-2003  jonathan (fast-ipsec): Add hooks to pass IPv4 IPsec traffic into fast-ipsec, if
configured with ``options FAST_IPSEC''. Kernels with KAME IPsec or
with no IPsec should work as before.

All calls to ip_output() now always pass an additional compulsory
argument: the inpcb associated with the packet being sent,
or 0 if no inpcb is available.

Fast-ipsec tested with ICMP or UDP over ESP. TCP doesn't work, yet.
 1.45  06-May-2003  grant branches: 1.45.2;
fix grammatical error in a diagnostic message.
 1.44  23-Feb-2003  simonb Remove assigned-to but not used variable.
 1.43  04-Jan-2003  wiz Spell output with two ts.
 1.42  14-Aug-2002  itojun avoid swapping endian of ip_len and ip_off on mbuf, to meet with M_LEADINGSPACE
optimization made last year. should solve PR 17867 and 10195.

IP_HDRINCL behavior of raw ip socket is kept unchanged. we may want to
provide IP_HDRINCL variant that does not swap endian.
 1.41  12-Aug-2002  itojun to be consistent with other sources, use "struct ip *ip", not inp.
(inp is usually used for pointing struct inpcb)
 1.40  10-Jun-2002  itojun return EPROTONOSUPPORT if unsupported protocol is specified
 1.39  10-Jun-2002  itojun don't abuse IFF_UP
 1.38  10-Jun-2002  itojun raise output errcnt
 1.37  10-Jun-2002  itojun ENETDOWN if outer ip address is not configured.
plug mbuf leak while here.
 1.36  10-Jun-2002  itojun don't use inner address configured by SIOCSIFADDR/DSTADDR
as outer addresses; now you need to configure outer address by
SIOCS*PHYADDR ("ifconfig tunnel"). as discussed on tech-net
 1.35  09-Jun-2002  itojun deprecate IFF_LINK2, !IFF_LINK0 is enough.
no need to manipulate IFF_LINK1 with IFF_LINK0.
remove reference to greconfig(8).
 1.34  09-Jun-2002  itojun no need for if_addrlen be 4. From: Martin Husemann <martin@duskware.de>
 1.33  09-Jun-2002  itojun make sure to bzero sockaddr_in
 1.32  09-Jun-2002  itojun style
 1.31  09-Jun-2002  itojun don't forget splx
 1.30  09-Jun-2002  itojun avoid code duplicate (route lookup)
 1.29  09-Jun-2002  itojun style
 1.28  09-Jun-2002  itojun support SIOCSLIFPHYADDR, SIOCDIFPHYADDR and SIOCGLIFPHYADDR, so that
we can manipulate tunnel endpoint by ifconfig(8).
 1.27  09-Jun-2002  martin Change default MTU to 1476 (same value that Cisco uses).
Do not limit the MTU when set by the admin with ifconfig, per discussion
on tech-net.

This fixes PR 16761 from Jasper Wallace.
 1.26  24-Feb-2002  martin branches: 1.26.8; 1.26.10;
Clear M_BCAST and M_MCAST on outgoing mbufs.
Don't copy ttl from the inner packet to the encapsulating packet. Make
the outer ttl sysctl'able. This should close PR 14269 from Jasper Wallace
(change partly from there) and it makes traceroute work over gre tunnels.
 1.25  24-Nov-2001  martin Sanity check the tunnel route after computing it and don't mark the
interface up if there is no route or the route loops back to ourself.
This helps to avoid pilot errors which would result in kernel stack
overflows.
 1.24  24-Nov-2001  martin Make this respect down interfaces.
 1.23  13-Nov-2001  lukem remove unnecessary #if NFOO > 0 .... #endif wrappers
 1.22  12-Nov-2001  lukem add RCSIDs
 1.21  10-May-2001  itojun branches: 1.21.2;
one more indentation fix
 1.20  10-May-2001  itojun whitespace/indentation cleanup
 1.19  10-May-2001  itojun no longer need to carry local version of inet_ntoa, we have it in libkern.
 1.18  12-Apr-2001  thorpej splimp -> splnet
 1.17  20-Feb-2001  itojun branches: 1.17.2;
explicitly use u_int32_t for DLT_NULL encapsulation.

correct gif address family. from chopps, sync with kame.
 1.16  17-Jan-2001  thorpej Fix a rather annoying problem where the sockaddr_dl which holds
the link level name for the interface (ifp->if_sadl) is allocated
before ifp->if_addrlen is initialized, which could lead to allocating
too little space for the link level address.

Do this by splitting allocation of the link level name out of
if_attach() and into if_alloc_sadl(), which is normally called
by functions like ether_ifattach(). Network interfaces which
don't have a link-specific attach routine must call if_alloc_sadl()
themselves (example: gif).

Link level names are freed by if_free_sadl(), which can be called
from e.g. ether_ifdetach(). Drivers never need call if_free_sadl()
themselves as if_detach() will do it if it is not already done.

While here, add the ability to pass an AF_LINK address to
SIOCSIFADDR in ether_ioctl() (this is what caused me to notice
the problem that the above fixes).
 1.15  18-Dec-2000  thorpej Fill in if_dlt.
 1.14  12-Dec-2000  thorpej Adapt to bpfattach() changes, and further centralize the bpfattach()
and bpfdetach() calls into link-type subroutines where possible.
 1.13  19-Nov-2000  martin Allow changing of settings via ioctl only for the superuser.
Fixes PR security/11524.
 1.12  25-Aug-2000  mjl Add bpf tap to gre interface.
 1.11  05-Jul-2000  thorpej Fix an omission in the gre cloning changes.
 1.10  05-Jul-2000  thorpej Make gre(4) a cloning network pseudo-device.
 1.9  25-Oct-1999  drochner branches: 1.9.6;
defopt the XNS protocol (options NS), clean up the use of related
option headers / defines
 1.8  28-Jun-1999  explorer branches: 1.8.2; 1.8.4; 1.8.6;
KNFify. Add LINK1 flag to turn off that address munging thing, for cases
where the tunnel endpoint is not the same as the remote GRE destination.
 1.7  12-Mar-1999  perry branches: 1.7.2; 1.7.4; 1.7.6;
exterminate ovbcopy. patches provided by Erik Bertelsen, pr-7145
 1.6  26-Jan-1999  hwr We no longer support IPIP (IP proto 4).
 1.5  11-Jan-1999  thorpej Pull the IP-in-IP tunneling support out of the GRE code. It's not handled
by a separate IP-IP input path.

XXX Should eventually do the same thing for IPPROTO_MOBILE.
 1.4  07-Oct-1998  thorpej Fix some typos in comments, and clean up some whitespace.
 1.3  30-Sep-1998  hwr Start supporting IPPROTO_MOBILE (55) encapsulation. This is yet
another tunneling protocol used by the Mobile-IP people. See RFC 2004
for this.
 1.2  13-Sep-1998  hwr The post 1.3.2 world is actually ready for this.
 1.1  13-Sep-1998  hwr Add a gre tunnel pseudo network device. Gre = generic route encapsulation.
This device shows up like any other network interface and can be used to
tunnel L3 protocols as e.g. IP over IP.
 1.7.6.1  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.7.4.1  01-Jul-1999  thorpej Sync w/ -current.
 1.7.2.1  02-Jul-1999  perry pullup 1.7->1.8 (explorer)
 1.8.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.4.1  15-Nov-1999  fvdl Sync with -current
 1.8.2.7  21-Apr-2001  bouyer Sync with HEAD
 1.8.2.6  12-Mar-2001  bouyer Sync with HEAD.
 1.8.2.5  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.8.2.4  05-Jan-2001  bouyer Sync with HEAD
 1.8.2.3  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.8.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.8.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.9.6.4  26-Feb-2002  he Pull up revision 1.26 (via patch, requested by martin):
Clear M_BCAST and M_MCAST on encapsulated packets on outgoing
mbufs. Also do not copy TTL from the inner packet, and make the
outer TTL sysctl'able. Fixes PR#14269, and makes traceroute work
over GRE tunnels.
 1.9.6.3  09-Dec-2001  he Pull up revisions 1.24-1.25 (via patch, requested by martin):
Respect down interfaces, and sanity check the tunnel route after
computing it, marking the interface down if there is no route or
it loops back to ourselves. Helps avoid pilot errors which would
result in kernel stack overflows.
 1.9.6.2  19-Nov-2000  tv Pullup 1.13 [sommerfeld]:
Allow changing of settings via ioctl only for the superuser.
Fixes PR security/11524.
 1.9.6.1  25-Aug-2000  mjl Add bpf tap to gre interfaces. Approved by thorpej.
 1.17.2.11  07-Jan-2003  thorpej Sync with HEAD.
 1.17.2.10  27-Aug-2002  nathanw Catch up to -current.
 1.17.2.9  13-Aug-2002  nathanw Catch up to -current.
 1.17.2.8  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.17.2.7  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.17.2.6  20-Jun-2002  nathanw Catch up to -current.
 1.17.2.5  28-Feb-2002  nathanw Catch up to -current.
 1.17.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.17.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.17.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.17.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.21.2.4  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.21.2.3  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.21.2.2  16-Mar-2002  jdolecek Catch up with -current.
 1.21.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.26.10.1  06-Nov-2002  tron Pull up revision 1.27 (requested by martin in ticket #226):
Change default MTU to 1476 (same value that Cisco uses).
Do not limit the MTU when set by the admin with ifconfig, per discussion
on tech-net.
This fixes PR 16761 from Jasper Wallace.
 1.26.8.2  29-Aug-2002  gehenna catch up with -current.
 1.26.8.1  20-Jun-2002  gehenna catch up with -current.
 1.45.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.45.2.7  01-Apr-2005  skrll Sync with HEAD.
 1.45.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.45.2.5  18-Dec-2004  skrll Sync with HEAD.
 1.45.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.45.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.45.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.45.2.1  03-Aug-2004  skrll Sync with HEAD
 1.49.2.1  20-May-2004  grant branches: 1.49.2.1.2;
Pull up revision 1.51 (requested by tron in ticket #324):

Mark gre(4) interfaces as IFT_TUNNEL (Encapsulation interface).
 1.49.2.1.2.2  24-May-2005  riz Pull up revision 1.57 (requested by christos in ticket #1536):
PR/30285: Miles Nordin: incorrect permission check joining/leaving multicast
groups.
 1.49.2.1.2.1  08-May-2005  snj Pull up revision 1.56 (requested by is in ticket #1382):
Add IPv6 over GRE (contributed by Gert Doering in PR 29150).
 1.54.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.54.4.1  29-Apr-2005  kent sync with -current
 1.55.2.3  26-Aug-2007  bouyer Pull up following revision(s) (requested by seanb in ticket #1830):
sys/net/if_gre.c: revision 1.99
- Check IFF_RUNNING | IFF_UP in gre_output() correctly.
 1.55.2.2  28-May-2005  tron Pull up revision 1.57 (requested by christos in ticket #330):
PR/30285: Mile Nordin: incorrect permission check joining/leaving multicast
groups.
 1.55.2.1  30-Mar-2005  tron Pull up revision 1.56 (requested by is in ticket #80):
Add IPv6 over GRE (contributed by Gert Doering in PR 29150).
 1.57.2.11  24-Mar-2008  yamt sync with head.
 1.57.2.10  27-Feb-2008  yamt sync with head.
 1.57.2.9  11-Feb-2008  yamt sync with head.
 1.57.2.8  21-Jan-2008  yamt sync with head
 1.57.2.7  07-Dec-2007  yamt sync with head
 1.57.2.6  15-Nov-2007  yamt sync with head.
 1.57.2.5  27-Oct-2007  yamt sync with head.
 1.57.2.4  03-Sep-2007  yamt sync with head.
 1.57.2.3  26-Feb-2007  yamt sync with head.
 1.57.2.2  30-Dec-2006  yamt sync with head.
 1.57.2.1  21-Jun-2006  yamt sync with head.
 1.59.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.59.10.3  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.59.10.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.59.10.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.59.8.4  14-Sep-2006  yamt sync with head.
 1.59.8.3  03-Sep-2006  yamt sync with head.
 1.59.8.2  11-Aug-2006  yamt sync with head
 1.59.8.1  24-May-2006  yamt sync with head.
 1.59.6.1  01-Jun-2006  kardel Sync with head.
 1.59.4.1  09-Sep-2006  rpaulo sync with head
 1.65.4.3  18-Dec-2006  yamt sync with head.
 1.65.4.2  10-Dec-2006  yamt sync with head.
 1.65.4.1  22-Oct-2006  yamt sync with head
 1.65.2.3  01-Feb-2007  ad Sync with head.
 1.65.2.2  12-Jan-2007  ad Sync with head.
 1.65.2.1  18-Nov-2006  ad Sync with head.
 1.76.2.3  31-Jan-2009  bouyer Pull up following revision(s) (requested by dholland in ticket #1266):
sys/net/if_gre.c: revision 1.80
initialize error, cause gcc3 says so.
 1.76.2.2  24-Aug-2007  liamjfoy Pull up following revision(s) (requested by seanb in ticket #829):
sys/net/if_gre.c: revision 1.99
- Check IFF_RUNNING | IFF_UP in gre_output() correctly.
 1.76.2.1  31-Mar-2007  bouyer branches: 1.76.2.1.2;
Pull up following revision(s) (requested by dyoung in ticket #530):
sys/net/if_gre.c: revision 1.77
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.
 1.76.2.1.2.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.83.2.5  07-May-2007  yamt sync with head.
 1.83.2.4  15-Apr-2007  yamt sync with head.
 1.83.2.3  24-Mar-2007  yamt sync with head.
 1.83.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.83.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.88.6.1  29-Mar-2007  reinoud Pullup to -current
 1.88.4.1  11-Jul-2007  mjf Sync with head.
 1.88.2.10  23-Oct-2007  ad Sync with head.
 1.88.2.9  09-Oct-2007  ad Sync with head.
 1.88.2.8  09-Oct-2007  ad Sync with head.
 1.88.2.7  20-Aug-2007  ad Sync with HEAD.
 1.88.2.6  09-Jun-2007  ad Sync with head.
 1.88.2.5  08-Jun-2007  ad Sync with head.
 1.88.2.4  13-May-2007  ad - Pass the error number and residual count to biodone(), and let it handle
setting error indicators. Prepare to eliminate B_ERROR.
- Add a flag argument to brelse() to be set into the buf's flags, instead
of doing it directly. Typically used to set B_INVAL.
- Add a "struct cpu_info *" argument to kthread_create(), to be used to
create bound threads. Change "bool mpsafe" to "int flags".
- Allow exit of LWPs in the IDL state when (l != curlwp).
- More locking fixes & conversion to the new API.
 1.88.2.3  10-Apr-2007  ad Sync with head.
 1.88.2.2  10-Apr-2007  ad Nuke the deferred kthread creation stuff, as it's no longer needed.
Pointed out by thorpej@.
 1.88.2.1  09-Apr-2007  ad - Add two new arguments to kthread_create1: pri_t pri, bool mpsafe.
- Fork kthreads off proc0 as new LWPs, not new processes.
 1.98.6.8  03-Dec-2007  joerg Sync with HEAD.
 1.98.6.7  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.98.6.6  11-Nov-2007  joerg Sync with HEAD.
 1.98.6.5  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.98.6.4  07-Oct-2007  joerg Sync with HEAD.
 1.98.6.3  02-Oct-2007  joerg Sync with HEAD.
 1.98.6.2  03-Sep-2007  jmcneill Sync with HEAD.
 1.98.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.98.2.3  10-Sep-2007  skrll Sync with HEAD.
 1.98.2.2  03-Sep-2007  skrll Sync with HEAD.
 1.98.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.102.2.4  23-Mar-2008  matt sync with HEAD
 1.102.2.3  09-Jan-2008  matt sync with HEAD
 1.102.2.2  08-Nov-2007  matt sync with -HEAD
 1.102.2.1  06-Nov-2007  matt sync with HEAD
 1.110.2.2  14-Oct-2007  yamt sync with head.
 1.110.2.1  06-Oct-2007  yamt sync with head.
 1.116.2.2  13-Nov-2007  bouyer Sync with HEAD
 1.116.2.1  25-Oct-2007  bouyer Sync with HEAD.
 1.117.2.4  18-Feb-2008  mjf Sync with HEAD.
 1.117.2.3  27-Dec-2007  mjf Sync with HEAD.
 1.117.2.2  08-Dec-2007  mjf Sync with HEAD.
 1.117.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.121.6.1  02-Jan-2008  bouyer Sync with HEAD
 1.121.2.1  26-Dec-2007  ad Sync with head.
 1.124.6.6  17-Jan-2009  mjf Sync with HEAD.
 1.124.6.5  28-Sep-2008  mjf Sync with HEAD.
 1.124.6.4  29-Jun-2008  mjf Sync with HEAD.
 1.124.6.3  05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.124.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.124.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.129.2.3  17-Jun-2008  yamt sync with head.
 1.129.2.2  04-Jun-2008  yamt sync with head
 1.129.2.1  18-May-2008  yamt sync with head.
 1.130.2.5  11-Aug-2010  yamt sync with head.
 1.130.2.4  11-Mar-2010  yamt sync with head
 1.130.2.3  16-Sep-2009  yamt sync with head
 1.130.2.2  04-May-2009  yamt sync with head.
 1.130.2.1  16-May-2008  yamt sync with head.
 1.131.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.131.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.135.2.2  27-Jun-2008  simonb Sync with head.
 1.135.2.1  18-Jun-2008  simonb Sync with head.
 1.137.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.137.2.1  19-Oct-2008  haad Sync with HEAD.
 1.138.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.139.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.142.4.3  31-May-2011  rmind sync with head
 1.142.4.2  03-Jul-2010  rmind sync with head
 1.142.4.1  30-May-2010  rmind sync with head
 1.142.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.142.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.144.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.149.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.149.2.1  10-Nov-2011  yamt sync with head
 1.150.20.1  03-Nov-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1117):
sys/dev/rasops/rasops.c: revision 1.72
sys/dev/vme/if_ie_vme.c: revision 1.31
sys/dev/qbus/if_qe.c: revision 1.73
sys/altq/altq_jobs.c: revision 1.7
sys/net/if_gre.c: revision 1.160
sys/dev/ic/oosiop.c: revision 1.14
- Fix error branches in altq_jobs.c to avoid leaks, noted by maxv@.
- Fix leaks in oosiop_alloc_cb error branches, noted by maxv@.
While here, avoid a sketchy pointer cast that probably falls afoul of
strict aliasing rules. Compile-tested only, with hppa.
- Don't leak f on failurein rasops.c. Noted by maxv@.
Compile-tested only, with zaurus.
- Avoid leak in error branch in if_qe.c, noted by maxv@, compile-tested for
vax.
- Sizeof struct ievme, not sizeof size_t in if_ie_vme.c.
Noted by maxv@, compile-tested for sparc.
- Don't leak in gre_clone_create error branch.
Noted by maxv@, compile-tested for amd64.
 1.150.14.2  18-May-2014  rmind sync with head
 1.150.14.1  28-Aug-2013  rmind Checkpoint work in progress:
- Initial split of the protocol user-request method into the following
methods: pr_attach, pr_detach and pr_generic for old the pr_usrreq.
- Adjust socreate(9) and sonewconn(9) to call pr_attach without the
socket lock held (as a preparation for the locking scheme adjustment).
- Adjust all pr_attach routines to assert that PCB is not set.
- Sprinkle various comments, document some routines and their locking.
- Remove M_PCB, replace with kmem(9).
- Fix few bugs spotted on the way.
 1.150.12.1  03-Nov-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1117):
sys/dev/rasops/rasops.c: revision 1.72
sys/dev/vme/if_ie_vme.c: revision 1.31
sys/dev/qbus/if_qe.c: revision 1.73
sys/altq/altq_jobs.c: revision 1.7
sys/net/if_gre.c: revision 1.160
sys/dev/ic/oosiop.c: revision 1.14
- Fix error branches in altq_jobs.c to avoid leaks, noted by maxv@.
- Fix leaks in oosiop_alloc_cb error branches, noted by maxv@.
While here, avoid a sketchy pointer cast that probably falls afoul of
strict aliasing rules. Compile-tested only, with hppa.
- Don't leak f on failurein rasops.c. Noted by maxv@.
Compile-tested only, with zaurus.
- Avoid leak in error branch in if_qe.c, noted by maxv@, compile-tested for
vax.
- Sizeof struct ievme, not sizeof size_t in if_ie_vme.c.
Noted by maxv@, compile-tested for sparc.
- Don't leak in gre_clone_create error branch.
Noted by maxv@, compile-tested for amd64.
 1.150.10.2  03-Dec-2017  jdolecek update from HEAD
 1.150.10.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.150.6.1  03-Nov-2014  msaitoh Pull up following revision(s) (requested by riastradh in ticket #1117):
sys/dev/rasops/rasops.c: revision 1.72
sys/dev/vme/if_ie_vme.c: revision 1.31
sys/dev/qbus/if_qe.c: revision 1.73
sys/altq/altq_jobs.c: revision 1.7
sys/net/if_gre.c: revision 1.160
sys/dev/ic/oosiop.c: revision 1.14
- Fix error branches in altq_jobs.c to avoid leaks, noted by maxv@.
- Fix leaks in oosiop_alloc_cb error branches, noted by maxv@.
While here, avoid a sketchy pointer cast that probably falls afoul of
strict aliasing rules. Compile-tested only, with hppa.
- Don't leak f on failurein rasops.c. Noted by maxv@.
Compile-tested only, with zaurus.
- Avoid leak in error branch in if_qe.c, noted by maxv@, compile-tested for
vax.
- Sizeof struct ievme, not sizeof size_t in if_ie_vme.c.
Noted by maxv@, compile-tested for sparc.
- Don't leak in gre_clone_create error branch.
Noted by maxv@, compile-tested for amd64.
 1.153.2.1  10-Aug-2014  tls Rebase.
 1.159.2.1  22-Aug-2014  martin Pull up following revision(s) (requested by riastradh in ticket #44):
sys/altq/altq_jobs.c 1.7
Fix error branches to avoid leaks, noted by maxv@.
sys/dev/ic/oosiop.c 1.14
Fix leaks in oosiop_alloc_cb error branches, noted by maxv@.
While here, avoid a sketchy pointer cast that probably falls afoul
of strict aliasing rules.
sys/dev/qbus/if_qe.c 1.73
Avoid leak in error branch, noted by maxv@, compile-tested for vax.
sys/dev/rasops/rasops.c 1.72
Don't leak f on failure. Noted by maxv@.
sys/dev/vme/if_ie_vme.c 1.31
Sizeof struct ievme, not sizeof size_t.
Noted by maxv@, compile-tested for sparc.
sys/net/if_gre.c 1.160
Don't leak in gre_clone_create error branch.
Noted by maxv@, compile-tested for amd64.
 1.161.2.6  05-Oct-2016  skrll Sync with HEAD
 1.161.2.5  09-Jul-2016  skrll Sync with HEAD
 1.161.2.4  29-May-2016  skrll Sync with HEAD
 1.161.2.3  22-Sep-2015  skrll Sync with HEAD
 1.161.2.2  06-Jun-2015  skrll Sync with HEAD
 1.161.2.1  06-Apr-2015  skrll Sync with HEAD
 1.169.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.172.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.173.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.173.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.173.2.1  10-Jun-2019  christos Sync with HEAD
 1.175.2.1  01-Nov-2019  martin Pull up following revision(s) (requested by knakahara in ticket #387):

sys/net/if_gre.c: revision 1.176
sys/net/if_l2tp.c: revision 1.40
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.56
sys/net/if_tap.c: revision 1.114

Fix missing kpreempt_disable() before softint_schedule() like if_vmx.c:r1.51.
 1.176.2.1  29-Feb-2020  ad Sync with head.
 1.177.6.1  03-Apr-2021  thorpej Sync with HEAD.
 1.184.4.1  04-Feb-2024  martin Pull up following revision(s) (requested by jdolecek in ticket #583):

sys/kern/uipc_socket.c: revision 1.308
sys/kern/uipc_syscalls.c: revision 1.211
sys/sys/socketvar.h: revision 1.168
sys/net/if_gre.c: revision 1.185

fix PIPE_SOCKETPAIR variant of pipe1() to apply correctly the 'flags'
passed when called via pipe2(2), fixing repeatable process hang during
compilation with 'gcc -pipe'

refactor fsocreate() to return the new socket and file pointers,
expect the caller to call fd_affix() once initialization is fully complete
use the new fsocreate() to replace the duplicate open-coded 'flags' handling
in makesocket() used for socketpair(2), and in the PIPE_SOCKETPAIR pipe1()
this also fixes lib/libc/sys/t_pipe2 pipe2_cloexec test to succeed
on PIPE_SOCKETPAIR kernel

fixes PR kern/55690
 1.185.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed