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: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
|
2007-12-10 16:03:40 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_inet6.h"
|
2009-02-27 14:12:05 +00:00
|
|
|
#include "opt_route.h"
|
2000-07-04 16:35:15 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#include <sys/time.h>
|
2001-06-11 12:39:29 +00:00
|
|
|
#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/errno.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>
|
2001-06-11 12:39:29 +00:00
|
|
|
#include <sys/queue.h>
|
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
|
|
|
#include <sys/vimage.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/radix.h>
|
2008-12-02 21:37:28 +00:00
|
|
|
#include <net/vnet.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
#include <net/if_llatbl.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
#include <netinet6/in6_var.h>
|
2001-06-11 12:39:29 +00:00
|
|
|
#include <netinet6/in6_ifattach.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>
|
|
|
|
#include <netinet6/nd6.h>
|
2000-07-04 16:35:15 +00:00
|
|
|
#include <netinet/icmp6.h>
|
|
|
|
#include <netinet6/scope6_var.h>
|
2008-12-02 21:37:28 +00:00
|
|
|
#include <netinet6/vinet6.h>
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-01-08 19:08:58 +00:00
|
|
|
static int rtpref(struct nd_defrouter *);
|
|
|
|
static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *);
|
2005-10-21 16:23:01 +00:00
|
|
|
static int prelist_update __P((struct nd_prefixctl *, struct nd_defrouter *,
|
|
|
|
struct mbuf *, int));
|
2008-01-08 19:08:58 +00:00
|
|
|
static struct in6_ifaddr *in6_ifadd(struct nd_prefixctl *, int);
|
2000-07-04 16:35:15 +00:00
|
|
|
static struct nd_pfxrouter *pfxrtr_lookup __P((struct nd_prefix *,
|
2001-06-11 12:39:29 +00:00
|
|
|
struct nd_defrouter *));
|
2008-01-08 19:08:58 +00:00
|
|
|
static void pfxrtr_add(struct nd_prefix *, struct nd_defrouter *);
|
|
|
|
static void pfxrtr_del(struct nd_pfxrouter *);
|
2000-07-04 16:35:15 +00:00
|
|
|
static struct nd_pfxrouter *find_pfxlist_reachable_router
|
2008-01-08 19:08:58 +00:00
|
|
|
(struct nd_prefix *);
|
|
|
|
static void defrouter_delreq(struct nd_defrouter *);
|
|
|
|
static void nd6_rtmsg(int, struct rtentry *);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-01-08 19:08:58 +00:00
|
|
|
static int in6_init_prefix_ltimes(struct nd_prefix *);
|
2003-10-09 16:13:47 +00:00
|
|
|
static void in6_init_address_ltimes __P((struct nd_prefix *,
|
|
|
|
struct in6_addrlifetime *));
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-01-08 19:08:58 +00:00
|
|
|
static int rt6_deleteroute(struct radix_node *, void *);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-11-26 22:32:07 +00:00
|
|
|
#ifdef VIMAGE_GLOBALS
|
2000-07-04 16:35:15 +00:00
|
|
|
extern int nd6_recalc_reachtm_interval;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
static struct ifnet *nd6_defifp;
|
2000-07-04 16:35:15 +00:00
|
|
|
int nd6_defifindex;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2008-11-19 09:39:34 +00:00
|
|
|
int ip6_use_tempaddr;
|
2001-06-11 12:39:29 +00:00
|
|
|
int ip6_desync_factor;
|
2008-11-19 09:39:34 +00:00
|
|
|
u_int32_t ip6_temp_preferred_lifetime;
|
|
|
|
u_int32_t ip6_temp_valid_lifetime;
|
|
|
|
int ip6_temp_regen_advance;
|
|
|
|
#endif
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/* RTPREF_MEDIUM has to be 0! */
|
|
|
|
#define RTPREF_HIGH 1
|
|
|
|
#define RTPREF_MEDIUM 0
|
|
|
|
#define RTPREF_LOW (-1)
|
|
|
|
#define RTPREF_RESERVED (-2)
|
|
|
|
#define RTPREF_INVALID (-3) /* internal */
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
|
|
|
* Receive Router Solicitation Message - just for routers.
|
|
|
|
* Router solicitation/advertisement is mostly managed by userland program
|
|
|
|
* (rtadvd) so here we have no function like nd6_ra_output().
|
|
|
|
*
|
|
|
|
* Based on RFC 2461
|
|
|
|
*/
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_rs_input(struct mbuf *m, int off, int icmp6len)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ifnet *ifp = m->m_pkthdr.rcvif;
|
|
|
|
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
2000-07-04 16:35:15 +00:00
|
|
|
struct nd_router_solicit *nd_rs;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct in6_addr saddr6 = ip6->ip6_src;
|
|
|
|
char *lladdr = NULL;
|
|
|
|
int lladdrlen = 0;
|
|
|
|
union nd_opts ndopts;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/* If I'm not a router, ignore it. */
|
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
|
|
|
if (V_ip6_accept_rtadv != 0 || V_ip6_forwarding != 1)
|
2000-07-04 16:35:15 +00:00
|
|
|
goto freeit;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/* Sanity checks */
|
|
|
|
if (ip6->ip6_hlim != 255) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
|
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto bad;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't update the neighbor cache, if src = ::.
|
|
|
|
* This indicates that the src has no IP address assigned yet.
|
|
|
|
*/
|
|
|
|
if (IN6_IS_ADDR_UNSPECIFIED(&saddr6))
|
2000-07-04 16:35:15 +00:00
|
|
|
goto freeit;
|
|
|
|
|
|
|
|
#ifndef PULLDOWN_TEST
|
|
|
|
IP6_EXTHDR_CHECK(m, off, icmp6len,);
|
|
|
|
nd_rs = (struct nd_router_solicit *)((caddr_t)ip6 + off);
|
|
|
|
#else
|
|
|
|
IP6_EXTHDR_GET(nd_rs, struct nd_router_solicit *, m, off, icmp6len);
|
|
|
|
if (nd_rs == NULL) {
|
2009-04-12 13:22:33 +00:00
|
|
|
ICMP6STAT_INC(icp6s_tooshort);
|
1999-11-22 02:45:11 +00:00
|
|
|
return;
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
icmp6len -= sizeof(*nd_rs);
|
|
|
|
nd6_option_init(nd_rs + 1, icmp6len, &ndopts);
|
|
|
|
if (nd6_options(&ndopts) < 0) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"nd6_rs_input: invalid ND option, ignored\n"));
|
|
|
|
/* nd6_options have incremented stats */
|
2000-07-04 16:35:15 +00:00
|
|
|
goto freeit;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ndopts.nd_opts_src_lladdr) {
|
|
|
|
lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1);
|
|
|
|
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
1999-11-22 02:45:11 +00:00
|
|
|
"nd6_rs_input: lladdrlen mismatch for %s "
|
|
|
|
"(if %d, RS packet %d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6bufs, &saddr6),
|
2003-10-09 16:13:47 +00:00
|
|
|
ifp->if_addrlen, lladdrlen - 2));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto bad;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nd6_cache_lladdr(ifp, &saddr6, lladdr, lladdrlen, ND_ROUTER_SOLICIT, 0);
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
freeit:
|
|
|
|
m_freem(m);
|
2001-06-11 12:39:29 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
bad:
|
2009-04-12 13:22:33 +00:00
|
|
|
ICMP6STAT_INC(icp6s_badrs);
|
2001-06-11 12:39:29 +00:00
|
|
|
m_freem(m);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive Router Advertisement Message.
|
|
|
|
*
|
|
|
|
* Based on RFC 2461
|
|
|
|
* TODO: on-link bit on prefix information
|
|
|
|
* TODO: ND_RA_FLAG_{OTHER,MANAGED} processing
|
|
|
|
*/
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_ra_input(struct mbuf *m, int off, int icmp6len)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ifnet *ifp = m->m_pkthdr.rcvif;
|
2003-10-17 15:46:31 +00:00
|
|
|
struct nd_ifinfo *ndi = ND_IFINFO(ifp);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
|
2000-07-04 16:35:15 +00:00
|
|
|
struct nd_router_advert *nd_ra;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct in6_addr saddr6 = ip6->ip6_src;
|
2005-10-21 16:23:01 +00:00
|
|
|
int mcast = 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
union nd_opts ndopts;
|
|
|
|
struct nd_defrouter *dr;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-08-05 14:57:11 +00:00
|
|
|
/*
|
|
|
|
* We only accept RAs only when
|
|
|
|
* the system-wide variable allows the acceptance, and
|
|
|
|
* per-interface variable allows RAs on the receiving interface.
|
|
|
|
*/
|
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
|
|
|
if (V_ip6_accept_rtadv == 0)
|
2000-07-04 16:35:15 +00:00
|
|
|
goto freeit;
|
2003-08-05 14:57:11 +00:00
|
|
|
if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV))
|
|
|
|
goto freeit;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
if (ip6->ip6_hlim != 255) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
|
|
|
|
ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto bad;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!IN6_IS_ADDR_LINKLOCAL(&saddr6)) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_ERR,
|
1999-11-22 02:45:11 +00:00
|
|
|
"nd6_ra_input: src %s is not link-local\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6bufs, &saddr6)));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto bad;
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PULLDOWN_TEST
|
|
|
|
IP6_EXTHDR_CHECK(m, off, icmp6len,);
|
|
|
|
nd_ra = (struct nd_router_advert *)((caddr_t)ip6 + off);
|
|
|
|
#else
|
|
|
|
IP6_EXTHDR_GET(nd_ra, struct nd_router_advert *, m, off, icmp6len);
|
|
|
|
if (nd_ra == NULL) {
|
2009-04-12 13:22:33 +00:00
|
|
|
ICMP6STAT_INC(icp6s_tooshort);
|
1999-11-22 02:45:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
#endif
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
icmp6len -= sizeof(*nd_ra);
|
|
|
|
nd6_option_init(nd_ra + 1, icmp6len, &ndopts);
|
|
|
|
if (nd6_options(&ndopts) < 0) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"nd6_ra_input: invalid ND option, ignored\n"));
|
|
|
|
/* nd6_options have incremented stats */
|
2000-07-04 16:35:15 +00:00
|
|
|
goto freeit;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
struct nd_defrouter dr0;
|
|
|
|
u_int32_t advreachable = nd_ra->nd_ra_reachable;
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/* remember if this is a multicasted advertisement */
|
|
|
|
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst))
|
|
|
|
mcast = 1;
|
|
|
|
|
|
|
|
bzero(&dr0, sizeof(dr0));
|
1999-11-22 02:45:11 +00:00
|
|
|
dr0.rtaddr = saddr6;
|
|
|
|
dr0.flags = nd_ra->nd_ra_flags_reserved;
|
2006-03-19 06:38:39 +00:00
|
|
|
dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime);
|
1999-11-22 02:45:11 +00:00
|
|
|
dr0.expire = time_second + dr0.rtlifetime;
|
|
|
|
dr0.ifp = ifp;
|
|
|
|
/* unspecified or not? (RFC 2461 6.3.4) */
|
|
|
|
if (advreachable) {
|
2002-02-18 20:35:27 +00:00
|
|
|
advreachable = ntohl(advreachable);
|
1999-11-22 02:45:11 +00:00
|
|
|
if (advreachable <= MAX_REACHABLE_TIME &&
|
|
|
|
ndi->basereachable != advreachable) {
|
|
|
|
ndi->basereachable = advreachable;
|
|
|
|
ndi->reachable = ND_COMPUTE_RTIME(ndi->basereachable);
|
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
|
|
|
ndi->recalctm = V_nd6_recalc_reachtm_interval; /* reset */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nd_ra->nd_ra_retransmit)
|
|
|
|
ndi->retrans = ntohl(nd_ra->nd_ra_retransmit);
|
|
|
|
if (nd_ra->nd_ra_curhoplimit)
|
|
|
|
ndi->chlim = nd_ra->nd_ra_curhoplimit;
|
|
|
|
dr = defrtrlist_update(&dr0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prefix
|
|
|
|
*/
|
|
|
|
if (ndopts.nd_opts_pi) {
|
|
|
|
struct nd_opt_hdr *pt;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct nd_opt_prefix_info *pi = NULL;
|
2005-10-21 16:23:01 +00:00
|
|
|
struct nd_prefixctl pr;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
for (pt = (struct nd_opt_hdr *)ndopts.nd_opts_pi;
|
|
|
|
pt <= (struct nd_opt_hdr *)ndopts.nd_opts_pi_end;
|
|
|
|
pt = (struct nd_opt_hdr *)((caddr_t)pt +
|
|
|
|
(pt->nd_opt_len << 3))) {
|
|
|
|
if (pt->nd_opt_type != ND_OPT_PREFIX_INFORMATION)
|
|
|
|
continue;
|
|
|
|
pi = (struct nd_opt_prefix_info *)pt;
|
|
|
|
|
|
|
|
if (pi->nd_opt_pi_len != 4) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"nd6_ra_input: invalid option "
|
|
|
|
"len %d for prefix information option, "
|
|
|
|
"ignored\n", pi->nd_opt_pi_len));
|
1999-11-22 02:45:11 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (128 < pi->nd_opt_pi_prefix_len) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"nd6_ra_input: invalid prefix "
|
|
|
|
"len %d for prefix information option, "
|
|
|
|
"ignored\n", pi->nd_opt_pi_prefix_len));
|
1999-11-22 02:45:11 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IN6_IS_ADDR_MULTICAST(&pi->nd_opt_pi_prefix)
|
|
|
|
|| IN6_IS_ADDR_LINKLOCAL(&pi->nd_opt_pi_prefix)) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"nd6_ra_input: invalid prefix "
|
|
|
|
"%s, ignored\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6bufs,
|
|
|
|
&pi->nd_opt_pi_prefix)));
|
1999-11-22 02:45:11 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bzero(&pr, sizeof(pr));
|
|
|
|
pr.ndpr_prefix.sin6_family = AF_INET6;
|
|
|
|
pr.ndpr_prefix.sin6_len = sizeof(pr.ndpr_prefix);
|
|
|
|
pr.ndpr_prefix.sin6_addr = pi->nd_opt_pi_prefix;
|
|
|
|
pr.ndpr_ifp = (struct ifnet *)m->m_pkthdr.rcvif;
|
|
|
|
|
|
|
|
pr.ndpr_raf_onlink = (pi->nd_opt_pi_flags_reserved &
|
2003-10-09 16:13:47 +00:00
|
|
|
ND_OPT_PI_FLAG_ONLINK) ? 1 : 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
pr.ndpr_raf_auto = (pi->nd_opt_pi_flags_reserved &
|
2003-10-09 16:13:47 +00:00
|
|
|
ND_OPT_PI_FLAG_AUTO) ? 1 : 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
pr.ndpr_plen = pi->nd_opt_pi_prefix_len;
|
|
|
|
pr.ndpr_vltime = ntohl(pi->nd_opt_pi_valid_time);
|
2003-10-09 16:13:47 +00:00
|
|
|
pr.ndpr_pltime = ntohl(pi->nd_opt_pi_preferred_time);
|
2005-10-21 16:23:01 +00:00
|
|
|
(void)prelist_update(&pr, dr, m, mcast);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MTU
|
|
|
|
*/
|
|
|
|
if (ndopts.nd_opts_mtu && ndopts.nd_opts_mtu->nd_opt_mtu_len == 1) {
|
2003-10-20 15:27:48 +00:00
|
|
|
u_long mtu;
|
|
|
|
u_long maxmtu;
|
2003-10-09 16:13:47 +00:00
|
|
|
|
2003-10-20 15:27:48 +00:00
|
|
|
mtu = (u_long)ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/* lower bound */
|
|
|
|
if (mtu < IPV6_MMTU) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu option "
|
2003-10-20 15:27:48 +00:00
|
|
|
"mtu=%lu sent from %s, ignoring\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src)));
|
1999-11-22 02:45:11 +00:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* upper bound */
|
2003-10-20 15:27:48 +00:00
|
|
|
maxmtu = (ndi->maxmtu && ndi->maxmtu < ifp->if_mtu)
|
|
|
|
? ndi->maxmtu : ifp->if_mtu;
|
|
|
|
if (mtu <= maxmtu) {
|
|
|
|
int change = (ndi->linkmtu != mtu);
|
|
|
|
|
|
|
|
ndi->linkmtu = mtu;
|
|
|
|
if (change) /* in6_maxmtu may change */
|
|
|
|
in6_setmaxmtu();
|
1999-11-22 02:45:11 +00:00
|
|
|
} else {
|
2003-10-20 15:27:48 +00:00
|
|
|
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu "
|
|
|
|
"mtu=%lu sent from %s; "
|
|
|
|
"exceeds maxmtu %lu, ignoring\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src), maxmtu));
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
skip:
|
2003-10-09 16:13:47 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2002-04-19 04:46:24 +00:00
|
|
|
* Source link layer address
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
char *lladdr = NULL;
|
|
|
|
int lladdrlen = 0;
|
2003-10-09 16:13:47 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
if (ndopts.nd_opts_src_lladdr) {
|
|
|
|
lladdr = (char *)(ndopts.nd_opts_src_lladdr + 1);
|
|
|
|
lladdrlen = ndopts.nd_opts_src_lladdr->nd_opt_len << 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_INFO,
|
1999-11-22 02:45:11 +00:00
|
|
|
"nd6_ra_input: lladdrlen mismatch for %s "
|
2006-12-12 12:17:58 +00:00
|
|
|
"(if %d, RA packet %d)\n", ip6_sprintf(ip6bufs, &saddr6),
|
2003-10-09 16:13:47 +00:00
|
|
|
ifp->if_addrlen, lladdrlen - 2));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto bad;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
nd6_cache_lladdr(ifp, &saddr6, lladdr,
|
|
|
|
lladdrlen, ND_ROUTER_ADVERT, 0);
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Installing a link-layer address might change the state of the
|
|
|
|
* router's neighbor cache, which might also affect our on-link
|
|
|
|
* detection of adveritsed prefixes.
|
|
|
|
*/
|
|
|
|
pfxlist_onlink_check();
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
freeit:
|
|
|
|
m_freem(m);
|
|
|
|
return;
|
|
|
|
|
|
|
|
bad:
|
2009-04-12 13:22:33 +00:00
|
|
|
ICMP6STAT_INC(icp6s_badra);
|
2000-07-04 16:35:15 +00:00
|
|
|
m_freem(m);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* default router list proccessing sub routines
|
|
|
|
*/
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
/* tell the change to user processes watching the routing socket. */
|
|
|
|
static void
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_rtmsg(int cmd, struct rtentry *rt)
|
2000-07-04 16:35:15 +00:00
|
|
|
{
|
|
|
|
struct rt_addrinfo info;
|
2009-04-20 21:37:46 +00:00
|
|
|
struct ifnet *ifp;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
bzero((caddr_t)&info, sizeof(info));
|
|
|
|
info.rti_info[RTAX_DST] = rt_key(rt);
|
|
|
|
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
|
|
|
|
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
|
2009-04-20 21:37:46 +00:00
|
|
|
ifp = rt->rt_ifp;
|
|
|
|
if (ifp != NULL) {
|
|
|
|
IF_ADDR_LOCK(ifp);
|
2005-10-21 16:23:01 +00:00
|
|
|
info.rti_info[RTAX_IFP] =
|
2009-04-20 21:37:46 +00:00
|
|
|
TAILQ_FIRST(&ifp->if_addrhead)->ifa_addr;
|
|
|
|
IF_ADDR_UNLOCK(ifp);
|
2005-10-21 16:23:01 +00:00
|
|
|
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
rt_missmsg(cmd, &info, rt->rt_flags, 0);
|
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
defrouter_addreq(struct nd_defrouter *new)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct sockaddr_in6 def, mask, gate;
|
2000-07-04 16:35:15 +00:00
|
|
|
struct rtentry *newrt = NULL;
|
2005-10-21 16:23:01 +00:00
|
|
|
int s;
|
|
|
|
int error;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2004-04-18 11:45:28 +00:00
|
|
|
bzero(&def, sizeof(def));
|
|
|
|
bzero(&mask, sizeof(mask));
|
|
|
|
bzero(&gate, sizeof(gate));
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
def.sin6_len = mask.sin6_len = gate.sin6_len =
|
|
|
|
sizeof(struct sockaddr_in6);
|
2005-10-21 16:23:01 +00:00
|
|
|
def.sin6_family = gate.sin6_family = AF_INET6;
|
1999-11-22 02:45:11 +00:00
|
|
|
gate.sin6_addr = new->rtaddr;
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
s = splnet();
|
|
|
|
error = rtrequest(RTM_ADD, (struct sockaddr *)&def,
|
2003-10-09 16:13:47 +00:00
|
|
|
(struct sockaddr *)&gate, (struct sockaddr *)&mask,
|
|
|
|
RTF_GATEWAY, &newrt);
|
2000-07-04 16:35:15 +00:00
|
|
|
if (newrt) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6_rtmsg(RTM_ADD, newrt); /* tell user process */
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
RTFREE(newrt);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
2005-10-21 16:23:01 +00:00
|
|
|
if (error == 0)
|
|
|
|
new->installed = 1;
|
|
|
|
splx(s);
|
1999-11-22 02:45:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nd_defrouter *
|
2007-07-05 16:23:49 +00:00
|
|
|
defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(ifp->if_vnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_defrouter *dr;
|
|
|
|
|
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
|
|
|
for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
|
2000-07-04 16:35:15 +00:00
|
|
|
dr = TAILQ_NEXT(dr, dr_entry)) {
|
1999-11-22 02:45:11 +00:00
|
|
|
if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
|
2003-10-06 14:02:09 +00:00
|
|
|
return (dr);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (NULL); /* search failed */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* Remove the default route for a given router.
|
|
|
|
* This is just a subroutine function for defrouter_select(), and should
|
|
|
|
* not be called from anywhere else.
|
|
|
|
*/
|
|
|
|
static void
|
2007-07-05 16:23:49 +00:00
|
|
|
defrouter_delreq(struct nd_defrouter *dr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct sockaddr_in6 def, mask, gate;
|
2000-07-04 16:35:15 +00:00
|
|
|
struct rtentry *oldrt = NULL;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2004-04-18 11:45:28 +00:00
|
|
|
bzero(&def, sizeof(def));
|
|
|
|
bzero(&mask, sizeof(mask));
|
|
|
|
bzero(&gate, sizeof(gate));
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
def.sin6_len = mask.sin6_len = gate.sin6_len =
|
|
|
|
sizeof(struct sockaddr_in6);
|
2005-10-21 16:23:01 +00:00
|
|
|
def.sin6_family = gate.sin6_family = AF_INET6;
|
1999-11-22 02:45:11 +00:00
|
|
|
gate.sin6_addr = dr->rtaddr;
|
|
|
|
|
|
|
|
rtrequest(RTM_DELETE, (struct sockaddr *)&def,
|
2003-10-09 16:13:47 +00:00
|
|
|
(struct sockaddr *)&gate,
|
|
|
|
(struct sockaddr *)&mask, RTF_GATEWAY, &oldrt);
|
2000-07-04 16:35:15 +00:00
|
|
|
if (oldrt) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6_rtmsg(RTM_DELETE, oldrt);
|
2002-12-25 10:21:02 +00:00
|
|
|
RTFREE(oldrt);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
dr->installed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove all default routes from default router list
|
|
|
|
*/
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
defrouter_reset(void)
|
2005-10-21 16:23:01 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2005-10-21 16:23:01 +00:00
|
|
|
struct nd_defrouter *dr;
|
|
|
|
|
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
|
|
|
for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
|
2005-10-21 16:23:01 +00:00
|
|
|
dr = TAILQ_NEXT(dr, dr_entry))
|
|
|
|
defrouter_delreq(dr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX should we also nuke any default routers in the kernel, by
|
|
|
|
* going through them by rtalloc1()?
|
|
|
|
*/
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
defrtrlist_del(struct nd_defrouter *dr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_defrouter *deldr = NULL;
|
|
|
|
struct nd_prefix *pr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flush all the routing table entries that use the router
|
|
|
|
* as a next hop.
|
|
|
|
*/
|
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
|
|
|
if (!V_ip6_forwarding && V_ip6_accept_rtadv) /* XXX: better condition? */
|
1999-11-22 02:45:11 +00:00
|
|
|
rt6_flush(&dr->rtaddr, dr->ifp);
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
if (dr->installed) {
|
|
|
|
deldr = dr;
|
|
|
|
defrouter_delreq(dr);
|
|
|
|
}
|
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
|
|
|
TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Also delete all the pointers to the router in each prefix lists.
|
|
|
|
*/
|
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
|
|
|
for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_pfxrouter *pfxrtr;
|
|
|
|
if ((pfxrtr = pfxrtr_lookup(pr, dr)) != NULL)
|
|
|
|
pfxrtr_del(pfxrtr);
|
|
|
|
}
|
|
|
|
pfxlist_onlink_check();
|
|
|
|
|
|
|
|
/*
|
2000-07-04 16:35:15 +00:00
|
|
|
* If the router is the primary one, choose a new one.
|
|
|
|
* Note that defrouter_select() will remove the current gateway
|
|
|
|
* from the routing table.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
if (deldr)
|
2000-07-04 16:35:15 +00:00
|
|
|
defrouter_select();
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
free(dr, M_IP6NDP);
|
|
|
|
}
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* Default Router Selection according to Section 6.3.6 of RFC 2461 and
|
|
|
|
* draft-ietf-ipngwg-router-selection:
|
|
|
|
* 1) Routers that are reachable or probably reachable should be preferred.
|
|
|
|
* If we have more than one (probably) reachable router, prefer ones
|
|
|
|
* with the highest router preference.
|
2000-07-04 16:35:15 +00:00
|
|
|
* 2) When no routers on the list are known to be reachable or
|
|
|
|
* probably reachable, routers SHOULD be selected in a round-robin
|
2005-10-21 16:23:01 +00:00
|
|
|
* fashion, regardless of router preference values.
|
2000-07-04 16:35:15 +00:00
|
|
|
* 3) If the Default Router List is empty, assume that all
|
|
|
|
* destinations are on-link.
|
2005-10-21 16:23:01 +00:00
|
|
|
*
|
|
|
|
* We assume nd_defrouter is sorted by router preference value.
|
|
|
|
* Since the code below covers both with and without router preference cases,
|
|
|
|
* we do not need to classify the cases by ifdef.
|
|
|
|
*
|
|
|
|
* At this moment, we do not try to install more than one default router,
|
|
|
|
* even when the multipath routing is available, because we're not sure about
|
|
|
|
* the benefits for stub hosts comparing to the risk of making the code
|
|
|
|
* complicated and the possibility of introducing bugs.
|
2000-07-04 16:35:15 +00:00
|
|
|
*/
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
defrouter_select(void)
|
2000-07-04 16:35:15 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2000-07-04 16:35:15 +00:00
|
|
|
int s = splnet();
|
2005-10-21 16:23:01 +00:00
|
|
|
struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
struct llentry *ln = NULL;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* This function should be called only when acting as an autoconfigured
|
|
|
|
* host. Although the remaining part of this function is not effective
|
|
|
|
* if the node is not an autoconfigured host, we explicitly exclude
|
|
|
|
* such cases here for safety.
|
|
|
|
*/
|
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
|
|
|
if (V_ip6_forwarding || !V_ip6_accept_rtadv) {
|
2005-10-21 16:23:01 +00:00
|
|
|
nd6log((LOG_WARNING,
|
|
|
|
"defrouter_select: called unexpectedly (forwarding=%d, "
|
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
|
|
|
"accept_rtadv=%d)\n", V_ip6_forwarding, V_ip6_accept_rtadv));
|
2005-10-21 16:23:01 +00:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Let's handle easy case (3) first:
|
|
|
|
* If default router list is empty, there's nothing to be done.
|
|
|
|
*/
|
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
|
|
|
if (!TAILQ_FIRST(&V_nd_defrouter)) {
|
2005-10-21 16:23:01 +00:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
|
|
|
* Search for a (probably) reachable router from the list.
|
2005-10-21 16:23:01 +00:00
|
|
|
* We just pick up the first reachable one (if any), assuming that
|
|
|
|
* the ordering rule of the list described in defrtrlist_update().
|
2000-07-04 16:35:15 +00:00
|
|
|
*/
|
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
|
|
|
for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
|
2000-07-04 16:35:15 +00:00
|
|
|
dr = TAILQ_NEXT(dr, dr_entry)) {
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
IF_AFDATA_LOCK(dr->ifp);
|
2005-10-21 16:23:01 +00:00
|
|
|
if (selected_dr == NULL &&
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
(ln = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
|
2000-07-04 16:35:15 +00:00
|
|
|
ND6_IS_LLINFO_PROBREACH(ln)) {
|
2005-10-21 16:23:01 +00:00
|
|
|
selected_dr = dr;
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
IF_AFDATA_UNLOCK(dr->ifp);
|
2009-02-04 10:35:27 +00:00
|
|
|
if (ln != NULL) {
|
2008-12-16 00:18:04 +00:00
|
|
|
LLE_RUNLOCK(ln);
|
2009-02-04 10:35:27 +00:00
|
|
|
ln = NULL;
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
if (dr->installed && installed_dr == NULL)
|
|
|
|
installed_dr = dr;
|
|
|
|
else if (dr->installed && installed_dr) {
|
|
|
|
/* this should not happen. warn for diagnosis. */
|
|
|
|
log(LOG_ERR, "defrouter_select: more than one router"
|
|
|
|
" is installed\n");
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* If none of the default routers was found to be reachable,
|
|
|
|
* round-robin the list regardless of preference.
|
|
|
|
* Otherwise, if we have an installed router, check if the selected
|
|
|
|
* (reachable) router should really be preferred to the installed one.
|
|
|
|
* We only prefer the new router when the old one is not reachable
|
|
|
|
* or when the new one has a really higher preference value.
|
|
|
|
*/
|
|
|
|
if (selected_dr == NULL) {
|
|
|
|
if (installed_dr == NULL || !TAILQ_NEXT(installed_dr, dr_entry))
|
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
|
|
|
selected_dr = TAILQ_FIRST(&V_nd_defrouter);
|
2005-10-21 16:23:01 +00:00
|
|
|
else
|
|
|
|
selected_dr = TAILQ_NEXT(installed_dr, dr_entry);
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
} else if (installed_dr) {
|
|
|
|
IF_AFDATA_LOCK(installed_dr->ifp);
|
|
|
|
if ((ln = nd6_lookup(&installed_dr->rtaddr, 0, installed_dr->ifp)) &&
|
|
|
|
ND6_IS_LLINFO_PROBREACH(ln) &&
|
|
|
|
rtpref(selected_dr) <= rtpref(installed_dr)) {
|
|
|
|
selected_dr = installed_dr;
|
|
|
|
}
|
|
|
|
IF_AFDATA_UNLOCK(installed_dr->ifp);
|
2008-12-16 00:18:04 +00:00
|
|
|
if (ln != NULL)
|
|
|
|
LLE_RUNLOCK(ln);
|
2005-10-21 16:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the selected router is different than the installed one,
|
|
|
|
* remove the installed router and install the selected one.
|
|
|
|
* Note that the selected router is never NULL here.
|
|
|
|
*/
|
|
|
|
if (installed_dr != selected_dr) {
|
|
|
|
if (installed_dr)
|
|
|
|
defrouter_delreq(installed_dr);
|
|
|
|
defrouter_addreq(selected_dr);
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* for default router selection
|
|
|
|
* regards router-preference field as a 2-bit signed integer
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
rtpref(struct nd_defrouter *dr)
|
|
|
|
{
|
|
|
|
switch (dr->flags & ND_RA_FLAG_RTPREF_MASK) {
|
|
|
|
case ND_RA_FLAG_RTPREF_HIGH:
|
|
|
|
return (RTPREF_HIGH);
|
|
|
|
case ND_RA_FLAG_RTPREF_MEDIUM:
|
|
|
|
case ND_RA_FLAG_RTPREF_RSV:
|
2006-03-19 06:38:39 +00:00
|
|
|
return (RTPREF_MEDIUM);
|
2005-10-21 16:23:01 +00:00
|
|
|
case ND_RA_FLAG_RTPREF_LOW:
|
|
|
|
return (RTPREF_LOW);
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* This case should never happen. If it did, it would mean a
|
|
|
|
* serious bug of kernel internal. We thus always bark here.
|
|
|
|
* Or, can we even panic?
|
|
|
|
*/
|
|
|
|
log(LOG_ERR, "rtpref: impossible RA flag %x\n", dr->flags);
|
|
|
|
return (RTPREF_INVALID);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
static struct nd_defrouter *
|
2007-07-05 16:23:49 +00:00
|
|
|
defrtrlist_update(struct nd_defrouter *new)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_defrouter *dr, *n;
|
|
|
|
int s = splnet();
|
|
|
|
|
|
|
|
if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) {
|
|
|
|
/* entry exists */
|
|
|
|
if (new->rtlifetime == 0) {
|
|
|
|
defrtrlist_del(dr);
|
|
|
|
dr = NULL;
|
|
|
|
} else {
|
2005-10-21 16:23:01 +00:00
|
|
|
int oldpref = rtpref(dr);
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/* override */
|
|
|
|
dr->flags = new->flags; /* xxx flag check */
|
|
|
|
dr->rtlifetime = new->rtlifetime;
|
|
|
|
dr->expire = new->expire;
|
2005-10-21 16:23:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the preference does not change, there's no need
|
|
|
|
* to sort the entries.
|
|
|
|
*/
|
|
|
|
if (rtpref(new) == oldpref) {
|
|
|
|
splx(s);
|
|
|
|
return (dr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* preferred router may be changed, so relocate
|
|
|
|
* this router.
|
|
|
|
* XXX: calling TAILQ_REMOVE directly is a bad manner.
|
|
|
|
* However, since defrtrlist_del() has many side
|
|
|
|
* effects, we intentionally do so here.
|
|
|
|
* defrouter_select() below will handle routing
|
|
|
|
* changes later.
|
|
|
|
*/
|
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
|
|
|
TAILQ_REMOVE(&V_nd_defrouter, dr, dr_entry);
|
2005-10-21 16:23:01 +00:00
|
|
|
n = dr;
|
|
|
|
goto insert;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
splx(s);
|
2003-10-06 14:02:09 +00:00
|
|
|
return (dr);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* entry does not exist */
|
|
|
|
if (new->rtlifetime == 0) {
|
|
|
|
splx(s);
|
2003-10-06 14:02:09 +00:00
|
|
|
return (NULL);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT);
|
|
|
|
if (n == NULL) {
|
|
|
|
splx(s);
|
2003-10-06 14:02:09 +00:00
|
|
|
return (NULL);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
bzero(n, sizeof(*n));
|
|
|
|
*n = *new;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
insert:
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* Insert the new router in the Default Router List;
|
|
|
|
* The Default Router List should be in the descending order
|
|
|
|
* of router-preferece. Routers with the same preference are
|
|
|
|
* sorted in the arriving time order.
|
2000-07-04 16:35:15 +00:00
|
|
|
*/
|
2005-10-21 16:23:01 +00:00
|
|
|
|
|
|
|
/* insert at the end of the group */
|
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
|
|
|
for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
|
2005-10-21 16:23:01 +00:00
|
|
|
dr = TAILQ_NEXT(dr, dr_entry)) {
|
|
|
|
if (rtpref(n) > rtpref(dr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (dr)
|
|
|
|
TAILQ_INSERT_BEFORE(dr, n, dr_entry);
|
|
|
|
else
|
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
|
|
|
TAILQ_INSERT_TAIL(&V_nd_defrouter, n, dr_entry);
|
2005-10-21 16:23:01 +00:00
|
|
|
|
|
|
|
defrouter_select();
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
splx(s);
|
2003-10-09 16:13:47 +00:00
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (n);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct nd_pfxrouter *
|
2007-07-05 16:23:49 +00:00
|
|
|
pfxrtr_lookup(struct nd_prefix *pr, struct nd_defrouter *dr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct nd_pfxrouter *search;
|
2003-10-09 16:13:47 +00:00
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) {
|
1999-11-22 02:45:11 +00:00
|
|
|
if (search->router == dr)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (search);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-07-05 16:23:49 +00:00
|
|
|
pfxrtr_add(struct nd_prefix *pr, struct nd_defrouter *dr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
struct nd_pfxrouter *new;
|
|
|
|
|
|
|
|
new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
|
|
|
|
if (new == NULL)
|
|
|
|
return;
|
|
|
|
bzero(new, sizeof(*new));
|
|
|
|
new->router = dr;
|
|
|
|
|
|
|
|
LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry);
|
|
|
|
|
|
|
|
pfxlist_onlink_check();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-07-05 16:23:49 +00:00
|
|
|
pfxrtr_del(struct nd_pfxrouter *pfr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
LIST_REMOVE(pfr, pfr_entry);
|
|
|
|
free(pfr, M_IP6NDP);
|
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
struct nd_prefix *
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_prefix_lookup(struct nd_prefixctl *key)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_prefix *search;
|
|
|
|
|
2008-08-20 01:05:56 +00:00
|
|
|
for (search = V_nd_prefix.lh_first;
|
2008-08-20 01:24:55 +00:00
|
|
|
search; search = search->ndpr_next) {
|
2005-10-21 16:23:01 +00:00
|
|
|
if (key->ndpr_ifp == search->ndpr_ifp &&
|
|
|
|
key->ndpr_plen == search->ndpr_plen &&
|
|
|
|
in6_are_prefix_equal(&key->ndpr_prefix.sin6_addr,
|
|
|
|
&search->ndpr_prefix.sin6_addr, key->ndpr_plen)) {
|
1999-11-22 02:45:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (search);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
|
|
|
|
struct nd_prefix **newp)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
struct nd_prefix *new = NULL;
|
2005-10-21 16:23:01 +00:00
|
|
|
int error = 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
int i, s;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT);
|
|
|
|
if (new == NULL)
|
2003-10-09 16:13:47 +00:00
|
|
|
return(ENOMEM);
|
1999-11-22 02:45:11 +00:00
|
|
|
bzero(new, sizeof(*new));
|
2005-10-21 16:23:01 +00:00
|
|
|
new->ndpr_ifp = pr->ndpr_ifp;
|
|
|
|
new->ndpr_prefix = pr->ndpr_prefix;
|
|
|
|
new->ndpr_plen = pr->ndpr_plen;
|
|
|
|
new->ndpr_vltime = pr->ndpr_vltime;
|
|
|
|
new->ndpr_pltime = pr->ndpr_pltime;
|
|
|
|
new->ndpr_flags = pr->ndpr_flags;
|
|
|
|
if ((error = in6_init_prefix_ltimes(new)) != 0) {
|
|
|
|
free(new, M_IP6NDP);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
new->ndpr_lastupdate = time_second;
|
2001-06-11 12:39:29 +00:00
|
|
|
if (newp != NULL)
|
|
|
|
*newp = new;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
/* initialization */
|
1999-11-22 02:45:11 +00:00
|
|
|
LIST_INIT(&new->ndpr_advrtrs);
|
|
|
|
in6_prefixlen2mask(&new->ndpr_mask, new->ndpr_plen);
|
|
|
|
/* make prefix in the canonical form */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
new->ndpr_prefix.sin6_addr.s6_addr32[i] &=
|
2003-10-09 16:13:47 +00:00
|
|
|
new->ndpr_mask.s6_addr32[i];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
s = splnet();
|
|
|
|
/* link ndpr_entry to nd_prefix list */
|
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
|
|
|
LIST_INSERT_HEAD(&V_nd_prefix, new, ndpr_entry);
|
1999-11-22 02:45:11 +00:00
|
|
|
splx(s);
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* ND_OPT_PI_FLAG_ONLINK processing */
|
|
|
|
if (new->ndpr_raf_onlink) {
|
|
|
|
int e;
|
|
|
|
|
|
|
|
if ((e = nd6_prefix_onlink(new)) != 0) {
|
|
|
|
nd6log((LOG_ERR, "nd6_prelist_add: failed to make "
|
|
|
|
"the prefix %s/%d on-link on %s (errno=%d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_plen, if_name(pr->ndpr_ifp), e));
|
|
|
|
/* proceed anyway. XXX: is it correct? */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
if (dr)
|
1999-11-22 02:45:11 +00:00
|
|
|
pfxrtr_add(new, dr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
prelist_remove(struct nd_prefix *pr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_pfxrouter *pfr, *next;
|
2001-06-11 12:39:29 +00:00
|
|
|
int e, s;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* make sure to invalidate the prefix until it is really freed. */
|
|
|
|
pr->ndpr_vltime = 0;
|
|
|
|
pr->ndpr_pltime = 0;
|
2005-10-21 16:23:01 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* Though these flags are now meaningless, we'd rather keep the value
|
2005-10-19 17:18:49 +00:00
|
|
|
* of pr->ndpr_raf_onlink and pr->ndpr_raf_auto not to confuse users
|
|
|
|
* when executing "ndp -p".
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
2005-10-19 17:18:49 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0 &&
|
|
|
|
(e = nd6_prefix_offlink(pr)) != 0) {
|
|
|
|
nd6log((LOG_ERR, "prelist_remove: failed to make %s/%d offlink "
|
|
|
|
"on %s, errno=%d\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_plen, if_name(pr->ndpr_ifp), e));
|
|
|
|
/* what should we do? */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pr->ndpr_refcnt > 0)
|
|
|
|
return; /* notice here? */
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
s = splnet();
|
2001-06-11 12:39:29 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/* unlink ndpr_entry from nd_prefix list */
|
|
|
|
LIST_REMOVE(pr, ndpr_entry);
|
|
|
|
|
|
|
|
/* free list of routers that adversed the prefix */
|
2000-07-04 16:35:15 +00:00
|
|
|
for (pfr = pr->ndpr_advrtrs.lh_first; pfr; pfr = next) {
|
|
|
|
next = pfr->pfr_next;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
free(pfr, M_IP6NDP);
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
splx(s);
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
free(pr, M_IP6NDP);
|
|
|
|
|
|
|
|
pfxlist_onlink_check();
|
|
|
|
}
|
|
|
|
|
2007-07-05 16:23:49 +00:00
|
|
|
/*
|
|
|
|
* dr - may be NULL
|
|
|
|
*/
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
static int
|
2007-07-05 16:23:49 +00:00
|
|
|
prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
|
|
|
|
struct mbuf *m, int mcast)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_ifaddr *ia6 = NULL, *ia6_match = NULL;
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct ifnet *ifp = new->ndpr_ifp;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_prefix *pr;
|
|
|
|
int s = splnet();
|
|
|
|
int error = 0;
|
2001-06-11 12:39:29 +00:00
|
|
|
int newprefix = 0;
|
1999-11-22 02:45:11 +00:00
|
|
|
int auth;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_addrlifetime lt6_tmp;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
auth = 0;
|
|
|
|
if (m) {
|
|
|
|
/*
|
|
|
|
* Authenticity for NA consists authentication for
|
|
|
|
* both IP header and IP datagrams, doesn't it ?
|
|
|
|
*/
|
|
|
|
#if defined(M_AUTHIPHDR) && defined(M_AUTHIPDGM)
|
2003-10-09 16:13:47 +00:00
|
|
|
auth = ((m->m_flags & M_AUTHIPHDR) &&
|
|
|
|
(m->m_flags & M_AUTHIPDGM));
|
1999-11-22 02:45:11 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if ((pr = nd6_prefix_lookup(new)) != NULL) {
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2001-06-11 12:39:29 +00:00
|
|
|
* nd6_prefix_lookup() ensures that pr and new have the same
|
|
|
|
* prefix on a same interface.
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* Update prefix information. Note that the on-link (L) bit
|
|
|
|
* and the autonomous (A) bit should NOT be changed from 1
|
|
|
|
* to 0.
|
|
|
|
*/
|
|
|
|
if (new->ndpr_raf_onlink == 1)
|
|
|
|
pr->ndpr_raf_onlink = 1;
|
|
|
|
if (new->ndpr_raf_auto == 1)
|
|
|
|
pr->ndpr_raf_auto = 1;
|
|
|
|
if (new->ndpr_raf_onlink) {
|
|
|
|
pr->ndpr_vltime = new->ndpr_vltime;
|
|
|
|
pr->ndpr_pltime = new->ndpr_pltime;
|
2005-10-21 16:23:01 +00:00
|
|
|
(void)in6_init_prefix_ltimes(pr); /* XXX error case? */
|
|
|
|
pr->ndpr_lastupdate = time_second;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if (new->ndpr_raf_onlink &&
|
|
|
|
(pr->ndpr_stateflags & NDPRF_ONLINK) == 0) {
|
|
|
|
int e;
|
|
|
|
|
|
|
|
if ((e = nd6_prefix_onlink(pr)) != 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"prelist_update: failed to make "
|
|
|
|
"the prefix %s/%d on-link on %s "
|
|
|
|
"(errno=%d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf,
|
|
|
|
&pr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_plen, if_name(pr->ndpr_ifp), e));
|
|
|
|
/* proceed anyway. XXX: is it correct? */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if (dr && pfxrtr_lookup(pr, dr) == NULL)
|
|
|
|
pfxrtr_add(pr, dr);
|
|
|
|
} else {
|
|
|
|
struct nd_prefix *newpr = NULL;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
newprefix = 1;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if (new->ndpr_vltime == 0)
|
|
|
|
goto end;
|
|
|
|
if (new->ndpr_raf_onlink == 0 && new->ndpr_raf_auto == 0)
|
|
|
|
goto end;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
error = nd6_prelist_add(new, dr, &newpr);
|
|
|
|
if (error != 0 || newpr == NULL) {
|
|
|
|
nd6log((LOG_NOTICE, "prelist_update: "
|
|
|
|
"nd6_prelist_add failed for %s/%d on %s "
|
|
|
|
"errno=%d, returnpr=%p\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr),
|
2003-10-09 16:13:47 +00:00
|
|
|
new->ndpr_plen, if_name(new->ndpr_ifp),
|
|
|
|
error, newpr));
|
2001-06-11 12:39:29 +00:00
|
|
|
goto end; /* we should just give up in this case. */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* XXX: from the ND point of view, we can ignore a prefix
|
|
|
|
* with the on-link bit being zero. However, we need a
|
|
|
|
* prefix structure for references from autoconfigured
|
2003-10-09 16:13:47 +00:00
|
|
|
* addresses. Thus, we explicitly make sure that the prefix
|
2001-06-11 12:39:29 +00:00
|
|
|
* itself expires now.
|
|
|
|
*/
|
|
|
|
if (newpr->ndpr_raf_onlink == 0) {
|
|
|
|
newpr->ndpr_vltime = 0;
|
|
|
|
newpr->ndpr_pltime = 0;
|
|
|
|
in6_init_prefix_ltimes(newpr);
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
pr = newpr;
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* Address autoconfiguration based on Section 5.5.3 of RFC 2462.
|
|
|
|
* Note that pr must be non NULL at this point.
|
|
|
|
*/
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* 5.5.3 (a). Ignore the prefix without the A bit set. */
|
|
|
|
if (!new->ndpr_raf_auto)
|
2005-10-21 16:23:01 +00:00
|
|
|
goto end;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* 5.5.3 (b). the link-local prefix should have been ignored in
|
|
|
|
* nd6_ra_input.
|
|
|
|
*/
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/* 5.5.3 (c). Consistency check on lifetimes: pltime <= vltime. */
|
|
|
|
if (new->ndpr_pltime > new->ndpr_vltime) {
|
|
|
|
error = EINVAL; /* XXX: won't be used */
|
|
|
|
goto end;
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2007-07-05 16:29:40 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* 5.5.3 (d). If the prefix advertised is not equal to the prefix of
|
|
|
|
* an address configured by stateless autoconfiguration already in the
|
|
|
|
* list of addresses associated with the interface, and the Valid
|
|
|
|
* Lifetime is not 0, form an address. We first check if we have
|
|
|
|
* a matching prefix.
|
|
|
|
* Note: we apply a clarification in rfc2462bis-02 here. We only
|
|
|
|
* consider autoconfigured addresses while RFC2462 simply said
|
|
|
|
* "address".
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
2009-04-20 21:37:46 +00:00
|
|
|
IF_ADDR_LOCK(ifp);
|
2009-04-20 22:45:21 +00:00
|
|
|
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_ifaddr *ifa6;
|
2005-10-21 16:23:01 +00:00
|
|
|
u_int32_t remaininglifetime;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ifa6 = (struct in6_ifaddr *)ifa;
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* We only consider autoconfigured addresses as per rfc2462bis.
|
|
|
|
*/
|
|
|
|
if (!(ifa6->ia6_flags & IN6_IFF_AUTOCONF))
|
|
|
|
continue;
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* Spec is not clear here, but I believe we should concentrate
|
|
|
|
* on unicast (i.e. not anycast) addresses.
|
|
|
|
* XXX: other ia6_flags? detached or duplicated?
|
|
|
|
*/
|
|
|
|
if ((ifa6->ia6_flags & IN6_IFF_ANYCAST) != 0)
|
|
|
|
continue;
|
2003-10-09 16:13:47 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* Ignore the address if it is not associated with a prefix
|
|
|
|
* or is associated with a prefix that is different from this
|
|
|
|
* one. (pr is never NULL here)
|
|
|
|
*/
|
|
|
|
if (ifa6->ia6_ndpr != pr)
|
2001-06-11 12:39:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ia6_match == NULL) /* remember the first one */
|
|
|
|
ia6_match = ifa6;
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
2001-06-11 12:39:29 +00:00
|
|
|
* An already autoconfigured address matched. Now that we
|
|
|
|
* are sure there is at least one matched address, we can
|
|
|
|
* proceed to 5.5.3. (e): update the lifetimes according to the
|
|
|
|
* "two hours" rule and the privacy extension.
|
2005-10-21 16:23:01 +00:00
|
|
|
* We apply some clarifications in rfc2462bis:
|
|
|
|
* - use remaininglifetime instead of storedlifetime as a
|
|
|
|
* variable name
|
|
|
|
* - remove the dead code in the "two-hour" rule
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2001-06-11 12:39:29 +00:00
|
|
|
#define TWOHOUR (120*60)
|
|
|
|
lt6_tmp = ifa6->ia6_lifetime;
|
|
|
|
|
2003-03-26 17:37:35 +00:00
|
|
|
if (lt6_tmp.ia6t_vltime == ND6_INFINITE_LIFETIME)
|
2005-10-21 16:23:01 +00:00
|
|
|
remaininglifetime = ND6_INFINITE_LIFETIME;
|
|
|
|
else if (time_second - ifa6->ia6_updatetime >
|
|
|
|
lt6_tmp.ia6t_vltime) {
|
|
|
|
/*
|
|
|
|
* The case of "invalid" address. We should usually
|
|
|
|
* not see this case.
|
|
|
|
*/
|
|
|
|
remaininglifetime = 0;
|
|
|
|
} else
|
|
|
|
remaininglifetime = lt6_tmp.ia6t_vltime -
|
|
|
|
(time_second - ifa6->ia6_updatetime);
|
2003-03-26 17:37:35 +00:00
|
|
|
|
|
|
|
/* when not updating, keep the current stored lifetime. */
|
2005-10-21 16:23:01 +00:00
|
|
|
lt6_tmp.ia6t_vltime = remaininglifetime;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
if (TWOHOUR < new->ndpr_vltime ||
|
2005-10-21 16:23:01 +00:00
|
|
|
remaininglifetime < new->ndpr_vltime) {
|
2001-06-11 12:39:29 +00:00
|
|
|
lt6_tmp.ia6t_vltime = new->ndpr_vltime;
|
2005-10-21 16:23:01 +00:00
|
|
|
} else if (remaininglifetime <= TWOHOUR) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (auth) {
|
|
|
|
lt6_tmp.ia6t_vltime = new->ndpr_vltime;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* new->ndpr_vltime <= TWOHOUR &&
|
2005-10-21 16:23:01 +00:00
|
|
|
* TWOHOUR < remaininglifetime
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
|
|
|
lt6_tmp.ia6t_vltime = TWOHOUR;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* The 2 hour rule is not imposed for preferred lifetime. */
|
|
|
|
lt6_tmp.ia6t_pltime = new->ndpr_pltime;
|
|
|
|
|
|
|
|
in6_init_address_ltimes(pr, <6_tmp);
|
|
|
|
|
2007-07-05 16:29:40 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* We need to treat lifetimes for temporary addresses
|
|
|
|
* differently, according to
|
|
|
|
* draft-ietf-ipv6-privacy-addrs-v2-01.txt 3.3 (1);
|
|
|
|
* we only update the lifetimes when they are in the maximum
|
|
|
|
* intervals.
|
2007-07-05 16:29:40 +00:00
|
|
|
*/
|
|
|
|
if ((ifa6->ia6_flags & IN6_IFF_TEMPORARY) != 0) {
|
2005-10-21 16:23:01 +00:00
|
|
|
u_int32_t maxvltime, maxpltime;
|
|
|
|
|
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
|
|
|
if (V_ip6_temp_valid_lifetime >
|
2005-10-21 16:23:01 +00:00
|
|
|
(u_int32_t)((time_second - ifa6->ia6_createtime) +
|
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
|
|
|
V_ip6_desync_factor)) {
|
|
|
|
maxvltime = V_ip6_temp_valid_lifetime -
|
2005-10-21 16:23:01 +00:00
|
|
|
(time_second - ifa6->ia6_createtime) -
|
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
|
|
|
V_ip6_desync_factor;
|
2005-10-21 16:23:01 +00:00
|
|
|
} else
|
|
|
|
maxvltime = 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
|
|
|
if (V_ip6_temp_preferred_lifetime >
|
2005-10-21 16:23:01 +00:00
|
|
|
(u_int32_t)((time_second - ifa6->ia6_createtime) +
|
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
|
|
|
V_ip6_desync_factor)) {
|
|
|
|
maxpltime = V_ip6_temp_preferred_lifetime -
|
2005-10-21 16:23:01 +00:00
|
|
|
(time_second - ifa6->ia6_createtime) -
|
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
|
|
|
V_ip6_desync_factor;
|
2005-10-21 16:23:01 +00:00
|
|
|
} else
|
|
|
|
maxpltime = 0;
|
|
|
|
|
|
|
|
if (lt6_tmp.ia6t_vltime == ND6_INFINITE_LIFETIME ||
|
|
|
|
lt6_tmp.ia6t_vltime > maxvltime) {
|
|
|
|
lt6_tmp.ia6t_vltime = maxvltime;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2005-10-21 16:23:01 +00:00
|
|
|
if (lt6_tmp.ia6t_pltime == ND6_INFINITE_LIFETIME ||
|
|
|
|
lt6_tmp.ia6t_pltime > maxpltime) {
|
|
|
|
lt6_tmp.ia6t_pltime = maxpltime;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ifa6->ia6_lifetime = lt6_tmp;
|
2005-10-21 16:23:01 +00:00
|
|
|
ifa6->ia6_updatetime = time_second;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2009-04-20 21:37:46 +00:00
|
|
|
IF_ADDR_UNLOCK(ifp);
|
2001-06-11 12:39:29 +00:00
|
|
|
if (ia6_match == NULL && new->ndpr_vltime) {
|
2005-10-21 16:23:01 +00:00
|
|
|
int ifidlen;
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* 5.5.3 (d) (continued)
|
2001-06-11 12:39:29 +00:00
|
|
|
* No address matched and the valid lifetime is non-zero.
|
|
|
|
* Create a new address.
|
|
|
|
*/
|
2005-10-21 16:23:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prefix Length check:
|
|
|
|
* If the sum of the prefix length and interface identifier
|
|
|
|
* length does not equal 128 bits, the Prefix Information
|
|
|
|
* option MUST be ignored. The length of the interface
|
|
|
|
* identifier is defined in a separate link-type specific
|
|
|
|
* document.
|
|
|
|
*/
|
|
|
|
ifidlen = in6_if2idlen(ifp);
|
|
|
|
if (ifidlen < 0) {
|
|
|
|
/* this should not happen, so we always log it. */
|
|
|
|
log(LOG_ERR, "prelist_update: IFID undefined (%s)\n",
|
|
|
|
if_name(ifp));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (ifidlen + pr->ndpr_plen != 128) {
|
|
|
|
nd6log((LOG_INFO,
|
|
|
|
"prelist_update: invalid prefixlen "
|
|
|
|
"%d for %s, ignored\n",
|
|
|
|
pr->ndpr_plen, if_name(ifp)));
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ia6 = in6_ifadd(new, mcast)) != NULL) {
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* note that we should use pr (not new) for reference.
|
|
|
|
*/
|
|
|
|
pr->ndpr_refcnt++;
|
|
|
|
ia6->ia6_ndpr = pr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC 3041 3.3 (2).
|
|
|
|
* When a new public address is created as described
|
|
|
|
* in RFC2462, also create a new temporary address.
|
|
|
|
*
|
|
|
|
* RFC 3041 3.5.
|
|
|
|
* When an interface connects to a new link, a new
|
|
|
|
* randomized interface identifier should be generated
|
|
|
|
* immediately together with a new set of temporary
|
|
|
|
* addresses. Thus, we specifiy 1 as the 2nd arg of
|
|
|
|
* in6_tmpifadd().
|
|
|
|
*/
|
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
|
|
|
if (V_ip6_use_tempaddr) {
|
2001-06-11 12:39:29 +00:00
|
|
|
int e;
|
2005-10-21 16:23:01 +00:00
|
|
|
if ((e = in6_tmpifadd(ia6, 1, 1)) != 0) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_NOTICE, "prelist_update: "
|
|
|
|
"failed to create a temporary "
|
|
|
|
"address, errno=%d\n",
|
|
|
|
e));
|
|
|
|
}
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* A newly added address might affect the status
|
|
|
|
* of other addresses, so we check and update it.
|
|
|
|
* XXX: what if address duplication happens?
|
|
|
|
*/
|
|
|
|
pfxlist_onlink_check();
|
|
|
|
} else {
|
|
|
|
/* just set an error. do not bark here. */
|
|
|
|
error = EADDRNOTAVAIL; /* XXX: might be unused. */
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
splx(s);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
|
|
|
* A supplement function used in the on-link detection below;
|
|
|
|
* detect if a given prefix has a (probably) reachable advertising router.
|
|
|
|
* XXX: lengthy function name...
|
|
|
|
*/
|
2001-06-11 12:39:29 +00:00
|
|
|
static struct nd_pfxrouter *
|
2007-07-05 16:23:49 +00:00
|
|
|
find_pfxlist_reachable_router(struct nd_prefix *pr)
|
2000-07-04 16:35:15 +00:00
|
|
|
{
|
|
|
|
struct nd_pfxrouter *pfxrtr;
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
struct llentry *ln;
|
2008-12-16 03:05:18 +00:00
|
|
|
int canreach;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
2008-12-16 23:56:24 +00:00
|
|
|
for (pfxrtr = LIST_FIRST(&pr->ndpr_advrtrs); pfxrtr != NULL;
|
2000-07-04 16:35:15 +00:00
|
|
|
pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) {
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
IF_AFDATA_LOCK(pfxrtr->router->ifp);
|
2008-12-16 03:05:18 +00:00
|
|
|
ln = nd6_lookup(&pfxrtr->router->rtaddr, 0, pfxrtr->router->ifp);
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
IF_AFDATA_UNLOCK(pfxrtr->router->ifp);
|
2008-12-16 23:56:24 +00:00
|
|
|
if (ln == NULL)
|
|
|
|
continue;
|
|
|
|
canreach = ND6_IS_LLINFO_PROBREACH(ln);
|
|
|
|
LLE_RUNLOCK(ln);
|
2008-12-16 03:05:18 +00:00
|
|
|
if (canreach)
|
|
|
|
break;
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
2003-10-06 14:02:09 +00:00
|
|
|
return (pfxrtr);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
|
|
|
* Check if each prefix in the prefix list has at least one available router
|
2001-06-11 12:39:29 +00:00
|
|
|
* that advertised the prefix (a router is "available" if its neighbor cache
|
|
|
|
* entry is reachable or probably reachable).
|
2000-07-04 16:35:15 +00:00
|
|
|
* If the check fails, the prefix may be off-link, because, for example,
|
1999-11-22 02:45:11 +00:00
|
|
|
* we have moved from the network but the lifetime of the prefix has not
|
2001-06-11 12:39:29 +00:00
|
|
|
* expired yet. So we should not use the prefix if there is another prefix
|
|
|
|
* that has an available router.
|
|
|
|
* But, if there is no prefix that has an available router, we still regards
|
|
|
|
* all the prefixes as on-link. This is because we can't tell if all the
|
1999-11-22 02:45:11 +00:00
|
|
|
* routers are simply dead or if we really moved from the network and there
|
|
|
|
* is no router around us.
|
|
|
|
*/
|
2000-07-04 16:35:15 +00:00
|
|
|
void
|
1999-11-22 02:45:11 +00:00
|
|
|
pfxlist_onlink_check()
|
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
1999-11-22 02:45:11 +00:00
|
|
|
struct nd_prefix *pr;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_ifaddr *ifa;
|
2005-10-21 16:23:01 +00:00
|
|
|
struct nd_defrouter *dr;
|
|
|
|
struct nd_pfxrouter *pfxrtr = NULL;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2000-07-04 16:35:15 +00:00
|
|
|
/*
|
|
|
|
* Check if there is a prefix that has a reachable advertising
|
|
|
|
* router.
|
|
|
|
*/
|
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
|
|
|
for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (pr->ndpr_raf_onlink && find_pfxlist_reachable_router(pr))
|
1999-11-22 02:45:11 +00:00
|
|
|
break;
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* If we have no such prefix, check whether we still have a router
|
|
|
|
* that does not advertise any prefixes.
|
|
|
|
*/
|
2005-10-19 10:09:19 +00:00
|
|
|
if (pr == NULL) {
|
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
|
|
|
for (dr = TAILQ_FIRST(&V_nd_defrouter); dr;
|
2005-10-21 16:23:01 +00:00
|
|
|
dr = TAILQ_NEXT(dr, dr_entry)) {
|
|
|
|
struct nd_prefix *pr0;
|
|
|
|
|
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
|
|
|
for (pr0 = V_nd_prefix.lh_first; pr0;
|
2005-10-21 16:23:01 +00:00
|
|
|
pr0 = pr0->ndpr_next) {
|
|
|
|
if ((pfxrtr = pfxrtr_lookup(pr0, dr)) != NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pfxrtr != NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
if (pr != NULL || (TAILQ_FIRST(&V_nd_defrouter) && pfxrtr == NULL)) {
|
2007-07-05 16:29:40 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* There is at least one prefix that has a reachable router,
|
|
|
|
* or at least a router which probably does not advertise
|
|
|
|
* any prefixes. The latter would be the case when we move
|
|
|
|
* to a new link where we have a router that does not provide
|
|
|
|
* prefixes and we configure an address by hand.
|
2007-07-05 16:29:40 +00:00
|
|
|
* Detach prefixes which have no reachable advertising
|
|
|
|
* router, and attach other prefixes.
|
|
|
|
*/
|
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
|
|
|
for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
/* XXX: a link-local prefix should never be detached */
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we aren't interested in prefixes without the L bit
|
|
|
|
* set.
|
|
|
|
*/
|
|
|
|
if (pr->ndpr_raf_onlink == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_DETACHED) == 0 &&
|
|
|
|
find_pfxlist_reachable_router(pr) == NULL)
|
|
|
|
pr->ndpr_stateflags |= NDPRF_DETACHED;
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
|
|
|
|
find_pfxlist_reachable_router(pr) != 0)
|
|
|
|
pr->ndpr_stateflags &= ~NDPRF_DETACHED;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
} else {
|
|
|
|
/* there is no prefix that has a reachable router */
|
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
|
|
|
for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pr->ndpr_raf_onlink == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0)
|
|
|
|
pr->ndpr_stateflags &= ~NDPRF_DETACHED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove each interface route associated with a (just) detached
|
|
|
|
* prefix, and reinstall the interface route for a (just) attached
|
|
|
|
* prefix. Note that all attempt of reinstallation does not
|
|
|
|
* necessarily success, when a same prefix is shared among multiple
|
|
|
|
* interfaces. Such cases will be handled in nd6_prefix_onlink,
|
|
|
|
* so we don't have to care about them.
|
|
|
|
*/
|
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
|
|
|
for (pr = V_nd_prefix.lh_first; pr; pr = pr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
int e;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pr->ndpr_raf_onlink == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
|
|
|
|
(pr->ndpr_stateflags & NDPRF_ONLINK) != 0) {
|
|
|
|
if ((e = nd6_prefix_offlink(pr)) != 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"pfxlist_onlink_check: failed to "
|
2005-10-19 17:18:49 +00:00
|
|
|
"make %s/%d offlink, errno=%d\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf,
|
|
|
|
&pr->ndpr_prefix.sin6_addr),
|
|
|
|
pr->ndpr_plen, e));
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_DETACHED) == 0 &&
|
|
|
|
(pr->ndpr_stateflags & NDPRF_ONLINK) == 0 &&
|
|
|
|
pr->ndpr_raf_onlink) {
|
|
|
|
if ((e = nd6_prefix_onlink(pr)) != 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"pfxlist_onlink_check: failed to "
|
2005-10-19 17:18:49 +00:00
|
|
|
"make %s/%d onlink, errno=%d\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf,
|
|
|
|
&pr->ndpr_prefix.sin6_addr),
|
|
|
|
pr->ndpr_plen, e));
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Changes on the prefix status might affect address status as well.
|
|
|
|
* Make sure that all addresses derived from an attached prefix are
|
|
|
|
* attached, and that all addresses derived from a detached prefix are
|
|
|
|
* detached. Note, however, that a manually configured address should
|
|
|
|
* always be attached.
|
|
|
|
* The precise detection logic is same as the one for prefixes.
|
|
|
|
*/
|
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
|
|
|
for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
|
2003-10-09 16:13:47 +00:00
|
|
|
if (!(ifa->ia6_flags & IN6_IFF_AUTOCONF))
|
2001-06-11 12:39:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ifa->ia6_ndpr == NULL) {
|
|
|
|
/*
|
|
|
|
* This can happen when we first configure the address
|
|
|
|
* (i.e. the address exists, but the prefix does not).
|
|
|
|
* XXX: complicated relationships...
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (find_pfxlist_reachable_router(ifa->ia6_ndpr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ifa) {
|
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
|
|
|
for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ifa->ia6_ndpr == NULL) /* XXX: see above. */
|
|
|
|
continue;
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
if (find_pfxlist_reachable_router(ifa->ia6_ndpr)) {
|
|
|
|
if (ifa->ia6_flags & IN6_IFF_DETACHED) {
|
|
|
|
ifa->ia6_flags &= ~IN6_IFF_DETACHED;
|
|
|
|
ifa->ia6_flags |= IN6_IFF_TENTATIVE;
|
|
|
|
nd6_dad_start((struct ifaddr *)ifa, 0);
|
|
|
|
}
|
|
|
|
} else {
|
2001-06-11 12:39:29 +00:00
|
|
|
ifa->ia6_flags |= IN6_IFF_DETACHED;
|
2005-10-21 16:23:01 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
else {
|
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
|
|
|
for (ifa = V_in6_ifaddr; ifa; ifa = ifa->ia_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
|
|
|
|
continue;
|
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
if (ifa->ia6_flags & IN6_IFF_DETACHED) {
|
|
|
|
ifa->ia6_flags &= ~IN6_IFF_DETACHED;
|
|
|
|
ifa->ia6_flags |= IN6_IFF_TENTATIVE;
|
|
|
|
/* Do we need a delay in this case? */
|
|
|
|
nd6_dad_start((struct ifaddr *)ifa, 0);
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_prefix_onlink(struct nd_prefix *pr)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
2009-04-26 22:06:42 +00:00
|
|
|
INIT_VNET_NET(curvnet);
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct ifnet *ifp = pr->ndpr_ifp;
|
|
|
|
struct sockaddr_in6 mask6;
|
|
|
|
struct nd_prefix *opr;
|
|
|
|
u_long rtflags;
|
|
|
|
int error = 0;
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
struct radix_node_head *rnh;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct rtentry *rt = NULL;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_prefix_onlink: %s/%d is already on-link\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
|
|
|
pr->ndpr_plen));
|
2005-10-19 10:09:19 +00:00
|
|
|
return (EEXIST);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the interface route associated with the prefix. Before
|
|
|
|
* installing the route, check if there's the same prefix on another
|
|
|
|
* interface, and the prefix has already installed the interface route.
|
|
|
|
* Although such a configuration is expected to be rare, we explicitly
|
|
|
|
* allow it.
|
|
|
|
*/
|
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
|
|
|
for (opr = V_nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (opr == pr)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((opr->ndpr_stateflags & NDPRF_ONLINK) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (opr->ndpr_plen == pr->ndpr_plen &&
|
|
|
|
in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr,
|
2003-10-09 16:13:47 +00:00
|
|
|
&opr->ndpr_prefix.sin6_addr, pr->ndpr_plen))
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2003-10-09 16:13:47 +00:00
|
|
|
* We prefer link-local addresses as the associated interface address.
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
|
|
|
/* search for a link-local addr */
|
|
|
|
ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp,
|
2003-10-09 16:13:47 +00:00
|
|
|
IN6_IFF_NOTREADY | IN6_IFF_ANYCAST);
|
2001-06-11 12:39:29 +00:00
|
|
|
if (ifa == NULL) {
|
|
|
|
/* XXX: freebsd does not have ifa_ifwithaf */
|
2009-04-20 22:45:21 +00:00
|
|
|
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (ifa->ifa_addr->sa_family == AF_INET6)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* should we care about ia6_flags? */
|
|
|
|
}
|
|
|
|
if (ifa == NULL) {
|
|
|
|
/*
|
|
|
|
* This can still happen, when, for example, we receive an RA
|
|
|
|
* containing a prefix with the L bit set and the A bit clear,
|
|
|
|
* after removing all IPv6 addresses on the receiving
|
|
|
|
* interface. This should, of course, be rare though.
|
|
|
|
*/
|
|
|
|
nd6log((LOG_NOTICE,
|
|
|
|
"nd6_prefix_onlink: failed to find any ifaddr"
|
|
|
|
" to add route for a prefix(%s/%d) on %s\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_plen, if_name(ifp)));
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
2001-06-11 12:39:29 +00:00
|
|
|
* in6_ifinit() sets nd6_rtrequest to ifa_rtrequest for all ifaddrs.
|
|
|
|
* ifa->ifa_rtrequest = nd6_rtrequest;
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2001-06-11 12:39:29 +00:00
|
|
|
bzero(&mask6, sizeof(mask6));
|
|
|
|
mask6.sin6_len = sizeof(mask6);
|
|
|
|
mask6.sin6_addr = pr->ndpr_mask;
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
rtflags = ifa->ifa_flags | RTF_UP;
|
2001-06-11 12:39:29 +00:00
|
|
|
error = rtrequest(RTM_ADD, (struct sockaddr *)&pr->ndpr_prefix,
|
2003-10-09 16:13:47 +00:00
|
|
|
ifa->ifa_addr, (struct sockaddr *)&mask6, rtflags, &rt);
|
2001-06-11 12:39:29 +00:00
|
|
|
if (error == 0) {
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
if (rt != NULL) /* this should be non NULL, though */ {
|
|
|
|
rnh = V_rt_tables[rt->rt_fibnum][AF_INET6];
|
|
|
|
RADIX_NODE_HEAD_LOCK(rnh);
|
|
|
|
RT_LOCK(rt);
|
|
|
|
if (!rt_setgate(rt, rt_key(rt), (struct sockaddr *)&null_sdl)) {
|
|
|
|
((struct sockaddr_dl *)rt->rt_gateway)->sdl_type =
|
|
|
|
rt->rt_ifp->if_type;
|
|
|
|
((struct sockaddr_dl *)rt->rt_gateway)->sdl_index =
|
|
|
|
rt->rt_ifp->if_index;
|
|
|
|
}
|
|
|
|
RADIX_NODE_HEAD_UNLOCK(rnh);
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6_rtmsg(RTM_ADD, rt);
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
RT_UNLOCK(rt);
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_stateflags |= NDPRF_ONLINK;
|
2003-10-09 16:13:47 +00:00
|
|
|
} else {
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6bufg[INET6_ADDRSTRLEN], ip6bufm[INET6_ADDRSTRLEN];
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add route for a"
|
|
|
|
" prefix (%s/%d) on %s, gw=%s, mask=%s, flags=%lx "
|
|
|
|
"errno = %d\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
pr->ndpr_plen, if_name(ifp),
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6bufg, &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr),
|
|
|
|
ip6_sprintf(ip6bufm, &mask6.sin6_addr), rtflags, error));
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-04 03:44:50 +00:00
|
|
|
if (rt != NULL) {
|
|
|
|
RT_LOCK(rt);
|
2003-11-08 23:36:32 +00:00
|
|
|
RT_REMREF(rt);
|
2003-10-04 03:44:50 +00:00
|
|
|
RT_UNLOCK(rt);
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (error);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_prefix_offlink(struct nd_prefix *pr)
|
2001-06-11 12:39:29 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
int error = 0;
|
|
|
|
struct ifnet *ifp = pr->ndpr_ifp;
|
|
|
|
struct nd_prefix *opr;
|
|
|
|
struct sockaddr_in6 sa6, mask6;
|
|
|
|
struct rtentry *rt = NULL;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
if ((pr->ndpr_stateflags & NDPRF_ONLINK) == 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_prefix_offlink: %s/%d is already off-link\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
|
|
|
|
pr->ndpr_plen));
|
2003-10-06 14:02:09 +00:00
|
|
|
return (EEXIST);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
bzero(&sa6, sizeof(sa6));
|
|
|
|
sa6.sin6_family = AF_INET6;
|
|
|
|
sa6.sin6_len = sizeof(sa6);
|
|
|
|
bcopy(&pr->ndpr_prefix.sin6_addr, &sa6.sin6_addr,
|
2003-10-09 16:13:47 +00:00
|
|
|
sizeof(struct in6_addr));
|
1999-11-22 02:45:11 +00:00
|
|
|
bzero(&mask6, sizeof(mask6));
|
|
|
|
mask6.sin6_family = AF_INET6;
|
|
|
|
mask6.sin6_len = sizeof(sa6);
|
|
|
|
bcopy(&pr->ndpr_mask, &mask6.sin6_addr, sizeof(struct in6_addr));
|
2001-06-11 12:39:29 +00:00
|
|
|
error = rtrequest(RTM_DELETE, (struct sockaddr *)&sa6, NULL,
|
2003-10-09 16:13:47 +00:00
|
|
|
(struct sockaddr *)&mask6, 0, &rt);
|
2001-06-11 12:39:29 +00:00
|
|
|
if (error == 0) {
|
|
|
|
pr->ndpr_stateflags &= ~NDPRF_ONLINK;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* report the route deletion to the routing socket. */
|
|
|
|
if (rt != NULL)
|
|
|
|
nd6_rtmsg(RTM_DELETE, rt);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* There might be the same prefix on another interface,
|
|
|
|
* the prefix which could not be on-link just because we have
|
|
|
|
* the interface route (see comments in nd6_prefix_onlink).
|
|
|
|
* If there's one, try to make the prefix on-link on the
|
|
|
|
* interface.
|
|
|
|
*/
|
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
|
|
|
for (opr = V_nd_prefix.lh_first; opr; opr = opr->ndpr_next) {
|
2001-06-11 12:39:29 +00:00
|
|
|
if (opr == pr)
|
|
|
|
continue;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if ((opr->ndpr_stateflags & NDPRF_ONLINK) != 0)
|
|
|
|
continue;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* KAME specific: detached prefixes should not be
|
|
|
|
* on-link.
|
|
|
|
*/
|
|
|
|
if ((opr->ndpr_stateflags & NDPRF_DETACHED) != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (opr->ndpr_plen == pr->ndpr_plen &&
|
|
|
|
in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr,
|
2003-10-09 16:13:47 +00:00
|
|
|
&opr->ndpr_prefix.sin6_addr, pr->ndpr_plen)) {
|
2001-06-11 12:39:29 +00:00
|
|
|
int e;
|
|
|
|
|
|
|
|
if ((e = nd6_prefix_onlink(opr)) != 0) {
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_prefix_offlink: failed to "
|
|
|
|
"recover a prefix %s/%d from %s "
|
|
|
|
"to %s (errno = %d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf,
|
|
|
|
&opr->ndpr_prefix.sin6_addr),
|
2001-06-11 12:39:29 +00:00
|
|
|
opr->ndpr_plen, if_name(ifp),
|
|
|
|
if_name(opr->ndpr_ifp), e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-09 16:13:47 +00:00
|
|
|
} else {
|
2001-06-11 12:39:29 +00:00
|
|
|
/* XXX: can we still set the NDPRF_ONLINK flag? */
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"nd6_prefix_offlink: failed to delete route: "
|
|
|
|
"%s/%d on %s (errno = %d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &sa6.sin6_addr), pr->ndpr_plen,
|
|
|
|
if_name(ifp), error));
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
if (rt != NULL) {
|
2002-12-25 10:21:02 +00:00
|
|
|
RTFREE(rt);
|
2003-10-09 16:13:47 +00:00
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (error);
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct in6_ifaddr *
|
2007-07-05 16:23:49 +00:00
|
|
|
in6_ifadd(struct nd_prefixctl *pr, int mcast)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
struct ifnet *ifp = pr->ndpr_ifp;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct ifaddr *ifa;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_aliasreq ifra;
|
|
|
|
struct in6_ifaddr *ia, *ib;
|
|
|
|
int error, plen0;
|
1999-11-22 02:45:11 +00:00
|
|
|
struct in6_addr mask;
|
2001-06-11 12:39:29 +00:00
|
|
|
int prefixlen = pr->ndpr_plen;
|
2005-10-21 16:23:01 +00:00
|
|
|
int updateflags;
|
2006-12-12 12:17:58 +00:00
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-17 17:50:09 +00:00
|
|
|
in6_prefixlen2mask(&mask, prefixlen);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* find a link-local address (will be interface ID).
|
|
|
|
* Is it really mandatory? Theoretically, a global or a site-local
|
|
|
|
* address can be configured without a link-local address, if we
|
|
|
|
* have a unique interface identifier...
|
|
|
|
*
|
|
|
|
* it is not mandatory to have a link-local address, we can generate
|
|
|
|
* interface identifier on the fly. we do this because:
|
|
|
|
* (1) it should be the easiest way to find interface identifier.
|
|
|
|
* (2) RFC2462 5.4 suggesting the use of the same interface identifier
|
|
|
|
* for multiple addresses on a single interface, and possible shortcut
|
|
|
|
* of DAD. we omitted DAD for this reason in the past.
|
2003-10-09 16:13:47 +00:00
|
|
|
* (3) a user can prevent autoconfiguration of global address
|
2001-06-11 12:39:29 +00:00
|
|
|
* by removing link-local address by hand (this is partly because we
|
2003-01-01 18:49:04 +00:00
|
|
|
* don't have other way to control the use of IPv6 on an interface.
|
2001-06-11 12:39:29 +00:00
|
|
|
* this has been our design choice - cf. NRL's "ifconfig auto").
|
|
|
|
* (4) it is easier to manage when an interface has addresses
|
|
|
|
* with the same interface identifier, than to have multiple addresses
|
|
|
|
* with different interface identifiers.
|
|
|
|
*/
|
2003-10-09 16:13:47 +00:00
|
|
|
ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 0); /* 0 is OK? */
|
1999-11-22 02:45:11 +00:00
|
|
|
if (ifa)
|
|
|
|
ib = (struct in6_ifaddr *)ifa;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* prefixlen + ifidlen must be equal to 128 */
|
2001-06-11 12:39:29 +00:00
|
|
|
plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL);
|
|
|
|
if (prefixlen != plen0) {
|
|
|
|
nd6log((LOG_INFO, "in6_ifadd: wrong prefixlen for %s "
|
|
|
|
"(prefix=%d ifid=%d)\n",
|
|
|
|
if_name(ifp), prefixlen, 128 - plen0));
|
1999-11-22 02:45:11 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make ifaddr */
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
bzero(&ifra, sizeof(ifra));
|
|
|
|
/*
|
|
|
|
* in6_update_ifa() does not use ifra_name, but we accurately set it
|
|
|
|
* for safety.
|
|
|
|
*/
|
|
|
|
strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name));
|
|
|
|
ifra.ifra_addr.sin6_family = AF_INET6;
|
|
|
|
ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6);
|
1999-11-22 02:45:11 +00:00
|
|
|
/* prefix */
|
2005-10-21 16:23:01 +00:00
|
|
|
ifra.ifra_addr.sin6_addr = pr->ndpr_prefix.sin6_addr;
|
2001-06-11 12:39:29 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[0] &= mask.s6_addr32[0];
|
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[1] &= mask.s6_addr32[1];
|
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[2] &= mask.s6_addr32[2];
|
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[3] &= mask.s6_addr32[3];
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* interface ID */
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[0] |=
|
2005-10-21 16:23:01 +00:00
|
|
|
(ib->ia_addr.sin6_addr.s6_addr32[0] & ~mask.s6_addr32[0]);
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[1] |=
|
2005-10-21 16:23:01 +00:00
|
|
|
(ib->ia_addr.sin6_addr.s6_addr32[1] & ~mask.s6_addr32[1]);
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[2] |=
|
2005-10-21 16:23:01 +00:00
|
|
|
(ib->ia_addr.sin6_addr.s6_addr32[2] & ~mask.s6_addr32[2]);
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[3] |=
|
2005-10-21 16:23:01 +00:00
|
|
|
(ib->ia_addr.sin6_addr.s6_addr32[3] & ~mask.s6_addr32[3]);
|
2003-10-09 16:13:47 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* new prefix mask. */
|
|
|
|
ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6);
|
|
|
|
ifra.ifra_prefixmask.sin6_family = AF_INET6;
|
|
|
|
bcopy(&mask, &ifra.ifra_prefixmask.sin6_addr,
|
2003-10-09 16:13:47 +00:00
|
|
|
sizeof(ifra.ifra_prefixmask.sin6_addr));
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
/* lifetimes. */
|
2001-06-11 12:39:29 +00:00
|
|
|
ifra.ifra_lifetime.ia6t_vltime = pr->ndpr_vltime;
|
|
|
|
ifra.ifra_lifetime.ia6t_pltime = pr->ndpr_pltime;
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* XXX: scope zone ID? */
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
ifra.ifra_flags |= IN6_IFF_AUTOCONF; /* obey autoconf */
|
2005-10-21 16:23:01 +00:00
|
|
|
|
2007-07-05 16:29:40 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* Make sure that we do not have this address already. This should
|
|
|
|
* usually not happen, but we can still see this case, e.g., if we
|
|
|
|
* have manually configured the exact address to be configured.
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
2005-10-21 16:23:01 +00:00
|
|
|
if (in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr) != NULL) {
|
|
|
|
/* this should be rare enough to make an explicit log */
|
|
|
|
log(LOG_INFO, "in6_ifadd: %s is already configured\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &ifra.ifra_addr.sin6_addr));
|
2005-10-21 16:23:01 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* Allocate ifaddr structure, link into chain, etc.
|
|
|
|
* If we are going to create a new address upon receiving a multicasted
|
|
|
|
* RA, we need to impose a random delay before starting DAD.
|
|
|
|
* [draft-ietf-ipv6-rfc2462bis-02.txt, Section 5.4.2]
|
1999-11-22 02:45:11 +00:00
|
|
|
*/
|
2005-10-21 16:23:01 +00:00
|
|
|
updateflags = 0;
|
|
|
|
if (mcast)
|
|
|
|
updateflags |= IN6_IFAUPDATE_DADDELAY;
|
|
|
|
if ((error = in6_update_ifa(ifp, &ifra, NULL, updateflags)) != 0) {
|
2001-06-11 12:39:29 +00:00
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n",
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &ifra.ifra_addr.sin6_addr),
|
|
|
|
if_name(ifp), error));
|
2003-10-06 14:02:09 +00:00
|
|
|
return (NULL); /* ifaddr must not have been allocated. */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
return (ia); /* this is always non-NULL */
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
|
|
|
|
2007-07-05 16:23:49 +00:00
|
|
|
/*
|
|
|
|
* ia0 - corresponding public address
|
|
|
|
*/
|
1999-11-22 02:45:11 +00:00
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_INET6(curvnet);
|
2001-06-11 12:39:29 +00:00
|
|
|
struct ifnet *ifp = ia0->ia_ifa.ifa_ifp;
|
2005-10-21 16:23:01 +00:00
|
|
|
struct in6_ifaddr *newia, *ia;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_aliasreq ifra;
|
|
|
|
int i, error;
|
|
|
|
int trylimit = 3; /* XXX: adhoc value */
|
2005-10-21 16:23:01 +00:00
|
|
|
int updateflags;
|
2001-06-11 12:39:29 +00:00
|
|
|
u_int32_t randid[2];
|
|
|
|
time_t vltime0, pltime0;
|
|
|
|
|
|
|
|
bzero(&ifra, sizeof(ifra));
|
|
|
|
strncpy(ifra.ifra_name, if_name(ifp), sizeof(ifra.ifra_name));
|
|
|
|
ifra.ifra_addr = ia0->ia_addr;
|
|
|
|
/* copy prefix mask */
|
|
|
|
ifra.ifra_prefixmask = ia0->ia_prefixmask;
|
|
|
|
/* clear the old IFID */
|
|
|
|
for (i = 0; i < 4; i++) {
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[i] &=
|
|
|
|
ifra.ifra_prefixmask.sin6_addr.s6_addr32[i];
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
again:
|
2005-10-21 16:23:01 +00:00
|
|
|
if (in6_get_tmpifid(ifp, (u_int8_t *)randid,
|
|
|
|
(const u_int8_t *)&ia0->ia_addr.sin6_addr.s6_addr[8], forcegen)) {
|
|
|
|
nd6log((LOG_NOTICE, "in6_tmpifadd: failed to find a good "
|
|
|
|
"random IFID\n"));
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2003-10-09 16:13:47 +00:00
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[2] |=
|
|
|
|
(randid[0] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[2]));
|
|
|
|
ifra.ifra_addr.sin6_addr.s6_addr32[3] |=
|
|
|
|
(randid[1] & ~(ifra.ifra_prefixmask.sin6_addr.s6_addr32[3]));
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2007-07-05 16:29:40 +00:00
|
|
|
/*
|
2005-10-21 16:23:01 +00:00
|
|
|
* in6_get_tmpifid() quite likely provided a unique interface ID.
|
|
|
|
* However, we may still have a chance to see collision, because
|
|
|
|
* there may be a time lag between generation of the ID and generation
|
|
|
|
* of the address. So, we'll do one more sanity check.
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
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
|
|
|
for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) {
|
2005-10-21 16:23:01 +00:00
|
|
|
if (IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr,
|
|
|
|
&ifra.ifra_addr.sin6_addr)) {
|
2007-07-05 16:29:40 +00:00
|
|
|
if (trylimit-- == 0) {
|
2005-10-21 16:23:01 +00:00
|
|
|
/*
|
|
|
|
* Give up. Something strange should have
|
|
|
|
* happened.
|
|
|
|
*/
|
|
|
|
nd6log((LOG_NOTICE, "in6_tmpifadd: failed to "
|
|
|
|
"find a unique random IFID\n"));
|
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
forcegen = 1;
|
|
|
|
goto again;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* The Valid Lifetime is the lower of the Valid Lifetime of the
|
|
|
|
* public address or TEMP_VALID_LIFETIME.
|
|
|
|
* The Preferred Lifetime is the lower of the Preferred Lifetime
|
|
|
|
* of the public address or TEMP_PREFERRED_LIFETIME -
|
|
|
|
* DESYNC_FACTOR.
|
|
|
|
*/
|
2005-10-21 16:23:01 +00:00
|
|
|
if (ia0->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
|
2001-06-11 12:39:29 +00:00
|
|
|
vltime0 = IFA6_IS_INVALID(ia0) ? 0 :
|
2005-10-21 16:23:01 +00:00
|
|
|
(ia0->ia6_lifetime.ia6t_vltime -
|
|
|
|
(time_second - ia0->ia6_updatetime));
|
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
|
|
|
if (vltime0 > V_ip6_temp_valid_lifetime)
|
|
|
|
vltime0 = V_ip6_temp_valid_lifetime;
|
2001-06-11 12:39:29 +00:00
|
|
|
} else
|
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
|
|
|
vltime0 = V_ip6_temp_valid_lifetime;
|
2005-10-21 16:23:01 +00:00
|
|
|
if (ia0->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
|
2001-06-11 12:39:29 +00:00
|
|
|
pltime0 = IFA6_IS_DEPRECATED(ia0) ? 0 :
|
2005-10-21 16:23:01 +00:00
|
|
|
(ia0->ia6_lifetime.ia6t_pltime -
|
|
|
|
(time_second - ia0->ia6_updatetime));
|
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
|
|
|
if (pltime0 > V_ip6_temp_preferred_lifetime - V_ip6_desync_factor){
|
|
|
|
pltime0 = V_ip6_temp_preferred_lifetime -
|
|
|
|
V_ip6_desync_factor;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
} else
|
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
|
|
|
pltime0 = V_ip6_temp_preferred_lifetime - V_ip6_desync_factor;
|
2001-06-11 12:39:29 +00:00
|
|
|
ifra.ifra_lifetime.ia6t_vltime = vltime0;
|
|
|
|
ifra.ifra_lifetime.ia6t_pltime = pltime0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A temporary address is created only if this calculated Preferred
|
|
|
|
* Lifetime is greater than REGEN_ADVANCE time units.
|
|
|
|
*/
|
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
|
|
|
if (ifra.ifra_lifetime.ia6t_pltime <= V_ip6_temp_regen_advance)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* XXX: scope zone ID? */
|
|
|
|
|
|
|
|
ifra.ifra_flags |= (IN6_IFF_AUTOCONF|IN6_IFF_TEMPORARY);
|
|
|
|
|
|
|
|
/* allocate ifaddr structure, link into chain, etc. */
|
2005-10-21 16:23:01 +00:00
|
|
|
updateflags = 0;
|
|
|
|
if (delay)
|
|
|
|
updateflags |= IN6_IFAUPDATE_DADDELAY;
|
|
|
|
if ((error = in6_update_ifa(ifp, &ifra, NULL, updateflags)) != 0)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (error);
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
newia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr);
|
|
|
|
if (newia == NULL) { /* XXX: can it happen? */
|
|
|
|
nd6log((LOG_ERR,
|
|
|
|
"in6_tmpifadd: ifa update succeeded, but we got "
|
|
|
|
"no ifaddr\n"));
|
2003-10-06 14:02:09 +00:00
|
|
|
return (EINVAL); /* XXX */
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
newia->ia6_ndpr = ia0->ia6_ndpr;
|
|
|
|
newia->ia6_ndpr->ndpr_refcnt++;
|
|
|
|
|
2001-06-18 11:37:06 +00:00
|
|
|
/*
|
|
|
|
* A newly added address might affect the status of other addresses.
|
|
|
|
* XXX: when the temporary address is generated with a new public
|
|
|
|
* address, the onlink check is redundant. However, it would be safe
|
|
|
|
* to do the check explicitly everywhere a new address is generated,
|
|
|
|
* and, in fact, we surely need the check when we create a new
|
|
|
|
* temporary address due to deprecation of an old temporary address.
|
|
|
|
*/
|
|
|
|
pfxlist_onlink_check();
|
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2003-10-09 16:13:47 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2005-10-21 16:23:01 +00:00
|
|
|
static int
|
1999-11-22 02:45:11 +00:00
|
|
|
in6_init_prefix_ltimes(struct nd_prefix *ndpr)
|
|
|
|
{
|
|
|
|
if (ndpr->ndpr_pltime == ND6_INFINITE_LIFETIME)
|
|
|
|
ndpr->ndpr_preferred = 0;
|
|
|
|
else
|
|
|
|
ndpr->ndpr_preferred = time_second + ndpr->ndpr_pltime;
|
|
|
|
if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME)
|
|
|
|
ndpr->ndpr_expire = 0;
|
|
|
|
else
|
|
|
|
ndpr->ndpr_expire = time_second + ndpr->ndpr_vltime;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-11 12:39:29 +00:00
|
|
|
in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
2001-06-11 12:39:29 +00:00
|
|
|
/* init ia6t_expire */
|
|
|
|
if (lt6->ia6t_vltime == ND6_INFINITE_LIFETIME)
|
|
|
|
lt6->ia6t_expire = 0;
|
|
|
|
else {
|
|
|
|
lt6->ia6t_expire = time_second;
|
|
|
|
lt6->ia6t_expire += lt6->ia6t_vltime;
|
1999-11-22 02:45:11 +00:00
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/* init ia6t_preferred */
|
|
|
|
if (lt6->ia6t_pltime == ND6_INFINITE_LIFETIME)
|
|
|
|
lt6->ia6t_preferred = 0;
|
|
|
|
else {
|
|
|
|
lt6->ia6t_preferred = time_second;
|
|
|
|
lt6->ia6t_preferred += lt6->ia6t_pltime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete all the routing table entries that use the specified gateway.
|
|
|
|
* XXX: this function causes search through all entries of routing table, so
|
|
|
|
* it shouldn't be called when acting as a router.
|
|
|
|
*/
|
|
|
|
void
|
2007-07-05 16:23:49 +00:00
|
|
|
rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_NET(curvnet);
|
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
|
|
|
struct radix_node_head *rnh = V_rt_tables[0][AF_INET6];
|
1999-11-22 02:45:11 +00:00
|
|
|
int s = splnet();
|
|
|
|
|
|
|
|
/* We'll care only link-local addresses */
|
|
|
|
if (!IN6_IS_ADDR_LINKLOCAL(gateway)) {
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-24 03:03:39 +00:00
|
|
|
RADIX_NODE_HEAD_LOCK(rnh);
|
1999-11-22 02:45:11 +00:00
|
|
|
rnh->rnh_walktree(rnh, rt6_deleteroute, (void *)gateway);
|
2002-12-24 03:03:39 +00:00
|
|
|
RADIX_NODE_HEAD_UNLOCK(rnh);
|
1999-11-22 02:45:11 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-07-05 16:23:49 +00:00
|
|
|
rt6_deleteroute(struct radix_node *rn, void *arg)
|
1999-11-22 02:45:11 +00:00
|
|
|
{
|
|
|
|
#define SIN6(s) ((struct sockaddr_in6 *)s)
|
|
|
|
struct rtentry *rt = (struct rtentry *)rn;
|
|
|
|
struct in6_addr *gate = (struct in6_addr *)arg;
|
|
|
|
|
|
|
|
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) {
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2003-10-09 16:13:47 +00:00
|
|
|
}
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/*
|
|
|
|
* Do not delete a static route.
|
|
|
|
* XXX: this seems to be a bit ad-hoc. Should we consider the
|
|
|
|
* 'cloned' bit instead?
|
|
|
|
*/
|
|
|
|
if ((rt->rt_flags & RTF_STATIC) != 0)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
2001-06-11 12:39:29 +00:00
|
|
|
|
1999-11-22 02:45:11 +00:00
|
|
|
/*
|
|
|
|
* We delete only host route. This means, in particular, we don't
|
|
|
|
* delete default route.
|
|
|
|
*/
|
|
|
|
if ((rt->rt_flags & RTF_HOST) == 0)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (0);
|
1999-11-22 02:45:11 +00:00
|
|
|
|
2003-10-09 16:13:47 +00:00
|
|
|
return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
|
|
|
|
rt_mask(rt), rt->rt_flags, 0));
|
1999-11-22 02:45:11 +00:00
|
|
|
#undef SIN6
|
|
|
|
}
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
int
|
2007-07-05 16:23:49 +00:00
|
|
|
nd6_setdefaultiface(int ifindex)
|
2000-07-04 16:35:15 +00:00
|
|
|
{
|
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
|
|
|
INIT_VNET_NET(curvnet);
|
|
|
|
INIT_VNET_INET6(curvnet);
|
2000-07-04 16:35:15 +00:00
|
|
|
int error = 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
|
|
|
if (ifindex < 0 || V_if_index < ifindex)
|
2003-10-06 14:02:09 +00:00
|
|
|
return (EINVAL);
|
2005-10-21 16:23:01 +00:00
|
|
|
if (ifindex != 0 && !ifnet_byindex(ifindex))
|
|
|
|
return (EINVAL);
|
2000-07-04 16:35:15 +00:00
|
|
|
|
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
|
|
|
if (V_nd6_defifindex != ifindex) {
|
|
|
|
V_nd6_defifindex = ifindex;
|
|
|
|
if (V_nd6_defifindex > 0)
|
|
|
|
V_nd6_defifp = ifnet_byindex(V_nd6_defifindex);
|
2000-07-04 16:35:15 +00:00
|
|
|
else
|
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
|
|
|
V_nd6_defifp = NULL;
|
2000-07-04 16:35:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Our current implementation assumes one-to-one maping between
|
|
|
|
* interfaces and links, so it would be natural to use the
|
|
|
|
* default interface as the default link.
|
|
|
|
*/
|
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
|
|
|
scope6_setdefault(V_nd6_defifp);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|
|
|
|
|
2003-10-06 14:02:09 +00:00
|
|
|
return (error);
|
2000-07-04 16:35:15 +00:00
|
|
|
}
|