Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd add -R (accept router renumbering packet). ...
details: https://anonhg.NetBSD.org/src/rev/8b28c1f95c6a
branches: trunk
changeset: 481557:8b28c1f95c6a
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Feb 02 04:07:50 2000 +0000
description:
add -R (accept router renumbering packet). now router renumbering is disabled
by default for ipsec config twists.
dies gracefully on SIGTERM.
diffstat:
usr.sbin/rtadvd/config.c | 5 +--
usr.sbin/rtadvd/config.h | 3 +-
usr.sbin/rtadvd/rtadvd.8 | 20 +++++++++++++--
usr.sbin/rtadvd/rtadvd.c | 59 ++++++++++++++++++++++++++++++++++++++++++++---
4 files changed, 76 insertions(+), 11 deletions(-)
diffs (227 lines):
diff -r debfc3f9e8ad -r 8b28c1f95c6a usr.sbin/rtadvd/config.c
--- a/usr.sbin/rtadvd/config.c Wed Feb 02 03:14:31 2000 +0000
+++ b/usr.sbin/rtadvd/config.c Wed Feb 02 04:07:50 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.c,v 1.3 1999/07/06 13:02:09 itojun Exp $ */
+/* $NetBSD: config.c,v 1.4 2000/02/02 04:07:50 itojun Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@@ -66,7 +66,6 @@
#include "config.h"
static void makeentry __P((char *, int, char *, int));
-static void make_packet __P((struct rainfo *));
static void get_prefix __P((struct rainfo *));
extern struct rainfo *ralist;
@@ -547,7 +546,7 @@
add_prefix(rai, &ipr);
}
-static void
+void
make_packet(struct rainfo *rainfo)
{
size_t packlen, lladdroptlen = 0;
diff -r debfc3f9e8ad -r 8b28c1f95c6a usr.sbin/rtadvd/config.h
--- a/usr.sbin/rtadvd/config.h Wed Feb 02 03:14:31 2000 +0000
+++ b/usr.sbin/rtadvd/config.h Wed Feb 02 04:07:50 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.2 1999/07/06 13:02:09 itojun Exp $ */
+/* $NetBSD: config.h,v 1.3 2000/02/02 04:07:50 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -32,3 +32,4 @@
extern void getconfig __P((char *));
extern void delete_prefix __P((struct rainfo *, struct prefix *));
extern void make_prefix __P((struct rainfo *, int, struct in6_addr *, int));
+extern void make_packet __P((struct rainfo *));
diff -r debfc3f9e8ad -r 8b28c1f95c6a usr.sbin/rtadvd/rtadvd.8
--- a/usr.sbin/rtadvd/rtadvd.8 Wed Feb 02 03:14:31 2000 +0000
+++ b/usr.sbin/rtadvd/rtadvd.8 Wed Feb 02 04:07:50 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rtadvd.8,v 1.5 2000/01/24 12:59:30 itojun Exp $
+.\" $NetBSD: rtadvd.8,v 1.6 2000/02/02 04:07:50 itojun Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" KAME Id: rtadvd.8,v 1.2 2000/01/06 07:54:28 itojun Exp
+.\" KAME Id: rtadvd.8,v 1.4 2000/02/02 03:55:44 itojun Exp
.\"
.Dd May 17, 1998
.Dt RTADVD 8
@@ -38,7 +38,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl c Ar configfile
-.Op Fl dDfs
+.Op Fl dDfsR
.Ar interface ...
.Sh DESCRIPTION
.Nm Rtadvd
@@ -91,7 +91,21 @@
Foreground mode (useful when debugging).
.It Fl s
Do not monitor routing table changes (static prefix).
+.It Fl R
+Accept router renumbering requests.
+If you enable it, certain IPsec setup is suggested for security reasons.
.El
+.Pp
+Use
+.Dv SIGTERM
+to kill
+.Nm
+gracefully.
+In this case,
+.Nm
+will transmit router advertisement with router lifetime 0
+to all the interfaces
+.Pq according to RFC2461 6.2.5 .
.Sh RETURN VALUES
The program exits with 0 on success, and non-zero on failures.
.Sh FILES
diff -r debfc3f9e8ad -r 8b28c1f95c6a usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c Wed Feb 02 03:14:31 2000 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c Wed Feb 02 04:07:50 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtadvd.c,v 1.4 1999/12/10 05:47:51 itojun Exp $ */
+/* $NetBSD: rtadvd.c,v 1.5 2000/02/02 04:07:51 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -68,7 +68,7 @@
struct sockaddr_in6 from;
struct sockaddr_in6 sin6_allnodes = {sizeof(sin6_allnodes), AF_INET6};
int sock, rtsock;
-int accept_rr = 1;
+int accept_rr = 0;
int dflag = 0, sflag = 0;
u_char *conffile = NULL;
@@ -109,6 +109,7 @@
};
int main __P((int, char *[]));
+static void die __P((int));
static void sock_open __P((void));
static void rtsock_open __P((void));
static void rtadvd_input __P((void));
@@ -141,7 +142,7 @@
openlog(*argv, LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* get command line options and arguments */
- while ((ch = getopt(argc, argv, "c:dDfs")) != -1) {
+ while ((ch = getopt(argc, argv, "c:dDfRs")) != -1) {
switch(ch) {
case 'c':
conffile = optarg;
@@ -155,15 +156,19 @@
case 'f':
fflag = 1;
break;
+ case 'R':
+ accept_rr = 1;
+ break;
case 's':
sflag = 1;
+ break;
}
}
argc -= optind;
argv += optind;
if (argc == 0) {
fprintf(stderr,
- "usage: rtadvd [-c conffile] [-d|D] [-f] [-s]"
+ "usage: rtadvd [-dDfsR] [-c conffile] "
"interfaces...\n");
exit(1);
}
@@ -205,6 +210,8 @@
maxfd = rtsock;
}
+ signal(SIGTERM, die);
+
while (1) {
struct fd_set select_fd = fdset; /* reinitialize */
@@ -234,6 +241,32 @@
}
static void
+die(sig)
+ int sig;
+{
+ struct rainfo *ra;
+ int i;
+ const int retrans = MAX_FINAL_RTR_ADVERTISEMENTS;
+
+ if (dflag > 1) {
+ syslog(LOG_DEBUG, "<%s> cease to be an advertising router\n",
+ __FUNCTION__);
+ }
+
+ for (ra = ralist; ra; ra = ra->next) {
+ ra->lifetime = 0;
+ make_packet(ra);
+ }
+ for (i = 0; i < retrans; i++) {
+ for (ra = ralist; ra; ra = ra->next)
+ ra_output(ra);
+ sleep(MIN_DELAY_BETWEEN_RAS);
+ }
+ exit(0);
+ /*NOTREACHED*/
+}
+
+static void
rtmsg_input()
{
int n, type, ifindex, plen;
@@ -1054,21 +1087,39 @@
/* specify to tell receiving interface */
on = 1;
+#ifdef IPV6_RECVPKTINFO
+ if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
+ sizeof(on)) < 0) {
+ syslog(LOG_ERR, "<%s> IPV6_RECVPKTINFO: %s",
+ __FUNCTION__, strerror(errno));
+ exit(1);
+ }
+#else /* old adv. API */
if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_PKTINFO: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
+#endif
on = 1;
/* specify to tell value of hoplimit field of received IP6 hdr */
+#ifdef IPV6_RECVHOPLIMIT
+ if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on,
+ sizeof(on)) < 0) {
+ syslog(LOG_ERR, "<%s> IPV6_RECVHOPLIMIT: %s",
+ __FUNCTION__, strerror(errno));
+ exit(1);
+ }
+#else /* old adv. API */
if (setsockopt(sock, IPPROTO_IPV6, IPV6_HOPLIMIT, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_HOPLIMIT: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
+#endif
ICMP6_FILTER_SETBLOCKALL(&filt);
ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT, &filt);
Home |
Main Index |
Thread Index |
Old Index