2001-01-21 15:25:46 +00:00
|
|
|
/* $FreeBSD$ */
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
/* $KAME: config.c,v 1.84 2003/08/05 12:34:23 itojun Exp $ */
|
2000-07-05 22:09:50 +00:00
|
|
|
|
2000-01-06 12:40:54 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1998 WIDE Project.
|
2011-07-17 19:24:54 +00:00
|
|
|
* Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
|
2000-01-06 12:40:54 +00:00
|
|
|
* All rights reserved.
|
2011-06-06 03:06:43 +00:00
|
|
|
*
|
2000-01-06 12:40:54 +00:00
|
|
|
* 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.
|
2011-06-06 03:06:43 +00:00
|
|
|
*
|
2000-01-06 12:40:54 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_var.h>
|
2000-02-10 19:33:58 +00:00
|
|
|
#include <netinet/ip6.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
#include <netinet6/ip6_var.h>
|
2000-02-10 19:33:58 +00:00
|
|
|
#include <netinet/icmp6.h>
|
2005-10-19 15:05:42 +00:00
|
|
|
#include <netinet6/nd6.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <syslog.h>
|
|
|
|
#include <errno.h>
|
2011-07-17 19:24:54 +00:00
|
|
|
#include <inttypes.h>
|
2011-06-06 03:06:43 +00:00
|
|
|
#include <netdb.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
#include <string.h>
|
2004-10-22 07:31:12 +00:00
|
|
|
#include <search.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
#include <stdlib.h>
|
2013-08-05 20:13:02 +00:00
|
|
|
#include <time.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
#include <unistd.h>
|
2001-06-11 12:39:29 +00:00
|
|
|
#include <ifaddrs.h>
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
#include "rtadvd.h"
|
|
|
|
#include "advcap.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "if.h"
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
/* label of tcapcode + number + domain name + zero octet */
|
|
|
|
static char entbuf[10 + 3 + NI_MAXHOST + 1];
|
|
|
|
static char oentbuf[10 + 3 + NI_MAXHOST + 1];
|
|
|
|
static char abuf[DNAME_LABELENC_MAXLEN];
|
|
|
|
|
2002-06-13 16:59:31 +00:00
|
|
|
static time_t prefix_timo = (60 * 120); /* 2 hours.
|
|
|
|
* XXX: should be configurable. */
|
|
|
|
|
2007-11-07 10:53:41 +00:00
|
|
|
static struct rtadvd_timer *prefix_timeout(void *);
|
2011-06-06 03:06:43 +00:00
|
|
|
static void makeentry(char *, size_t, int, const char *);
|
2014-10-11 23:24:09 +00:00
|
|
|
static ssize_t dname_labelenc(char *, const char *);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
/* Encode domain name label encoding in RFC 1035 Section 3.1 */
|
2014-10-11 23:24:09 +00:00
|
|
|
static ssize_t
|
2011-06-06 03:06:43 +00:00
|
|
|
dname_labelenc(char *dst, const char *src)
|
2000-01-06 12:40:54 +00:00
|
|
|
{
|
2011-06-06 03:06:43 +00:00
|
|
|
char *dst_origin;
|
|
|
|
char *p;
|
|
|
|
size_t len;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
dst_origin = dst;
|
|
|
|
len = strlen(src);
|
|
|
|
|
2014-10-11 23:24:09 +00:00
|
|
|
if (len + len / 64 + 1 + 1 > DNAME_LABELENC_MAXLEN)
|
|
|
|
return (-1);
|
2011-06-06 03:06:43 +00:00
|
|
|
/* Length fields per 63 octets + '\0' (<= DNAME_LABELENC_MAXLEN) */
|
|
|
|
memset(dst, 0, len + len / 64 + 1 + 1);
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> labelenc = %s", __func__, src);
|
|
|
|
while (src && (len = strlen(src)) != 0) {
|
|
|
|
/* Put a length field with 63 octet limitation first. */
|
|
|
|
p = strchr(src, '.');
|
|
|
|
if (p == NULL)
|
2014-10-11 23:24:09 +00:00
|
|
|
*dst = len = MIN(63, len);
|
|
|
|
else
|
|
|
|
*dst = len = MIN(63, p - src);
|
|
|
|
if (dst + 1 + len < dst_origin + DNAME_LABELENC_MAXLEN)
|
|
|
|
dst++;
|
2011-06-06 03:06:43 +00:00
|
|
|
else
|
2014-10-11 23:24:09 +00:00
|
|
|
return (-1);
|
2011-06-06 03:06:43 +00:00
|
|
|
/* Copy 63 octets at most. */
|
|
|
|
memcpy(dst, src, len);
|
|
|
|
dst += len;
|
|
|
|
if (p == NULL) /* the last label */
|
|
|
|
break;
|
|
|
|
src = p + 1;
|
|
|
|
}
|
|
|
|
/* Always need a 0-length label at the tail. */
|
|
|
|
*dst++ = '\0';
|
|
|
|
|
2011-06-06 10:51:00 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s> labellen = %td", __func__, dst - dst_origin);
|
2011-06-06 03:06:43 +00:00
|
|
|
return (dst - dst_origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MUSTHAVE(var, cap) \
|
2000-07-05 22:09:50 +00:00
|
|
|
do { \
|
2003-08-11 15:46:37 +00:00
|
|
|
int64_t t; \
|
2000-01-06 12:40:54 +00:00
|
|
|
if ((t = agetnum(cap)) < 0) { \
|
|
|
|
fprintf(stderr, "rtadvd: need %s for interface %s\n", \
|
|
|
|
cap, intface); \
|
|
|
|
exit(1); \
|
|
|
|
} \
|
|
|
|
var = t; \
|
2000-07-05 22:09:50 +00:00
|
|
|
} while (0)
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
#define MAYHAVE(var, cap, def) \
|
2000-07-05 22:09:50 +00:00
|
|
|
do { \
|
2000-01-06 12:40:54 +00:00
|
|
|
if ((var = agetnum(cap)) < 0) \
|
|
|
|
var = def; \
|
2000-07-05 22:09:50 +00:00
|
|
|
} while (0)
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
int
|
|
|
|
loadconfig_index(int idx)
|
|
|
|
{
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> enter", __func__);
|
|
|
|
|
|
|
|
if (if_indextoname(idx, ifname) != NULL)
|
|
|
|
return (loadconfig_ifname(ifname));
|
|
|
|
else
|
|
|
|
return (1);
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
|
2011-06-11 03:25:10 +00:00
|
|
|
int
|
2011-07-17 19:24:54 +00:00
|
|
|
loadconfig_ifname(char *ifname)
|
2011-06-11 03:25:10 +00:00
|
|
|
{
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> enter", __func__);
|
|
|
|
|
|
|
|
update_ifinfo(&ifilist, UPDATE_IFINFO_ALL);
|
|
|
|
TAILQ_FOREACH(ifi, &ifilist, ifi_next) {
|
|
|
|
/* NULL means all IFs will be processed. */
|
|
|
|
if (ifname != NULL &&
|
|
|
|
strcmp(ifi->ifi_ifname, ifname) != 0)
|
|
|
|
continue;
|
2011-06-11 03:25:10 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if (!ifi->ifi_persist) {
|
|
|
|
syslog(LOG_INFO,
|
|
|
|
"<%s> %s is not a target interface. "
|
|
|
|
"Ignored at this moment.", __func__,
|
|
|
|
ifi->ifi_ifname);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ifi->ifi_ifindex == 0) {
|
2011-06-11 03:25:10 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> %s not found. "
|
|
|
|
"Ignored at this moment.", __func__,
|
|
|
|
ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
if (getconfig(ifi) == NULL) {
|
2011-06-11 03:25:10 +00:00
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> invalid configuration for %s. "
|
2011-07-17 19:24:54 +00:00
|
|
|
"Ignored at this moment.", __func__,
|
|
|
|
ifi->ifi_ifname);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rm_ifinfo_index(int idx)
|
|
|
|
{
|
|
|
|
struct ifinfo *ifi;
|
|
|
|
|
|
|
|
ifi = if_indextoifinfo(idx);
|
|
|
|
if (ifi == NULL) {
|
|
|
|
syslog(LOG_ERR, "<%s>: ifinfo not found (idx=%d)",
|
|
|
|
__func__, idx);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (rm_ifinfo(ifi));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rm_ifinfo(struct ifinfo *ifi)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> enter (%s).", __func__, ifi->ifi_ifname);
|
|
|
|
switch (ifi->ifi_state) {
|
|
|
|
case IFI_STATE_UNCONFIGURED:
|
|
|
|
return (0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ifi->ifi_state = IFI_STATE_UNCONFIGURED;
|
|
|
|
syslog(LOG_DEBUG,
|
|
|
|
"<%s> ifname=%s marked as UNCONFIGURED.",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
|
2011-12-30 10:58:14 +00:00
|
|
|
/* XXX: No MC leaving here because index is disappeared */
|
2011-07-17 19:24:54 +00:00
|
|
|
|
|
|
|
/* Inactivate timer */
|
|
|
|
rtadvd_remove_timer(ifi->ifi_ra_timer);
|
|
|
|
ifi->ifi_ra_timer = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up ifi */
|
|
|
|
if (!ifi->ifi_persist) {
|
|
|
|
TAILQ_REMOVE(&ifilist, ifi, ifi_next);
|
|
|
|
syslog(LOG_DEBUG, "<%s>: ifinfo (idx=%d) removed.",
|
|
|
|
__func__, ifi->ifi_ifindex);
|
|
|
|
} else {
|
|
|
|
/* recreate an empty entry */
|
|
|
|
update_persist_ifinfo(&ifilist, ifi->ifi_ifname);
|
|
|
|
syslog(LOG_DEBUG, "<%s>: ifname=%s is persistent.",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up rai if any */
|
|
|
|
switch (ifi->ifi_state) {
|
|
|
|
case IFI_STATE_CONFIGURED:
|
|
|
|
if (ifi->ifi_rainfo != NULL) {
|
|
|
|
error = rm_rainfo(ifi->ifi_rainfo);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ifi->ifi_rainfo = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IFI_STATE_TRANSITIVE:
|
|
|
|
if (ifi->ifi_rainfo == ifi->ifi_rainfo_trans) {
|
|
|
|
if (ifi->ifi_rainfo != NULL) {
|
|
|
|
error = rm_rainfo(ifi->ifi_rainfo);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ifi->ifi_rainfo = NULL;
|
|
|
|
ifi->ifi_rainfo_trans = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ifi->ifi_rainfo != NULL) {
|
|
|
|
error = rm_rainfo(ifi->ifi_rainfo);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ifi->ifi_rainfo = NULL;
|
|
|
|
}
|
|
|
|
if (ifi->ifi_rainfo_trans != NULL) {
|
|
|
|
error = rm_rainfo(ifi->ifi_rainfo_trans);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ifi->ifi_rainfo_trans = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-06-11 03:25:10 +00:00
|
|
|
}
|
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s> leave (%s).", __func__, ifi->ifi_ifname);
|
2016-05-12 04:54:32 +00:00
|
|
|
if (!ifi->ifi_persist)
|
|
|
|
free(ifi);
|
2011-06-11 03:25:10 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
int
|
2011-07-17 19:24:54 +00:00
|
|
|
rm_rainfo(struct rainfo *rai)
|
2011-06-06 03:06:43 +00:00
|
|
|
{
|
|
|
|
struct prefix *pfx;
|
|
|
|
struct soliciter *sol;
|
|
|
|
struct rdnss *rdn;
|
|
|
|
struct rdnss_addr *rdna;
|
|
|
|
struct dnssl *dns;
|
|
|
|
struct rtinfo *rti;
|
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s>: enter", __func__);
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
TAILQ_REMOVE(&railist, rai, rai_next);
|
2011-07-17 19:24:54 +00:00
|
|
|
if (rai->rai_ifinfo != NULL)
|
|
|
|
syslog(LOG_DEBUG, "<%s>: rainfo (idx=%d) removed.",
|
|
|
|
__func__, rai->rai_ifinfo->ifi_ifindex);
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
if (rai->rai_ra_data != NULL)
|
|
|
|
free(rai->rai_ra_data);
|
|
|
|
|
2013-08-27 11:50:33 +00:00
|
|
|
while ((pfx = TAILQ_FIRST(&rai->rai_prefix)) != NULL)
|
|
|
|
delete_prefix(pfx);
|
2011-06-06 03:06:43 +00:00
|
|
|
while ((sol = TAILQ_FIRST(&rai->rai_soliciter)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rai->rai_soliciter, sol, sol_next);
|
|
|
|
free(sol);
|
|
|
|
}
|
|
|
|
while ((rdn = TAILQ_FIRST(&rai->rai_rdnss)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rai->rai_rdnss, rdn, rd_next);
|
|
|
|
while ((rdna = TAILQ_FIRST(&rdn->rd_list)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rdn->rd_list, rdna, ra_next);
|
|
|
|
free(rdna);
|
|
|
|
}
|
|
|
|
free(rdn);
|
|
|
|
}
|
|
|
|
while ((dns = TAILQ_FIRST(&rai->rai_dnssl)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rai->rai_dnssl, dns, dn_next);
|
|
|
|
free(dns);
|
|
|
|
}
|
|
|
|
while ((rti = TAILQ_FIRST(&rai->rai_route)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rai->rai_route, rti, rti_next);
|
|
|
|
free(rti);
|
|
|
|
}
|
|
|
|
free(rai);
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s>: leave", __func__);
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *
|
|
|
|
getconfig(struct ifinfo *ifi)
|
2011-06-06 03:06:43 +00:00
|
|
|
{
|
|
|
|
int stat, i;
|
2011-07-17 19:24:54 +00:00
|
|
|
int error;
|
2011-06-06 03:06:43 +00:00
|
|
|
char tbuf[BUFSIZ];
|
|
|
|
struct rainfo *rai;
|
2011-06-11 03:25:10 +00:00
|
|
|
struct rainfo *rai_old;
|
2011-07-17 19:24:54 +00:00
|
|
|
int32_t val;
|
2011-06-06 03:06:43 +00:00
|
|
|
int64_t val64;
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
char *bp = buf;
|
|
|
|
char *addr, *flagstr;
|
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if (ifi == NULL) /* if does not exist */
|
|
|
|
return (NULL);
|
2011-06-06 03:06:43 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if (ifi->ifi_state == IFI_STATE_TRANSITIVE &&
|
|
|
|
ifi->ifi_rainfo == NULL) {
|
|
|
|
syslog(LOG_INFO, "<%s> %s is shutting down. Skipped.",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
return (NULL);
|
|
|
|
}
|
2011-06-11 03:25:10 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((stat = agetent(tbuf, ifi->ifi_ifname)) <= 0) {
|
2000-01-06 12:40:54 +00:00
|
|
|
memset(tbuf, 0, sizeof(tbuf));
|
|
|
|
syslog(LOG_INFO,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> %s isn't defined in the configuration file"
|
|
|
|
" or the configuration file doesn't exist."
|
|
|
|
" Treat it as default",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ifi->ifi_ifname);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 12:00:29 +00:00
|
|
|
ELM_MALLOC(rai, exit(1));
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_INIT(&rai->rai_prefix);
|
|
|
|
TAILQ_INIT(&rai->rai_route);
|
|
|
|
TAILQ_INIT(&rai->rai_rdnss);
|
|
|
|
TAILQ_INIT(&rai->rai_dnssl);
|
|
|
|
TAILQ_INIT(&rai->rai_soliciter);
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_ifinfo = ifi;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
/* gather on-link prefixes from the network interfaces. */
|
|
|
|
if (agetflag("noifprefix"))
|
|
|
|
rai->rai_advifprefix = 0;
|
|
|
|
else
|
|
|
|
rai->rai_advifprefix = 1;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
/* get interface information */
|
|
|
|
if (agetflag("nolladdr"))
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_advlinkopt = 0;
|
2000-01-06 12:40:54 +00:00
|
|
|
else
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_advlinkopt = 1;
|
|
|
|
if (rai->rai_advlinkopt) {
|
2011-07-17 19:24:54 +00:00
|
|
|
if (ifi->ifi_sdl.sdl_type == 0) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> can't get information of %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set router configuration variables.
|
|
|
|
*/
|
|
|
|
MAYHAVE(val, "maxinterval", DEF_MAXRTRADVINTERVAL);
|
|
|
|
if (val < MIN_MAXINTERVAL || val > MAX_MAXINTERVAL) {
|
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> maxinterval (%" PRIu32 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be between %u and %u)", __func__, val,
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi->ifi_ifname, MIN_MAXINTERVAL, MAX_MAXINTERVAL);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_maxinterval = (uint16_t)val;
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
MAYHAVE(val, "mininterval", rai->rai_maxinterval/3);
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((uint16_t)val < MIN_MININTERVAL ||
|
|
|
|
(uint16_t)val > (rai->rai_maxinterval * 3) / 4) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> mininterval (%" PRIu32 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be between %d and %d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val, ifi->ifi_ifname, MIN_MININTERVAL,
|
2011-06-06 03:06:43 +00:00
|
|
|
(rai->rai_maxinterval * 3) / 4);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_mininterval = (uint16_t)val;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
MAYHAVE(val, "chlim", DEF_ADVCURHOPLIMIT);
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_hoplimit = val & 0xff;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if ((flagstr = (char *)agetstr("raflags", &bp))) {
|
|
|
|
val = 0;
|
|
|
|
if (strchr(flagstr, 'm'))
|
|
|
|
val |= ND_RA_FLAG_MANAGED;
|
|
|
|
if (strchr(flagstr, 'o'))
|
|
|
|
val |= ND_RA_FLAG_OTHER;
|
|
|
|
if (strchr(flagstr, 'h'))
|
|
|
|
val |= ND_RA_FLAG_RTPREF_HIGH;
|
|
|
|
if (strchr(flagstr, 'l')) {
|
|
|
|
if ((val & ND_RA_FLAG_RTPREF_HIGH)) {
|
|
|
|
syslog(LOG_ERR, "<%s> the \'h\' and \'l\'"
|
|
|
|
" router flags are exclusive", __func__);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
|
|
|
val |= ND_RA_FLAG_RTPREF_LOW;
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
} else
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
MAYHAVE(val, "raflags", 0);
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
rai->rai_managedflg = val & ND_RA_FLAG_MANAGED;
|
|
|
|
rai->rai_otherflg = val & ND_RA_FLAG_OTHER;
|
2001-06-11 12:39:29 +00:00
|
|
|
#ifndef ND_RA_FLAG_RTPREF_MASK
|
|
|
|
#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
|
|
|
|
#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
|
|
|
|
#endif
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_rtpref = val & ND_RA_FLAG_RTPREF_MASK;
|
|
|
|
if (rai->rai_rtpref == ND_RA_FLAG_RTPREF_RSV) {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_ERR, "<%s> invalid router preference (%02x) on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, rai->rai_rtpref, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
MAYHAVE(val, "rltime", rai->rai_maxinterval * 3);
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((uint16_t)val && ((uint16_t)val < rai->rai_maxinterval ||
|
|
|
|
(uint16_t)val > MAXROUTERLIFETIME)) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> router lifetime (%" PRIu32 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be 0 or between %d and %d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val, ifi->ifi_ifname, rai->rai_maxinterval,
|
2011-06-06 03:06:43 +00:00
|
|
|
MAXROUTERLIFETIME);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_lifetime = val & 0xffff;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
MAYHAVE(val, "rtime", DEF_ADVREACHABLETIME);
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if (val < 0 || val > MAXREACHABLETIME) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> reachable time (%" PRIu32 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be no greater than %d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val, ifi->ifi_ifname, MAXREACHABLETIME);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_reachabletime = (uint32_t)val;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
MAYHAVE(val64, "retrans", DEF_ADVRETRANSTIMER);
|
|
|
|
if (val64 < 0 || val64 > 0xffffffff) {
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> retrans time (%" PRIu64 ") on %s out of range",
|
|
|
|
__func__, val64, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_retranstimer = (uint32_t)val64;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if (agetnum("hapref") != -1 || agetnum("hatime") != -1) {
|
2001-06-11 12:39:29 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> mobile-ip6 configuration not supported",
|
|
|
|
__func__);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
/* prefix information */
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/*
|
2003-08-08 16:56:01 +00:00
|
|
|
* This is an implementation specific parameter to consider
|
2001-06-11 12:39:29 +00:00
|
|
|
* link propagation delays and poorly synchronized clocks when
|
|
|
|
* checking consistency of advertised lifetimes.
|
|
|
|
*/
|
|
|
|
MAYHAVE(val, "clockskew", 0);
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_clockskew = val;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_pfxs = 0;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
for (i = -1; i < MAXPREFIX; i++) {
|
|
|
|
struct prefix *pfx;
|
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "addr");
|
|
|
|
addr = (char *)agetstr(entbuf, &bp);
|
|
|
|
if (addr == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* allocate memory to store prefix information */
|
2011-06-06 03:06:43 +00:00
|
|
|
ELM_MALLOC(pfx, exit(1));
|
2011-06-07 12:00:29 +00:00
|
|
|
pfx->pfx_rainfo = rai;
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_origin = PREFIX_FROM_CONFIG;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
if (inet_pton(AF_INET6, addr, &pfx->pfx_prefix) != 1) {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> inet_pton failed for %s",
|
|
|
|
__func__, addr);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_pfx;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
if (IN6_IS_ADDR_MULTICAST(&pfx->pfx_prefix)) {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> multicast prefix (%s) must "
|
|
|
|
"not be advertised on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, addr, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_pfx;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&pfx->pfx_prefix))
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_NOTICE,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> link-local prefix (%s) will be"
|
|
|
|
" advertised on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, addr, ifi->ifi_ifname);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "prefixlen");
|
|
|
|
MAYHAVE(val, entbuf, 64);
|
|
|
|
if (val < 0 || val > 128) {
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> prefixlen (%" PRIu32 ") for %s "
|
2011-06-06 03:06:43 +00:00
|
|
|
"on %s out of range",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val, addr, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_pfx;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_prefixlen = (int)val;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "pinfoflags");
|
|
|
|
if ((flagstr = (char *)agetstr(entbuf, &bp))) {
|
|
|
|
val = 0;
|
|
|
|
if (strchr(flagstr, 'l'))
|
|
|
|
val |= ND_OPT_PI_FLAG_ONLINK;
|
|
|
|
if (strchr(flagstr, 'a'))
|
|
|
|
val |= ND_OPT_PI_FLAG_AUTO;
|
|
|
|
} else {
|
|
|
|
MAYHAVE(val, entbuf,
|
|
|
|
(ND_OPT_PI_FLAG_ONLINK|ND_OPT_PI_FLAG_AUTO));
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_onlinkflg = val & ND_OPT_PI_FLAG_ONLINK;
|
|
|
|
pfx->pfx_autoconfflg = val & ND_OPT_PI_FLAG_AUTO;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "vltime");
|
|
|
|
MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME);
|
|
|
|
if (val64 < 0 || val64 > 0xffffffff) {
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> vltime (%" PRIu64 ") for "
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
"%s/%d on %s is out of range",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val64,
|
|
|
|
addr, pfx->pfx_prefixlen, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_pfx;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
pfx->pfx_validlifetime = (uint32_t)val64;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "vltimedecr");
|
|
|
|
if (agetflag(entbuf)) {
|
2013-08-05 20:13:02 +00:00
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_vltimeexpire =
|
|
|
|
now.tv_sec + pfx->pfx_validlifetime;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "pltime");
|
|
|
|
MAYHAVE(val64, entbuf, DEF_ADVPREFERREDLIFETIME);
|
|
|
|
if (val64 < 0 || val64 > 0xffffffff) {
|
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> pltime (%" PRIu64 ") for %s/%d on %s "
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
"is out of range",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val64,
|
|
|
|
addr, pfx->pfx_prefixlen, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_pfx;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
pfx->pfx_preflifetime = (uint32_t)val64;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "pltimedecr");
|
|
|
|
if (agetflag(entbuf)) {
|
2013-08-05 20:13:02 +00:00
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_pltimeexpire =
|
|
|
|
now.tv_sec + pfx->pfx_preflifetime;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-06-07 12:00:29 +00:00
|
|
|
/* link into chain */
|
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next);
|
|
|
|
rai->rai_pfxs++;
|
2011-06-11 03:25:10 +00:00
|
|
|
continue;
|
|
|
|
getconfig_free_pfx:
|
|
|
|
free(pfx);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_advifprefix && rai->rai_pfxs == 0)
|
|
|
|
get_prefix(rai);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
MAYHAVE(val64, "mtu", 0);
|
|
|
|
if (val < 0 || val64 > 0xffffffff) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> mtu (%" PRIu64 ") on %s out of range",
|
|
|
|
__func__, val64, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_linkmtu = (uint32_t)val64;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_linkmtu == 0) {
|
2000-01-06 12:40:54 +00:00
|
|
|
char *mtustr;
|
|
|
|
|
|
|
|
if ((mtustr = (char *)agetstr("mtu", &bp)) &&
|
|
|
|
strcmp(mtustr, "auto") == 0)
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_linkmtu = ifi->ifi_phymtu;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
else if (rai->rai_linkmtu < IPV6_MMTU ||
|
2011-07-17 19:24:54 +00:00
|
|
|
rai->rai_linkmtu > ifi->ifi_phymtu) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-07-17 19:24:54 +00:00
|
|
|
"<%s> advertised link mtu (%" PRIu32 ") on %s is invalid (must "
|
2011-06-06 03:06:43 +00:00
|
|
|
"be between least MTU (%d) and physical link MTU (%d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, rai->rai_linkmtu, ifi->ifi_ifname,
|
|
|
|
IPV6_MMTU, ifi->ifi_phymtu);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
2005-10-19 15:05:42 +00:00
|
|
|
#ifdef SIOCSIFINFO_IN6
|
|
|
|
{
|
|
|
|
struct in6_ndireq ndi;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
|
|
|
syslog(LOG_ERR, "<%s> socket: %s", __func__,
|
2011-06-06 03:06:43 +00:00
|
|
|
strerror(errno));
|
2005-10-19 15:05:42 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memset(&ndi, 0, sizeof(ndi));
|
2016-05-15 22:06:21 +00:00
|
|
|
strlcpy(ndi.ifname, ifi->ifi_ifname, sizeof(ndi.ifname));
|
2011-06-06 03:06:43 +00:00
|
|
|
if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&ndi) < 0)
|
2005-10-19 15:05:42 +00:00
|
|
|
syslog(LOG_INFO, "<%s> ioctl:SIOCGIFINFO_IN6 at %s: %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ifi->ifi_ifname, strerror(errno));
|
2005-10-19 15:05:42 +00:00
|
|
|
|
|
|
|
/* reflect the RA info to the host variables in kernel */
|
2011-06-06 03:06:43 +00:00
|
|
|
ndi.ndi.chlim = rai->rai_hoplimit;
|
|
|
|
ndi.ndi.retrans = rai->rai_retranstimer;
|
|
|
|
ndi.ndi.basereachable = rai->rai_reachabletime;
|
|
|
|
if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&ndi) < 0)
|
2005-10-19 15:05:42 +00:00
|
|
|
syslog(LOG_INFO, "<%s> ioctl:SIOCSIFINFO_IN6 at %s: %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ifi->ifi_ifname, strerror(errno));
|
2011-06-06 03:06:43 +00:00
|
|
|
|
2005-10-19 15:05:42 +00:00
|
|
|
close(s);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
/* route information */
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_routes = 0;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
for (i = -1; i < MAXROUTE; i++) {
|
2001-06-11 12:39:29 +00:00
|
|
|
struct rtinfo *rti;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rtprefix");
|
|
|
|
addr = (char *)agetstr(entbuf, &bp);
|
|
|
|
if (addr == NULL) {
|
|
|
|
makeentry(oentbuf, sizeof(oentbuf), i, "rtrprefix");
|
|
|
|
addr = (char *)agetstr(oentbuf, &bp);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (addr)
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
fprintf(stderr, "%s was obsoleted. Use %s.\n",
|
2011-06-06 03:06:43 +00:00
|
|
|
oentbuf, entbuf);
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
|
|
|
if (addr == NULL)
|
|
|
|
continue;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* allocate memory to store prefix information */
|
2011-06-06 03:06:43 +00:00
|
|
|
ELM_MALLOC(rti, exit(1));
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
if (inet_pton(AF_INET6, addr, &rti->rti_prefix) != 1) {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_ERR, "<%s> inet_pton failed for %s",
|
2011-06-06 03:06:43 +00:00
|
|
|
__func__, addr);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* XXX: currently there's no restriction in route information
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
* prefix according to
|
|
|
|
* draft-ietf-ipngwg-router-selection-00.txt.
|
|
|
|
* However, I think the similar restriction be necessary.
|
2001-06-11 12:39:29 +00:00
|
|
|
*/
|
|
|
|
MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME);
|
|
|
|
if (IN6_IS_ADDR_MULTICAST(&rti->prefix)) {
|
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> multicast route (%s) must "
|
|
|
|
"not be advertised on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, addr, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&rti->prefix)) {
|
|
|
|
syslog(LOG_NOTICE,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> link-local route (%s) will "
|
|
|
|
"be advertised on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, addr, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
|
|
|
#endif
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rtplen");
|
|
|
|
/* XXX: 256 is a magic number for compatibility check. */
|
|
|
|
MAYHAVE(val, entbuf, 256);
|
|
|
|
if (val == 256) {
|
|
|
|
makeentry(oentbuf, sizeof(oentbuf), i, "rtrplen");
|
|
|
|
MAYHAVE(val, oentbuf, 256);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (val != 256)
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
fprintf(stderr, "%s was obsoleted. Use %s.\n",
|
2011-06-06 03:06:43 +00:00
|
|
|
oentbuf, entbuf);
|
|
|
|
else
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
val = 64;
|
|
|
|
}
|
|
|
|
if (val < 0 || val > 128) {
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> prefixlen (%" PRIu32 ") for %s on %s "
|
2011-06-06 03:06:43 +00:00
|
|
|
"out of range",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, val, addr, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
rti->rti_prefixlen = (int)val;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rtflags");
|
|
|
|
if ((flagstr = (char *)agetstr(entbuf, &bp))) {
|
|
|
|
val = 0;
|
|
|
|
if (strchr(flagstr, 'h'))
|
|
|
|
val |= ND_RA_FLAG_RTPREF_HIGH;
|
|
|
|
if (strchr(flagstr, 'l')) {
|
|
|
|
if ((val & ND_RA_FLAG_RTPREF_HIGH)) {
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> the \'h\' and \'l\' route"
|
|
|
|
" preferences are exclusive",
|
|
|
|
__func__);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
|
|
|
val |= ND_RA_FLAG_RTPREF_LOW;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
MAYHAVE(val, entbuf, 256); /* XXX */
|
|
|
|
if (val == 256) {
|
|
|
|
makeentry(oentbuf, sizeof(oentbuf), i, "rtrflags");
|
|
|
|
MAYHAVE(val, oentbuf, 256);
|
|
|
|
if (val != 256) {
|
|
|
|
fprintf(stderr, "%s was obsoleted. Use %s.\n",
|
2011-06-06 03:06:43 +00:00
|
|
|
oentbuf, entbuf);
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
} else
|
|
|
|
val = 0;
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
rti->rti_rtpref = val & ND_RA_FLAG_RTPREF_MASK;
|
|
|
|
if (rti->rti_rtpref == ND_RA_FLAG_RTPREF_RSV) {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
syslog(LOG_ERR, "<%s> invalid route preference (%02x) "
|
2011-06-06 03:06:43 +00:00
|
|
|
"for %s/%d on %s",
|
|
|
|
__func__, rti->rti_rtpref, addr,
|
2011-07-17 19:24:54 +00:00
|
|
|
rti->rti_prefixlen, ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the spec does not a default value, we should make
|
|
|
|
* this entry mandatory. However, FreeBSD 4.4 has shipped
|
|
|
|
* with this field being optional, we use the router lifetime
|
|
|
|
* as an ad-hoc default value with a warning message.
|
|
|
|
*/
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rtltime");
|
|
|
|
MAYHAVE(val64, entbuf, -1);
|
|
|
|
if (val64 == -1) {
|
|
|
|
makeentry(oentbuf, sizeof(oentbuf), i, "rtrltime");
|
|
|
|
MAYHAVE(val64, oentbuf, -1);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (val64 != -1)
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
fprintf(stderr, "%s was obsoleted. Use %s.\n",
|
2011-06-06 03:06:43 +00:00
|
|
|
oentbuf, entbuf);
|
|
|
|
else {
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
fprintf(stderr, "%s should be specified "
|
2011-07-17 19:24:54 +00:00
|
|
|
"for interface %s.\n", entbuf,
|
|
|
|
ifi->ifi_ifname);
|
2011-06-06 03:06:43 +00:00
|
|
|
val64 = rai->rai_lifetime;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (val64 < 0 || val64 > 0xffffffff) {
|
2011-07-17 19:24:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> route lifetime (%" PRIu64 ") for "
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
"%s/%d on %s out of range", __func__,
|
2011-07-17 19:24:54 +00:00
|
|
|
val64, addr, rti->rti_prefixlen,
|
|
|
|
ifi->ifi_ifname);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rti;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
rti->rti_ltime = (uint32_t)val64;
|
2011-06-11 03:25:10 +00:00
|
|
|
|
|
|
|
/* link into chain */
|
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_route, rti, rti_next);
|
|
|
|
rai->rai_routes++;
|
|
|
|
continue;
|
|
|
|
getconfig_free_rti:
|
|
|
|
free(rti);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
/* DNS server and DNS search list information */
|
|
|
|
for (i = -1; i < MAXRDNSSENT ; i++) {
|
|
|
|
struct rdnss *rdn;
|
|
|
|
struct rdnss_addr *rdna;
|
|
|
|
char *ap;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rdnss");
|
|
|
|
addr = (char *)agetstr(entbuf, &bp);
|
|
|
|
if (addr == NULL)
|
2015-10-22 09:55:40 +00:00
|
|
|
continue;
|
2011-06-06 03:06:43 +00:00
|
|
|
ELM_MALLOC(rdn, exit(1));
|
|
|
|
|
|
|
|
TAILQ_INIT(&rdn->rd_list);
|
|
|
|
|
|
|
|
for (ap = addr; ap - addr < (ssize_t)strlen(addr); ap += c+1) {
|
|
|
|
c = strcspn(ap, ",");
|
|
|
|
strncpy(abuf, ap, c);
|
|
|
|
abuf[c] = '\0';
|
2011-06-11 03:25:10 +00:00
|
|
|
ELM_MALLOC(rdna, goto getconfig_free_rdn);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (inet_pton(AF_INET6, abuf, &rdna->ra_dns) != 1) {
|
|
|
|
syslog(LOG_ERR, "<%s> inet_pton failed for %s",
|
|
|
|
__func__, abuf);
|
|
|
|
free(rdna);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rdn;
|
2011-06-06 03:06:43 +00:00
|
|
|
}
|
|
|
|
TAILQ_INSERT_TAIL(&rdn->rd_list, rdna, ra_next);
|
|
|
|
}
|
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "rdnssltime");
|
|
|
|
MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2));
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((uint16_t)val < rai->rai_maxinterval ||
|
|
|
|
(uint16_t)val > rai->rai_maxinterval * 2) {
|
|
|
|
syslog(LOG_ERR, "%s (%" PRIu16 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be between %d and %d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
entbuf, val, ifi->ifi_ifname, rai->rai_maxinterval,
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_maxinterval * 2);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_rdn;
|
2011-06-06 03:06:43 +00:00
|
|
|
}
|
|
|
|
rdn->rd_ltime = val;
|
|
|
|
|
|
|
|
/* link into chain */
|
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_rdnss, rdn, rd_next);
|
2011-06-11 03:25:10 +00:00
|
|
|
continue;
|
|
|
|
getconfig_free_rdn:
|
|
|
|
while ((rdna = TAILQ_FIRST(&rdn->rd_list)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&rdn->rd_list, rdna, ra_next);
|
|
|
|
free(rdna);
|
|
|
|
}
|
|
|
|
free(rdn);
|
2011-06-06 03:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = -1; i < MAXDNSSLENT ; i++) {
|
|
|
|
struct dnssl *dns;
|
|
|
|
struct dnssl_addr *dnsa;
|
|
|
|
char *ap;
|
|
|
|
int c;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "dnssl");
|
|
|
|
addr = (char *)agetstr(entbuf, &bp);
|
|
|
|
if (addr == NULL)
|
2015-10-22 09:55:40 +00:00
|
|
|
continue;
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
ELM_MALLOC(dns, exit(1));
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_INIT(&dns->dn_list);
|
|
|
|
|
|
|
|
for (ap = addr; ap - addr < (ssize_t)strlen(addr); ap += c+1) {
|
|
|
|
c = strcspn(ap, ",");
|
|
|
|
strncpy(abuf, ap, c);
|
|
|
|
abuf[c] = '\0';
|
2011-06-11 03:25:10 +00:00
|
|
|
ELM_MALLOC(dnsa, goto getconfig_free_dns);
|
2011-06-06 03:06:43 +00:00
|
|
|
dnsa->da_len = dname_labelenc(dnsa->da_dom, abuf);
|
2014-10-11 23:24:09 +00:00
|
|
|
if (dnsa->da_len < 0) {
|
|
|
|
syslog(LOG_ERR, "Invalid dnssl entry: %s",
|
|
|
|
abuf);
|
|
|
|
goto getconfig_free_dns;
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s>: dnsa->da_len = %d", __func__,
|
|
|
|
dnsa->da_len);
|
|
|
|
TAILQ_INSERT_TAIL(&dns->dn_list, dnsa, da_next);
|
|
|
|
}
|
|
|
|
|
|
|
|
makeentry(entbuf, sizeof(entbuf), i, "dnsslltime");
|
|
|
|
MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2));
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((uint16_t)val < rai->rai_maxinterval ||
|
|
|
|
(uint16_t)val > rai->rai_maxinterval * 2) {
|
|
|
|
syslog(LOG_ERR, "%s (%" PRIu16 ") on %s is invalid "
|
2011-06-06 03:06:43 +00:00
|
|
|
"(must be between %d and %d)",
|
2011-07-17 19:24:54 +00:00
|
|
|
entbuf, val, ifi->ifi_ifname, rai->rai_maxinterval,
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_maxinterval * 2);
|
2011-06-11 03:25:10 +00:00
|
|
|
goto getconfig_free_dns;
|
2011-06-06 03:06:43 +00:00
|
|
|
}
|
|
|
|
dns->dn_ltime = val;
|
|
|
|
|
|
|
|
/* link into chain */
|
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_dnssl, dns, dn_next);
|
2011-06-11 03:25:10 +00:00
|
|
|
continue;
|
|
|
|
getconfig_free_dns:
|
|
|
|
while ((dnsa = TAILQ_FIRST(&dns->dn_list)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&dns->dn_list, dnsa, da_next);
|
|
|
|
free(dnsa);
|
|
|
|
}
|
|
|
|
free(dns);
|
2011-06-06 03:06:43 +00:00
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
/* construct the sending packet */
|
2011-06-06 03:06:43 +00:00
|
|
|
make_packet(rai);
|
2011-06-11 03:25:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If an entry with the same ifindex exists, remove it first.
|
|
|
|
* Before the removal, RDNSS and DNSSL options with
|
|
|
|
* zero-lifetime will be sent.
|
|
|
|
*/
|
2011-07-17 19:24:54 +00:00
|
|
|
switch (ifi->ifi_state) {
|
|
|
|
case IFI_STATE_UNCONFIGURED:
|
|
|
|
/* UNCONFIGURED -> TRANSITIVE */
|
|
|
|
|
|
|
|
error = sock_mc_join(&sock, ifi->ifi_ifindex);
|
|
|
|
if (error)
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
ifi->ifi_state = IFI_STATE_TRANSITIVE;
|
|
|
|
ifi->ifi_burstcount = MAX_INITIAL_RTR_ADVERTISEMENTS;
|
|
|
|
ifi->ifi_burstinterval = MAX_INITIAL_RTR_ADVERT_INTERVAL;
|
2011-06-11 03:25:10 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
/* The same two rai mean initial burst */
|
|
|
|
ifi->ifi_rainfo = rai;
|
|
|
|
ifi->ifi_rainfo_trans = rai;
|
|
|
|
TAILQ_INSERT_TAIL(&railist, rai, rai_next);
|
2011-06-11 03:25:10 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if (ifi->ifi_ra_timer == NULL)
|
|
|
|
ifi->ifi_ra_timer = rtadvd_add_timer(ra_timeout,
|
|
|
|
ra_timer_update, ifi, ifi);
|
|
|
|
ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm);
|
|
|
|
rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm,
|
|
|
|
ifi->ifi_ra_timer);
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG,
|
|
|
|
"<%s> ifname=%s marked as TRANSITIVE (initial burst).",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
break;
|
|
|
|
case IFI_STATE_CONFIGURED:
|
|
|
|
/* CONFIGURED -> TRANSITIVE */
|
|
|
|
rai_old = ifi->ifi_rainfo;
|
|
|
|
if (rai_old == NULL) {
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> ifi_rainfo is NULL"
|
|
|
|
" in IFI_STATE_CONFIGURED.", __func__);
|
|
|
|
ifi = NULL;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
struct rdnss *rdn;
|
|
|
|
struct dnssl *dns;
|
|
|
|
|
|
|
|
rai_old->rai_lifetime = 0;
|
|
|
|
TAILQ_FOREACH(rdn, &rai_old->rai_rdnss, rd_next)
|
|
|
|
rdn->rd_ltime = 0;
|
|
|
|
TAILQ_FOREACH(dns, &rai_old->rai_dnssl, dn_next)
|
|
|
|
dns->dn_ltime = 0;
|
|
|
|
|
|
|
|
ifi->ifi_rainfo_trans = rai_old;
|
|
|
|
ifi->ifi_state = IFI_STATE_TRANSITIVE;
|
|
|
|
ifi->ifi_burstcount = MAX_FINAL_RTR_ADVERTISEMENTS;
|
|
|
|
ifi->ifi_burstinterval = MIN_DELAY_BETWEEN_RAS;
|
|
|
|
|
|
|
|
ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm);
|
|
|
|
rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm,
|
|
|
|
ifi->ifi_ra_timer);
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG,
|
|
|
|
"<%s> ifname=%s marked as TRANSITIVE"
|
|
|
|
" (transitional burst)",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
}
|
|
|
|
ifi->ifi_rainfo = rai;
|
|
|
|
TAILQ_INSERT_TAIL(&railist, rai, rai_next);
|
|
|
|
break;
|
|
|
|
case IFI_STATE_TRANSITIVE:
|
|
|
|
if (ifi->ifi_rainfo != NULL) {
|
|
|
|
if (ifi->ifi_rainfo == ifi->ifi_rainfo_trans) {
|
|
|
|
/* Reinitialize initial burst */
|
|
|
|
rm_rainfo(ifi->ifi_rainfo);
|
|
|
|
ifi->ifi_rainfo = rai;
|
|
|
|
ifi->ifi_rainfo_trans = rai;
|
|
|
|
ifi->ifi_burstcount =
|
|
|
|
MAX_INITIAL_RTR_ADVERTISEMENTS;
|
|
|
|
ifi->ifi_burstinterval =
|
|
|
|
MAX_INITIAL_RTR_ADVERT_INTERVAL;
|
|
|
|
} else {
|
|
|
|
/* Replace ifi_rainfo with the new one */
|
|
|
|
rm_rainfo(ifi->ifi_rainfo);
|
|
|
|
ifi->ifi_rainfo = rai;
|
|
|
|
}
|
|
|
|
TAILQ_INSERT_TAIL(&railist, rai, rai_next);
|
|
|
|
|
|
|
|
ra_timer_update(ifi, &ifi->ifi_ra_timer->rat_tm);
|
|
|
|
rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm,
|
|
|
|
ifi->ifi_ra_timer);
|
|
|
|
} else {
|
|
|
|
/* XXX: NOTREACHED. Being shut down. */
|
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> %s is shutting down. Skipped.",
|
|
|
|
__func__, ifi->ifi_ifname);
|
|
|
|
rm_rainfo(rai);
|
|
|
|
|
|
|
|
return (NULL);
|
2011-06-11 03:25:10 +00:00
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
break;
|
2011-06-11 03:25:10 +00:00
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
return (ifi);
|
2011-06-06 03:06:43 +00:00
|
|
|
|
2011-06-11 03:25:10 +00:00
|
|
|
getconfig_free_rai:
|
|
|
|
free(rai);
|
2011-07-17 19:24:54 +00:00
|
|
|
return (NULL);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
void
|
2000-01-06 12:40:54 +00:00
|
|
|
get_prefix(struct rainfo *rai)
|
|
|
|
{
|
2001-06-11 12:39:29 +00:00
|
|
|
struct ifaddrs *ifap, *ifa;
|
2011-06-06 03:06:43 +00:00
|
|
|
struct prefix *pfx;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct in6_addr *a;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
char *p, *ep, *m, *lim;
|
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
if (getifaddrs(&ifap) < 0) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> can't get interface addresses",
|
|
|
|
__func__);
|
2000-01-06 12:40:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2003-08-08 16:56:01 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
2002-06-01 19:16:13 +00:00
|
|
|
int plen;
|
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
if (strcmp(ifa->ifa_name, ifi->ifi_ifname) != 0)
|
2001-06-11 12:39:29 +00:00
|
|
|
continue;
|
|
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
|
|
continue;
|
|
|
|
a = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(a))
|
|
|
|
continue;
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2002-06-01 19:16:13 +00:00
|
|
|
/* get prefix length */
|
2011-07-17 19:24:54 +00:00
|
|
|
m = (char *)&((struct sockaddr_in6 *)ifa->ifa_netmask)->sin6_addr;
|
|
|
|
lim = (char *)(ifa->ifa_netmask) + ifa->ifa_netmask->sa_len;
|
2002-06-01 19:16:13 +00:00
|
|
|
plen = prefixlen(m, lim);
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if (plen <= 0 || plen > 128) {
|
2002-06-01 19:16:13 +00:00
|
|
|
syslog(LOG_ERR, "<%s> failed to get prefixlen "
|
2011-06-06 03:06:43 +00:00
|
|
|
"or prefix is invalid",
|
|
|
|
__func__);
|
2000-01-06 12:40:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if (plen == 128) /* XXX */
|
|
|
|
continue;
|
2002-06-01 19:16:13 +00:00
|
|
|
if (find_prefix(rai, a, plen)) {
|
|
|
|
/* ignore a duplicated prefix. */
|
|
|
|
continue;
|
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2002-06-01 19:16:13 +00:00
|
|
|
/* allocate memory to store prefix info. */
|
2011-06-06 03:06:43 +00:00
|
|
|
ELM_MALLOC(pfx, exit(1));
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
/* set prefix, sweep bits outside of prefixlen */
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_prefixlen = plen;
|
|
|
|
memcpy(&pfx->pfx_prefix, a, sizeof(*a));
|
2011-07-17 19:24:54 +00:00
|
|
|
p = (char *)&pfx->pfx_prefix;
|
|
|
|
ep = (char *)(&pfx->pfx_prefix + 1);
|
2006-03-23 14:39:38 +00:00
|
|
|
while (m < lim && p < ep)
|
2001-06-11 12:39:29 +00:00
|
|
|
*p++ &= *m++;
|
|
|
|
while (p < ep)
|
|
|
|
*p++ = 0x00;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (!inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf,
|
2001-06-11 12:39:29 +00:00
|
|
|
sizeof(ntopbuf))) {
|
2003-08-08 16:38:23 +00:00
|
|
|
syslog(LOG_ERR, "<%s> inet_ntop failed", __func__);
|
2001-06-11 12:39:29 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_DEBUG,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> add %s/%d to prefix list on %s",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ntopbuf, pfx->pfx_prefixlen, ifi->ifi_ifname);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
/* set other fields with protocol defaults */
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_validlifetime = DEF_ADVVALIDLIFETIME;
|
|
|
|
pfx->pfx_preflifetime = DEF_ADVPREFERREDLIFETIME;
|
|
|
|
pfx->pfx_onlinkflg = 1;
|
|
|
|
pfx->pfx_autoconfflg = 1;
|
|
|
|
pfx->pfx_origin = PREFIX_FROM_KERNEL;
|
|
|
|
pfx->pfx_rainfo = rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
/* link into chain */
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
/* counter increment */
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_pfxs++;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
freeifaddrs(ifap);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-06-06 03:06:43 +00:00
|
|
|
makeentry(char *buf, size_t len, int id, const char *string)
|
2000-01-06 12:40:54 +00:00
|
|
|
{
|
2002-06-01 16:50:21 +00:00
|
|
|
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
if (id < 0)
|
|
|
|
strlcpy(buf, string, len);
|
|
|
|
else
|
|
|
|
snprintf(buf, len, "%s%d", string, id);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a prefix to the list of specified interface and reconstruct
|
|
|
|
* the outgoing packet.
|
|
|
|
* The prefix must not be in the list.
|
2005-11-17 02:34:50 +00:00
|
|
|
* XXX: other parameters of the prefix (e.g. lifetime) should be
|
2000-01-06 12:40:54 +00:00
|
|
|
* able to be specified.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr)
|
|
|
|
{
|
2011-06-06 03:06:43 +00:00
|
|
|
struct prefix *pfx;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2011-06-06 03:06:43 +00:00
|
|
|
ELM_MALLOC(pfx, return);
|
|
|
|
pfx->pfx_prefix = ipr->ipr_prefix.sin6_addr;
|
|
|
|
pfx->pfx_prefixlen = ipr->ipr_plen;
|
|
|
|
pfx->pfx_validlifetime = ipr->ipr_vltime;
|
|
|
|
pfx->pfx_preflifetime = ipr->ipr_pltime;
|
|
|
|
pfx->pfx_onlinkflg = ipr->ipr_raf_onlink;
|
|
|
|
pfx->pfx_autoconfflg = ipr->ipr_raf_auto;
|
|
|
|
pfx->pfx_origin = PREFIX_FROM_DYNAMIC;
|
2013-08-23 10:57:05 +00:00
|
|
|
pfx->pfx_rainfo = rai;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s",
|
|
|
|
__func__,
|
|
|
|
inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf,
|
2011-07-17 19:24:54 +00:00
|
|
|
sizeof(ntopbuf)), ipr->ipr_plen, ifi->ifi_ifname);
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_pfxs++;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete a prefix to the list of specified interface and reconstruct
|
|
|
|
* the outgoing packet.
|
2000-07-05 22:09:50 +00:00
|
|
|
* The prefix must be in the list.
|
2000-01-06 12:40:54 +00:00
|
|
|
*/
|
|
|
|
void
|
2011-06-06 03:06:43 +00:00
|
|
|
delete_prefix(struct prefix *pfx)
|
2000-01-06 12:40:54 +00:00
|
|
|
{
|
2011-06-06 03:06:43 +00:00
|
|
|
struct rainfo *rai;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai = pfx->pfx_rainfo;
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_REMOVE(&rai->rai_prefix, pfx, pfx_next);
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s> prefix %s/%d was deleted on %s",
|
2011-06-06 03:06:43 +00:00
|
|
|
__func__,
|
|
|
|
inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf,
|
2011-07-17 19:24:54 +00:00
|
|
|
sizeof(ntopbuf)), pfx->pfx_prefixlen, ifi->ifi_ifname);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_timer)
|
|
|
|
rtadvd_remove_timer(pfx->pfx_timer);
|
|
|
|
free(pfx);
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_pfxs--;
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-06 03:06:43 +00:00
|
|
|
invalidate_prefix(struct prefix *pfx)
|
2002-06-13 16:59:31 +00:00
|
|
|
{
|
2013-08-05 20:13:02 +00:00
|
|
|
struct timespec timo;
|
2011-06-06 03:06:43 +00:00
|
|
|
struct rainfo *rai;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2002-06-13 16:59:31 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai = pfx->pfx_rainfo;
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_timer) { /* sanity check */
|
2002-06-13 16:59:31 +00:00
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> assumption failure: timer already exists",
|
2003-08-08 16:38:23 +00:00
|
|
|
__func__);
|
2002-06-13 16:59:31 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> prefix %s/%d was invalidated on %s, "
|
2003-08-08 16:38:23 +00:00
|
|
|
"will expire in %ld seconds", __func__,
|
2011-06-06 03:06:43 +00:00
|
|
|
inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, sizeof(ntopbuf)),
|
2011-07-17 19:24:54 +00:00
|
|
|
pfx->pfx_prefixlen, ifi->ifi_ifname, (long)prefix_timo);
|
2002-06-13 16:59:31 +00:00
|
|
|
|
|
|
|
/* set the expiration timer */
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_timer = rtadvd_add_timer(prefix_timeout, NULL, pfx, NULL);
|
|
|
|
if (pfx->pfx_timer == NULL) {
|
2002-06-13 16:59:31 +00:00
|
|
|
syslog(LOG_ERR, "<%s> failed to add a timer for a prefix. "
|
2003-08-08 16:38:23 +00:00
|
|
|
"remove the prefix", __func__);
|
2011-06-06 03:06:43 +00:00
|
|
|
delete_prefix(pfx);
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
|
|
|
timo.tv_sec = prefix_timo;
|
2013-08-05 20:13:02 +00:00
|
|
|
timo.tv_nsec = 0;
|
2011-06-06 03:06:43 +00:00
|
|
|
rtadvd_set_timer(&timo, pfx->pfx_timer);
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct rtadvd_timer *
|
|
|
|
prefix_timeout(void *arg)
|
|
|
|
{
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
delete_prefix((struct prefix *)arg);
|
|
|
|
|
|
|
|
return (NULL);
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-06 03:06:43 +00:00
|
|
|
update_prefix(struct prefix *pfx)
|
2002-06-13 16:59:31 +00:00
|
|
|
{
|
2011-06-06 03:06:43 +00:00
|
|
|
struct rainfo *rai;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2002-06-13 16:59:31 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
rai = pfx->pfx_rainfo;
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_timer == NULL) { /* sanity check */
|
2002-06-13 16:59:31 +00:00
|
|
|
syslog(LOG_ERR,
|
|
|
|
"<%s> assumption failure: timer does not exist",
|
2003-08-08 16:38:23 +00:00
|
|
|
__func__);
|
2002-06-13 16:59:31 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s> prefix %s/%d was re-enabled on %s",
|
2011-06-06 03:06:43 +00:00
|
|
|
__func__, inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf,
|
2011-07-17 19:24:54 +00:00
|
|
|
sizeof(ntopbuf)), pfx->pfx_prefixlen, ifi->ifi_ifname);
|
2002-06-13 16:59:31 +00:00
|
|
|
|
|
|
|
/* stop the expiration timer */
|
2011-06-06 03:06:43 +00:00
|
|
|
rtadvd_remove_timer(pfx->pfx_timer);
|
|
|
|
pfx->pfx_timer = NULL;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to get an in6_prefixreq contents for a prefix which matches
|
|
|
|
* ipr->ipr_prefix and ipr->ipr_plen and belongs to
|
|
|
|
* the interface whose name is ipr->ipr_name[].
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
init_prefix(struct in6_prefixreq *ipr)
|
|
|
|
{
|
2002-06-15 18:56:32 +00:00
|
|
|
#if 0
|
2000-01-06 12:40:54 +00:00
|
|
|
int s;
|
|
|
|
|
|
|
|
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
2003-08-08 16:38:23 +00:00
|
|
|
syslog(LOG_ERR, "<%s> socket: %s", __func__,
|
2011-06-06 03:06:43 +00:00
|
|
|
strerror(errno));
|
2000-01-06 12:40:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioctl(s, SIOCGIFPREFIX_IN6, (caddr_t)ipr) < 0) {
|
2003-08-08 16:38:23 +00:00
|
|
|
syslog(LOG_INFO, "<%s> ioctl:SIOCGIFPREFIX %s", __func__,
|
2011-06-06 03:06:43 +00:00
|
|
|
strerror(errno));
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
|
|
|
|
ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
|
|
|
|
ipr->ipr_raf_onlink = 1;
|
|
|
|
ipr->ipr_raf_auto = 1;
|
|
|
|
/* omit other field initialization */
|
|
|
|
}
|
|
|
|
else if (ipr->ipr_origin < PR_ORIG_RR) {
|
2011-07-17 19:24:54 +00:00
|
|
|
char ntopbuf[INET6_ADDRSTRLEN];
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
syslog(LOG_WARNING, "<%s> Added prefix(%s)'s origin %d is"
|
2011-06-06 03:06:43 +00:00
|
|
|
"lower than PR_ORIG_RR(router renumbering)."
|
|
|
|
"This should not happen if I am router", __func__,
|
|
|
|
inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf,
|
|
|
|
sizeof(ntopbuf)), ipr->ipr_origin);
|
2000-03-09 14:51:05 +00:00
|
|
|
close(s);
|
2011-06-06 03:06:43 +00:00
|
|
|
return (1);
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close(s);
|
2011-06-06 03:06:43 +00:00
|
|
|
return (0);
|
2002-06-15 18:56:32 +00:00
|
|
|
#else
|
|
|
|
ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
|
|
|
|
ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
|
|
|
|
ipr->ipr_raf_onlink = 1;
|
|
|
|
ipr->ipr_raf_auto = 1;
|
2011-06-06 03:06:43 +00:00
|
|
|
return (0);
|
2002-06-15 18:56:32 +00:00
|
|
|
#endif
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
|
|
|
|
{
|
|
|
|
struct in6_prefixreq ipr;
|
|
|
|
|
|
|
|
memset(&ipr, 0, sizeof(ipr));
|
|
|
|
if (if_indextoname(ifindex, ipr.ipr_name) == NULL) {
|
2013-07-09 07:03:54 +00:00
|
|
|
syslog(LOG_ERR, "<%s> Prefix added interface No.%d doesn't "
|
2011-06-06 03:06:43 +00:00
|
|
|
"exist. This should not happen! %s", __func__,
|
|
|
|
ifindex, strerror(errno));
|
2000-01-06 12:40:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ipr.ipr_prefix.sin6_len = sizeof(ipr.ipr_prefix);
|
|
|
|
ipr.ipr_prefix.sin6_family = AF_INET6;
|
|
|
|
ipr.ipr_prefix.sin6_addr = *addr;
|
|
|
|
ipr.ipr_plen = plen;
|
|
|
|
|
|
|
|
if (init_prefix(&ipr))
|
|
|
|
return; /* init failed by some error */
|
|
|
|
add_prefix(rai, &ipr);
|
|
|
|
}
|
|
|
|
|
2000-07-05 22:09:50 +00:00
|
|
|
void
|
2011-06-06 03:06:43 +00:00
|
|
|
make_packet(struct rainfo *rai)
|
2000-01-06 12:40:54 +00:00
|
|
|
{
|
|
|
|
size_t packlen, lladdroptlen = 0;
|
|
|
|
char *buf;
|
|
|
|
struct nd_router_advert *ra;
|
|
|
|
struct nd_opt_prefix_info *ndopt_pi;
|
|
|
|
struct nd_opt_mtu *ndopt_mtu;
|
2001-06-11 12:39:29 +00:00
|
|
|
struct nd_opt_route_info *ndopt_rti;
|
|
|
|
struct rtinfo *rti;
|
2011-06-06 03:06:43 +00:00
|
|
|
struct nd_opt_rdnss *ndopt_rdnss;
|
|
|
|
struct rdnss *rdn;
|
|
|
|
struct nd_opt_dnssl *ndopt_dnssl;
|
|
|
|
struct dnssl *dns;
|
|
|
|
size_t len;
|
- supported a string notation for xxflags.
- deprecate routes#N, as it is hard to keep consistency with
rtprefixN. accept any number of "rtprefix", "rtrefix0",
..., "rtprefix99".
- deprecate "addrs#N", as it is difficult for users to keep
consistency with "addrN".
accept 100 prefix info in maximum - like "addr", "addr0"
... "addr99". WARNS=2 clean on netbsd.
old configuration file should work just fine.
behavior change:
previously, we rejected "addrN" if there's "addr", and we rejected
"addr" if there is "addrN". now we accept both without problem.
- when an advertised prefix configured from the kernel has been added
or invalidated, notice the change in a short delay.
- when invalidating a prefix, do not bark even if there is
inconsistency about prefix lifetimes.
- wrap more specific route info code into ROUTEINFO.
Obtained from: KAME
MFC after: 1 week
2003-08-15 19:13:53 +00:00
|
|
|
struct prefix *pfx;
|
2011-07-17 19:24:54 +00:00
|
|
|
struct ifinfo *ifi;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-07-17 19:24:54 +00:00
|
|
|
ifi = rai->rai_ifinfo;
|
2000-01-06 12:40:54 +00:00
|
|
|
/* calculate total length */
|
|
|
|
packlen = sizeof(struct nd_router_advert);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_advlinkopt) {
|
2011-07-17 19:24:54 +00:00
|
|
|
if ((lladdroptlen = lladdropt_length(&ifi->ifi_sdl)) == 0) {
|
2000-01-06 12:40:54 +00:00
|
|
|
syslog(LOG_INFO,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> link-layer address option has"
|
|
|
|
" null length on %s. Treat as not included.",
|
2011-07-17 19:24:54 +00:00
|
|
|
__func__, ifi->ifi_ifname);
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_advlinkopt = 0;
|
2000-01-06 12:40:54 +00:00
|
|
|
}
|
|
|
|
packlen += lladdroptlen;
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_pfxs)
|
|
|
|
packlen += sizeof(struct nd_opt_prefix_info) * rai->rai_pfxs;
|
|
|
|
if (rai->rai_linkmtu)
|
2000-01-06 12:40:54 +00:00
|
|
|
packlen += sizeof(struct nd_opt_mtu);
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(rti, &rai->rai_route, rti_next)
|
|
|
|
packlen += sizeof(struct nd_opt_route_info) +
|
|
|
|
((rti->rti_prefixlen + 0x3f) >> 6) * 8;
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) {
|
|
|
|
struct rdnss_addr *rdna;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
packlen += sizeof(struct nd_opt_rdnss);
|
|
|
|
TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next)
|
|
|
|
packlen += sizeof(rdna->ra_dns);
|
|
|
|
}
|
|
|
|
TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) {
|
|
|
|
struct dnssl_addr *dnsa;
|
|
|
|
|
|
|
|
packlen += sizeof(struct nd_opt_dnssl);
|
|
|
|
len = 0;
|
|
|
|
TAILQ_FOREACH(dnsa, &dns->dn_list, da_next)
|
|
|
|
len += dnsa->da_len;
|
|
|
|
|
|
|
|
/* A zero octet and 8 octet boundary */
|
|
|
|
len++;
|
|
|
|
len += (len % 8) ? 8 - len % 8 : 0;
|
|
|
|
|
|
|
|
packlen += len;
|
|
|
|
}
|
2000-01-06 12:40:54 +00:00
|
|
|
/* allocate memory for the packet */
|
|
|
|
if ((buf = malloc(packlen)) == NULL) {
|
|
|
|
syslog(LOG_ERR,
|
2011-06-06 03:06:43 +00:00
|
|
|
"<%s> can't get enough memory for an RA packet",
|
|
|
|
__func__);
|
2000-01-06 12:40:54 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
memset(buf, 0, packlen);
|
|
|
|
if (rai->rai_ra_data) /* Free old data if any. */
|
|
|
|
free(rai->rai_ra_data);
|
|
|
|
rai->rai_ra_data = buf;
|
2000-01-06 12:40:54 +00:00
|
|
|
/* XXX: what if packlen > 576? */
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_ra_datalen = packlen;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* construct the packet
|
|
|
|
*/
|
|
|
|
ra = (struct nd_router_advert *)buf;
|
|
|
|
ra->nd_ra_type = ND_ROUTER_ADVERT;
|
|
|
|
ra->nd_ra_code = 0;
|
|
|
|
ra->nd_ra_cksum = 0;
|
2011-07-17 19:24:54 +00:00
|
|
|
ra->nd_ra_curhoplimit = (uint8_t)(0xff & rai->rai_hoplimit);
|
2001-06-11 12:39:29 +00:00
|
|
|
ra->nd_ra_flags_reserved = 0; /* just in case */
|
|
|
|
/*
|
|
|
|
* XXX: the router preference field, which is a 2-bit field, should be
|
|
|
|
* initialized before other fields.
|
|
|
|
*/
|
2011-06-06 03:06:43 +00:00
|
|
|
ra->nd_ra_flags_reserved = 0xff & rai->rai_rtpref;
|
2000-01-06 12:40:54 +00:00
|
|
|
ra->nd_ra_flags_reserved |=
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_managedflg ? ND_RA_FLAG_MANAGED : 0;
|
2000-01-06 12:40:54 +00:00
|
|
|
ra->nd_ra_flags_reserved |=
|
2011-06-06 03:06:43 +00:00
|
|
|
rai->rai_otherflg ? ND_RA_FLAG_OTHER : 0;
|
|
|
|
ra->nd_ra_router_lifetime = htons(rai->rai_lifetime);
|
|
|
|
ra->nd_ra_reachable = htonl(rai->rai_reachabletime);
|
|
|
|
ra->nd_ra_retransmit = htonl(rai->rai_retranstimer);
|
2000-01-06 12:40:54 +00:00
|
|
|
buf += sizeof(*ra);
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_advlinkopt) {
|
2011-07-17 19:24:54 +00:00
|
|
|
lladdropt_fill(&ifi->ifi_sdl, (struct nd_opt_hdr *)buf);
|
2000-01-06 12:40:54 +00:00
|
|
|
buf += lladdroptlen;
|
|
|
|
}
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
if (rai->rai_linkmtu) {
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_mtu = (struct nd_opt_mtu *)buf;
|
|
|
|
ndopt_mtu->nd_opt_mtu_type = ND_OPT_MTU;
|
|
|
|
ndopt_mtu->nd_opt_mtu_len = 1;
|
|
|
|
ndopt_mtu->nd_opt_mtu_reserved = 0;
|
2011-06-06 03:06:43 +00:00
|
|
|
ndopt_mtu->nd_opt_mtu_mtu = htonl(rai->rai_linkmtu);
|
2000-01-06 12:40:54 +00:00
|
|
|
buf += sizeof(struct nd_opt_mtu);
|
|
|
|
}
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) {
|
2011-07-17 19:24:54 +00:00
|
|
|
uint32_t vltime, pltime;
|
2013-08-05 20:13:02 +00:00
|
|
|
struct timespec now;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_pi = (struct nd_opt_prefix_info *)buf;
|
|
|
|
ndopt_pi->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION;
|
|
|
|
ndopt_pi->nd_opt_pi_len = 4;
|
2011-06-06 03:06:43 +00:00
|
|
|
ndopt_pi->nd_opt_pi_prefix_len = pfx->pfx_prefixlen;
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_pi->nd_opt_pi_flags_reserved = 0;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_onlinkflg)
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_pi->nd_opt_pi_flags_reserved |=
|
|
|
|
ND_OPT_PI_FLAG_ONLINK;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_autoconfflg)
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_pi->nd_opt_pi_flags_reserved |=
|
|
|
|
ND_OPT_PI_FLAG_AUTO;
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_timer)
|
2002-06-13 16:59:31 +00:00
|
|
|
vltime = 0;
|
|
|
|
else {
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_vltimeexpire || pfx->pfx_pltimeexpire)
|
2013-08-05 20:13:02 +00:00
|
|
|
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_vltimeexpire == 0)
|
|
|
|
vltime = pfx->pfx_validlifetime;
|
2002-06-13 16:59:31 +00:00
|
|
|
else
|
2011-07-17 19:24:54 +00:00
|
|
|
vltime = ((time_t)pfx->pfx_vltimeexpire > now.tv_sec) ?
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_vltimeexpire - now.tv_sec : 0;
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_timer)
|
2002-06-13 16:59:31 +00:00
|
|
|
pltime = 0;
|
|
|
|
else {
|
2011-06-06 03:06:43 +00:00
|
|
|
if (pfx->pfx_pltimeexpire == 0)
|
|
|
|
pltime = pfx->pfx_preflifetime;
|
2002-06-13 16:59:31 +00:00
|
|
|
else
|
2011-07-17 19:24:54 +00:00
|
|
|
pltime = ((time_t)pfx->pfx_pltimeexpire > now.tv_sec) ?
|
2011-06-06 03:06:43 +00:00
|
|
|
pfx->pfx_pltimeexpire - now.tv_sec : 0;
|
2002-06-13 16:59:31 +00:00
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
if (vltime < pltime) {
|
|
|
|
/*
|
|
|
|
* this can happen if vltime is decrement but pltime
|
|
|
|
* is not.
|
|
|
|
*/
|
|
|
|
pltime = vltime;
|
|
|
|
}
|
|
|
|
ndopt_pi->nd_opt_pi_valid_time = htonl(vltime);
|
|
|
|
ndopt_pi->nd_opt_pi_preferred_time = htonl(pltime);
|
2000-01-06 12:40:54 +00:00
|
|
|
ndopt_pi->nd_opt_pi_reserved2 = 0;
|
2011-06-06 03:06:43 +00:00
|
|
|
ndopt_pi->nd_opt_pi_prefix = pfx->pfx_prefix;
|
2000-01-06 12:40:54 +00:00
|
|
|
|
|
|
|
buf += sizeof(struct nd_opt_prefix_info);
|
|
|
|
}
|
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(rti, &rai->rai_route, rti_next) {
|
2011-07-17 19:24:54 +00:00
|
|
|
uint8_t psize = (rti->rti_prefixlen + 0x3f) >> 6;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
|
|
|
ndopt_rti = (struct nd_opt_route_info *)buf;
|
|
|
|
ndopt_rti->nd_opt_rti_type = ND_OPT_ROUTE_INFO;
|
|
|
|
ndopt_rti->nd_opt_rti_len = 1 + psize;
|
2011-06-06 03:06:43 +00:00
|
|
|
ndopt_rti->nd_opt_rti_prefixlen = rti->rti_prefixlen;
|
|
|
|
ndopt_rti->nd_opt_rti_flags = 0xff & rti->rti_rtpref;
|
|
|
|
ndopt_rti->nd_opt_rti_lifetime = htonl(rti->rti_ltime);
|
|
|
|
memcpy(ndopt_rti + 1, &rti->rti_prefix, psize * 8);
|
2001-06-11 12:39:29 +00:00
|
|
|
buf += sizeof(struct nd_opt_route_info) + psize * 8;
|
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) {
|
|
|
|
struct rdnss_addr *rdna;
|
|
|
|
|
|
|
|
ndopt_rdnss = (struct nd_opt_rdnss *)buf;
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_type = ND_OPT_RDNSS;
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_len = 0;
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_reserved = 0;
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_lifetime = htonl(rdn->rd_ltime);
|
|
|
|
buf += sizeof(struct nd_opt_rdnss);
|
|
|
|
|
|
|
|
TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next) {
|
|
|
|
memcpy(buf, &rdna->ra_dns, sizeof(rdna->ra_dns));
|
|
|
|
buf += sizeof(rdna->ra_dns);
|
|
|
|
}
|
|
|
|
/* Length field should be in 8 octets */
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_len = (buf - (char *)ndopt_rdnss) / 8;
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
syslog(LOG_DEBUG, "<%s>: nd_opt_dnss_len = %d", __func__,
|
|
|
|
ndopt_rdnss->nd_opt_rdnss_len);
|
|
|
|
}
|
2011-07-17 19:24:54 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) {
|
|
|
|
struct dnssl_addr *dnsa;
|
|
|
|
|
|
|
|
ndopt_dnssl = (struct nd_opt_dnssl *)buf;
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_type = ND_OPT_DNSSL;
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_len = 0;
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_reserved = 0;
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_lifetime = htonl(dns->dn_ltime);
|
|
|
|
buf += sizeof(*ndopt_dnssl);
|
|
|
|
|
|
|
|
TAILQ_FOREACH(dnsa, &dns->dn_list, da_next) {
|
|
|
|
memcpy(buf, dnsa->da_dom, dnsa->da_len);
|
|
|
|
buf += dnsa->da_len;
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
|
2011-06-06 03:06:43 +00:00
|
|
|
/* A zero octet after encoded DNS server list. */
|
|
|
|
*buf++ = '\0';
|
|
|
|
|
|
|
|
/* Padding to next 8 octets boundary */
|
|
|
|
len = buf - (char *)ndopt_dnssl;
|
|
|
|
len += (len % 8) ? 8 - len % 8 : 0;
|
2015-10-22 09:55:40 +00:00
|
|
|
buf = (char *)ndopt_dnssl + len;
|
2011-06-06 03:06:43 +00:00
|
|
|
|
|
|
|
/* Length field must be in 8 octets */
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_len = len / 8;
|
|
|
|
|
|
|
|
syslog(LOG_DEBUG, "<%s>: nd_opt_dnssl_len = %d", __func__,
|
|
|
|
ndopt_dnssl->nd_opt_dnssl_len);
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|
2011-06-06 03:06:43 +00:00
|
|
|
return;
|
2001-06-11 12:39:29 +00:00
|
|
|
}
|