Home | History | Annotate | only in /src/sys/netatalk
History log of /src/sys/netatalk
RevisionDateAuthorComments
 1.2 26-Nov-2002  lukem Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.1 12-Jun-1998  cgd branches: 1.1.26;
Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.1.26.1 11-Dec-2002  thorpej Sync with HEAD.
 1.47 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.46 31-Jul-2023  dholland branches: 1.46.6;
aarp.c: one more thing -- both macro params should get parens
 1.45 31-Jul-2023  dholland aarp.c: whitespace
 1.44 31-Jul-2023  dholland aarp.c: fix wrong indent and add missing braces inside macro
 1.43 22-Dec-2018  maxv Replace M_ALIGN and MH_ALIGN by m_align.
 1.42 29-May-2018  maxv branches: 1.42.2;
Remove aarp_clean, unused. By the way this function was probably buggy
since it didn't reset aat_hold to NULL.
 1.41 17-Feb-2018  rjs branches: 1.41.2;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.40 09-Dec-2017  maxv Mmh, pull up the packet to ether_aarp, otherwise we're reading past the
end of the mbuf.
 1.39 01-Aug-2016  ozaki-r branches: 1.39.8;
Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.38 07-Jul-2016  ozaki-r branches: 1.38.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.37 20-Jun-2016  knakahara apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).
 1.36 31-Jan-2012  hauke branches: 1.36.6; 1.36.24;
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.

Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.

Needs to be pulled up to netbsd-5.
 1.35 08-May-2011  bouyer branches: 1.35.4; 1.35.8;
aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Should fix PR kern/44734
 1.34 12-Sep-2009  tsutsui branches: 1.34.4; 1.34.6;
Make sure to set length in AARP-response packets. PR kern/41124
 1.33 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.32 18-Mar-2009  cegger bcopy -> memcpy
 1.31 18-Mar-2009  cegger bzero -> memset
 1.30 18-Mar-2009  cegger bcmp -> memcmp
 1.29 15-Mar-2009  cegger ansify function definitions
 1.28 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.27 24-Apr-2008  ad branches: 1.27.2; 1.27.10; 1.27.12; 1.27.16;
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.26 04-Dec-2007  dyoung branches: 1.26.12; 1.26.14;
Use IFADDR_FOREACH().
 1.25 26-Aug-2007  dyoung branches: 1.25.2; 1.25.8; 1.25.10;
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.
 1.24 09-Jul-2007  ad branches: 1.24.2; 1.24.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.23 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.22 17-Feb-2007  dyoung branches: 1.22.4; 1.22.6;
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.21 16-Nov-2006  christos branches: 1.21.4;
__unused removal on arguments; approved by core.
 1.20 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19 10-Oct-2006  dogcow change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
 1.18 11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17 24-Aug-2005  christos PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.16 29-May-2005  christos branches: 1.16.2;
sprinkle const.
 1.15 08-Jan-2005  yamt branches: 1.15.8;
netatalk: remove a redundant extern decl of etherbroadcastaddr.
 1.14 23-Jun-2003  martin branches: 1.14.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.13 27-May-2003  itojun - don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.12 26-Feb-2003  matt Update for MBUFTRACE.
 1.11 28-Jan-2003  wiz allocate, not alocate. Noted by mjl, not mjll.
 1.10 21-Dec-2002  kristerw aarptab_size is never used. Remove.
 1.9 22-Oct-2002  perry ARGSUSED
 1.8 15-Nov-2001  lukem branches: 1.8.10;
don't need <sys/types.h> when including <sys/param.h>
 1.7 13-Nov-2001  lukem add RCSIDs
 1.6 13-Apr-2001  thorpej branches: 1.6.2;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.5 23-Mar-2000  thorpej branches: 1.5.6;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.4 21-Sep-1999  matt branches: 1.4.2;
Make NETATALK over FDDI.
 1.3 13-Oct-1998  kim branches: 1.3.4;
Use ETHERTYPE_ATALK instead of ETHERTYPE_AT. The former seems more common.
Our other constants also use "ATALK".

Added many new ETHERTYPE constants to sys/net/ethertypes.h, including the
ones from libpcap and tcpdump "ethertype.h" files.
 1.2 03-Apr-1997  christos Make at_ifawithnet take an ifnet arg instead of an ifaddr. Suggested by
Ignatios.
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.3.4.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.4.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.6.5 29-Dec-2002  thorpej Sync with HEAD.
 1.5.6.4 11-Nov-2002  nathanw Catch up to -current
 1.5.6.3 08-Jan-2002  nathanw Catch up to -current.
 1.5.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.5.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.10.2 26-Oct-2005  riz Pull up following revision(s) (requested by taca in ticket #5851):
sys/netatalk/aarp.c: revision 1.17
PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.8.10.1 19-Jun-2003  grant Pull up revision 1.13 (requested by itojun in ticket #1316):

- don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.14.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.15.8.1 09-May-2006  tron Pull up following revision(s) (requested by hira in ticket #1310):
sys/netatalk/aarp.c: revision 1.17
PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.16.2.5 07-Dec-2007  yamt sync with head
 1.16.2.4 03-Sep-2007  yamt sync with head.
 1.16.2.3 26-Feb-2007  yamt sync with head.
 1.16.2.2 30-Dec-2006  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.18.22.2 10-Dec-2006  yamt sync with head.
 1.18.22.1 22-Oct-2006  yamt sync with head
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.21.4.2 07-May-2007  yamt sync with head.
 1.21.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.6.1 11-Jul-2007  mjf Sync with head.
 1.22.4.3 09-Oct-2007  ad Sync with head.
 1.22.4.2 01-Jul-2007  ad Adapt to callout API change.
 1.22.4.1 08-Jun-2007  ad Sync with head.
 1.24.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.24.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.25.10.1 08-Dec-2007  ad Sync with head.
 1.25.8.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.2.1 09-Jan-2008  matt sync with HEAD
 1.26.14.1 18-May-2008  yamt sync with head.
 1.26.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.16.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.12.2 21-Apr-2012  riz Pull up following revision(s) (requested by hauke in ticket #1749):
sys/netatalk/aarp.c: revision 1.36
sys/netatalk/ddp_output.c: revision 1.16
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.
Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.
Needs to be pulled up to netbsd-5.
 1.27.12.1 30-Jun-2011  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1622):
sys/netatalk/aarp.c: revision 1.35
sys/netatalk/aarp.h: revision 1.3
sys/netatalk/ddp_usrreq.c: revision 1.40

aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Fixes PR kern/44734
 1.27.10.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.2.2 16-Sep-2009  yamt sync with head
 1.27.2.1 04-May-2009  yamt sync with head.
 1.34.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.4.1 31-May-2011  rmind sync with head
 1.35.8.1 18-Feb-2012  mrg merge to -current.
 1.35.4.1 17-Apr-2012  yamt sync with head
 1.36.24.2 05-Oct-2016  skrll Sync with HEAD
 1.36.24.1 09-Jul-2016  skrll Sync with HEAD
 1.36.6.1 03-Dec-2017  jdolecek update from HEAD
 1.38.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.39.8.1 09-Jan-2018  snj Pull up following revision(s) (requested by maxv in ticket #479):
sys/netatalk/aarp.c: revision 1.40
Mmh, pull up the packet to ether_aarp, otherwise we're reading past the
end of the mbuf.
 1.41.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.41.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.42.2.1 10-Jun-2019  christos Sync with HEAD
 1.46.6.1 02-Aug-2025  perseant Sync with HEAD
 1.3 08-May-2011  bouyer aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Should fix PR kern/44734
 1.2 10-Dec-2005  elad branches: 1.2.86; 1.2.98; 1.2.104;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.1 02-Apr-1997  christos branches: 1.1.56; 1.1.72;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.72.1 21-Jun-2006  yamt sync with head.
 1.1.56.1 11-Dec-2005  christos Sync with head.
 1.2.104.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.98.1 31-May-2011  rmind sync with head
 1.2.86.1 30-Jun-2011  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1622):
sys/netatalk/aarp.c: revision 1.35
sys/netatalk/aarp.h: revision 1.3
sys/netatalk/ddp_usrreq.c: revision 1.40

aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Fixes PR kern/44734
 1.8 02-Dec-2014  christos - s/u_intX/uintX/
- add routines to print sockaddr_at and ataddr.
 1.7 10-Dec-2005  elad branches: 1.7.120; 1.7.140;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.6 06-May-2005  matt branches: 1.6.2;
#include <sys/protosw.h> if _KERNEL
 1.5 22-Apr-2004  matt Constify protosw arrays. This can reduce the kernel .data section by
over 4K (if all the network protocols) are loaded.
 1.4 28-Jul-2000  kleink branches: 1.4.24;
Avoid recursion with traditional cpp.
 1.3 26-Jun-2000  kleink Define sa_family_t, and use it for sat_family.
 1.2 09-Sep-1998  thorpej branches: 1.2.12;
Add/move some Ethertypes, PR #5997, Heiko W.Rupp.
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.4.24.5 11-Dec-2005  christos Sync with head.
 1.4.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.24.1 03-Aug-2004  skrll Sync with HEAD
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.7.140.1 06-Apr-2015  skrll Sync with HEAD
 1.7.120.1 03-Dec-2017  jdolecek update from HEAD
 1.44 30-Mar-2023  riastradh atalk(4): Don't let userland control sa_len when adding addresses.

- The struct sockaddr_at object accessed by at_ifinit always comes
from an ioctl buffer that is adequately sized and fully initialized
from userland memory.

- The newly created sockaddr_at object is later used with
sockaddr_copy, which requires sa_len to be correctly initialized.

- sa_len is not generally required to be correctly initialized by
userland in most entry points (with some exceptions, e.g. gif(4)
configuration).

I don't know whether existing userland programs initialize sa_len
correctly; if they do, we can verify it matches sizeof(struct
sockaddr_at), but there's no need to copy sa_len then if it is
verified to be that fixed value.

Reported-by: syzbot+fb4e112846e31bc4c09d@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=6e511f97443d681b8917c6258d6463b28b36e8c9

Reported-by: syzbot+dce8a2b69dc06d9d6115@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=e521a01ced5d0bbd363e998b81bc29f3282fd75f

Reported-by: syzbot+705a2a35990549b12c8d@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=b9147d4070e1d240acd27155ce1f863997175517

Reported-by: syzbot+b9c649832cc9b1fdc7d6@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=d5c9ad3d43042ec6e9f7bd30e13a37205e7e0373

Reported-by: syzbot+ac4ab136ca76e8152218@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=349c0c4eded3eff1ff5fc2cd2d88b42806e08a47

Reported-by: syzbot+b75c731d20e46e9543e9@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=e014d790e218797e217dd590ebe5a3a89e65b627

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.43 30-Mar-2023  riastradh atalk(4): Don't abuse queue(9) internals.
 1.42 21-Sep-2021  christos branches: 1.42.4;
don't opencode kauth_cred_get()
 1.41 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.40 17-Feb-2018  rjs branches: 1.40.8;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.39 01-Aug-2016  ozaki-r branches: 1.39.8;
Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.38 07-Jul-2016  ozaki-r branches: 1.38.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.37 18-Oct-2014  snj branches: 1.37.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.36 09-Sep-2014  rmind Eliminate IFAREF() and IFAFREE() macros in favour of functions.
 1.35 01-Jul-2014  rtr fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
 1.34 19-Oct-2011  dyoung branches: 1.34.12; 1.34.26;
Use if_addr_init() instead of ifp->if_ioctl().
 1.33 30-Jan-2010  is Use the symbolic names. No functional change.
 1.32 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.31 18-Mar-2009  cegger bcopy -> memcpy
 1.30 18-Mar-2009  cegger bzero -> memset
 1.29 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.28 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.27 07-Nov-2008  dyoung branches: 1.27.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.26 30-Apr-2008  ad branches: 1.26.6; 1.26.8;
Back out previous. softnet_lock is no longer held for at_control.
 1.25 28-Apr-2008  ad Fix hang with atalkd. PR kern/38513.
 1.24 06-Dec-2007  dyoung branches: 1.24.12; 1.24.16;
Use ifa_insert(), ifa_remove().
 1.23 05-Dec-2007  dyoung Extract common code, creating a subroutine if_purgeaddrs(ifp,
family, purgeaddr) which applies function `purgeaddr' to each
address on `ifp' belonging to `family'.
 1.22 05-Dec-2007  dyoung Use IFADDR_FIRST() and IFADDR_NEXT().
 1.21 05-Dec-2007  dyoung Bring this dead code, aa_clean(), into the 21st century, *shrug*.

Use IFADDR_FOREACH().
 1.20 01-Sep-2007  dyoung branches: 1.20.6; 1.20.8;
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.
 1.19 09-Jul-2007  ad branches: 1.19.2; 1.19.6; 1.19.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.18 04-Mar-2007  christos branches: 1.18.2; 1.18.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 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.16 25-Oct-2006  elad branches: 1.16.4;
Kill KAUTH_GENERIC_ISSUSER use.
 1.15 23-Jul-2006  ad branches: 1.15.4; 1.15.6;
Use the LWP cached credentials where sane.
 1.14 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.13 14-May-2006  elad branches: 1.13.2;
integrate kauth.
 1.12 09-Apr-2006  christos Coverity CID 1090: Only check suser if we have a process context.
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10; 1.11.12;
merge ktrace-lwp.
 1.10 26-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 18-Apr-2004  matt branches: 1.9.4; 1.9.6;
Use M_ZERO as appropriate. (fix an improper use of M_WAIT to M_WAITOK)
 1.8 02-Jun-2003  is branches: 1.8.2;
Make "ifconfig $interface" display phase 1 addresses also.
 1.7 15-Nov-2001  lukem branches: 1.7.10;
don't need <sys/types.h> when including <sys/param.h>
 1.6 13-Nov-2001  lukem add RCSIDs
 1.5 13-Apr-2001  thorpej branches: 1.5.2;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.4 23-Mar-2000  thorpej branches: 1.4.6;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.3 02-Feb-2000  thorpej PRU_PURGEADDR -> PRU_PURGEIF, per a discussion w/ itojun. In the IPv4
and IPv6 code, also use this to traverse PCB tables, looking for cached
routes referencing the dying ifnet, forcing them to be refreshed.
 1.2 01-Feb-2000  thorpej First-draft if_detach() implementation, originally from Bill Studnemund,
although this version has been changed somewhat:
- reference counting on ifaddrs isn't as complete as Bill's original
work was. This is hard to get right, and we should attack one
protocol at a time.
- This doesn't do reference counting or dynamic allocation of ifnets yet.
- This version introduces a new PRU -- PRU_PURGEADDR, which is used to
purge an ifaddr from a protocol. The old method Bill used didn't work
on all protocols, and it only worked on some because it was Very Lucky.

This mostly works ... i.e. works for my USB Ethernet, except for a dangling
ifaddr reference left by the IPv6 code; have not yet tracked this down.
 1.1 02-Apr-1997  christos branches: 1.1.14; 1.1.22;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.22.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.1.14.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.4.6.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.10.1 19-Jun-2003  grant Pull up revision 1.8 (requested by is in ticket #1313):

Make "ifconfig $interface" display phase 1 addresses also.
 1.8.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.4.1 29-Apr-2005  kent sync with -current
 1.10.4.5 07-Dec-2007  yamt sync with head
 1.10.4.4 03-Sep-2007  yamt sync with head.
 1.10.4.3 26-Feb-2007  yamt sync with head.
 1.10.4.2 30-Dec-2006  yamt sync with head.
 1.10.4.1 21-Jun-2006  yamt sync with head.
 1.11.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.11.10.3 19-Apr-2006  elad sync with head.
 1.11.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.11.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.11.8.4 11-Aug-2006  yamt sync with head
 1.11.8.3 26-Jun-2006  yamt sync with head.
 1.11.8.2 24-May-2006  yamt sync with head.
 1.11.8.1 11-Apr-2006  yamt sync with head
 1.11.6.3 01-Jun-2006  kardel Sync with head.
 1.11.6.2 22-Apr-2006  simonb Sync with head.
 1.11.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time(), use bintime's for timeout
calculations and use "time_second" instead of "time.tv_sec".
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 19-Jun-2006  chap Sync with head.
 1.15.6.1 10-Dec-2006  yamt sync with head.
 1.15.4.1 18-Nov-2006  ad Sync with head.
 1.16.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.16.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.18.4.1 11-Jul-2007  mjf Sync with head.
 1.18.2.2 09-Oct-2007  ad Sync with head.
 1.18.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.19.8.2 09-Jan-2008  matt sync with HEAD
 1.19.8.1 06-Nov-2007  matt sync with HEAD
 1.19.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.19.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.19.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.20.8.1 08-Dec-2007  ad Sync with head.
 1.20.6.1 08-Dec-2007  mjf Sync with HEAD.
 1.24.16.2 11-Mar-2010  yamt sync with head
 1.24.16.1 04-May-2009  yamt sync with head.
 1.24.12.1 17-Jan-2009  mjf Sync with HEAD.
 1.26.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.26.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.27.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.26.1 10-Aug-2014  tls Rebase.
 1.34.12.2 03-Dec-2017  jdolecek update from HEAD
 1.34.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.2.2 05-Oct-2016  skrll Sync with HEAD
 1.37.2.1 09-Jul-2016  skrll Sync with HEAD
 1.38.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.39.8.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1866):

sys/netatalk/at_control.c: revision 1.44

atalk(4): Don't let userland control sa_len when adding addresses.
- The struct sockaddr_at object accessed by at_ifinit always comes
from an ioctl buffer that is adequately sized and fully initialized
from userland memory.
- The newly created sockaddr_at object is later used with
sockaddr_copy, which requires sa_len to be correctly initialized.
- sa_len is not generally required to be correctly initialized by
userland in most entry points (with some exceptions, e.g. gif(4)
configuration).

I don't know whether existing userland programs initialize sa_len
correctly; if they do, we can verify it matches sizeof(struct
sockaddr_at), but there's no need to copy sa_len then if it is
verified to be that fixed value.
 1.40.8.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1684):

sys/netatalk/at_control.c: revision 1.44

atalk(4): Don't let userland control sa_len when adding addresses.
- The struct sockaddr_at object accessed by at_ifinit always comes
from an ioctl buffer that is adequately sized and fully initialized
from userland memory.
- The newly created sockaddr_at object is later used with
sockaddr_copy, which requires sa_len to be correctly initialized.
- sa_len is not generally required to be correctly initialized by
userland in most entry points (with some exceptions, e.g. gif(4)
configuration).

I don't know whether existing userland programs initialize sa_len
correctly; if they do, we can verify it matches sizeof(struct
sockaddr_at), but there's no need to copy sa_len then if it is
verified to be that fixed value.
 1.42.4.2 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #278):

sys/netatalk/ddp_output.c: revision 1.22
sys/compat/common/if_43.c: revision 1.27
sys/netatalk/ddp_input.c: revision 1.34
sys/netatalk/at_control.c: revision 1.43

atalk(4): Don't abuse queue(9) internals.

atalk(4): Omit spurious satosat.
The input is already a struct sockaddr_at pointer.
 1.42.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #276):

sys/netatalk/at_control.c: revision 1.44

atalk(4): Don't let userland control sa_len when adding addresses.
- The struct sockaddr_at object accessed by at_ifinit always comes
from an ioctl buffer that is adequately sized and fully initialized
from userland memory.
- The newly created sockaddr_at object is later used with
sockaddr_copy, which requires sa_len to be correctly initialized.
- sa_len is not generally required to be correctly initialized by
userland in most entry points (with some exceptions, e.g. gif(4)
configuration).

I don't know whether existing userland programs initialize sa_len
correctly; if they do, we can verify it matches sizeof(struct
sockaddr_at), but there's no need to copy sa_len then if it is
verified to be that fixed value.
 1.21 03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.20 29-May-2018  maxv Remove aarp_clean, unused. By the way this function was probably buggy
since it didn't reset aat_hold to NULL.
 1.19 20-Jan-2016  riastradh branches: 1.19.16;
Give proper prototype to ddp_output.
 1.18 01-Jul-2014  rtr branches: 1.18.4;
fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
 1.17 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.16 05-Dec-2007  dyoung branches: 1.16.60; 1.16.66; 1.16.76;
Extract common code, creating a subroutine if_purgeaddrs(ifp,
family, purgeaddr) which applies function `purgeaddr' to each
address on `ifp' belonging to `family'.
 1.15 04-Mar-2007  christos branches: 1.15.14; 1.15.16; 1.15.22; 1.15.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 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.13 17-Aug-2006  christos branches: 1.13.8;
Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.12 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8;
merge ktrace-lwp.
 1.10 10-Dec-2005  elad Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.9 29-May-2005  christos branches: 1.9.2;
sprinkle const.
 1.8 29-Jun-2003  fvdl branches: 1.8.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.6 26-Feb-2003  matt Update for MBUFTRACE.
 1.5 02-Feb-2000  thorpej PRU_PURGEADDR -> PRU_PURGEIF, per a discussion w/ itojun. In the IPv4
and IPv6 code, also use this to traverse PCB tables, looking for cached
routes referencing the dying ifnet, forcing them to be refreshed.
 1.4 01-Feb-2000  thorpej First-draft if_detach() implementation, originally from Bill Studnemund,
although this version has been changed somewhat:
- reference counting on ifaddrs isn't as complete as Bill's original
work was. This is hard to get right, and we should attack one
protocol at a time.
- This doesn't do reference counting or dynamic allocation of ifnets yet.
- This version introduces a new PRU -- PRU_PURGEADDR, which is used to
purge an ifaddr from a protocol. The old method Bill used didn't work
on all protocols, and it only worked on some because it was Very Lucky.

This mostly works ... i.e. works for my USB Ethernet, except for a dangling
ifaddr reference left by the IPv6 code; have not yet tracked this down.
 1.3 03-Apr-1997  christos branches: 1.3.14; 1.3.22;
Make at_ifawithnet take an ifnet arg instead of an ifaddr. Suggested by
Ignatios.
 1.2 02-Apr-1997  christos move atintr prototype to the header file.
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.3.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.14.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.8.2.5 11-Dec-2005  christos Sync with head.
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.9.2.5 07-Dec-2007  yamt sync with head
 1.9.2.4 03-Sep-2007  yamt sync with head.
 1.9.2.3 26-Feb-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.11.8.2 03-Sep-2006  yamt sync with head.
 1.11.8.1 11-Aug-2006  yamt sync with head
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.13.8.2 12-Mar-2007  rmind Sync with HEAD.
 1.13.8.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.15.24.1 08-Dec-2007  ad Sync with head.
 1.15.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.16.1 09-Jan-2008  matt sync with HEAD
 1.15.14.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.76.1 10-Aug-2014  tls Rebase.
 1.16.66.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.16.60.2 03-Dec-2017  jdolecek update from HEAD
 1.16.60.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.4.1 19-Mar-2016  skrll Sync with HEAD
 1.19.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.2 21-Jul-2021  skrll need <sys/param.h> for COHERENCY_UNIT

Minor KNF along the way.
 1.1 02-Dec-2014  christos branches: 1.1.2; 1.1.18; 1.1.38;
- s/u_intX/uintX/
- add routines to print sockaddr_at and ataddr.
 1.1.38.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 02-Dec-2014  jdolecek file at_print.c was added on branch tls-maxphys on 2017-12-03 11:39:03 +0000
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 02-Dec-2014  skrll file at_print.c was added on branch nick-nhusb on 2015-04-06 15:18:22 +0000
 1.23 03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.22 21-Sep-2017  ozaki-r Invalidate rtcache based on a global generation counter

The change introduces a global generation counter that is incremented when any
routes have been added or deleted. When a rtcache caches a rtentry into itself,
it also stores a snapshot of the generation counter. If the snapshot equals to
the global counter, the cache is still valid, otherwise invalidated.

One drawback of the change is that all rtcaches of all protocol families are
invalidated when any routes of any protocol families are added or deleted.
If that matters, we should have separate generation counters based on
protocol families.

This change removes LIST_ENTRY from struct route, which fixes a part of
PR kern/52515.
 1.21 21-Jan-2016  riastradh branches: 1.21.10;
Revert previous: ran cvs commit when I meant cvs diff. Sorry!

Hit up-arrow one too few times.
 1.20 21-Jan-2016  riastradh Give proper prototype to ip_output.
 1.19 20-Jan-2016  riastradh Eliminate struct protosw::pr_output.

You can't use this unless you know what it is a priori: the formal
prototype is variadic, and the different instances (e.g., ip_output,
route_output) have different real prototypes.

Convert the only user of it, raw_send in net/raw_cb.c, to take an
explicit callback argument. Convert the only instances of it,
route_output and key_output, to such explicit callbacks for raw_send.
Use assertions to make sure the conversion to explicit callbacks is
warranted.

Discussed on tech-net with no objections:
https://mail-index.netbsd.org/tech-net/2016/01/16/msg005484.html
 1.18 18-May-2014  rmind branches: 1.18.4;
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.17 31-Mar-2011  dyoung branches: 1.17.14; 1.17.18; 1.17.28;
Hide the radix-trie implementation of the forwarding table so that we
will have an easier time replacing it with something different, even if
it is a second radix-trie implementation.

sys/net/route.c and sys/net/rtsock.c no longer operate directly on
radix_nodes or radix_node_heads.

Hopefully this will reduce the temptation to implement multipath or
source-based routing using grotty hacks to the grotty old radix-trie
code, too. :-)
 1.16 24-Apr-2008  ad branches: 1.16.24; 1.16.30;
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.15 30-Aug-2007  dyoung branches: 1.15.20; 1.15.22;
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.
 1.14 06-May-2007  dyoung branches: 1.14.2; 1.14.6; 1.14.8;
In AppleTalk, IPv4, and IPv6 routing domains, help sockaddr_cmp()
avoid an indirect function call by comparing the family, length,
and bytes [dom->dom_sa_cmpofs, dom->dom_sa_cmpofs + dom->dom_sa_cmplen),
corresponding to the the sockaddrs' "address" members.

For ISO, actually use sockaddr_iso_cmp, for a change. Thanks to
yamt@ for pointing out my error.
 1.13 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.12 18-Feb-2007  matt branches: 1.12.4; 1.12.6;
Convert atalksw to structure initializers.
 1.11 09-Dec-2006  dyoung branches: 1.11.2;
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.
 1.10 10-Oct-2006  dogcow change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
 1.9 27-Aug-2006  christos branches: 1.9.2; 1.9.4;
Fix initializers
 1.8 25-Aug-2006  matt One step closer to loadable domains. Store pointers to a domain's soft
interrupt queues so if_detach can remove packets to removed interfaces from
them. This eliminates a lot of conditional ugly code in if.c
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.8;
merge ktrace-lwp.
 1.6 23-Jan-2005  matt branches: 1.6.8;
Commit missing files with domain list sets.
 1.5 22-Apr-2004  matt branches: 1.5.4;
Constify protosw arrays. This can reduce the kernel .data section by
over 4K (if all the network protocols) are loaded.
 1.4 15-Nov-2001  lukem branches: 1.4.16;
don't need <sys/types.h> when including <sys/param.h>
 1.3 13-Nov-2001  lukem add RCSIDs
 1.2 14-Jan-1999  thorpej branches: 1.2.20; 1.2.22;
Domains are associated with protocol families, not address families.
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.2.22.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.20.2 08-Jan-2002  nathanw Catch up to -current.
 1.2.20.1 14-Nov-2001  nathanw Catch up to -current.
 1.4.16.4 24-Jan-2005  skrll Sync with HEAD.
 1.4.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.16.1 03-Aug-2004  skrll Sync with HEAD
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.6.8.3 03-Sep-2007  yamt sync with head.
 1.6.8.2 26-Feb-2007  yamt sync with head.
 1.6.8.1 30-Dec-2006  yamt sync with head.
 1.7.8.1 03-Sep-2006  yamt sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.9.4.2 10-Dec-2006  yamt sync with head.
 1.9.4.1 22-Oct-2006  yamt sync with head
 1.9.2.2 12-Jan-2007  ad Sync with head.
 1.9.2.1 18-Nov-2006  ad Sync with head.
 1.11.2.2 07-May-2007  yamt sync with head.
 1.11.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.12.6.1 11-Jul-2007  mjf Sync with head.
 1.12.4.2 09-Oct-2007  ad Sync with head.
 1.12.4.1 08-Jun-2007  ad Sync with head.
 1.14.8.1 06-Nov-2007  matt sync with HEAD
 1.14.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.14.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.15.22.1 18-May-2008  yamt sync with head.
 1.15.20.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.30.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.24.1 21-Apr-2011  rmind sync with head
 1.17.28.1 10-Aug-2014  tls Rebase.
 1.17.18.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.17.14.2 03-Dec-2017  jdolecek update from HEAD
 1.17.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.4.1 19-Mar-2016  skrll Sync with HEAD
 1.21.10.1 24-Oct-2017  snj Pull up following revision(s) (requested by ozaki-r in ticket #305):
distrib/sets/lists/tests/mi: revision 1.762
sys/net/route.c: revision 1.198-1.201
sys/net/route.h: revision 1.114
sys/netatalk/at_proto.c: revision 1.22
sys/netinet/in_proto.c: revision 1.124
sys/netinet6/in6_proto.c: revision 1.118
sys/netmpls/mpls_proto.c: revision 1.31
sys/netnatm/natm_proto.c: revision 1.18
sys/rump/net/lib/libsockin/sockin.c: revision 1.65
sys/sys/domain.h: revision 1.33
tests/net/route/Makefile: revision 1.6
tests/net/route/t_rtcache.sh: revision 1.1
Add tests of rtcache invalidation
Remove unnecessary NULL check of rt_ifp
It's always non-NULL.
Invalidate rtcache based on a global generation counter
The change introduces a global generation counter that is incremented when any
routes have been added or deleted. When a rtcache caches a rtentry into itself,
it also stores a snapshot of the generation counter. If the snapshot equals to
the global counter, the cache is still valid, otherwise invalidated.
One drawback of the change is that all rtcaches of all protocol families are
invalidated when any routes of any protocol families are added or deleted.
If that matters, we should have separate generation counters based on
protocol families.
This change removes LIST_ENTRY from struct route, which fixes a part of
PR kern/52515.
Remove the global lock for rtcache
Thanks to removal of LIST_ENTRY of struct route, rtcaches are accessed only by
their users. And in existing usages a rtcache is guranteed to be not accessed
simultaneously. So the rtcache framework doesn't need any exclusion controls
in itself.
Synchronize on rtcache_generation with rtlock
It's racy if NET_MPSAFE is enabled.
Pointed out by joerg@
 1.6 17-Aug-2006  christos Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.8;
merge ktrace-lwp.
 1.4 17-May-2005  christos branches: 1.4.2;
Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.3 21-Apr-2004  itojun kill sprintf, use snprintf
 1.2 13-Nov-2001  lukem branches: 1.2.16;
add RCSIDs
 1.1 02-Apr-1997  christos branches: 1.1.34; 1.1.36;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.36.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.34.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.16.1 03-Aug-2004  skrll Sync with HEAD
 1.4.2.1 30-Dec-2006  yamt sync with head.
 1.5.8.1 03-Sep-2006  yamt sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.10 03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.9 09-Oct-2019  maxv Memset to prevent stack info leak.
 1.8 19-Apr-2018  christos branches: 1.8.2; 1.8.6;
s/static inline/static __inline/g for consistency.
 1.7 30-Aug-2007  dyoung branches: 1.7.110;
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.
 1.6 02-May-2007  dyoung branches: 1.6.2; 1.6.6; 1.6.8;
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.5 17-Feb-2007  dyoung branches: 1.5.4; 1.5.6;
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.4 10-Dec-2005  elad branches: 1.4.26;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.3 12-May-2002  matt branches: 1.3.10; 1.3.26;
Eliminate commons.
 1.2 23-Mar-2000  thorpej branches: 1.2.6; 1.2.8;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.1 02-Apr-1997  christos branches: 1.1.22;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.2.8.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.6.1 20-Jun-2002  nathanw Catch up to -current.
 1.3.26.3 03-Sep-2007  yamt sync with head.
 1.3.26.2 26-Feb-2007  yamt sync with head.
 1.3.26.1 21-Jun-2006  yamt sync with head.
 1.3.10.1 11-Dec-2005  christos Sync with head.
 1.4.26.2 07-May-2007  yamt sync with head.
 1.4.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.5.6.1 11-Jul-2007  mjf Sync with head.
 1.5.4.2 09-Oct-2007  ad Sync with head.
 1.5.4.1 08-Jun-2007  ad Sync with head.
 1.6.8.1 06-Nov-2007  matt sync with HEAD
 1.6.6.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.6.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.7.110.1 22-Apr-2018  pgoyette Sync with HEAD
 1.8.6.1 10-Oct-2019  martin Pull up following revision(s) (requested by maxv in ticket #297):

sys/netatalk/at_var.h: revision 1.9

Memset to prevent stack info leak.
 1.8.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 10-Dec-2005  elad Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.1 02-Apr-1997  christos branches: 1.1.56; 1.1.72;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.72.1 21-Jun-2006  yamt sync with head.
 1.1.56.1 11-Dec-2005  christos Sync with head.
 1.34 30-Mar-2023  riastradh atalk(4): Don't abuse queue(9) internals.
 1.33 03-Sep-2022  thorpej branches: 1.33.4;
Garbage-collect the remaining vestiges of netisr.
 1.32 03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.31 21-Mar-2018  roy Sprinkle more soroverflow().
 1.30 17-Feb-2018  rjs branches: 1.30.2;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.29 08-Dec-2016  ozaki-r branches: 1.29.8;
Add rtcache_unref to release points of rtentry stemming from rtcache

In the MP-safe world, a rtentry stemming from a rtcache can be freed at any
points. So we need to protect rtentries somehow say by reference couting or
passive references. Regardless of the method, we need to call some release
function of a rtentry after using it.

The change adds a new function rtcache_unref to release a rtentry. At this
point, this function does nothing because for now we don't add a reference
to a rtentry when we get one from a rtcache. We will add something useful
in a further commit.

This change is a part of changes for MP-safe routing table. It is separated
to avoid one big change that makes difficult to debug by bisecting.
 1.28 03-Oct-2016  ozaki-r Fix race condition on ifqueue used by traditional netisr

If a underlying network device driver supports MSI/MSI-X, RX interrupts
can be delivered to arbitrary CPUs. This means that Layer 2 subroutines
such as ether_input (softint) and subsequent Layer 3 subroutines (softint)
which are called via traditional netisr can be dispatched on an arbitrary
CPU. Layer 2 subroutines now run without any locks (expected) and so a
Layer 2 subroutine and a Layer 3 subroutine can run in parallel.

There is a shared data between a Layer 2 routine and a Layer 3 routine,
that is ifqueue and IF_ENQUEUE (from L2) and IF_DEQUEUE (from L3) on it
are racy now.

To fix the race condition, use ifqueue#ifq_lock to protect ifqueue
instead of splnet that is meaningless now.

The same race condition exists in route_intr. Fix it as well.

Reviewed by knakahara@
 1.27 10-Jun-2016  ozaki-r branches: 1.27.2;
Avoid storing a pointer of an interface in a mbuf

Having a pointer of an interface in a mbuf isn't safe if we remove big
kernel locks; an interface object (ifnet) can be destroyed anytime in any
packet processing and accessing such object via a pointer is racy. Instead
we have to get an object from the interface collection (ifindex2ifnet) via
an interface index (if_index) that is stored to a mbuf instead of an
pointer.

The change provides two APIs: m_{get,put}_rcvif_psref that use psref(9)
for sleep-able critical sections and m_{get,put}_rcvif that use
pserialize(9) for other critical sections. The change also adds another
API called m_get_rcvif_NOMPSAFE, that is NOT MP-safe and for transition
moratorium, i.e., it is intended to be used for places where are not
planned to be MP-ified soon.

The change adds some overhead due to psref to performance sensitive paths,
however the overhead is not serious, 2% down at worst.

Proposed on tech-kern and tech-net.
 1.26 31-Aug-2011  plunky branches: 1.26.12; 1.26.30;
NULL does not need a cast
 1.25 18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.24 18-Mar-2009  cegger bcopy -> memcpy
 1.23 18-Mar-2009  cegger bzero -> memset
 1.22 15-Mar-2009  cegger ansify function definitions
 1.21 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.20 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.19 24-Apr-2008  ad branches: 1.19.2; 1.19.10; 1.19.16;
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.18 23-Apr-2008  thorpej Make DDP stats per-cpu. While here, bump the counters to 64-bit and
make them available by sysctl.
 1.17 21-Dec-2007  dyoung branches: 1.17.6; 1.17.8;
Get the rtentry from forwro in one less step.
 1.16 20-Dec-2007  dyoung 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.
 1.15 02-May-2007  dyoung branches: 1.15.8; 1.15.16; 1.15.20;
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.14 04-Mar-2007  christos branches: 1.14.2; 1.14.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 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.12 15-Dec-2006  joerg branches: 1.12.2;
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.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 17-May-2005  christos branches: 1.10.2;
Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.9 24-Jun-2004  jonathan Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c
 1.8 26-Feb-2003  matt branches: 1.8.2; 1.8.4;
Update for MBUFTRACE.
 1.7 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.6 13-Nov-2001  lukem add RCSIDs
 1.5 13-Apr-2001  thorpej branches: 1.5.2;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.4 27-Mar-1999  aidan branches: 1.4.8; 1.4.20;
Added per-addr input/output statistics. Currently just support netatalk
and netinet, currently only tested under netinet.

Disabled by default, enabled by compiling the kernel with option
IFA_STATS. Enabling this feature seems to make the ip_output function
take 13% longer than before, which should be OK for people that need
this feature.
 1.3 10-Jun-1998  wrstuden branches: 1.3.6;
Remove two incorrect ntoh's which make a comparison of a constant w/ a
value from a packet not work right (only one of them needs ntoh!).

Fixes a bug reported by David Brownlee, and which has been present
in NetAtalk from the Sun 4 port (and thus FreeBSD and OpenBSD too).
 1.2 02-Apr-1997  christos branches: 1.2.8;
move atintr prototype to the header file.
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.2.8.1 14-Jul-1998  mellon Pull up 1.3
 1.3.6.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.4.20.3 08-Jan-2002  nathanw Catch up to -current.
 1.4.20.2 14-Nov-2001  nathanw Catch up to -current.
 1.4.20.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.8.1 21-Apr-2001  bouyer Sync with HEAD
 1.5.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.1 14-Jul-2004  tron Pull up revision 1.9 (requested by jonathan in ticket #648):
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:
sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.2.4 21-Jan-2008  yamt sync with head
 1.10.2.3 03-Sep-2007  yamt sync with head.
 1.10.2.2 26-Feb-2007  yamt sync with head.
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.22.1 18-Dec-2006  yamt sync with head.
 1.11.20.1 12-Jan-2007  ad Sync with head.
 1.12.2.3 07-May-2007  yamt sync with head.
 1.12.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.12.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.14.4.1 11-Jul-2007  mjf Sync with head.
 1.14.2.1 08-Jun-2007  ad Sync with head.
 1.15.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.16.1 26-Dec-2007  ad Sync with head.
 1.15.8.1 09-Jan-2008  matt sync with HEAD
 1.17.8.1 18-May-2008  yamt sync with head.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.16.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.10.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.2.1 04-May-2009  yamt sync with head.
 1.26.30.3 05-Feb-2017  skrll Sync with HEAD
 1.26.30.2 05-Oct-2016  skrll Sync with HEAD
 1.26.30.1 09-Jul-2016  skrll Sync with HEAD
 1.26.12.1 03-Dec-2017  jdolecek update from HEAD
 1.27.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.27.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.29.8.1 09-Apr-2018  bouyer Pull up following revision(s) (requested by roy in ticket #724):
tests/net/icmp/t_ping.c: revision 1.19
sys/netinet6/raw_ip6.c: revision 1.166
sys/netinet6/ip6_input.c: revision 1.195
sys/net/raw_usrreq.c: revision 1.59
sys/sys/socketvar.h: revision 1.151
sys/kern/uipc_socket2.c: revision 1.128
tests/lib/libc/sys/t_recvmmsg.c: revision 1.2
lib/libc/sys/recv.2: revision 1.38
sys/net/rtsock.c: revision 1.239
sys/netinet/udp_usrreq.c: revision 1.246
sys/netinet6/icmp6.c: revision 1.224
tests/net/icmp/t_ping.c: revision 1.20
sys/netipsec/keysock.c: revision 1.63
sys/netinet/raw_ip.c: revision 1.172
sys/kern/uipc_socket.c: revision 1.260
tests/net/icmp/t_ping.c: revision 1.22
sys/kern/uipc_socket.c: revision 1.261
tests/net/icmp/t_ping.c: revision 1.23
sys/netinet/ip_mroute.c: revision 1.155
sbin/route/route.c: revision 1.159
sys/netinet6/ip6_mroute.c: revision 1.123
sys/netatalk/ddp_input.c: revision 1.31
sys/netcan/can.c: revision 1.3
sys/kern/uipc_usrreq.c: revision 1.184
sys/netinet6/udp6_usrreq.c: revision 1.138
tests/net/icmp/t_ping.c: revision 1.18
socket: report receive buffer overflows
Add soroverflow() which increments the overflow counter, sets so_error
to ENOBUFS and wakes the receive socket up.
Replace all code that manually increments this counter with soroverflow().
Add soroverflow() to raw_input().
This allows userland to detect route(4) overflows so it can re-sync
with the current state.
socket: clear error even when peeking
The error has already been reported and it's pointless requiring another
recv(2) call just to clear it.
socket: remove now incorrect comment that so_error is only udp
As it can be affected by route(4) sockets which are raw.
rtsock: log dropped messages that we cannot report to userland
Handle ENOBUFS when receiving messages.
Don't send messages if the receiver has died.
Sprinkle more soroverflow().
Handle ENOBUFS in recv
Handle ENOBUFS in sendto
Note value received. Harden another sendto for ENOBUFS.
Handle the routing socket overflowing gracefully.
Allow a valid sendto .... duh
Handle errors better.
Fix test for checking we sent all the data we asked to.
 1.30.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.33.4.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #278):

sys/netatalk/ddp_output.c: revision 1.22
sys/compat/common/if_43.c: revision 1.27
sys/netatalk/ddp_input.c: revision 1.34
sys/netatalk/at_control.c: revision 1.43

atalk(4): Don't abuse queue(9) internals.

atalk(4): Omit spurious satosat.
The input is already a struct sockaddr_at pointer.
 1.22 30-Mar-2023  riastradh atalk(4): Omit spurious satosat.

The input is already a struct sockaddr_at pointer.
 1.21 17-Feb-2018  rjs branches: 1.21.34;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.20 08-Dec-2016  ozaki-r Add rtcache_unref to release points of rtentry stemming from rtcache

In the MP-safe world, a rtentry stemming from a rtcache can be freed at any
points. So we need to protect rtentries somehow say by reference couting or
passive references. Regardless of the method, we need to call some release
function of a rtentry after using it.

The change adds a new function rtcache_unref to release a rtentry. At this
point, this function does nothing because for now we don't add a reference
to a rtentry when we get one from a rtcache. We will add something useful
in a further commit.

This change is a part of changes for MP-safe routing table. It is separated
to avoid one big change that makes difficult to debug by bisecting.
 1.19 20-Jun-2016  knakahara branches: 1.19.2;
apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).
 1.18 20-Jan-2016  riastradh Give proper prototype to ddp_output.
 1.17 12-Sep-2013  martin branches: 1.17.6;
Remove unused variable
 1.16 31-Jan-2012  hauke branches: 1.16.6; 1.16.10;
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.

Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.

Needs to be pulled up to netbsd-5.
 1.15 17-Jul-2011  joerg branches: 1.15.2; 1.15.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.14 06-Apr-2008  dyoung branches: 1.14.14;
Fix a bug that I introduced in rev 1.11, when I left out an assignment
to ifp as I converted this code to use rtcache_getrt(). I have
high hopes that this will fix PR37916.
 1.13 14-Jan-2008  dyoung branches: 1.13.6;
Use rtcache_validate() instead of rtcache_getrt().
 1.12 20-Dec-2007  dyoung 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.
 1.11 17-Feb-2007  dyoung branches: 1.11.18; 1.11.24; 1.11.26; 1.11.30;
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.10 07-Oct-2006  rpaulo branches: 1.10.4;
PR 10301: Change "oops" to something more interesting. (but less funny :-).
 1.9 11-Dec-2005  christos branches: 1.9.20; 1.9.22;
merge ktrace-lwp.
 1.8 25-Apr-2004  matt branches: 1.8.12;
remove #else clause of #if __STDC__
 1.7 27-May-2003  itojun branches: 1.7.2;
- don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.6 26-Feb-2003  matt Update for MBUFTRACE.
 1.5 26-Feb-2003  matt Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
 1.4 15-Nov-2001  lukem branches: 1.4.10;
don't need <sys/types.h> when including <sys/param.h>
 1.3 13-Nov-2001  lukem add RCSIDs
 1.2 27-Mar-1999  aidan branches: 1.2.20; 1.2.22;
Added per-addr input/output statistics. Currently just support netatalk
and netinet, currently only tested under netinet.

Disabled by default, enabled by compiling the kernel with option
IFA_STATS. Enabling this feature seems to make the ip_output function
take 13% longer than before, which should be OK for people that need
this feature.
 1.1 02-Apr-1997  christos branches: 1.1.14;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.14.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.2.22.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.20.2 08-Jan-2002  nathanw Catch up to -current.
 1.2.20.1 14-Nov-2001  nathanw Catch up to -current.
 1.4.10.1 19-Jun-2003  grant Apply patch (requested by itojun in ticket #1316):

- don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.12.3 21-Jan-2008  yamt sync with head
 1.8.12.2 26-Feb-2007  yamt sync with head.
 1.8.12.1 30-Dec-2006  yamt sync with head.
 1.9.22.1 22-Oct-2006  yamt sync with head
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.10.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.11.30.2 19-Jan-2008  bouyer Sync with HEAD
 1.11.30.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.26.1 26-Dec-2007  ad Sync with head.
 1.11.24.1 18-Feb-2008  mjf Sync with HEAD.
 1.11.18.2 23-Mar-2008  matt sync with HEAD
 1.11.18.1 09-Jan-2008  matt sync with HEAD
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.14.1 21-Apr-2012  riz Pull up following revision(s) (requested by hauke in ticket #1749):
sys/netatalk/aarp.c: revision 1.36
sys/netatalk/ddp_output.c: revision 1.16
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.
Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.
Needs to be pulled up to netbsd-5.
 1.15.6.1 18-Feb-2012  mrg merge to -current.
 1.15.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.15.2.1 17-Apr-2012  yamt sync with head
 1.16.10.1 18-May-2014  rmind sync with head
 1.16.6.2 03-Dec-2017  jdolecek update from HEAD
 1.16.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.3 05-Feb-2017  skrll Sync with HEAD
 1.17.6.2 09-Jul-2016  skrll Sync with HEAD
 1.17.6.1 19-Mar-2016  skrll Sync with HEAD
 1.19.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.21.34.1 31-Jul-2023  martin Pull up following revision(s) (requested by riastradh in ticket #278):

sys/netatalk/ddp_output.c: revision 1.22
sys/compat/common/if_43.c: revision 1.27
sys/netatalk/ddp_input.c: revision 1.34
sys/netatalk/at_control.c: revision 1.43

atalk(4): Don't abuse queue(9) internals.

atalk(4): Omit spurious satosat.
The input is already a struct sockaddr_at pointer.
 1.2 28-Apr-2008  martin branches: 1.2.4; 1.2.6;
Remove clause 3 and 4 from TNF licenses
 1.1 23-Apr-2008  thorpej branches: 1.1.2;
Make DDP stats per-cpu. While here, bump the counters to 64-bit and
make them available by sysctl.
 1.1.2.1 16-May-2008  yamt sync with head.
 1.2.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.6.1 28-Apr-2008  mjf file ddp_private.h was added on branch mjf-devfs2 on 2008-06-02 13:24:23 +0000
 1.2.4.2 18-May-2008  yamt sync with head.
 1.2.4.1 28-Apr-2008  yamt file ddp_private.h was added on branch yamt-pf42 on 2008-05-18 12:35:28 +0000
 1.76 03-Sep-2022  thorpej Convert NETATALK from a legacy netisr to pktqueue.
 1.75 21-Sep-2021  christos don't opencode kauth_cred_get()
 1.74 29-Nov-2019  maxv Add sanity check, only sat_len bytes got copied in, the rest is
uninitialized. Found by KMSAN.
 1.73 24-Feb-2019  maxv RIP, RIP6, DDP, SCTP and SCTP6 lack a length check in their _connect()
functions. Fix the first three, and add a big XXX in the SCTP ones.

Found by KASAN, triggered by SyzKaller.

Reported-by: syzbot+9eaf98dad6ca738c250d@syzkaller.appspotmail.com
 1.72 28-Jan-2019  martin Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
 1.71 17-Feb-2018  rjs branches: 1.71.4;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.70 08-Dec-2016  ozaki-r branches: 1.70.8;
Add rtcache_unref to release points of rtentry stemming from rtcache

In the MP-safe world, a rtentry stemming from a rtcache can be freed at any
points. So we need to protect rtentries somehow say by reference couting or
passive references. Regardless of the method, we need to call some release
function of a rtentry after using it.

The change adds a new function rtcache_unref to release a rtentry. At this
point, this function does nothing because for now we don't add a reference
to a rtentry when we get one from a rtcache. We will add something useful
in a further commit.

This change is a part of changes for MP-safe routing table. It is separated
to avoid one big change that makes difficult to debug by bisecting.
 1.69 03-Oct-2016  ozaki-r Fix race condition on ifqueue used by traditional netisr

If a underlying network device driver supports MSI/MSI-X, RX interrupts
can be delivered to arbitrary CPUs. This means that Layer 2 subroutines
such as ether_input (softint) and subsequent Layer 3 subroutines (softint)
which are called via traditional netisr can be dispatched on an arbitrary
CPU. Layer 2 subroutines now run without any locks (expected) and so a
Layer 2 subroutine and a Layer 3 subroutine can run in parallel.

There is a shared data between a Layer 2 routine and a Layer 3 routine,
that is ifqueue and IF_ENQUEUE (from L2) and IF_DEQUEUE (from L3) on it
are racy now.

To fix the race condition, use ifqueue#ifq_lock to protect ifqueue
instead of splnet that is meaningless now.

The same race condition exists in route_intr. Fix it as well.

Reviewed by knakahara@
 1.68 02-May-2015  rtr branches: 1.68.2;
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.67 26-Apr-2015  rtr remove pr_generic from struct pr_usrreqs and all implementations of
pr_generic in protocols.

bump to 7.99.13

approved by rmind@
 1.66 24-Apr-2015  rtr make at_pcbconnect() take sockaddr_at * instead of mbuf *.

move m_len check into callers which results in small duplication of
code that will go away when the callers are converted to receive
sockaddr * instead of mbuf *.
 1.65 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.64 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.63 09-Aug-2014  rtr branches: 1.63.2; 1.63.4; 1.63.6; 1.63.10;
split PRU_CONNECT2 & PRU_PURGEIF function out of pr_generic() usrreq
switches and put into separate functions

- always KASSERT(solocked(so)) even if not implemented
(for PRU_CONNECT2 only)

- replace calls to pr_generic() with req = PRU_CONNECT2 with calls to
pr_connect2()

- replace calls to pr_generic() with req = PRU_PURGEIF with calls to
pr_purgeif()

put common code from unp_connect2() (used by unp_connect() into
unp_connect1() and call out to it when needed

patch only briefly reviewed by rmind@
 1.62 08-Aug-2014  rtr 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.61 07-Aug-2014  rtr suppress possibly used uninitialized warning on sgimips

from martin@
 1.60 07-Aug-2014  rtr remove KASSERT(nam != NULL) from ddp_send() the following code makes
the validity of it questionable. we'll investigate later whether it
can be put back and the code simplified.
 1.59 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.58 05-Aug-2014  rtr revert the removal of struct lwp * parameter from bind, listen and connect
user requests.

this should resolve the issue relating to nfs client hangs presented
recently by wiz on current-users@
 1.57 31-Jul-2014  rtr split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions

xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)

- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively

rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().

- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()

patch reviewed by rmind
 1.56 30-Jul-2014  rtr split PRU_CONNECT function out of pr_generic() usrreq switches and put
into seaparate functions

xxx_listen(struct socket *, struct mbuf *)

- always KASSERT(solocked(so)) and KASSERT(nam != NULL)
- replace calls to pr_generic() with req = PRU_CONNECT with
pr_connect()
- rename existin {l2cap,sco,rfcomm}_connect() to
{l2cap,sco,rfcomm}_connect_pcb() respectively to permit
naming consistency with other protocols functions.
- drop struct lwp * parameter from unp_connect() and at_pcbconnect()
and use curlwp instead where appropriate.

patch reviewed by rmind
 1.55 24-Jul-2014  rtr split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreq
switches and put into separate functions
xxx_bind(struct socket *, struct mbuf *)
xxx_listen(struct socket *)

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

- replace calls to pr_generic() with req = PRU_BIND with call to
pr_bind()

- replace calls to pr_generic() with req = PRU_LISTEN with call to
pr_listen()

- drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and
unp_bind() and always use curlwp.

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_{bind,listen}() PRUs

- l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb()
- sco_{bind,listen}() -> sco_{bind,listen}_pcb()
- rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb()

patch reviewed by rmind

welcome to netbsd 6.99.48
 1.54 23-Jul-2014  rtr split PRU_SENDOOB and PRU_RCVOOB function out of pr_generic() usrreq
switches and put into separate functions
xxx_sendoob(struct socket *, struct mbuf *, struct mbuf *)
xxx_recvoob(struct socket *, struct mbuf *, int)

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

- replace calls to pr_generic() with req = PRU_{SEND,RCV}OOB with
calls to pr_{send,recv}oob() respectively.

there is still some tweaking of m_freem(m) and m_freem(control) to come
for consistency. not performed with this commit for clarity.

reviewed by rmind
 1.53 09-Jul-2014  rtr * split PRU_ACCEPT function out of pr_generic() usrreq switches and put
into a separate function xxx_accept(struct socket *, struct mbuf *)

note: future cleanup will take place to remove struct mbuf parameter
type and replace it with a more appropriate type.

patch reviewed by rmind
 1.52 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.51 07-Jul-2014  rtr * sprinkle KASSERT(solocked(so)); in all pr_stat() functions.
* fix remaining inconsistent struct socket parameter names.
 1.50 07-Jul-2014  rtr backout change that made pr_stat return EOPNOTSUPP for protocols that
were not filling in struct stat.

decision made after further discussion with rmind and investigation of
how other operating systems behave. soo_stat() is doing just enough to
be able to call what gets returned valid and thus justifys a return of
success.

additional review will be done to determine of the pr_stat functions
that were already returning EOPNOTSUPP can be considered successful with
what soo_stat() is doing.
 1.49 07-Jul-2014  rtr * have pr_stat return EOPNOTSUPP consistently for all protocols that do
not fill in struct stat instead of returning success.

* in pr_stat remove all checks for non-NULL so->so_pcb except where the
pcb is actually used (i.e. cases where we don't return EOPNOTSUPP).

proposed on tech-net@
 1.48 06-Jul-2014  rtr * split PRU_SENSE functionality out of xxx_usrreq() switches and place into
separate xxx_stat(struct socket *, struct stat *) functions.
* replace calls using pr_generic with req == PRU_SENSE with pr_stat().

further change will follow that cleans up the pattern used to extract the
pcb and test for its presence.

reviewed by rmind
 1.47 01-Jul-2014  rtr fix parameter types in pr_ioctl, called xx_control() functions and remove
abuse of pointer to struct mbuf type.

param2 changed to u_long type and uses parameter name 'cmd' (ioctl command)
param3 changed to void * type and uses parameter name 'data'
param4 changed to struct ifnet * and uses parameter name 'ifp'
param5 has been removed (formerly struct lwp *) and uses of 'l' have been
replaced with curlwp from curproc(9).

callers have had (now unnecessary) casts to struct mbuf * removed, called
code has had (now unnecessary) casts to u_long, void * and struct ifnet *
respectively removed.

reviewed by rmind@
 1.46 23-Jun-2014  rtr where appropriate rename xxx_ioctl() struct mbuf * parameters from
`control' to `ifp' after split from xxx_usrreq().

sys_socket.c
fix wrapping of arguments to be consistent with other function calls
in the file after replacing pr_usrreq() call with pr_ioctl() which
required one less argument.

link_proto.c
fix indentation of parameters in link_ioctl() prototype to be
consistent with the rest of the file.

discussed with rmind@
 1.45 22-Jun-2014  rtr * split PRU_CONTROL functionality out of xxx_userreq() switches and place
into separate xxx_ioctl() functions.
* place KASSERT(req != PRU_CONTROL) inside xxx_userreq() as it is now
inappropriate for req = PRU_CONTROL in xxx_userreq().
* replace calls to pr_generic() with req = PRU_CONTROL with pr_ioctl().
* remove & fixup references to PRU_CONTROL xxx_userreq() function comments.
* fix various comments references for xxx_userreq() that mentioned
PRU_CONTROL as xxx_userreq() no longer handles the request.

a further change will follow to fix parameter and naming inconsistencies
retained from original code.

Reviewed by rmind@
 1.44 20-May-2014  rmind Adjust PR_WRAP_USRREQS() to include the attach/detach functions.
We still need the kernel-lock for some corner cases.
 1.43 19-May-2014  rmind - Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.
 1.42 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.41 25-Feb-2014  pooka branches: 1.41.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.40 08-May-2011  bouyer branches: 1.40.4; 1.40.14; 1.40.18;
aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Should fix PR kern/44734
 1.39 16-Apr-2009  elad branches: 1.39.4; 1.39.6;
Remove three more trivial KAUTH_GENERIC_ISSUSER uses:

- Binding to privileged ports in netatalk and netiso
- Setting privileged socket options in netiso
 1.38 18-Mar-2009  cegger bzero -> memset
 1.37 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.36 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.35 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.34 17-Dec-2008  cegger branches: 1.34.2;
kill MALLOC and FREE macros.
 1.33 04-May-2008  thorpej branches: 1.33.8; 1.33.10;
Simplify the interface to netstat_sysctl() and allocate space for
the collated counters using kmem_alloc().

PR kern/38577
 1.32 24-Apr-2008  ad branches: 1.32.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.31 23-Apr-2008  thorpej Make DDP stats per-cpu. While here, bump the counters to 64-bit and
make them available by sysctl.
 1.30 28-Jan-2008  dyoung branches: 1.30.6; 1.30.8;
Make one call to rtcache_lookup() out of calls to rtcache_setdst()
and rtcache_init().
 1.29 14-Jan-2008  dyoung Use rtcache_validate() instead of rtcache_getrt().
 1.28 12-Jan-2008  dyoung Good-bye, rtcache_check(). Call both rtcache_validate() and
rtcache_update(,1) instead of rtcache_check().
 1.27 10-Jan-2008  dyoung Save a rtcache_getrt() call.
 1.26 20-Dec-2007  dyoung 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.
 1.25 02-May-2007  dyoung branches: 1.25.8; 1.25.14; 1.25.16; 1.25.20;
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.24 04-Mar-2007  christos branches: 1.24.2; 1.24.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 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.22 04-Jan-2007  elad branches: 1.22.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.21 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.20 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.19 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.18 10-Oct-2006  dogcow change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
 1.17 23-Jul-2006  ad branches: 1.17.4; 1.17.6;
Use the LWP cached credentials where sane.
 1.16 14-May-2006  elad integrate kauth.
 1.15 12-Apr-2006  christos Coverity CID 2852: Avoid NULL deref.
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
merge ktrace-lwp.
 1.13 26-Feb-2005  perry branches: 1.13.4;
nuke trailing whitespace
 1.12 18-Apr-2004  matt branches: 1.12.4; 1.12.6;
Use M_ZERO as appropriate. (fix an improper use of M_WAIT to M_WAITOK)
 1.11 29-Jun-2003  fvdl branches: 1.11.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.10 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.9 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.8 26-Feb-2003  matt Update for MBUFTRACE.
 1.7 12-May-2002  matt Eliminate commons.
 1.6 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.5 13-Nov-2001  lukem add RCSIDs
 1.4 02-Feb-2000  thorpej branches: 1.4.6; 1.4.8;
PRU_PURGEADDR -> PRU_PURGEIF, per a discussion w/ itojun. In the IPv4
and IPv6 code, also use this to traverse PCB tables, looking for cached
routes referencing the dying ifnet, forcing them to be refreshed.
 1.3 01-Feb-2000  thorpej First-draft if_detach() implementation, originally from Bill Studnemund,
although this version has been changed somewhat:
- reference counting on ifaddrs isn't as complete as Bill's original
work was. This is hard to get right, and we should attack one
protocol at a time.
- This doesn't do reference counting or dynamic allocation of ifnets yet.
- This version introduces a new PRU -- PRU_PURGEADDR, which is used to
purge an ifaddr from a protocol. The old method Bill used didn't work
on all protocols, and it only worked on some because it was Very Lucky.

This mostly works ... i.e. works for my USB Ethernet, except for a dangling
ifaddr reference left by the IPv6 code; have not yet tracked this down.
 1.2 29-Apr-1997  christos branches: 1.2.14; 1.2.22;
Increase the receive space to improve write performance. From Bill Studenmund
 1.1 02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.2.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.2.14.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.4.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.3 20-Jun-2002  nathanw Catch up to -current.
 1.4.6.2 08-Jan-2002  nathanw Catch up to -current.
 1.4.6.1 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.2 03-Aug-2004  skrll Sync with HEAD
 1.11.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.12.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.4.1 29-Apr-2005  kent sync with -current
 1.13.4.6 04-Feb-2008  yamt sync with head.
 1.13.4.5 21-Jan-2008  yamt sync with head
 1.13.4.4 03-Sep-2007  yamt sync with head.
 1.13.4.3 26-Feb-2007  yamt sync with head.
 1.13.4.2 30-Dec-2006  yamt sync with head.
 1.13.4.1 21-Jun-2006  yamt sync with head.
 1.14.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.10.4 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.14.10.3 19-Apr-2006  elad sync with head.
 1.14.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.14.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.14.8.2 11-Aug-2006  yamt sync with head
 1.14.8.1 24-May-2006  yamt sync with head.
 1.14.6.2 01-Jun-2006  kardel Sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.17.6.3 18-Dec-2006  yamt sync with head.
 1.17.6.2 10-Dec-2006  yamt sync with head.
 1.17.6.1 22-Oct-2006  yamt sync with head
 1.17.4.2 12-Jan-2007  ad Sync with head.
 1.17.4.1 18-Nov-2006  ad Sync with head.
 1.22.2.3 07-May-2007  yamt sync with head.
 1.22.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.22.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.24.4.1 11-Jul-2007  mjf Sync with head.
 1.24.2.1 08-Jun-2007  ad Sync with head.
 1.25.20.3 19-Jan-2008  bouyer Sync with HEAD
 1.25.20.2 10-Jan-2008  bouyer Sync with HEAD
 1.25.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.25.16.1 26-Dec-2007  ad Sync with head.
 1.25.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.25.8.2 23-Mar-2008  matt sync with HEAD
 1.25.8.1 09-Jan-2008  matt sync with HEAD
 1.30.8.1 18-May-2008  yamt sync with head.
 1.30.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.30.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.2.2 04-May-2009  yamt sync with head.
 1.32.2.1 16-May-2008  yamt sync with head.
 1.33.10.1 30-Jun-2011  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1622):
sys/netatalk/aarp.c: revision 1.35
sys/netatalk/aarp.h: revision 1.3
sys/netatalk/ddp_usrreq.c: revision 1.40

aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Fixes PR kern/44734
 1.33.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.33.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.39.4.1 31-May-2011  rmind sync with head
 1.40.18.2 18-May-2014  rmind sync with head
 1.40.18.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.40.14.2 03-Dec-2017  jdolecek update from HEAD
 1.40.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.4.1 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.41.2.1 10-Aug-2014  tls Rebase.
 1.63.10.1 29-Jan-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1676):
sys/net/link_proto.c 1.37
sys/netatalk/ddp_usrreq.c 1.72
sys/netbt/hci_socket.c 1.46
sys/netbt/l2cap_socket.c 1.36
sys/netbt/rfcomm_socket.c 1.38
sys/netbt/sco_socket.c 1.38
sys/netinet/tcp_usrreq.c 1.223 via patch
sys/netinet6/raw_ip6.c 1.173
sys/netinet6/udp6_usrreq.c 1.146
sys/netmpls/mpls_proto.c 1.32
sys/netnatm/natm.c patch

Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
 1.63.6.1 29-Jan-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1676):
sys/net/link_proto.c 1.37
sys/netatalk/ddp_usrreq.c 1.72
sys/netbt/hci_socket.c 1.46
sys/netbt/l2cap_socket.c 1.36
sys/netbt/rfcomm_socket.c 1.38
sys/netbt/sco_socket.c 1.38
sys/netinet/tcp_usrreq.c 1.223 via patch
sys/netinet6/raw_ip6.c 1.173
sys/netinet6/udp6_usrreq.c 1.146
sys/netmpls/mpls_proto.c 1.32
sys/netnatm/natm.c patch

Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
 1.63.4.4 05-Feb-2017  skrll Sync with HEAD
 1.63.4.3 05-Oct-2016  skrll Sync with HEAD
 1.63.4.2 06-Jun-2015  skrll Sync with HEAD
 1.63.4.1 06-Apr-2015  skrll Sync with HEAD
 1.63.2.1 29-Jan-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1676):
sys/net/link_proto.c 1.37
sys/netatalk/ddp_usrreq.c 1.72
sys/netbt/hci_socket.c 1.46
sys/netbt/l2cap_socket.c 1.36
sys/netbt/rfcomm_socket.c 1.38
sys/netbt/sco_socket.c 1.38
sys/netinet/tcp_usrreq.c 1.223 via patch
sys/netinet6/raw_ip6.c 1.173
sys/netinet6/udp6_usrreq.c 1.146
sys/netmpls/mpls_proto.c 1.32
sys/netnatm/natm.c patch

Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
 1.68.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.68.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.70.8.1 29-Jan-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1175):
sys/net/link_proto.c 1.37
sys/netatalk/ddp_usrreq.c 1.72
sys/netbt/hci_socket.c 1.46
sys/netbt/l2cap_socket.c 1.36
sys/netbt/rfcomm_socket.c 1.38
sys/netbt/sco_socket.c 1.38
sys/netinet/sctp_usrreq.c 1.14
sys/netinet/tcp_usrreq.c 1.223
sys/netinet6/raw_ip6.c 1.173
sys/netinet6/sctp6_usrreq.c 1.17
sys/netinet6/udp6_usrreq.c 1.146
sys/netmpls/mpls_proto.c 1.32
sys/netnatm/natm.c patch

Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
 1.71.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.71.4.1 10-Jun-2019  christos Sync with HEAD
 1.4 23-Apr-2008  thorpej Make DDP stats per-cpu. While here, bump the counters to 64-bit and
make them available by sysctl.
 1.3 10-Dec-2005  elad branches: 1.3.70; 1.3.72;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.2 12-May-2002  matt branches: 1.2.10; 1.2.26;
Eliminate commons.
 1.1 02-Apr-1997  christos branches: 1.1.34; 1.1.36;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.36.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.34.1 20-Jun-2002  nathanw Catch up to -current.
 1.2.26.1 21-Jun-2006  yamt sync with head.
 1.2.10.1 11-Dec-2005  christos Sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.4 17-Feb-2018  rjs Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.3 08-Dec-2014  uebayasi Define netatalk module.
 1.2 02-Dec-2014  christos - s/u_intX/uintX/
- add routines to print sockaddr_at and ataddr.
 1.1 10-Oct-2002  thorpej branches: 1.1.2; 1.1.156; 1.1.176;
Move netatalk config defns to netatalk/files.netatalk.
 1.1.176.1 06-Apr-2015  skrll Sync with HEAD
 1.1.156.1 03-Dec-2017  jdolecek update from HEAD
 1.1.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.1 10-Oct-2002  nathanw file files.netatalk was added on branch nathanw_sa on 2002-10-18 02:45:14 +0000
 1.3 06-Sep-2015  dholland More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
 1.2 10-Dec-2005  elad branches: 1.2.120; 1.2.140;
Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
 1.1 02-Apr-1997  christos branches: 1.1.56; 1.1.72;
Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.1.72.1 21-Jun-2006  yamt sync with head.
 1.1.56.1 11-Dec-2005  christos Sync with head.
 1.2.140.1 22-Sep-2015  skrll Sync with HEAD
 1.2.120.1 03-Dec-2017  jdolecek update from HEAD

RSS XML Feed