Home | History | Annotate | Download | only in net
History log of /src/sys/net/radix.c
RevisionDateAuthorComments
 1.49  18-Oct-2020  gson Suppress the "rn_init: radix functions require max_keylen be set"
message when _KERNEL is defined, to avoid spurious messages from
kernels that have no routable network domains. Fixes PR kern/55691.
 1.48  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.47  12-Dec-2016  ozaki-r branches: 1.47.14; 1.47.16;
Make the routing table and rtcaches MP-safe

See the following descriptions for details.

Proposed on tech-kern and tech-net


Overview
 1.46  15-Nov-2016  ozaki-r Don't use rt_walktree to delete routes

Some functions use rt_walktree to scan the routing table and delete
matched routes. However, we shouldn't use rt_walktree to delete
routes because rt_walktree is recursive to the routing table (radix
tree) and isn't friendly to MP-ification. rt_walktree allows a caller
to pass a callback function to delete an matched entry. The callback
function is called from an API of the radix tree (rn_walktree) but
also calls an API of the radix tree to delete an entry.

This change adds a new API of the radix tree, rn_search_matched,
which returns a matched entry that is selected by a callback
function passed by a caller and the caller itself deletes the
entry. By using the API, we can avoid the recursive form.
 1.45  24-Aug-2015  pooka branches: 1.45.2;
sprinkle _KERNEL_OPT
 1.44  17-Jul-2011  joerg branches: 1.44.12; 1.44.30;
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.43  27-May-2009  pooka Make it possible to register delayed radix tree head inits which
will be processed when the radix "subsystem" is initialized -- all
users must be attached before any inits to know the max keylength.
Use of link sets is no longer required, and only attached domains
need to be considered.
 1.42  15-Mar-2009  cegger ansify function definitions
 1.41  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.40  25-Nov-2008  pooka branches: 1.40.4;
Make dom_maxrtkey of inet/inet6domain the size of the ip_encap pack
structures. This is far from optimal, but gets rid of iffy
#ifdef INET in radix.c. The radix bonsai still needs lots of love
before loading domains dynamically is possible...
 1.39  11-May-2008  dyoung branches: 1.39.4; 1.39.6;
Use memset, memmove, and memcmp instead of Bzero, Bcopy, and Bcmp,
respectively.
 1.38  12-Jul-2007  dyoung branches: 1.38.28; 1.38.30; 1.38.32; 1.38.34;
Cosmetic: KNF. Shorten a staircase.
 1.37  11-Jul-2007  dyoung Cosmetic: KNF.
 1.36  13-Jun-2007  dyoung Remove unnecessary __UNCONST().
 1.35  09-Jun-2007  dyoung Get rid of radix_node_head.rnh_walktree, because it is only ever
set to rn_walktree.

Introduce rt_walktree(), which applies a subroutine to every route
in a particular address family. Use it instead of rn_walktree()
virtually everywhere. This helps to hide the routing table
implementation.
 1.34  04-Mar-2007  christos branches: 1.34.2; 1.34.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33  17-Feb-2007  dyoung branches: 1.33.2;
Clean this code up some.

Extract subroutine rn_delete1() to ease RADIX_MPATH integration,
should we ever do that.

Remove RN_DEBUG code that does not compile.

Join some lines of the type

type var1;
type var2;
type var3;

making

type var1, var2, var3.

Break lines of the type if (expr) stmt1; else stmt2; so that normal
people can read them.
 1.32  04-Dec-2006  dyoung Extract subroutines rn_walkfirst() and rn_walknext() from rn_walktree().
No functional change intended.

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

XXX The format of the diagnostic print-outs needs improvement.
 1.31  25-Feb-2006  wiz branches: 1.31.14; 1.31.16;
Fix typos, reported by Alexey Dobriyan ("Gathered from Linux"),
forwarded by jmc@openbsd.
 1.30  11-Dec-2005  christos branches: 1.30.2; 1.30.4; 1.30.6;
merge ktrace-lwp.
 1.29  29-May-2005  christos branches: 1.29.2;
- sprinkle const
- remove unneeded casts
- use more mem*() instead of b*() funcs.
 1.28  26-Feb-2005  perry nuke trailing whitespace
 1.27  24-Jan-2005  enami branches: 1.27.2;
To fix bad pointer dereference on start up when gif is used,
- Allow rn_init() to be called multiple times, but do nothing except the
first call.
- Include opt_inet.h so that #ifdef INET works.
- Call rn_init() from encap_init() explicitly rather than depending on the
order of initialization.
 1.26  23-Jan-2005  matt Change initialzie of domains to use link sets. Switch to using STAILQ.
Add a convenience macro DOMAIN_FOREACH to interate through the domain.
 1.25  06-Dec-2004  christos branches: 1.25.4;
Sprinkle #ifdef INET to make a GENERIC kernel compile with INET undefined.
 1.24  17-Aug-2004  itojun initialize max_keylen for ip_encap.c earlier
 1.23  21-Apr-2004  matt ANSI-fy and some additional de-__P and constification.
 1.22  21-Apr-2004  christos fix constification botch. (hi gimpy)
 1.21  21-Apr-2004  matt Constify if.c radix.c and route.c (and fix related fallout).
 1.20  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19  25-Nov-2002  thorpej branches: 1.19.6;
Avoid strict-alias warnings.
 1.18  12-Nov-2001  lukem add RCSIDs
 1.17  10-Jan-2001  itojun branches: 1.17.2; 1.17.4;
fix indentation
 1.16  04-Jan-2001  enami Missing newline in log messsage.
 1.15  17-Dec-2000  itojun fix typo in function name (rn_satsifies_leaf -> satisfies). indent.
split rn_inithead() into two function - i'm putting some hook around here.
 1.14  30-Mar-2000  augustss Kill some more register declarations.
 1.13  01-Mar-1998  fvdl branches: 1.13.12; 1.13.14;
Merge with Lite2 + local changes
 1.12  02-Apr-1997  christos Sync with Lite2.
 1.11  16-Mar-1996  christos - fix misparenthesized ((a&(B|C) == 0))
- fix printf format arguments
 1.10  13-Feb-1996  christos Net prototypes
 1.9  17-May-1995  mycroft Newer version from CSRG.
 1.8  28-Mar-1995  jtc KERNEL -> _KERNEL
 1.7  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.6  13-May-1994  mycroft Update to 4.4-Lite networking code, with a few local changes.
 1.5  14-Mar-1994  glass put declarations in argument order
 1.4  18-Dec-1993  mycroft Canonicalize all #includes.
 1.3  04-Sep-1993  jtc branches: 1.3.2;
include systm.h to get prototypes (and possibly inlines) of *max functions.
 1.2  20-May-1993  cgd add rcs ids to everything, and clean up headers
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.4  01-Mar-1998  fvdl Import some files that were changed after Lite2
 1.1.1.3  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3.2.2  14-Nov-1993  mycroft Munged a directory name in last change.
 1.3.2.1  14-Nov-1993  mycroft Canonicalize all #includes.
 1.13.14.3  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.13.14.2  05-Jan-2001  bouyer Sync with HEAD
 1.13.14.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.13.12.3  30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

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

synchronization to latest KAME will take place on HEAD branch soon.
 1.13.12.2  06-Jul-1999  itojun KAME/NetBSD 1.4, SNAP kit 1999/07/05.
NOTE: this branch is just for reference purposes (i.e. for taking cvs diff).
do not touch anything on the branch. actual work must be done on HEAD branch.
 1.13.12.1  28-Jun-1999  itojun KAME/NetBSD 1.4 SNAP kit, dated 19990628.

NOTE: this branch (kame) is used just for refernce. this may not compile
due to multiple reasons.
 1.17.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.2  11-Dec-2002  thorpej Sync with HEAD.
 1.17.2.1  14-Nov-2001  nathanw Catch up to -current.
 1.19.6.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.6.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.6.6  24-Jan-2005  skrll Sync with HEAD.
 1.19.6.5  18-Dec-2004  skrll Sync with HEAD.
 1.19.6.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.6.3  18-Sep-2004  skrll Sync with HEAD.
 1.19.6.2  25-Aug-2004  skrll Sync with HEAD.
 1.19.6.1  03-Aug-2004  skrll Sync with HEAD
 1.25.4.1  29-Apr-2005  kent sync with -current
 1.27.2.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.2.4  03-Sep-2007  yamt sync with head.
 1.29.2.3  26-Feb-2007  yamt sync with head.
 1.29.2.2  30-Dec-2006  yamt sync with head.
 1.29.2.1  21-Jun-2006  yamt sync with head.
 1.30.6.1  22-Apr-2006  simonb Sync with head.
 1.30.4.1  09-Sep-2006  rpaulo sync with head
 1.30.2.1  01-Mar-2006  yamt sync with head.
 1.31.16.1  10-Dec-2006  yamt sync with head.
 1.31.14.1  12-Jan-2007  ad Sync with head.
 1.33.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.33.2.1  17-Feb-2007  rmind file radix.c was added on branch yamt-idlelwp on 2007-03-12 05:59:15 +0000
 1.34.4.1  11-Jul-2007  mjf Sync with head.
 1.34.2.1  15-Jul-2007  ad Sync with head.
 1.38.34.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.38.32.3  20-Jun-2009  yamt sync with head
 1.38.32.2  04-May-2009  yamt sync with head.
 1.38.32.1  16-May-2008  yamt sync with head.
 1.38.30.1  18-May-2008  yamt sync with head.
 1.38.28.2  17-Jan-2009  mjf Sync with HEAD.
 1.38.28.1  02-Jun-2008  mjf Sync with HEAD.
 1.39.6.2  28-Apr-2009  skrll Sync with HEAD.
 1.39.6.1  19-Jan-2009  skrll Sync with HEAD.
 1.39.4.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.40.4.2  23-Jul-2009  jym Sync with HEAD.
 1.40.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.44.30.3  05-Feb-2017  skrll Sync with HEAD
 1.44.30.2  05-Dec-2016  skrll Sync with HEAD
 1.44.30.1  22-Sep-2015  skrll Sync with HEAD
 1.44.12.1  03-Dec-2017  jdolecek update from HEAD
 1.45.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.16.1  10-Jun-2019  christos Sync with HEAD
 1.47.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)

RSS XML Feed