From 832f8d224926758a9ae0b23a6b45353e44fbc87a Mon Sep 17 00:00:00 2001 From: ume Date: Mon, 11 Jun 2001 12:39:29 +0000 Subject: Sync with recent KAME. This work was based on kame-20010528-freebsd43-snap.tgz and some critical problem after the snap was out were fixed. There are many many changes since last KAME merge. TODO: - The definitions of SADB_* in sys/net/pfkeyv2.h are still different from RFC2407/IANA assignment because of binary compatibility issue. It should be fixed under 5-CURRENT. - ip6po_m member of struct ip6_pktopts is no longer used. But, it is still there because of binary compatibility issue. It should be removed under 5-CURRENT. Reviewed by: itojun Obtained from: KAME MFC after: 3 weeks --- usr.sbin/rrenumd/lexer.l | 13 ++++- usr.sbin/rrenumd/parser.y | 50 +++++++++++-------- usr.sbin/rrenumd/rrenumd.8 | 26 +++++++--- usr.sbin/rrenumd/rrenumd.c | 64 +++++++++++++++++------- usr.sbin/rrenumd/rrenumd.conf.5 | 107 +++++++++++++++++++++++++++------------- usr.sbin/rrenumd/rrenumd.h | 2 +- 6 files changed, 180 insertions(+), 82 deletions(-) (limited to 'usr.sbin/rrenumd') diff --git a/usr.sbin/rrenumd/lexer.l b/usr.sbin/rrenumd/lexer.l index d906b0c..6ad9953 100644 --- a/usr.sbin/rrenumd/lexer.l +++ b/usr.sbin/rrenumd/lexer.l @@ -1,4 +1,4 @@ -/* $KAME$ */ +/* $KAME: lexer.l,v 1.7 2000/11/08 02:40:53 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -32,9 +32,12 @@ */ %{ +#define YY_NO_UNPUT + #include #include #include +#include #include @@ -55,6 +58,10 @@ int lineno = 1; #define LINEBUF_SIZE 1000 char linebuf[LINEBUF_SIZE]; + +int parse __P((FILE **)); +void yyerror __P((const char *)); +int yylex __P((void)); %} /* common section */ @@ -248,9 +255,11 @@ off { int parse(FILE **fp) { + extern int yyparse __P((void)); + yyin = *fp; - if(yyparse()) + if (yyparse()) return(-1); return(0); diff --git a/usr.sbin/rrenumd/parser.y b/usr.sbin/rrenumd/parser.y index 15ca06d..0cfe3b5 100644 --- a/usr.sbin/rrenumd/parser.y +++ b/usr.sbin/rrenumd/parser.y @@ -1,4 +1,4 @@ -/* $KAME$ */ +/* $KAME: parser.y,v 1.8 2000/11/08 03:03:34 jinmei Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -36,6 +36,7 @@ #include #include #include +#include #include #if defined(__FreeBSD__) && __FreeBSD__ >= 3 @@ -48,6 +49,7 @@ #include #include +#include #include "rrenumd.h" @@ -62,6 +64,7 @@ char errbuf[LINE_MAX]; extern int lineno; extern void yyerror __P((const char *s)); +extern int yylex __P((void)); static struct payload_list * pllist_lookup __P((int seqnum)); static void pllist_enqueue __P((struct payload_list *pl_entry)); @@ -192,8 +195,9 @@ dest_addr : hints.ai_protocol = 0; error = getaddrinfo($1.cp, 0, &hints, &res); if (error) { - sprintf(errbuf, "name resolution failed for %s" - ":%s", $1, gai_strerror(error)); + snprintf(errbuf, sizeof(errbuf), + "name resolution failed for %s:%s", + $1.cp, gai_strerror(error)); yyerror(errbuf); } ss = (struct sockaddr_storage *)malloc(sizeof(*ss)); @@ -274,8 +278,9 @@ rrenum_statement_with_seqnum: SEQNUM_CMD seqnum { if (pllist_lookup($2)) { - sprintf(errbuf, "duplicate seqnum %d specified" - " at %d", $2, lineno); + snprintf(errbuf, sizeof(errbuf), + "duplicate seqnum %ld specified at %d", + $2, lineno); yyerror(errbuf); } } @@ -294,9 +299,10 @@ seqnum: | decstring { if ($1 > MAX_SEQNUM) { - sprintf(errbuf, "seqnum %d is illegal for this" - " program. should be between 0 and %d", - $1, MAX_SEQNUM); + snprintf(errbuf, sizeof(errbuf), + "seqnum %ld is illegal for this program. " + "should be between 0 and %d", + $1, MAX_SEQNUM); yyerror(errbuf); } $$ = $1; @@ -307,8 +313,9 @@ rrenum_statement_without_seqnum: rrenum_statement EOS { if (pllist_lookup(0)) { - sprintf(errbuf, "duplicate seqnum %d specified" - " at %d", 0, lineno); + snprintf(errbuf, sizeof(errbuf), + "duplicate seqnum %d specified at %d", + 0, lineno); yyerror(errbuf); } $1->pl_irr.rr_seqnum = 0; @@ -435,8 +442,8 @@ use_prefix_values: rpu = (struct rr_pco_use *)(rpm + 1); memset(rpu, 0, sizeof(*rpu)); - rpu->rpu_vltime = DEF_VLTIME; - rpu->rpu_pltime = DEF_PLTIME; + rpu->rpu_vltime = htonl(DEF_VLTIME); + rpu->rpu_pltime = htonl(DEF_PLTIME); rpu->rpu_ramask = 0; rpu->rpu_flags = 0; } @@ -510,7 +517,7 @@ keeplen: vltime: /* empty */ { - $$ = DEF_VLTIME; + $$ = htonl(DEF_VLTIME); } | VLTIME_CMD lifetime { @@ -521,7 +528,7 @@ vltime: pltime: /* empty */ { - $$ = DEF_PLTIME; + $$ = htonl(DEF_PLTIME); } | PLTIME_CMD lifetime { @@ -573,8 +580,8 @@ raf_decrprefd: ; flag: - ON - | OFF + ON { $$ = ON; } + | OFF { $$ = OFF; } ; lifetime: @@ -653,15 +660,16 @@ static void pllist_enqueue(struct payload_list *pl_entry) { struct payload_list *pl, *pl_last; - if (pl_head == NULL) { - pl_head = pl_entry; - return; - } + + pl_last = NULL; for (pl = pl_head; pl && pl->pl_irr.rr_seqnum < pl_entry->pl_irr.rr_seqnum; pl_last = pl, pl = pl->pl_next) continue; - pl_last->pl_next = pl_entry; + if (pl_last) + pl_last->pl_next = pl_entry; + else + pl_head = pl_entry; return; } diff --git a/usr.sbin/rrenumd/rrenumd.8 b/usr.sbin/rrenumd/rrenumd.8 index 42ea29d..09e3089 100644 --- a/usr.sbin/rrenumd/rrenumd.8 +++ b/usr.sbin/rrenumd/rrenumd.8 @@ -1,4 +1,4 @@ -.\" $KAME$ +.\" $KAME: rrenumd.8,v 1.6 2001/01/22 02:06:24 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. @@ -37,13 +37,19 @@ .Nd router renumbering daemon .Sh SYNOPSIS .Nm +.Op Fl df .Oo .Fl c Ar conf_file | Fl s .Oc -.Op Fl df .Sh DESCRIPTION -.Nm Rrenumd -assigns prefixes to subnets inside the site, or renumbers them. +.Nm +transmits router renumbering request packets, +to renumber the routers in the site network. +.Pp +On KAME-based systems, +router renumbering requests are received and processed by +.Xr rtadvd 8 . +For other systems, refer to relevant documents. .Pp The program will daemonize itself on invocation. It reads configuration information from standard input if @@ -78,8 +84,16 @@ Specify a configuration file where configuration information is kept. .Sh RETURN VALUES The program exits with 0 on success, and non-zero on failures. .Sh SEE ALSO -.Xr daemon 3 , -.Xr rrenumd.conf 5 +.Xr rrenumd.conf 5 , +.Xr rtadvd 8 +.Sh STANDARDS +.Rs +.%A Matt Crawford +.%R RFC +.%N 2894 +.%D August 2000 +.%T "Router Renumbering for IPv6" +.Re .Sh HISTORY The .Nm diff --git a/usr.sbin/rrenumd/rrenumd.c b/usr.sbin/rrenumd/rrenumd.c index fa3257d..686a869 100644 --- a/usr.sbin/rrenumd/rrenumd.c +++ b/usr.sbin/rrenumd/rrenumd.c @@ -1,4 +1,4 @@ -/* $KAME$ */ +/* $KAME: rrenumd.c,v 1.20 2000/11/08 02:40:53 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -64,6 +64,8 @@ #define LL_ALLROUTERS "ff02::2" #define SL_ALLROUTERS "ff05::2" +#define RR_MCHLIM_DEFAULT 64 + #ifndef IN6_IS_SCOPE_LINKLOCAL #define IN6_IS_SCOPE_LINKLOCAL(a) \ ((IN6_IS_ADDR_LINKLOCAL(a)) || \ @@ -93,7 +95,30 @@ int with_v4dest, with_v6dest; struct in6_addr prefix; /* ADHOC */ int prefixlen = 64; /* ADHOC */ -extern int parse(FILE **fp); +extern int parse __P((FILE **)); + +static void show_usage __P((void)); +static void init_sin6 __P((struct sockaddr_in6 *, const char *)); +#if 0 +static void join_multi __P((const char *)); +#endif +static void init_globals __P((void)); +static void config __P((FILE **)); +#ifdef IPSEC_POLICY_IPSEC +static void sock6_open __P((struct flags *, char *)); +static void sock4_open __P((struct flags *, char *)); +#else +static void sock6_open __P((struct flags *)); +static void sock4_open __P((struct flags *)); +#endif +static void rrenum_output __P((struct payload_list *, struct dst_list *)); +static void rrenum_snd_eachdst __P((struct payload_list *)); +#if 0 +static void rrenum_snd_fullsequence __P((void)); +#endif +static void rrenum_input __P((int)); +int main __P((int, char *[])); + /* Print usage. Don't call this after daemonized. */ static void @@ -111,7 +136,7 @@ show_usage() exit(1); } -void +static void init_sin6(struct sockaddr_in6 *sin6, const char *addr_ascii) { memset(sin6, 0, sizeof(*sin6)); @@ -122,7 +147,7 @@ init_sin6(struct sockaddr_in6 *sin6, const char *addr_ascii) } #if 0 /* XXX: not necessary ?? */ -void +static void join_multi(const char *addrname) { struct ipv6_mreq mreq; @@ -151,7 +176,7 @@ join_multi(const char *addrname) } #endif -void +static void init_globals() { static struct iovec rcviov; @@ -193,7 +218,7 @@ init_globals() sndmhdr.msg_controllen = sndcmsglen; } -void +static void config(FILE **fpp) { struct payload_list *pl; @@ -236,7 +261,7 @@ config(FILE **fpp) } } -void +static void sock6_open(struct flags *flags #ifdef IPSEC_POLICY_IPSEC , char *policy @@ -297,7 +322,7 @@ sock6_open(struct flags *flags /* XXX should handle in/out bound policy. */ if (setsockopt(s6, IPPROTO_IPV6, IPV6_IPSEC_POLICY, buf, ipsec_get_policylen(buf)) < 0) - err(1, NULL); + err(1, "setsockopt(IPV6_IPSEC_POLICY)"); free(buf); } #else /* IPSEC_POLICY_IPSEC */ @@ -325,7 +350,7 @@ sock6_open(struct flags *flags return; } -void +static void sock4_open(struct flags *flags #ifdef IPSEC_POLICY_IPSEC , char *policy @@ -363,7 +388,7 @@ sock4_open(struct flags *flags /* XXX should handle in/out bound policy. */ if (setsockopt(s4, IPPROTO_IP, IP_IPSEC_POLICY, buf, ipsec_get_policylen(buf)) < 0) - err(1, NULL); + err(1, "setsockopt(IP_IPSEC_POLICY)"); free(buf); } #else /* IPSEC_POLICY_IPSEC */ @@ -391,7 +416,7 @@ sock4_open(struct flags *flags return; } -void +static void rrenum_output(struct payload_list *pl, struct dst_list *dl) { int i, msglen = 0; @@ -404,8 +429,8 @@ rrenum_output(struct payload_list *pl, struct dst_list *dl) sin6 = (struct sockaddr_in6 *)dl->dl_dst; if (sin6 != NULL && - IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr)) { - int hoplimit = 255; + IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { + int hoplimit = RR_MCHLIM_DEFAULT; cm = CMSG_FIRSTHDR(&sndmhdr); /* specify the outgoing interface */ @@ -438,7 +463,7 @@ rrenum_output(struct payload_list *pl, struct dst_list *dl) strerror(errno)); } -void +static void rrenum_snd_eachdst(struct payload_list *pl) { struct dst_list *dl; @@ -448,7 +473,8 @@ rrenum_snd_eachdst(struct payload_list *pl) } } -void +#if 0 +static void rrenum_snd_fullsequence() { struct payload_list *pl; @@ -457,8 +483,9 @@ rrenum_snd_fullsequence() rrenum_snd_eachdst(pl); } } +#endif -void +static void rrenum_input(int s) { int i; @@ -603,9 +630,8 @@ main(int argc, char *argv[]) /* ADHOC: timeout each 30seconds */ memset(&timeout, 0, sizeof(timeout)); - timeout.tv_sec = 30; - /* init temporal payload_list and send_counter*/ + /* init temporary payload_list and send_counter*/ pl = pl_head; send_counter = retry + 1; while (1) { @@ -622,7 +648,9 @@ main(int argc, char *argv[]) exit(0); rrenum_snd_eachdst(pl); send_counter--; + timeout.tv_sec = 30; if (send_counter == 0) { + timeout.tv_sec = 0; pl = pl->pl_next; send_counter = retry + 1; } diff --git a/usr.sbin/rrenumd/rrenumd.conf.5 b/usr.sbin/rrenumd/rrenumd.conf.5 index 1fba85b..833bc6b 100644 --- a/usr.sbin/rrenumd/rrenumd.conf.5 +++ b/usr.sbin/rrenumd/rrenumd.conf.5 @@ -1,4 +1,4 @@ -.\" $KAME$ +.\" $KAME: rrenumd.conf.5,v 1.8 2001/02/06 02:17:23 jinmei Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. @@ -62,8 +62,8 @@ square brackets (`[' and `]') are used to show optional keywords and parameters. The vertical bar (`|') is used to indicate between a choice of optional parameters. -Parentheses (`(' and -`)') are used to group keywords and parameters when necessary. +Curly braces (`{' and +`}') are used to group keywords and parameters when necessary. .\" .Sh Interface specification There are some statements that may or have to specify interface. @@ -84,7 +84,8 @@ then debugging is enabled, If .Ic off is specified, -then debugging is disabled. It is disabled by default. +then debugging is disabled. +It is disabled by default. .\" .It Ic dest Ar dest-list Op Ar retrycmd ; Specifies destinations to which router renumbering messages should be @@ -102,12 +103,25 @@ specifies how many router renumbering messages are sent repeatedly. .El .It Op Ic add|change|setglobal .Cm match-prefix Ar match-prefix-val +.Bk -words .Op /match-prefix-len +.Ek +.Bk -words .Op Cm maxlen Ar maxlen-val +.Ek +.Bk -words .Op Cm minlen Ar minlen-val +.Ek +.Bk -words .Op Cm use-prefix Ar use-prefix-val +.Ek +.Bk -words .Op /use-prefix-len +.Ek +.Bk -words .Op Cm keeplen Ar keeplen-val +.Ek +.Bk -words .Op Ar use-prefix-values ; .Pp Specifies contents of sending router renumbering message with seqnum 0. @@ -121,11 +135,21 @@ has following syntax. .Pp { .Op Cm vltime Ar vltime-val +.Bk -words .Op Cm pltime Ar pltime-val +.Ek +.Bk -words .Op Cm raf_onlink Cm on|off +.Ek +.Bk -words .Op Cm raf_auto Cm on|off +.Ek +.Bk -words .Op Cm rrf_decrprefd Cm on|off +.Ek +.Bk -words .Op Cm rrf_decrvalid Cm on|off +.Ek } .Pp Each value has following meaning. @@ -163,7 +187,7 @@ copied to the starting part of prefixes to be added on .Cm add|change|setglobal command, as decimal bit number. .It Cm keeplen Ar keeplen-val -Specify the midium part of +Specify the medium part of .Ar use-prefix-val just next to the starting part specified by .Ar use-prefix-len @@ -180,7 +204,8 @@ Valid value for .Ar time is decimal seconds number or special format as "d00h00m00s00", where 00 can take any decimal number, and "d" means days, "h" means hours, -"m" means minutes, "s" means seconds. And alternatively, special keyword +"m" means minutes, "s" means seconds. +And alternatively, special keyword "infinity" can be also be specified. .It Cm pltime Ar pltime-val Assign an @@ -192,38 +217,49 @@ is same as for .Ar vltime-val . .It Cm raf_onlink Cm on|off Let the prefix to be added to have on-link or off-link nature -for the assigned interface. If +for the assigned interface. +If .Cm on -is specified, the prefix have on-link nature. (e.g. the prefix -belong to the link) If +is specified, the prefix have on-link nature +(e.g. the prefix +belong to the link). +If .Cm off -is specified, the prefix have off-link nature. (e.g. the -prefix does not belong to the link) +is specified, the prefix have off-link nature +(e.g. the +prefix does not belong to the link). .It Cm raf_auto Cm on|off Enable or disable the autonomous address auto configuration -for the prefix to be added. If +for the prefix to be added. +If .Cm on is specified, autonomous address auto configuration is -enabled. If +enabled. +If .Cm off is specified, it is disabled. .It Cm rrf_decrprefd Cm on|off -Enable or disable the decrementation of the pltime. If +Enable or disable the decrementation of the pltime. +If .Cm on -is specified, decrementation of the pltime is enabled. If +is specified, decrementation of the pltime is enabled. +If .Cm off is specified, decrementation of the pltime is disabled. .It Cm rrf_decrvalid Cm on|off -Enable or disable the decrementation of the vltime. If +Enable or disable the decrementation of the vltime. +If .Cm on -is specified, decrementation of the vltime is enabled. If +is specified, decrementation of the vltime is enabled. +If .Cm off is specified, decrementation of the vltime is disabled. .El .\" .It seqnum Ar seqnum-val { Ar rrenum-cmd } ; Specifies contents of sending router renumbering message with some -specific seqnum. Multiple of this statement can be specified if they +specific seqnum. +Multiple of this statement can be specified if they have different .Ar seqnum-val each other. @@ -234,19 +270,20 @@ has just same syntax with above add|change|setglobal statement. .Sh EXAMPLES For each configuration file example shown below, we suppose every IPv6 subnet has its own prefix beginning with -fec0:0:0::/48 and with its own subnet number. (in this case, -subnet number is 7th and 8th octet value of the prefix) +fec0:0:0::/48 and with its own subnet number +(in this case, +subnet number is 7th and 8th octet value of the prefix). .Pp -If you want to assigne prefixes beginning with fec0:1:1::/48 +If you want to assign prefixes beginning with 3ffe:501:ffff::/48 to each subnet, then following configuration will be enough, if each of your routers supports IPv6 multicast forwarding. The subnet number of the existing fec0:0:0::/48 prefix and the -newly assigned fec0:1:1::/48 prefix will be same. +newly assigned 3ffe:501:ffff::/48 prefix will be same. .\" .Bd -literal -offset indent dest ff05::2; -add match-prefix fec0:0:0:: /48 use-prefix fec0:1:1:: /48 keeplen 16; +add match-prefix fec0:0:0:: /48 use-prefix 3ffe:501:ffff:: /48 keeplen 16; .Ed .Pp .\" @@ -258,20 +295,21 @@ command. .Bd -literal -offset indent dest fec0:0:0:1:260:8ff:fe24:fb3a fec0:0:0:2:200:eff:fe2e:dfe1 fec0:0:0:3:5254:ff:fedc:5217; -add match-prefix fec0:0:0:: /48 use-prefix fec0:1:1:: /48 keeplen 16; +add match-prefix fec0:0:0:: /48 use-prefix 3ffe:501:ffff:: /48 keeplen 16; .Ed .Pp .\" If you are going to do renumbering, then following procedure will be natural. .Bl -enum -offset indent .It -Assigne new prefix. +Assign a new prefix. .It Set old prefix lifetimes to some appropriate transition -period. In the followng example we use 1 week for valid +period. +In the followng example we use 1 week for valid lifetime, and 0 for preferred lifetime. -Also, enable old prefix lifetime expiration. -(By default, it is static and does not expire) +Also, enable old prefix lifetime expiration +(By default, it is static and does not expire). .It After the transition period, old prefixes should become invalid, and may have been deleted. @@ -287,23 +325,24 @@ The following configuration file will do 1 and 2. dest ff05::2; seqnum 0 { - add match-prefix fec0:0:0:: /48 use-prefix fec0:2:2:: /48 keeplen 16; + add match-prefix fec0:0:0:: /48 use-prefix 3ffe:501:fffe:: /48 keeplen 16; }; seqnum 1 { - change match-prefix fec0:1:1:: /48 use-prefix fec0:1:1:: /48 keeplen 16 vltime d7 pltime 0 rrf_decrvalid on rrf_decrprefd on; + change match-prefix 3ffe:501:ffff:: /48 use-prefix 3ffe:501:ffff:: /48 keeplen 16 vltime d7 pltime 0 rrf_decrvalid on rrf_decrprefd on; }; .Ed .Pp .\" -And the following configuration file will do 3. (should be +And the following configuration file will do 3 +(should be used for the router renumbering message to be sent 1 week -afterward) +afterward). .\" .Bd -literal -offset indent dest ff05::2; -change match-prefix fec0:1:1:: /48; +change match-prefix 3ffe:501:ffff:: /48; .Ed .Pp .\" @@ -319,7 +358,7 @@ command is almost same with .Cm change command except that it deletes all pre-defined IPv6 global address. .Sh SEE ALSO -.Xr rrenumd 8 +.Xr rrenumd 8 , .Xr prefix 8 .Sh HISTORY The diff --git a/usr.sbin/rrenumd/rrenumd.h b/usr.sbin/rrenumd/rrenumd.h index 4854cb4..df0280b 100644 --- a/usr.sbin/rrenumd/rrenumd.h +++ b/usr.sbin/rrenumd/rrenumd.h @@ -1,4 +1,4 @@ -/* $KAME$ */ +/* $KAME: rrenumd.h,v 1.2 2000/07/03 02:54:09 itojun Exp $ */ /* * Copyright (C) 1998 WIDE Project. -- cgit v1.1