2005-01-07 02:30:35 +00:00
|
|
|
/*-
|
1999-11-22 02:45:11 +00:00
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2007-12-10 16:03:40 +00:00
|
|
|
*
|
|
|
|
* $KAME: in6_rmx.c,v 1.11 2001/07/26 06:53:16 jinmei Exp $
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
|
2005-01-07 02:30:35 +00:00
|
|
|
/*-
|
1999-11-22 02:45:11 +00:00
|
|
|
* Copyright 1994, 1995 Massachusetts Institute of Technology
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and
|
|
|
|
* its documentation for any purpose and without fee is hereby
|
|
|
|
* granted, provided that both the above copyright notice and this
|
|
|
|
* permission notice appear in all copies, that both the above
|
|
|
|
* copyright notice and this permission notice appear in all
|
|
|
|
* supporting documentation, and that the name of M.I.T. not be used
|
|
|
|
* in advertising or publicity pertaining to distribution of the
|
|
|
|
* software without specific, written prior permission. M.I.T. makes
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
* warranty.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
|
|
|
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
|
|
|
* SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-12-10 16:03:40 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2008-12-08 00:28:21 +00:00
|
|
|
#include <sys/lock.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/mbuf.h>
|
2008-12-07 21:15:43 +00:00
|
|
|
#include <sys/rwlock.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/syslog.h>
|
2003-10-04 03:44:50 +00:00
|
|
|
#include <sys/callout.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2009-06-23 14:54:42 +00:00
|
|
|
#include <net/route.h>
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
#include <net/route_var.h>
|
2008-12-02 21:37:28 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/ip_var.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
#include <netinet/ip6.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <netinet6/ip6_var.h>
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
#include <netinet/icmp6.h>
|
2003-10-20 15:27:48 +00:00
|
|
|
#include <netinet6/nd6.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/tcp_seq.h>
|
|
|
|
#include <netinet/tcp_timer.h>
|
|
|
|
#include <netinet/tcp_var.h>
|
|
|
|
|
2008-01-08 19:08:58 +00:00
|
|
|
extern int in6_inithead(void **head, int off);
|
Introduce an infrastructure for dismantling vnet instances.
Vnet modules and protocol domains may now register destructor
functions to clean up and release per-module state. The destructor
mechanisms can be triggered by invoking "vimage -d", or a future
equivalent command which will be provided via the new jail framework.
While this patch introduces numerous placeholder destructor functions,
many of those are currently incomplete, thus leaking memory or (even
worse) failing to stop all running timers. Many of such issues are
already known and will be incrementaly fixed over the next weeks in
smaller incremental commits.
Apart from introducing new fields in structs ifnet, domain, protosw
and vnet_net, which requires the kernel and modules to be rebuilt, this
change should have no impact on nooptions VIMAGE builds, since vnet
destructors can only be called in VIMAGE kernels. Moreover,
destructor functions should be in general compiled in only in
options VIMAGE builds, except for kernel modules which can be safely
kldunloaded at run time.
Bump __FreeBSD_version to 800097.
Reviewed by: bz, julian
Approved by: rwatson, kib (re), julian (mentor)
2009-06-08 17:15:40 +00:00
|
|
|
#ifdef VIMAGE
|
|
|
|
extern int in6_detachhead(void **head, int off);
|
|
|
|
#endif
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do what we need to do when inserting a route.
|
|
|
|
*/
|
|
|
|
static struct radix_node *
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
in6_addroute(void *v_arg, void *n_arg, struct radix_head *head,
|
2007-07-05 16:29:40 +00:00
|
|
|
struct radix_node *treenodes)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct rtentry *rt = (struct rtentry *)treenodes;
|
|
|
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt);
|
|
|
|
|
|
|
|
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
|
|
|
rt->rt_flags |= RTF_MULTICAST;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A little bit of help for both IPv6 output and input:
|
|
|
|
* For local addresses, we make sure that RTF_LOCAL is set,
|
|
|
|
* with the thought that this might one day be used to speed up
|
|
|
|
* ip_input().
|
|
|
|
*
|
|
|
|
* We also mark routes to multicast addresses as such, because
|
|
|
|
* it's easy to do and might be useful (but this is much more
|
|
|
|
* dubious since it's so easy to inspect the address). (This
|
|
|
|
* is done above.)
|
|
|
|
*
|
|
|
|
* XXX
|
|
|
|
* should elaborate the code.
|
|
|
|
*/
|
|
|
|
if (rt->rt_flags & RTF_HOST) {
|
|
|
|
if (IN6_ARE_ADDR_EQUAL(&satosin6(rt->rt_ifa->ifa_addr)
|
|
|
|
->sin6_addr,
|
|
|
|
&sin6->sin6_addr)) {
|
|
|
|
rt->rt_flags |= RTF_LOCAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Make checks for rt_mtu generic:
Some virtual if drivers has (ab)used ifa ifa_rtrequest hook to enforce
route MTU to be not bigger that interface MTU. While ifa_rtrequest hooking
might be an option in some situation, it is not feasible to do MTU checks
there: generic (or per-domain) routing code is perfectly capable of doing
this.
We currrently have 3 places where MTU is altered:
1) route addition.
In this case domain overrides radix _addroute callback (in[6]_addroute)
and all necessary checks/fixes are/can be done there.
2) route change (especially, GW change).
In this case, there are no explicit per-domain calls, but one can
override rte by setting ifa_rtrequest hook to domain handler
(inet6 does this).
3) ifconfig ifaceX mtu YYYY
In this case, we have no callbacks, but ip[6]_output performes runtime
checks and decreases rt_mtu if necessary.
Generally, the goals are to be able to handle all MTU changes in
control plane, not in runtime part, and properly deal with increased
interface MTU.
This commit changes the following:
* removes hooks setting MTU from drivers side
* adds proper per-doman MTU checks for case 1)
* adds generic MTU check for case 2)
* The latter is done by using new dom_ifmtu callback since
if_mtu denotes L3 interface MTU, e.g. maximum trasmitted _packet_ size.
However, IPv6 mtu might be different from if_mtu one (e.g. default 1280)
for some cases, so we need an abstract way to know maximum MTU size
for given interface and domain.
* moves rt_setmetrics() before MTU/ifa_rtrequest hooks since it copies
user-supplied data which must be checked.
* removes RT_LOCK_ASSERT() from other ifa_rtrequest hooks to be able to
use this functions on new non-inserted rte.
More changes will follow soon.
MFC after: 1 month
Sponsored by: Yandex LLC
2014-11-06 13:13:09 +00:00
|
|
|
if (rt->rt_ifp != NULL) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check route MTU:
|
|
|
|
* inherit interface MTU if not set or
|
|
|
|
* check if MTU is too large.
|
|
|
|
*/
|
|
|
|
if (rt->rt_mtu == 0) {
|
|
|
|
rt->rt_mtu = IN6_LINKMTU(rt->rt_ifp);
|
|
|
|
} else if (rt->rt_mtu > IN6_LINKMTU(rt->rt_ifp))
|
|
|
|
rt->rt_mtu = IN6_LINKMTU(rt->rt_ifp);
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2016-01-09 11:41:37 +00:00
|
|
|
return (rn_addroute(v_arg, n_arg, head, treenodes));
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Age old PMTUs.
|
|
|
|
*/
|
|
|
|
struct mtuex_arg {
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
struct rib_head *rnh;
|
1999-11-22 02:45:11 +00:00
|
|
|
time_t nextstop;
|
|
|
|
};
|
2010-11-22 19:32:54 +00:00
|
|
|
static VNET_DEFINE(struct callout, rtq_mtutimer);
|
2009-07-16 21:13:04 +00:00
|
|
|
#define V_rtq_mtutimer VNET(rtq_mtutimer)
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
static int
|
2015-08-08 18:14:59 +00:00
|
|
|
in6_mtuexpire(struct rtentry *rt, void *rock)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct mtuex_arg *ap = rock;
|
|
|
|
|
2014-03-05 01:17:47 +00:00
|
|
|
if (rt->rt_expire && !(rt->rt_flags & RTF_PROBEMTU)) {
|
|
|
|
if (rt->rt_expire <= time_uptime) {
|
1999-11-22 02:45:11 +00:00
|
|
|
rt->rt_flags |= RTF_PROBEMTU;
|
|
|
|
} else {
|
2014-03-05 01:17:47 +00:00
|
|
|
ap->nextstop = lmin(ap->nextstop, rt->rt_expire);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-08 18:14:59 +00:00
|
|
|
return (0);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MTUTIMO_DEFAULT (60*1)
|
|
|
|
|
|
|
|
static void
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
in6_mtutimo_setwa(struct rib_head *rnh, uint32_t fibum, int af,
|
2015-08-10 20:50:31 +00:00
|
|
|
void *_arg)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
2015-08-08 18:14:59 +00:00
|
|
|
struct mtuex_arg *arg;
|
|
|
|
|
|
|
|
arg = (struct mtuex_arg *)_arg;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2015-08-08 18:14:59 +00:00
|
|
|
arg->rnh = rnh;
|
2012-02-03 13:08:44 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2012-02-03 13:08:44 +00:00
|
|
|
static void
|
|
|
|
in6_mtutimo(void *rock)
|
|
|
|
{
|
|
|
|
CURVNET_SET_QUIET((struct vnet *) rock);
|
|
|
|
struct timeval atv;
|
2015-08-08 18:14:59 +00:00
|
|
|
struct mtuex_arg arg;
|
2012-02-03 13:08:44 +00:00
|
|
|
|
2015-08-10 20:50:31 +00:00
|
|
|
rt_foreach_fib_walk(AF_INET6, in6_mtutimo_setwa, in6_mtuexpire, &arg);
|
2012-02-03 13:08:44 +00:00
|
|
|
|
|
|
|
atv.tv_sec = MTUTIMO_DEFAULT;
|
|
|
|
atv.tv_usec = 0;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
callout_reset(&V_rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock);
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
CURVNET_RESTORE();
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize our routing tree.
|
|
|
|
*/
|
2012-02-03 13:08:44 +00:00
|
|
|
static VNET_DEFINE(int, _in6_rt_was_here);
|
|
|
|
#define V__in6_rt_was_here VNET(_in6_rt_was_here)
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
int
|
|
|
|
in6_inithead(void **head, int off)
|
|
|
|
{
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
struct rib_head *rh;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3);
|
|
|
|
if (rh == NULL)
|
2014-11-05 00:58:01 +00:00
|
|
|
return (0);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route)
with different requirements. In fact, first 3 don't have _any_ requirements
and first 2 does not use radix locking. On the other hand, routing
structure do have these requirements (rnh_gen, multipath, custom
to-be-added control plane functions, different locking).
Additionally, radix should not known anything about its consumers internals.
So, radix code now uses tiny 'struct radix_head' structure along with
internal 'struct radix_mask_head' instead of 'struct radix_node_head'.
Existing consumers still uses the same 'struct radix_node_head' with
slight modifications: they need to pass pointer to (embedded)
'struct radix_head' to all radix callbacks.
Routing code now uses new 'struct rib_head' with different locking macro:
RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing
information base).
New net/route_var.h header was added to hold routing subsystem internal
data. 'struct rib_head' was placed there. 'struct rtentry' will also
be moved there soon.
2016-01-25 06:33:15 +00:00
|
|
|
rh->rnh_addaddr = in6_addroute;
|
|
|
|
*head = (void *)rh;
|
2012-02-03 13:08:44 +00:00
|
|
|
|
|
|
|
if (V__in6_rt_was_here == 0) {
|
2015-05-22 17:05:21 +00:00
|
|
|
callout_init(&V_rtq_mtutimer, 1);
|
2012-02-03 13:08:44 +00:00
|
|
|
in6_mtutimo(curvnet); /* kick off timeout first time */
|
|
|
|
V__in6_rt_was_here = 1;
|
|
|
|
}
|
|
|
|
|
2014-11-05 00:58:01 +00:00
|
|
|
return (1);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
Introduce an infrastructure for dismantling vnet instances.
Vnet modules and protocol domains may now register destructor
functions to clean up and release per-module state. The destructor
mechanisms can be triggered by invoking "vimage -d", or a future
equivalent command which will be provided via the new jail framework.
While this patch introduces numerous placeholder destructor functions,
many of those are currently incomplete, thus leaking memory or (even
worse) failing to stop all running timers. Many of such issues are
already known and will be incrementaly fixed over the next weeks in
smaller incremental commits.
Apart from introducing new fields in structs ifnet, domain, protosw
and vnet_net, which requires the kernel and modules to be rebuilt, this
change should have no impact on nooptions VIMAGE builds, since vnet
destructors can only be called in VIMAGE kernels. Moreover,
destructor functions should be in general compiled in only in
options VIMAGE builds, except for kernel modules which can be safely
kldunloaded at run time.
Bump __FreeBSD_version to 800097.
Reviewed by: bz, julian
Approved by: rwatson, kib (re), julian (mentor)
2009-06-08 17:15:40 +00:00
|
|
|
|
|
|
|
#ifdef VIMAGE
|
|
|
|
int
|
|
|
|
in6_detachhead(void **head, int off)
|
|
|
|
{
|
|
|
|
|
|
|
|
callout_drain(&V_rtq_mtutimer);
|
2015-12-22 14:53:19 +00:00
|
|
|
return (rn_detachhead(head));
|
Introduce an infrastructure for dismantling vnet instances.
Vnet modules and protocol domains may now register destructor
functions to clean up and release per-module state. The destructor
mechanisms can be triggered by invoking "vimage -d", or a future
equivalent command which will be provided via the new jail framework.
While this patch introduces numerous placeholder destructor functions,
many of those are currently incomplete, thus leaking memory or (even
worse) failing to stop all running timers. Many of such issues are
already known and will be incrementaly fixed over the next weeks in
smaller incremental commits.
Apart from introducing new fields in structs ifnet, domain, protosw
and vnet_net, which requires the kernel and modules to be rebuilt, this
change should have no impact on nooptions VIMAGE builds, since vnet
destructors can only be called in VIMAGE kernels. Moreover,
destructor functions should be in general compiled in only in
options VIMAGE builds, except for kernel modules which can be safely
kldunloaded at run time.
Bump __FreeBSD_version to 800097.
Reviewed by: bz, julian
Approved by: rwatson, kib (re), julian (mentor)
2009-06-08 17:15:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-02-03 09:33:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Extended API for IPv6 FIB support.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
in6_rtredirect(struct sockaddr *dst, struct sockaddr *gw, struct sockaddr *nm,
|
|
|
|
int flags, struct sockaddr *src, u_int fibnum)
|
|
|
|
{
|
|
|
|
|
|
|
|
rtredirect_fib(dst, gw, nm, flags, src, fibnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
in6_rtrequest(int req, struct sockaddr *dst, struct sockaddr *gw,
|
|
|
|
struct sockaddr *mask, int flags, struct rtentry **ret_nrt, u_int fibnum)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (rtrequest_fib(req, dst, gw, mask, flags, ret_nrt, fibnum));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
in6_rtalloc(struct route_in6 *ro, u_int fibnum)
|
|
|
|
{
|
|
|
|
|
|
|
|
rtalloc_ign_fib((struct route *)ro, 0ul, fibnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
in6_rtalloc_ign(struct route_in6 *ro, u_long ignflags, u_int fibnum)
|
|
|
|
{
|
|
|
|
|
|
|
|
rtalloc_ign_fib((struct route *)ro, ignflags, fibnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct rtentry *
|
|
|
|
in6_rtalloc1(struct sockaddr *dst, int report, u_long ignflags, u_int fibnum)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (rtalloc1_fib(dst, report, ignflags, fibnum));
|
|
|
|
}
|