CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:16:53 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: advcap.c config.c dump.c if.c timer.c

Log Message:
print function names as %s: not <%s> everywhere for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/dump.c
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/advcap.c
diff -u src/usr.sbin/rtadvd/advcap.c:1.18 src/usr.sbin/rtadvd/advcap.c:1.19
--- src/usr.sbin/rtadvd/advcap.c:1.18	Sat Feb  2 22:19:31 2019
+++ src/usr.sbin/rtadvd/advcap.c	Tue Mar 23 14:16:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: advcap.c,v 1.18 2019/02/03 03:19:31 mrg Exp $	*/
+/*	$NetBSD: advcap.c,v 1.19 2021/03/23 18:16:53 christos Exp $	*/
 /*	$KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $	*/
 
 /*
@@ -139,7 +139,7 @@ getent(char *bp, char *name, char *cp)
 		tf = open(RM = cp, O_RDONLY);
 	}
 	if (tf < 0) {
-		logit(LOG_INFO, "<%s> open: %m", __func__);
+		logit(LOG_INFO, "%s: open `%s': %m", __func__, cp);
 		return (-2);
 	}
 	for (;;) {

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.45 src/usr.sbin/rtadvd/config.c:1.46
--- src/usr.sbin/rtadvd/config.c:1.45	Mon Mar 22 14:41:11 2021
+++ src/usr.sbin/rtadvd/config.c	Tue Mar 23 14:16:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.45 2021/03/22 18:41:11 christos Exp $	*/
+/*	$NetBSD: config.c,v 1.46 2021/03/23 18:16:53 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -169,44 +169,46 @@ getconfig(const char *intface, int exith
 	struct rdnss *rdnss;
 	struct dnssl *dnssl;
 
-#define MUSTHAVE(var, cap)	\
+#define MUSTHAVE(var, cap)		\
 do {\
 	int64_t t;			\
 	if ((t = agetnum(cap)) < 0) {	\
-		fprintf(stderr, "rtadvd: need %s for interface %s\n",	\
-			cap, intface);	\
+		logit(LOG_ERR, "%s: need %s for interface %s",		\
+		__func__, cap, intface);\
 		goto errexit;		\
 	}\
 	var = t;			\
- } while (0)
-#define MAYHAVE(var, cap, def)	\
+ } while (/*CONSTCOND*/0)
+
+#define MAYHAVE(var, cap, def)		\
  do {\
 	if ((var = agetnum(cap)) < 0)	\
 		var = def;		\
- } while (0)
-#define	ELM_MALLOC(p)	\
+ } while (/*CONSTCOND*/0)
+
+#define	ELM_MALLOC(p)			\
 	do {\
 		p = calloc(1, sizeof(*p));\
 		if (p == NULL) {	\
-			logit(LOG_ERR, "<%s> calloc failed: %m",	\
+			logit(LOG_ERR, "%s: calloc failed: %m",	\
 			__func__);	\
 			goto errexit;	\
 		}			\
 	} while(/*CONSTCOND*/0)
 
 	if (if_nametoindex(intface) == 0) {
-		logit(LOG_INFO, "<%s> interface %s not found, ignoring",
+		logit(LOG_INFO, "%s: interface %s not found, ignoring",
 		   __func__, intface);
 		return;
 	}
 
-	logit(LOG_DEBUG, "<%s> loading configuration for interface %s",
+	logit(LOG_DEBUG, "%s: loading configuration for interface %s",
 	   __func__, intface);
 
 	if ((stat = agetent(tbuf, intface)) <= 0) {
 		memset(tbuf, 0, sizeof(tbuf));
 		logit(LOG_INFO,
-		   "<%s> %s isn't defined in the configuration file"
+		   "%s: %s isn't defined in the configuration file"
 		   " or the configuration file doesn't exist."
 		   " Treat it as default",
 		__func__, intface);
@@ -222,7 +224,7 @@ getconfig(const char *intface, int exith
 	/* check if we are allowed to forward packets (if not determined) */
 	if (forwarding < 0) {
 		if ((forwarding = getinet6sysctl(IPV6CTL_FORWARDING)) < 0)
-			exit(1);
+			exit(EXIT_FAILURE);
 	}
 
 	/* get interface information */
@@ -233,7 +235,7 @@ getconfig(const char *intface, int exith
 	if (tmp->advlinkopt) {
 		if ((tmp->sdl = if_nametosdl(intface)) == NULL) {
 			logit(LOG_ERR,
-			   "<%s> can't get information of %s",
+			   "%s: can't get information of %s",
 			   __func__, intface);
 			goto errexit;
 		}
@@ -242,7 +244,7 @@ getconfig(const char *intface, int exith
 		tmp->ifindex = if_nametoindex(intface);
 		if (tmp->ifindex == 0) {
 			logit(LOG_ERR,
-			   "<%s> can't get information of %s",
+			   "%s: can't get information of %s",
 			   __func__, intface);
 			goto errexit;
 		}
@@ -252,7 +254,7 @@ getconfig(const char *intface, int exith
 	if ((tmp->phymtu = if_getmtu(intface)) == 0) {
 		tmp->phymtu = IPV6_MMTU;
 		logit(LOG_WARNING,
-		   "<%s> can't get interface mtu of %s. Treat as %d",
+		   "%s: can't get interface mtu of %s. Treat as %d",
 		   __func__, intface, IPV6_MMTU);
 	}
 
@@ -262,7 +264,7 @@ getconfig(const char *intface, int exith
 	MAYHAVE(val, "maxinterval", DEF_MAXRTRADVINTERVAL);
 	if (val < MIN_MAXINTERVAL || val > MAX_MAXINTERVAL) {
 		

CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:16:53 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: advcap.c config.c dump.c if.c timer.c

Log Message:
print function names as %s: not <%s> everywhere for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/dump.c
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:16:21 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: if.c if.h

Log Message:
interface indexes are unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/rtadvd/if.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:16:21 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: if.c if.h

Log Message:
interface indexes are unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/rtadvd/if.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/if.c
diff -u src/usr.sbin/rtadvd/if.c:1.27 src/usr.sbin/rtadvd/if.c:1.28
--- src/usr.sbin/rtadvd/if.c:1.27	Mon Mar 22 14:41:11 2021
+++ src/usr.sbin/rtadvd/if.c	Tue Mar 23 14:16:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.27 2021/03/22 18:41:11 christos Exp $	*/
+/*	$NetBSD: if.c,v 1.28 2021/03/23 18:16:21 christos Exp $	*/
 /*	$KAME: if.c,v 1.36 2004/11/30 22:32:01 suz Exp $	*/
 
 /*
@@ -132,7 +132,7 @@ if_getmtu(const char *name)
 
 /* give interface index and its old flags, then new flags returned */
 int
-if_getflags(int ifindex, int oifflags)
+if_getflags(unsigned int ifindex, int oifflags)
 {
 	struct ifreq ifr;
 	int s;
@@ -194,7 +194,8 @@ lladdropt_fill(struct sockaddr_dl *sdl, 
 #define SIN6(s) ((const struct sockaddr_in6 *)(s))
 #define SDL(s) ((const struct sockaddr_dl *)(s))
 char *
-get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter)
+get_next_msg(char *buf, char *lim, unsigned int ifindex, size_t *lenp,
+int filter)
 {
 	struct rt_msghdr *rtm;
 	struct ifa_msghdr *ifam;
@@ -294,7 +295,7 @@ get_addr(const void *buf)
 	return (rti_info[RTAX_DST])->sin6_addr;
 }
 
-int
+unsigned int
 get_rtm_ifindex(const void *buf)
 {
 	const struct rt_msghdr *rtm = buf;
@@ -306,20 +307,20 @@ get_rtm_ifindex(const void *buf)
 	return SDL(rti_info[RTAX_GATEWAY])->sdl_index;
 }
 
-int
+unsigned int
 get_ifm_ifindex(const void *buf)
 {
 	const struct if_msghdr *ifm = buf;
 
-	return (int)ifm->ifm_index;
+	return ifm->ifm_index;
 }
 
-int
+unsigned int
 get_ifam_ifindex(const void *buf)
 {
 	const struct ifa_msghdr *ifam = buf;
 
-	return (int)ifam->ifam_index;
+	return ifam->ifam_index;
 }
 
 int
@@ -331,12 +332,12 @@ get_ifm_flags(const void *buf)
 }
 
 #ifdef RTM_IFANNOUNCE
-int
+unsigned int
 get_ifan_ifindex(const void *buf)
 {
 	const struct if_announcemsghdr *ifan = buf;
 
-	return (int)ifan->ifan_index;
+	return ifan->ifan_index;
 }
 
 int

Index: src/usr.sbin/rtadvd/if.h
diff -u src/usr.sbin/rtadvd/if.h:1.12 src/usr.sbin/rtadvd/if.h:1.13
--- src/usr.sbin/rtadvd/if.h:1.12	Mon Mar 22 14:41:11 2021
+++ src/usr.sbin/rtadvd/if.h	Tue Mar 23 14:16:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.12 2021/03/22 18:41:11 christos Exp $	*/
+/*	$NetBSD: if.h,v 1.13 2021/03/23 18:16:21 christos Exp $	*/
 /*	$KAME: if.h,v 1.12 2003/09/21 07:17:03 itojun Exp $	*/
 
 /*
@@ -35,17 +35,17 @@
 struct nd_opt_hdr;
 struct sockaddr_dl *if_nametosdl(const char *);
 int if_getmtu(const char *);
-int if_getflags(int, int);
+int if_getflags(unsigned int, int);
 int lladdropt_length(struct sockaddr_dl *);
 void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *);
-char *get_next_msg(char *, char *, int, size_t *, int);
+char *get_next_msg(char *, char *, unsigned int, size_t *, int);
 const struct in6_addr *get_addr(const void *);
-int get_rtm_ifindex(const void *);
-int get_ifm_ifindex(const void *);
-int get_ifam_ifindex(const void *);
+unsigned int get_rtm_ifindex(const void *);
+unsigned int get_ifm_ifindex(const void *);
+unsigned int get_ifam_ifindex(const void *);
 int get_ifm_flags(const void *);
 #ifdef RTM_IFANNOUNCE
-int get_ifan_ifindex(const void *);
+unsigned int get_ifan_ifindex(const void *);
 int get_ifan_what(const void *);
 #endif
 int get_prefixlen(const void *);



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:13:07 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
call tzset() before chroot so we initialize our timezone data


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:13:07 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
call tzset() before chroot so we initialize our timezone data


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.81 src/usr.sbin/rtadvd/rtadvd.c:1.82
--- src/usr.sbin/rtadvd/rtadvd.c:1.81	Tue Mar 23 14:06:19 2021
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Mar 23 14:13:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.81 2021/03/23 18:06:19 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.82 2021/03/23 18:13:07 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -283,6 +283,7 @@ main(int argc, char *argv[])
 		set[1].fd = -1;
 
 	logit(LOG_INFO, "dropping privileges to %s", RTADVD_USER);
+	tzset();
 	if (prog_chroot(pw->pw_dir) == -1) {
 		logit(LOG_ERR, "chroot: %s: %m", pw->pw_dir);
 		return EXIT_FAILURE;



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:06:19 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
fix misplaced paren, add missing va_end()


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2021-03-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 23 18:06:19 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
fix misplaced paren, add missing va_end()


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.80 src/usr.sbin/rtadvd/rtadvd.c:1.81
--- src/usr.sbin/rtadvd/rtadvd.c:1.80	Mon Mar 22 14:41:11 2021
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Mar 23 14:06:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.80 2021/03/22 18:41:11 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.81 2021/03/23 18:06:19 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1615,7 +1615,7 @@ rtsock_open(void)
 	}
 #ifdef RO_MSGFILTER
 	if (prog_setsockopt(rtsock, PF_ROUTE, RO_MSGFILTER,
-	, sizeof(msgfilter) == -1))
+	, sizeof(msgfilter)) == -1)
 		logit(LOG_ERR, "%s: RO_MSGFILTER: %m", __func__);
 #endif
 }
@@ -1804,13 +1804,14 @@ logit(int level, const char *fmt, ...)
 	va_start(ap, fmt);
 	if (!Dflag && after_daemon) {
 		vsyslog(level, fmt, ap);
-		va_end(ap);
-		return;
+		goto out;
+	}
+	if (level >= LOG_INFO && !dflag) {
+		goto out;
 	}
-	if (level >= LOG_INFO && !dflag)
-		return;
 
 	vwarnx(expandm(fmt, "", ), ap);
 	free(buf);
+out:
 	va_end(ap);
 }



CVS commit: src/usr.sbin/rtadvd

2021-03-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 22 18:41:11 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: config.c config.h if.c if.h rtadvd.c rtadvd.h

Log Message:
- remove extra \n from stderr logging
- add string message types
- sprinkle const


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/rtadvd/config.h \
src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.79 -r1.80 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.44 src/usr.sbin/rtadvd/config.c:1.45
--- src/usr.sbin/rtadvd/config.c:1.44	Tue Apr 21 08:16:47 2020
+++ src/usr.sbin/rtadvd/config.c	Mon Mar 22 14:41:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.44 2020/04/21 12:16:47 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.45 2021/03/22 18:41:11 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -965,7 +965,8 @@ update_prefix(struct prefix * prefix)
  * able to be specified.
  */
 void
-add_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
+add_prefix(struct rainfo *rai, int ifindex, const struct in6_addr *addr,
+int plen)
 {
 	struct prefix *prefix;
 	char ntopbuf[INET6_ADDRSTRLEN];

Index: src/usr.sbin/rtadvd/config.h
diff -u src/usr.sbin/rtadvd/config.h:1.11 src/usr.sbin/rtadvd/config.h:1.12
--- src/usr.sbin/rtadvd/config.h:1.11	Tue Apr 21 08:16:47 2020
+++ src/usr.sbin/rtadvd/config.h	Mon Mar 22 14:41:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.h,v 1.11 2020/04/21 12:16:47 roy Exp $	*/
+/*	$NetBSD: config.h,v 1.12 2021/03/22 18:41:11 christos Exp $	*/
 /*	$KAME: config.h,v 1.9 2003/08/06 04:19:40 ono Exp $	*/
 
 /*
@@ -35,7 +35,7 @@ extern void getconfig(const char *, int)
 extern void delete_prefix(struct prefix *);
 extern void invalidate_prefix(struct prefix *);
 extern void update_prefix(struct prefix *);
-extern void add_prefix(struct rainfo *, int, struct in6_addr *, int);
+extern void add_prefix(struct rainfo *, int, const struct in6_addr *, int);
 extern void make_packet(struct rainfo *);
 extern void get_prefix(struct rainfo *);
 
Index: src/usr.sbin/rtadvd/if.h
diff -u src/usr.sbin/rtadvd/if.h:1.11 src/usr.sbin/rtadvd/if.h:1.12
--- src/usr.sbin/rtadvd/if.h:1.11	Fri Apr 20 06:39:37 2018
+++ src/usr.sbin/rtadvd/if.h	Mon Mar 22 14:41:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.11 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: if.h,v 1.12 2021/03/22 18:41:11 christos Exp $	*/
 /*	$KAME: if.h,v 1.12 2003/09/21 07:17:03 itojun Exp $	*/
 
 /*
@@ -39,16 +39,17 @@ int if_getflags(int, int);
 int lladdropt_length(struct sockaddr_dl *);
 void lladdropt_fill(struct sockaddr_dl *, struct nd_opt_hdr *);
 char *get_next_msg(char *, char *, int, size_t *, int);
-struct in6_addr *get_addr(char *);
-int get_rtm_ifindex(char *);
-int get_ifm_ifindex(char *);
-int get_ifam_ifindex(char *);
-int get_ifm_flags(char *);
+const struct in6_addr *get_addr(const void *);
+int get_rtm_ifindex(const void *);
+int get_ifm_ifindex(const void *);
+int get_ifam_ifindex(const void *);
+int get_ifm_flags(const void *);
 #ifdef RTM_IFANNOUNCE
-int get_ifan_ifindex(char *);
-int get_ifan_what(char *);
+int get_ifan_ifindex(const void *);
+int get_ifan_what(const void *);
 #endif
-int get_prefixlen(char *);
+int get_prefixlen(const void *);
 int prefixlen(const unsigned char *, const unsigned char *);
-int rtmsg_type(char *);
-int rtmsg_len(char *);
+const char *rtmsg_typestr(const void *);
+int rtmsg_type(const void *);
+int rtmsg_len(const void *);

Index: src/usr.sbin/rtadvd/if.c
diff -u src/usr.sbin/rtadvd/if.c:1.26 src/usr.sbin/rtadvd/if.c:1.27
--- src/usr.sbin/rtadvd/if.c:1.26	Fri Apr 20 06:39:37 2018
+++ src/usr.sbin/rtadvd/if.c	Mon Mar 22 14:41:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.26 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: if.c,v 1.27 2021/03/22 18:41:11 christos Exp $	*/
 /*	$KAME: if.c,v 1.36 2004/11/30 22:32:01 suz Exp $	*/
 
 /*
@@ -30,6 +30,7 @@
  * SUCH DAMAGE.
  */
 
+#define RTM_NAMES
 #include 
 #include 
 #include 
@@ -65,7 +66,8 @@
 #endif
 
 static void
-get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)
+get_rtaddrs(int addrs, const struct sockaddr *sa,
+const struct sockaddr **rti_info)
 {
 	int i;
 
@@ -189,14 +191,14 @@ lladdropt_fill(struct sockaddr_dl *sdl, 
 }
 
 #define FILTER_MATCH(type, filter) ((0x1 << type) & filter)
-#define SIN6(s) ((struct sockaddr_in6 *)(s))
-#define SDL(s) ((struct sockaddr_dl *)(s))
+#define SIN6(s) ((const struct sockaddr_in6 *)(s))
+#define SDL(s) ((const struct sockaddr_dl *)(s))
 char *
 get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter)
 {
 	struct rt_msghdr *rtm;
 	struct ifa_msghdr *ifam;
-	

CVS commit: src/usr.sbin/rtadvd

2021-03-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 22 18:41:11 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: config.c config.h if.c if.h rtadvd.c rtadvd.h

Log Message:
- remove extra \n from stderr logging
- add string message types
- sprinkle const


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/rtadvd/config.h \
src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.79 -r1.80 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2021-02-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Feb  3 06:50:08 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: Makefile

Log Message:
rtadvd: no longer need packed member warning


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/Makefile
diff -u src/usr.sbin/rtadvd/Makefile:1.25 src/usr.sbin/rtadvd/Makefile:1.26
--- src/usr.sbin/rtadvd/Makefile:1.25	Sun Sep  6 07:20:32 2020
+++ src/usr.sbin/rtadvd/Makefile	Wed Feb  3 06:50:07 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.25 2020/09/06 07:20:32 mrg Exp $
+# $NetBSD: Makefile,v 1.26 2021/02/03 06:50:07 roy Exp $
 
 WARNS?=	4
 
@@ -31,9 +31,6 @@ LDADD.rump+=	-lrumpres
 DPADD.rump+=	${LIBRUMPRES}
 .endif
 
-CWARNFLAGS.clang+=	-Wno-error=address-of-packed-member
-CWARNFLAGS.gcc+=	${GCC_NO_ADDR_OF_PACKED_MEMBER}
-
 COPTS.if.c+=		${GCC_NO_STRINGOP_TRUNCATION}
 COPTS.config.c+=	${GCC_NO_STRINGOP_TRUNCATION}
 



CVS commit: src/usr.sbin/rtadvd

2021-02-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Feb  3 06:50:08 UTC 2021

Modified Files:
src/usr.sbin/rtadvd: Makefile

Log Message:
rtadvd: no longer need packed member warning


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-08-27 Thread Robert Swindells
Module Name:src
Committed By:   rjs
Date:   Fri Aug 28 00:19:37 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use wrapper name for call to setsockopt(2), NFC for non-rump builds.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-08-27 Thread Robert Swindells
Module Name:src
Committed By:   rjs
Date:   Fri Aug 28 00:19:37 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use wrapper name for call to setsockopt(2), NFC for non-rump builds.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.78 src/usr.sbin/rtadvd/rtadvd.c:1.79
--- src/usr.sbin/rtadvd/rtadvd.c:1.78	Thu May 14 23:42:18 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Aug 28 00:19:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.78 2020/05/14 23:42:18 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.79 2020/08/28 00:19:37 rjs Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1614,7 +1614,7 @@ rtsock_open(void)
 		exit(EXIT_FAILURE);
 	}
 #ifdef RO_MSGFILTER
-	if (setsockopt(rtsock, PF_ROUTE, RO_MSGFILTER,
+	if (prog_setsockopt(rtsock, PF_ROUTE, RO_MSGFILTER,
 	, sizeof(msgfilter) == -1))
 		logit(LOG_ERR, "%s: RO_MSGFILTER: %m", __func__);
 #endif



CVS commit: src/usr.sbin/rtadvd

2020-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 14 23:42:18 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
If we could not lock the pid file, don't continue as we end up with multiple
rtadvd's (thanks roy@)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.77 src/usr.sbin/rtadvd/rtadvd.c:1.78
--- src/usr.sbin/rtadvd/rtadvd.c:1.77	Sun May 10 18:38:51 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Thu May 14 19:42:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.77 2020/05/10 22:38:51 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.78 2020/05/14 23:42:18 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -224,12 +224,11 @@ main(int argc, char *argv[])
 	if ((pid = pidfile_lock(pidfilepath)) != 0) {
 		if (pid == -1) {
 			logit(LOG_ERR, "pidfile_lock: %m");
-			/* Continue */
 		} else {
 			logit(LOG_ERR, "Another instance of `%s' is running "
 			"(pid %d); exiting.", getprogname(), pid);
-			return EXIT_FAILURE;
 		}
+		return EXIT_FAILURE;
 	}
 
 	if (prog_init && prog_init() == -1)



CVS commit: src/usr.sbin/rtadvd

2020-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 14 23:42:18 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
If we could not lock the pid file, don't continue as we end up with multiple
rtadvd's (thanks roy@)


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:38:51 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
warn only for > INFO level messages.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:38:51 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
warn only for > INFO level messages.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.76 src/usr.sbin/rtadvd/rtadvd.c:1.77
--- src/usr.sbin/rtadvd/rtadvd.c:1.76	Sun May 10 18:33:09 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun May 10 18:38:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.76 2020/05/10 22:33:09 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.77 2020/05/10 22:38:51 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1808,6 +1808,8 @@ logit(int level, const char *fmt, ...)
 		va_end(ap);
 		return;
 	}
+	if (level >= LOG_INFO && !dflag)
+		return;
 
 	vwarnx(expandm(fmt, "\n", ), ap);
 	free(buf);



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:33:09 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Print errors to stderr until we daemonize.
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-05-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 10 22:33:09 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Print errors to stderr until we daemonize.
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.75 src/usr.sbin/rtadvd/rtadvd.c:1.76
--- src/usr.sbin/rtadvd/rtadvd.c:1.75	Tue Apr 21 08:23:13 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun May 10 18:33:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.75 2020/04/21 12:23:13 wiz Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.76 2020/05/10 22:33:09 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #ifdef __NetBSD__
 #include 
@@ -87,6 +88,7 @@ static const char *dumpfilename = "/var/
 int sock;
 int rtsock = -1;
 int Cflag = 0, dflag = 0, sflag = 0, Dflag;
+static int after_daemon = 0;
 
 static char **if_argv;
 static int if_argc;
@@ -214,16 +216,16 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 	if (argc == 0) {
-		fprintf(stderr, "Ysage: %s [-CDdfs] [-c conffile]"
+		fprintf(stderr, "Usage: %s [-CDdfs] [-c conffile]"
 		" [-p pidfile] interface ...\n", getprogname());
 		return EXIT_FAILURE;
 	}
 
 	if ((pid = pidfile_lock(pidfilepath)) != 0) {
-		if (pid == -1)
+		if (pid == -1) {
 			logit(LOG_ERR, "pidfile_lock: %m");
 			/* Continue */
-		else {
+		} else {
 			logit(LOG_ERR, "Another instance of `%s' is running "
 			"(pid %d); exiting.", getprogname(), pid);
 			return EXIT_FAILURE;
@@ -265,6 +267,7 @@ main(int argc, char *argv[])
 
 	if (!fflag) {
 		prog_daemon(1, 0);
+		after_daemon = 1;
 		if (pidfile_lock(pidfilepath) != 0)
 			logit(LOG_ERR, " pidfile_lock: %m");
 	}
@@ -1800,13 +1803,13 @@ logit(int level, const char *fmt, ...)
 	char *buf;
 
 	va_start(ap, fmt);
-	if (!Dflag) {
+	if (!Dflag && after_daemon) {
 		vsyslog(level, fmt, ap);
 		va_end(ap);
 		return;
 	}
 
-	vfprintf(stderr, expandm(fmt, "\n", ), ap);
+	vwarnx(expandm(fmt, "\n", ), ap);
 	free(buf);
 	va_end(ap);
 }



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:23:13 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Remove dst variable that was only set but not used.

(This broke the build for me.)


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:23:13 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Remove dst variable that was only set but not used.

(This broke the build for me.)


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.74 src/usr.sbin/rtadvd/rtadvd.c:1.75
--- src/usr.sbin/rtadvd/rtadvd.c:1.74	Tue Apr 21 12:21:27 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Apr 21 12:23:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.74 2020/04/21 12:21:27 wiz Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.75 2020/04/21 12:23:13 wiz Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -725,7 +725,6 @@ rtadvd_input(void)
 	struct cmsghdr *cm;
 	struct in6_pktinfo *pi = NULL;
 	char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ];
-	struct in6_addr dst = in6addr_any;
 	struct rainfo *rai;
 
 	/*
@@ -750,7 +749,6 @@ rtadvd_input(void)
 		cm->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) {
 			pi = (struct in6_pktinfo *)(CMSG_DATA(cm));
 			ifindex = pi->ipi6_ifindex;
-			dst = pi->ipi6_addr;
 		}
 		if (cm->cmsg_level == IPPROTO_IPV6 &&
 		cm->cmsg_type == IPV6_HOPLIMIT &&



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:21:27 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Update getopt string.

Remove -M. Add -C (the code is there and documented, even if noone could
activate it...).
Sync usage with manpage.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.73 src/usr.sbin/rtadvd/rtadvd.c:1.74
--- src/usr.sbin/rtadvd/rtadvd.c:1.73	Tue Apr 21 12:16:47 2020
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Apr 21 12:21:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.73 2020/04/21 12:16:47 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.74 2020/04/21 12:21:27 wiz Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -184,7 +184,7 @@ main(int argc, char *argv[])
 	pid_t pid;
 
 	/* get command line options and arguments */
-#define OPTIONS "c:dDfM:p:s"
+#define OPTIONS "Cc:dDfp:s"
 	while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
 #undef OPTIONS
 		switch (ch) {
@@ -214,8 +214,8 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 	if (argc == 0) {
-		fprintf(stderr, "Ysage: %s [-DdfRs] [-c conffile]"
-		" [-M ifname] [-p pidfile] interface ...\n", getprogname());
+		fprintf(stderr, "Ysage: %s [-CDdfs] [-c conffile]"
+		" [-p pidfile] interface ...\n", getprogname());
 		return EXIT_FAILURE;
 	}
 



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:21:27 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Update getopt string.

Remove -M. Add -C (the code is there and documented, even if noone could
activate it...).
Sync usage with manpage.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:19:44 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.8

Log Message:
Remove -M from SYNOPSIS as well.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/rtadvd/rtadvd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Apr 21 12:19:44 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: rtadvd.8

Log Message:
Remove -M from SYNOPSIS as well.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/rtadvd/rtadvd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.8
diff -u src/usr.sbin/rtadvd/rtadvd.8:1.28 src/usr.sbin/rtadvd/rtadvd.8:1.29
--- src/usr.sbin/rtadvd/rtadvd.8:1.28	Tue Apr 21 12:05:54 2020
+++ src/usr.sbin/rtadvd/rtadvd.8	Tue Apr 21 12:19:44 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rtadvd.8,v 1.28 2020/04/21 12:05:54 roy Exp $
+.\"	$NetBSD: rtadvd.8,v 1.29 2020/04/21 12:19:44 wiz Exp $
 .\"	$KAME: rtadvd.8,v 1.24 2002/05/31 16:16:08 jinmei Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -38,7 +38,6 @@
 .Nm
 .Op Fl CDdfs
 .Op Fl c Ar configfile
-.Op Fl M Ar ifname
 .Op Fl p Ar pidfile
 .Ar interface ...
 .Sh DESCRIPTION



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 21 12:16:47 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: config.c config.h rtadvd.c

Log Message:
rtadvd: Remove disabled use of SIOCGIFPREFIX_IN6

It's not been enabled since the functionality was added to ifconfig(8)
many many years ago.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 21 12:16:47 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: config.c config.h rtadvd.c

Log Message:
rtadvd: Remove disabled use of SIOCGIFPREFIX_IN6

It's not been enabled since the functionality was added to ifconfig(8)
many many years ago.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.72 -r1.73 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.43 src/usr.sbin/rtadvd/config.c:1.44
--- src/usr.sbin/rtadvd/config.c:1.43	Mon Nov 11 13:42:49 2019
+++ src/usr.sbin/rtadvd/config.c	Tue Apr 21 12:16:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.43 2019/11/11 13:42:49 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.44 2020/04/21 12:16:47 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -875,49 +875,6 @@ makeentry(char *buf, size_t len, int id,
 }
 
 /*
- * Add a prefix to the list of specified interface and reconstruct
- * the outgoing packet.
- * The prefix must not be in the list.
- * XXX: other parameters of the prefix(e.g. lifetime) should be
- * able to be specified.
- */
-static void
-add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr)
-{
-	struct prefix *prefix;
-	char ntopbuf[INET6_ADDRSTRLEN];
-
-	if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
-		logit(LOG_ERR, "<%s> memory allocation failed",
-		   __func__);
-		return;		/* XXX: error or exit? */
-	}
-	prefix->prefix = ipr->ipr_prefix.sin6_addr;
-	prefix->prefixlen = ipr->ipr_plen;
-	prefix->validlifetime = ipr->ipr_vltime;
-	prefix->preflifetime = ipr->ipr_pltime;
-	prefix->onlinkflg = ipr->ipr_raf_onlink;
-	prefix->autoconfflg = ipr->ipr_raf_auto;
-	prefix->origin = PREFIX_FROM_DYNAMIC;
-
-	prefix->rainfo = rai;
-	TAILQ_INSERT_TAIL(>prefix, prefix, next);
-	rai->pfxs++;
-
-	logit(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s",
-	   __func__, inet_ntop(AF_INET6, >ipr_prefix.sin6_addr,
-   ntopbuf, INET6_ADDRSTRLEN),
-	   ipr->ipr_plen, rai->ifname);
-
-	/* free the previous packet */
-	free(rai->ra_data);
-	rai->ra_data = NULL;
-
-	/* reconstruct the packet */
-	make_packet(rai);
-}
-
-/*
  * Delete a prefix to the list of specified interface and reconstruct
  * the outgoing packet.
  * The prefix must be in the list.
@@ -1001,73 +958,45 @@ update_prefix(struct prefix * prefix)
 }
 
 /*
- * 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[].
+ * Add a prefix to the list of specified interface and reconstruct
+ * the outgoing packet.
+ * The prefix must not be in the list.
+ * XXX: other parameters of the prefix(e.g. lifetime) should be
+ * able to be specified.
  */
-static int
-init_prefix(struct in6_prefixreq *ipr)
+void
+add_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
-#if 0
-	int s;
+	struct prefix *prefix;
+	char ntopbuf[INET6_ADDRSTRLEN];
 
-	if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-		logit(LOG_ERR, "<%s> socket: %m", __func__);
-		exit(1);
+	if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
+		logit(LOG_ERR, "<%s> memory allocation failed",
+		   __func__);
+		return;		/* XXX: error or exit? */
 	}
+	prefix->prefix = *addr;
+	prefix->prefixlen = plen;
+	prefix->validlifetime = DEF_ADVVALIDLIFETIME;
+	prefix->preflifetime = DEF_ADVPREFERREDLIFETIME;
+	prefix->onlinkflg = 1;
+	prefix->autoconfflg = 0;
+	prefix->origin = PREFIX_FROM_DYNAMIC;
 
-	if (prog_ioctl(s, SIOCGIFPREFIX_IN6, ipr) < 0) {
-		logit(LOG_INFO, "<%s> ioctl:SIOCGIFPREFIX: %m", __func__);
+	prefix->rainfo = rai;
+	TAILQ_INSERT_TAIL(>prefix, prefix, next);
+	rai->pfxs++;
 
-		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) {
-		char ntopbuf[INET6_ADDRSTRLEN];
-
-		logit(LOG_WARNING, "<%s> Added prefix(%s)'s origin %d is"
-		   "lower than PR_ORIG_RR(router renumbering)."
-		   "This should not happen if I am router", __func__,
-		   inet_ntop(AF_INET6, >ipr_prefix.sin6_addr, ntopbuf,
- sizeof(ntopbuf)), ipr->ipr_origin);
-		prog_close(s);
-		return 1;
-	}
-
-	prog_close(s);
-	return 0;
-#else
-	ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
-	ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-	ipr->ipr_raf_onlink = 1;
-	ipr->ipr_raf_auto = 1;
-	return 0;
-#endif
-}
+	logit(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s",
+	   __func__, inet_ntop(AF_INET6, addr, ntopbuf, INET6_ADDRSTRLEN),
+	   plen, rai->ifname);
 
-void
-make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)

CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 21 12:05:54 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: Makefile rtadvd.8 rtadvd.c
Removed Files:
src/usr.sbin/rtadvd: rrenum.c rrenum.h

Log Message:
rtadvd: Remove router renumbering - it's been disable for years


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/rtadvd/Makefile
cvs rdiff -u -r1.21 -r0 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.6 -r0 src/usr.sbin/rtadvd/rrenum.h
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2020-04-21 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 21 12:05:54 UTC 2020

Modified Files:
src/usr.sbin/rtadvd: Makefile rtadvd.8 rtadvd.c
Removed Files:
src/usr.sbin/rtadvd: rrenum.c rrenum.h

Log Message:
rtadvd: Remove router renumbering - it's been disable for years


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/rtadvd/Makefile
cvs rdiff -u -r1.21 -r0 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.6 -r0 src/usr.sbin/rtadvd/rrenum.h
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/Makefile
diff -u src/usr.sbin/rtadvd/Makefile:1.23 src/usr.sbin/rtadvd/Makefile:1.24
--- src/usr.sbin/rtadvd/Makefile:1.23	Sun Oct 13 07:28:21 2019
+++ src/usr.sbin/rtadvd/Makefile	Tue Apr 21 12:05:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.23 2019/10/13 07:28:21 mrg Exp $
+# $NetBSD: Makefile,v 1.24 2020/04/21 12:05:54 roy Exp $
 
 WARNS?=	4
 
@@ -7,7 +7,7 @@ WARNS?=	4
 USE_FORT?=	yes	# network server
 
 RUMPPRG=	rtadvd
-SRCS=		rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
+SRCS=		rtadvd.c advcap.c if.c config.c timer.c dump.c
 MAN=		rtadvd.8 rtadvd.conf.5
 
 CPPFLAGS+=	-DINET6

Index: src/usr.sbin/rtadvd/rtadvd.8
diff -u src/usr.sbin/rtadvd/rtadvd.8:1.27 src/usr.sbin/rtadvd/rtadvd.8:1.28
--- src/usr.sbin/rtadvd/rtadvd.8:1.27	Mon Nov 11 13:42:49 2019
+++ src/usr.sbin/rtadvd/rtadvd.8	Tue Apr 21 12:05:54 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rtadvd.8,v 1.27 2019/11/11 13:42:49 roy Exp $
+.\"	$NetBSD: rtadvd.8,v 1.28 2020/04/21 12:05:54 roy Exp $
 .\"	$KAME: rtadvd.8,v 1.24 2002/05/31 16:16:08 jinmei Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 11, 2019
+.Dd April 21, 2020
 .Dt RTADVD 8
 .Os
 .Sh NAME
@@ -36,7 +36,7 @@
 .Nd router advertisement daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl CDdfRs
+.Op Fl CDdfs
 .Op Fl c Ar configfile
 .Op Fl M Ar ifname
 .Op Fl p Ar pidfile
@@ -137,15 +137,6 @@ Repeating this option, adds more verbose
 .It Fl f
 Foreground mode (useful when debugging).
 Log messages will be dumped to stderr when this option is specified.
-.It Fl M Ar ifname
-Specify an interface to join the all-routers site-local multicast group.
-By default,
-.Nm
-tries to join the first advertising interface appearing on the command
-line.
-This option has meaning only with the
-.Fl R
-option, which enables routing renumbering protocol support.
 .\".It Fl m
 .\"Enables mobile IPv6 support.
 .\"This changes the content of router advertisement option, as well as
@@ -157,17 +148,6 @@ for the PID file.
 By default,
 .Pa /var/run/rtadvd.pid
 is used.
-.It Fl R
-Accept router renumbering requests.
-If you enable it, an
-.Xr ipsec 4
-setup is suggested for security reasons.
-.\"On KAME-based systems,
-.\".Xr rrenumd 8
-.\"generates router renumbering request packets.
-This option is currently disabled, and is ignored by
-.Nm
-with a warning message.
 .It Fl s
 Do not add or delete prefixes dynamically.
 Only statically configured prefixes, if any, will be advertised.

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.71 src/usr.sbin/rtadvd/rtadvd.c:1.72
--- src/usr.sbin/rtadvd/rtadvd.c:1.71	Mon Nov 11 13:42:49 2019
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Apr 21 12:05:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.71 2019/11/11 13:42:49 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.72 2020/04/21 12:05:54 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -62,7 +62,6 @@
 #include 
 
 #include "rtadvd.h"
-#include "rrenum.h"
 #include "advcap.h"
 #include "timer.h"
 #include "if.h"
@@ -85,10 +84,8 @@ struct iovec rcviov[2];
 struct iovec sndiov[2];
 struct sockaddr_in6 rcvfrom;
 static const char *dumpfilename = "/var/run/rtadvd.dump"; /* XXX configurable */
-static char *mcastif;
 int sock;
 int rtsock = -1;
-int accept_rr = 0;
 int Cflag = 0, dflag = 0, sflag = 0, Dflag;
 
 static char **if_argv;
@@ -187,7 +184,7 @@ main(int argc, char *argv[])
 	pid_t pid;
 
 	/* get command line options and arguments */
-#define OPTIONS "c:dDfM:p:Rs"
+#define OPTIONS "c:dDfM:p:s"
 	while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
 #undef OPTIONS
 		switch (ch) {
@@ -206,18 +203,9 @@ main(int argc, char *argv[])
 		case 'f':
 			fflag = 1;
 			break;
-		case 'M':
-			mcastif = optarg;
-			break;
 		case 'p':
 			pidfilepath = optarg;
 			break;
-		case 'R':
-			fprintf(stderr, "rtadvd: "
-"the -R option is currently ignored.\n");
-			/* accept_rr = 1; */
-			/* run anyway... */
-			break;
 		case 's':
 			sflag = 1;
 			break;
@@ -889,16 +877,6 @@ rtadvd_input(void)
 		}
 		ra_input(i, (struct nd_router_advert *)icp, pi, );
 		break;
-	case ICMP6_ROUTER_RENUMBERING:
-		

CVS commit: src/usr.sbin/rtadvd

2019-11-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Nov 11 13:42:49 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.8 rtadvd.c rtadvd.h

Log Message:
rtadvd: Add C flag to control the zeroing of the leaving configuration

This is only intended to assist the testing of clients which consume
Router Advertisement messages, such as dhcpcd(8).


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.42 src/usr.sbin/rtadvd/config.c:1.43
--- src/usr.sbin/rtadvd/config.c:1.42	Sun Nov 10 21:32:38 2019
+++ src/usr.sbin/rtadvd/config.c	Mon Nov 11 13:42:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.42 2019/11/10 21:32:38 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.43 2019/11/11 13:42:49 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -719,6 +719,11 @@ getconfig(const char *intface, int exith
 	TAILQ_FOREACH(rai, , next) {
 		if (rai->ifindex == tmp->ifindex) {
 			TAILQ_REMOVE(, rai, next);
+			if (Cflag) {
+free_rainfo(rai);
+rai = NULL;
+break;
+			}
 			/* If we already have a leaving RA use that
 			 * as this config hasn't been advertised */
 			if (rai->leaving) {

Index: src/usr.sbin/rtadvd/rtadvd.8
diff -u src/usr.sbin/rtadvd/rtadvd.8:1.26 src/usr.sbin/rtadvd/rtadvd.8:1.27
--- src/usr.sbin/rtadvd/rtadvd.8:1.26	Mon Nov  6 15:15:04 2017
+++ src/usr.sbin/rtadvd/rtadvd.8	Mon Nov 11 13:42:49 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rtadvd.8,v 1.26 2017/11/06 15:15:04 christos Exp $
+.\"	$NetBSD: rtadvd.8,v 1.27 2019/11/11 13:42:49 roy Exp $
 .\"	$KAME: rtadvd.8,v 1.24 2002/05/31 16:16:08 jinmei Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 6, 2017
+.Dd November 11, 2019
 .Dt RTADVD 8
 .Os
 .Sh NAME
@@ -36,7 +36,7 @@
 .Nd router advertisement daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl DdfRs
+.Op Fl CDdfRs
 .Op Fl c Ar configfile
 .Op Fl M Ar ifname
 .Op Fl p Ar pidfile
@@ -112,6 +112,10 @@ advertising interface.
 The command line options are:
 .Bl -tag -width indent
 .\"
+.It Fl C
+Don't expire the existing configuration on receipt of SIGHUP.
+This option is only intended to aid the testing of clients that consume
+Router Advertisement messages.
 .It Fl c Ar configfile
 Specify an alternate location,
 .Ar configfile ,
@@ -175,7 +179,9 @@ to reload the configuration file
 .Pa /etc/rtadvd.conf .
 If an invalid parameter is found in the configuration file upon the reload, the
 entry will be ignored and the old configuration will be used.
-When parameters in an existing entry are updated,
+When parameters in an existing entry are updated and the
+.Fl C
+flag is not used,
 .Nm
 will send Router Advertisement messages with the old configuration but zero
 router lifetime to the interface first, and then start to send a new message.

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.70 src/usr.sbin/rtadvd/rtadvd.c:1.71
--- src/usr.sbin/rtadvd/rtadvd.c:1.70	Sun Nov 10 21:07:39 2019
+++ src/usr.sbin/rtadvd/rtadvd.c	Mon Nov 11 13:42:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.70 2019/11/10 21:07:39 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.71 2019/11/11 13:42:49 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -89,7 +89,7 @@ static char *mcastif;
 int sock;
 int rtsock = -1;
 int accept_rr = 0;
-int dflag = 0, sflag = 0, Dflag;
+int Cflag = 0, dflag = 0, sflag = 0, Dflag;
 
 static char **if_argv;
 static int if_argc;
@@ -194,6 +194,9 @@ main(int argc, char *argv[])
 		case 'c':
 			conffile = optarg;
 			break;
+		case 'C':
+			Cflag++;
+			break;
 		case 'd':
 			dflag++;
 			break;

Index: src/usr.sbin/rtadvd/rtadvd.h
diff -u src/usr.sbin/rtadvd/rtadvd.h:1.19 src/usr.sbin/rtadvd/rtadvd.h:1.20
--- src/usr.sbin/rtadvd/rtadvd.h:1.19	Fri Apr 20 16:37:17 2018
+++ src/usr.sbin/rtadvd/rtadvd.h	Mon Nov 11 13:42:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.h,v 1.19 2018/04/20 16:37:17 roy Exp $	*/
+/*	$NetBSD: rtadvd.h,v 1.20 2019/11/11 13:42:49 roy Exp $	*/
 /*	$KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -197,3 +197,5 @@ void ra_timer_set_short_delay(struct rai
 int prefix_match(struct in6_addr *, int, struct in6_addr *, int);
 struct rainfo *if_indextorainfo(unsigned int);
 struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int);
+
+extern int Cflag;



CVS commit: src/usr.sbin/rtadvd

2019-11-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Nov 11 13:42:49 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.8 rtadvd.c rtadvd.h

Log Message:
rtadvd: Add C flag to control the zeroing of the leaving configuration

This is only intended to assist the testing of clients which consume
Router Advertisement messages, such as dhcpcd(8).


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-11-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov 10 21:32:38 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
rtadvd: remove support for SIOCSIFINFO_IN6

It's been broken since we enabled dropping privs.
It's also probably the wrong place to do this, and support for
SIOCSIFINFO_IN6 will be in the next dhcpcd import.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-11-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov 10 21:32:38 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
rtadvd: remove support for SIOCSIFINFO_IN6

It's been broken since we enabled dropping privs.
It's also probably the wrong place to do this, and support for
SIOCSIFINFO_IN6 will be in the next dhcpcd import.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.41 src/usr.sbin/rtadvd/config.c:1.42
--- src/usr.sbin/rtadvd/config.c:1.41	Fri Jun 14 09:06:45 2019
+++ src/usr.sbin/rtadvd/config.c	Sun Nov 10 21:32:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.41 2019/06/14 09:06:45 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.42 2019/11/10 21:32:38 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -507,34 +507,6 @@ getconfig(const char *intface, int exith
 		goto errexit;
 	}
 
-#ifdef SIOCSIFINFO_IN6
-	{
-		struct in6_ndireq ndi;
-		int s;
-
-		if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-			logit(LOG_ERR, "<%s> socket: %m", __func__);
-			goto errexit;
-		}
-		memset(, 0, sizeof(ndi));
-		strncpy(ndi.ifname, intface, IFNAMSIZ);
-		if (prog_ioctl(s, SIOCGIFINFO_IN6, ) < 0) {
-			logit(LOG_INFO, "<%s> ioctl:SIOCGIFINFO_IN6 at %s: %m",
-			 __func__, intface);
-		}
-
-		/* reflect the RA info to the host variables in kernel */
-		ndi.ndi.chlim = tmp->hoplimit;
-		ndi.ndi.retrans = tmp->retranstimer;
-		ndi.ndi.basereachable = tmp->reachabletime;
-		if (prog_ioctl(s, SIOCSIFINFO_IN6, ) < 0) {
-			logit(LOG_INFO, "<%s> ioctl:SIOCSIFINFO_IN6 at %s: %m",
-			 __func__, intface);
-		}
-		prog_close(s);
-	}
-#endif
-
 	/* route information */
 	for (i = -1; i < MAXROUTE; i++) {
 		struct rtinfo *rti;



CVS commit: src/usr.sbin/rtadvd

2019-11-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov 10 21:07:39 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
rtadvd: Fix reloading configuration killing interface timers


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-11-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov 10 21:07:39 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
rtadvd: Fix reloading configuration killing interface timers


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.69 src/usr.sbin/rtadvd/rtadvd.c:1.70
--- src/usr.sbin/rtadvd/rtadvd.c:1.69	Fri Mar 29 21:51:52 2019
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun Nov 10 21:07:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.69 2019/03/29 21:51:52 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.70 2019/11/10 21:07:39 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -452,6 +452,18 @@ die(void)
 }
 
 static void
+ra_timer_reset(struct rainfo *rai)
+{
+
+	rtadvd_remove_timer(>timer);
+	rai->timer = rtadvd_add_timer(ra_timeout, ra_timer_update, rai, rai);
+	ra_timer_update(rai, >timer->tm);
+	rtadvd_set_timer(>timer->tm, rai->timer);
+	rtadvd_remove_timer(>timer_sol);
+	rai->timer_sol = rtadvd_add_timer(ra_timeout_sol, NULL, rai, NULL);
+}
+
+static void
 rtmsg_input(void)
 {
 	int n, type, ifindex = 0, plen;
@@ -698,14 +710,7 @@ rtmsg_input(void)
 
 			rai->initcounter = 0; /* reset the counter */
 			rai->waiting = 0; /* XXX */
-			rtadvd_remove_timer(>timer);
-			rai->timer = rtadvd_add_timer(ra_timeout,
-			ra_timer_update, rai, rai);
-			ra_timer_update(rai, >timer->tm);
-			rtadvd_set_timer(>timer->tm, rai->timer);
-			rtadvd_remove_timer(>timer_sol);
-			rai->timer_sol = rtadvd_add_timer(ra_timeout_sol,
-			NULL, rai, NULL);
+			ra_timer_reset(rai);
 		} else if (prefixchange && rai->ifflags & IFF_UP) {
 			/*
 			 * An advertised prefix has been added or invalidated.
@@ -1760,10 +1765,7 @@ ra_output(struct rainfo *rai, bool solic
 			   "%s: expired RA,"
 			   " new config active for interface (%s)",
 			   __func__, rai->ifname);
-			rai->leaving_for->timer = rtadvd_add_timer(ra_timeout,
-			ra_timer_update,
-			rai->leaving_for, rai->leaving_for);
-			ra_timer_set_short_delay(rai->leaving_for, rai->timer);
+			ra_timer_reset(rai->leaving_for);
 			rai->leaving_for->leaving = NULL;
 			free_rainfo(rai);
 			return NULL;



CVS commit: src/usr.sbin/rtadvd

2019-06-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 14 09:06:45 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
rtadvd: fix rdnss and dnssl lifetime assignment

Treat it the same as a prefix valid time as per the RFC.
This allows to set a zero value to remove the assignment from the node.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-06-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 14 09:06:45 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
rtadvd: fix rdnss and dnssl lifetime assignment

Treat it the same as a prefix valid time as per the RFC.
This allows to set a zero value to remove the assignment from the node.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.40 src/usr.sbin/rtadvd/config.c:1.41
--- src/usr.sbin/rtadvd/config.c:1.40	Fri Apr 20 15:57:23 2018
+++ src/usr.sbin/rtadvd/config.c	Fri Jun 14 09:06:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.40 2018/04/20 15:57:23 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.41 2019/06/14 09:06:45 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -701,9 +701,7 @@ getconfig(const char *intface, int exith
 
 		makeentry(entbuf, sizeof(entbuf), i, "rdnssltime");
 		MAYHAVE(val64, entbuf, tmp->maxinterval * 3 / 2);
-		if (val64 < tmp->maxinterval ||
-		val64 > tmp->maxinterval * 2)
-		{
+		if (val64 < 0 || val64 > 0x) {
 			logit(LOG_ERR, "<%s> %s (%lld) on %s is invalid",
 			 __func__, entbuf, (long long)val64, intface);
 			goto errexit;
@@ -737,9 +735,7 @@ getconfig(const char *intface, int exith
 
 		makeentry(entbuf, sizeof(entbuf), i, "dnsslltime");
 		MAYHAVE(val64, entbuf, tmp->maxinterval * 3 / 2);
-		if (val64 < tmp->maxinterval ||
-		val64 > tmp->maxinterval * 2)
-		{
+		if (val64 < 0 || val64 > 0x) {
 			logit(LOG_ERR, "<%s> %s (%lld) on %s is invalid",
 			 __func__, entbuf, (long long)val64, intface);
 			goto errexit;



CVS commit: src/usr.sbin/rtadvd

2019-03-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 29 21:51:52 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
- die sooner (if we got interrupted)
- when we finish resending exit.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.68 src/usr.sbin/rtadvd/rtadvd.c:1.69
--- src/usr.sbin/rtadvd/rtadvd.c:1.68	Sat Jan 12 14:09:25 2019
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Mar 29 17:51:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.68 2019/01/12 19:09:25 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.69 2019/03/29 21:51:52 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -351,8 +351,11 @@ main(int argc, char *argv[])
 		(timeout->tv_nsec + 99) / 100) : INFTIM)) == -1)
 		{
 			/* EINTR would occur upon SIGUSR1 for status dump */
-			if (errno == EINTR)
+			if (errno == EINTR) {
+if (do_die)
+	die();
 continue;
+			}
 
 			logit(LOG_ERR, "%s: poll: %m", __func__);
 			if (Dflag)
@@ -445,6 +448,7 @@ die(void)
 		ra_timer_update(rai, >timer->tm);
 		rtadvd_set_timer(>timer->tm, rai->timer);
 	}
+	exit(EXIT_SUCCESS);
 }
 
 static void



CVS commit: src/usr.sbin/rtadvd

2019-03-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 29 21:51:52 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
- die sooner (if we got interrupted)
- when we finish resending exit.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 12 19:09:25 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
adjust to new expandm.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.67 src/usr.sbin/rtadvd/rtadvd.c:1.68
--- src/usr.sbin/rtadvd/rtadvd.c:1.67	Fri Jan 11 15:41:53 2019
+++ src/usr.sbin/rtadvd/rtadvd.c	Sat Jan 12 14:09:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.67 2019/01/11 20:41:53 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.68 2019/01/12 19:09:25 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1856,8 +1856,7 @@ logit(int level, const char *fmt, ...)
 		return;
 	}
 
-	vfprintf(stderr, buf = expandm(fmt, "\n"), ap);
-	if (buf != fmt)
-		free(buf);
+	vfprintf(stderr, expandm(fmt, "\n", ), ap);
+	free(buf);
 	va_end(ap);
 }



CVS commit: src/usr.sbin/rtadvd

2019-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 12 19:09:25 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
adjust to new expandm.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2019-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 11 20:41:53 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: Makefile rtadvd.c

Log Message:
use expandm from libwrap.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/rtadvd/Makefile
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/Makefile
diff -u src/usr.sbin/rtadvd/Makefile:1.21 src/usr.sbin/rtadvd/Makefile:1.22
--- src/usr.sbin/rtadvd/Makefile:1.21	Tue Oct 10 15:30:41 2017
+++ src/usr.sbin/rtadvd/Makefile	Fri Jan 11 15:41:53 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.21 2017/10/10 19:30:41 christos Exp $
+# $NetBSD: Makefile,v 1.22 2019/01/11 20:41:53 christos Exp $
 
 WARNS?=	4
 
@@ -14,6 +14,12 @@ CPPFLAGS+=	-DINET6
 LDADD+=		-lutil
 DPADD+=		${LIBUTIL}
 
+LIBWRAP=	${NETBSDSRCDIR}/lib/libwrap
+SRCS+=		expandm.c
+.PATH.c:	${LIBWRAP}
+CPPFLAGS+=	-I${LIBWRAP}
+
+
 .if ${MKSHARE} != "no"
 FILESDIR=	/usr/share/examples/rtadvd
 FILES=	rtadvd.conf

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.66 src/usr.sbin/rtadvd/rtadvd.c:1.67
--- src/usr.sbin/rtadvd/rtadvd.c:1.66	Tue Apr 24 14:31:48 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Jan 11 15:41:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.66 2018/04/24 18:31:48 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.67 2019/01/11 20:41:53 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -70,6 +70,7 @@
 #include "dump.h"
 #include "logit.h"
 #include "prog_ops.h"
+#include "expandm.h"
 
 struct msghdr rcvmhdr;
 static unsigned char *rcvcmsgbuf;
@@ -1842,36 +1843,11 @@ ra_timer_update(void *data, struct times
 	   (intmax_t)tm->tv_sec, (intmax_t)tm->tv_nsec);
 }
 
- __format_arg(3)
-static const char *
-expandm(char *buf, size_t len, const char *fmt)
-{
-	char *ptr;
-	const char *e = strerror(errno);
-	size_t cur = 0, elen = strlen(e);
-
-	*buf = '\0';
-	while ((ptr = strstr(fmt, "%m")) != NULL) {
-		size_t l = (size_t)(ptr - fmt);
-		if (cur + elen + l + 1 >= len)
-			return buf;
-		memcpy(buf + cur, fmt, l);
-		cur += l;
-		memcpy(buf + cur, e, elen);
-		cur += elen;
-		fmt += l + 2;
-		buf[cur] = '\0';
-	}
-	strlcat(buf, fmt, len);
-	strlcat(buf, "\n", len); /* syslog does not need \n, printf does */
-	return buf;
-}
-
 void
 logit(int level, const char *fmt, ...)
 {
 	va_list ap;
-	char buf[1024];
+	char *buf;
 
 	va_start(ap, fmt);
 	if (!Dflag) {
@@ -1880,6 +1856,8 @@ logit(int level, const char *fmt, ...)
 		return;
 	}
 
-	vfprintf(stderr, expandm(buf, sizeof(buf), fmt), ap);
+	vfprintf(stderr, buf = expandm(fmt, "\n"), ap);
+	if (buf != fmt)
+		free(buf);
 	va_end(ap);
 }



CVS commit: src/usr.sbin/rtadvd

2019-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 11 20:41:53 UTC 2019

Modified Files:
src/usr.sbin/rtadvd: Makefile rtadvd.c

Log Message:
use expandm from libwrap.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/rtadvd/Makefile
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-11-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Nov 16 08:57:10 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: dump.c

Log Message:
rtadvd: use %u to print unsigned variables


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/dump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-11-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Nov 16 08:57:10 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: dump.c

Log Message:
rtadvd: use %u to print unsigned variables


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/dump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/dump.c
diff -u src/usr.sbin/rtadvd/dump.c:1.16 src/usr.sbin/rtadvd/dump.c:1.17
--- src/usr.sbin/rtadvd/dump.c:1.16	Fri Apr 20 10:39:37 2018
+++ src/usr.sbin/rtadvd/dump.c	Fri Nov 16 08:57:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump.c,v 1.16 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: dump.c,v 1.17 2018/11/16 08:57:10 ozaki-r Exp $	*/
 /*	$KAME: dump.c,v 1.34 2004/06/14 05:35:59 itojun Exp $	*/
 
 /*
@@ -138,23 +138,23 @@ if_dump(void)
 		if (rai->advlinkopt)
 			fprintf(fp, "  Link-layer address: %s\n",
 			ether_str(rai->sdl));
-		fprintf(fp, "  MTU: %d\n", rai->phymtu);
+		fprintf(fp, "  MTU: %u\n", rai->phymtu);
 
 		/* Router configuration variables */
-		fprintf(fp, "  DefaultLifetime: %d, MaxAdvInterval: %d, "
-		"MinAdvInterval: %d\n", rai->lifetime, rai->maxinterval,
+		fprintf(fp, "  DefaultLifetime: %u, MaxAdvInterval: %u, "
+		"MinAdvInterval: %u\n", rai->lifetime, rai->maxinterval,
 		rai->mininterval);
 		fprintf(fp, "  Flags: %s%s%s, ",
 		rai->managedflg ? "M" : "", rai->otherflg ? "O" : "",
 		"");
 		fprintf(fp, "Preference: %s, ",
 			rtpref_str[(rai->rtpref >> 3) & 0xff]);
-		fprintf(fp, "MTU: %d\n", rai->linkmtu);
-		fprintf(fp, "  ReachableTime: %d, RetransTimer: %d, "
-			"CurHopLimit: %d\n", rai->reachabletime,
+		fprintf(fp, "MTU: %u\n", rai->linkmtu);
+		fprintf(fp, "  ReachableTime: %u, RetransTimer: %u, "
+			"CurHopLimit: %u\n", rai->reachabletime,
 			rai->retranstimer, rai->hoplimit);
 		if (rai->clockskew)
-			fprintf(fp, "  Clock skew: %dsec\n",
+			fprintf(fp, "  Clock skew: %usec\n",
 			rai->clockskew);
 		TAILQ_FOREACH(pfx, >prefix, next) {
 			if (pfx == TAILQ_FIRST(>prefix))
@@ -176,8 +176,7 @@ if_dump(void)
 			if (pfx->validlifetime == ND6_INFINITE_LIFETIME)
 fprintf(fp, "vltime: infinity");
 			else
-fprintf(fp, "vltime: %ld",
-	(long)pfx->validlifetime);
+fprintf(fp, "vltime: %u", pfx->validlifetime);
 			if (pfx->vltimeexpire != 0)
 fprintf(fp, "(decr,expire %lld), ", (long long)
 	(pfx->vltimeexpire > now.tv_sec ?
@@ -187,8 +186,7 @@ if_dump(void)
 			if (pfx->preflifetime ==  ND6_INFINITE_LIFETIME)
 fprintf(fp, "pltime: infinity");
 			else
-fprintf(fp, "pltime: %ld",
-	(long)pfx->preflifetime);
+fprintf(fp, "pltime: %u", pfx->preflifetime);
 			if (pfx->pltimeexpire != 0)
 fprintf(fp, "(decr,expire %lld), ", (long long)
 	(pfx->pltimeexpire > now.tv_sec ?



CVS commit: src/usr.sbin/rtadvd

2018-04-24 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 24 18:31:48 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Back out part of the prior commit where we added space for IPV6_HOPLIMIT
to the sending control message buffer.
That code never worked on ERLITE, so I elected to set socket options
instead but forgot to revert this part.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-24 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 24 18:31:48 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Back out part of the prior commit where we added space for IPV6_HOPLIMIT
to the sending control message buffer.
That code never worked on ERLITE, so I elected to set socket options
instead but forgot to revert this part.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.65 src/usr.sbin/rtadvd/rtadvd.c:1.66
--- src/usr.sbin/rtadvd/rtadvd.c:1.65	Fri Apr 20 15:57:23 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Apr 24 18:31:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.65 2018/04/20 15:57:23 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.66 2018/04/24 18:31:48 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1514,8 +1514,7 @@ sock_open(void)
 		exit(EXIT_FAILURE);
 	}
 
-	sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
-CMSG_SPACE(sizeof(int));
+	sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo));
 	sndcmsgbuf = malloc(sndcmsgbuflen);
 	if (sndcmsgbuf == NULL) {
 		logit(LOG_ERR, "%s: malloc: %m", __func__);



CVS commit: src/usr.sbin/rtadvd

2018-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 21 09:31:08 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.conf.5

Log Message:
Minor improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rtadvd.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.conf.5
diff -u src/usr.sbin/rtadvd/rtadvd.conf.5:1.19 src/usr.sbin/rtadvd/rtadvd.conf.5:1.20
--- src/usr.sbin/rtadvd/rtadvd.conf.5:1.19	Fri Apr 20 16:37:17 2018
+++ src/usr.sbin/rtadvd/rtadvd.conf.5	Sat Apr 21 09:31:08 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rtadvd.conf.5,v 1.19 2018/04/20 16:37:17 roy Exp $
+.\"	$NetBSD: rtadvd.conf.5,v 1.20 2018/04/21 09:31:08 wiz Exp $
 .\"	$KAME: rtadvd.conf.5,v 1.50 2005/01/14 05:30:59 jinmei Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -142,9 +142,7 @@ means low.
 Bits 10 is reserved, and must not be specified.
 There is no character to specify the medium preference explicitly.
 The default value of the entire flag is 0
-.Po
-or a null string,
-.Pc
+(or a null string),
 which means no additional
 configuration methods, and the medium router preference.
 .It Cm \
@@ -448,7 +446,7 @@ The following example configures the
 .Li wlan0
 interface and adds two DNS servers and a DNS domain search options
 using the default option lifetime values.
-.Bd -literal -offset
+.Bd -literal -offset 8n
 wlan0:\\
 	:addr="2001:db8::1000::":prefixlen#64:\\
 	:rdnss="2001:db8:::10,2001:db8:::2:43":\\



CVS commit: src/usr.sbin/rtadvd

2018-04-21 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Apr 21 09:31:08 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.conf.5

Log Message:
Minor improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rtadvd.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:37:17 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.conf.5 rtadvd.h

Log Message:
Update values from RFC 8319


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/rtadvd/rtadvd.conf.5 \
src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.conf.5
diff -u src/usr.sbin/rtadvd/rtadvd.conf.5:1.18 src/usr.sbin/rtadvd/rtadvd.conf.5:1.19
--- src/usr.sbin/rtadvd/rtadvd.conf.5:1.18	Tue Dec 11 16:37:23 2012
+++ src/usr.sbin/rtadvd/rtadvd.conf.5	Fri Apr 20 16:37:17 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rtadvd.conf.5,v 1.18 2012/12/11 16:37:23 roy Exp $
+.\"	$NetBSD: rtadvd.conf.5,v 1.19 2018/04/20 16:37:17 roy Exp $
 .\"	$KAME: rtadvd.conf.5,v 1.50 2005/01/14 05:30:59 jinmei Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 11, 2012
+.Dd April 20, 2018
 .Dt RTADVD.CONF 5
 .Os
 .Sh NAME
@@ -83,7 +83,7 @@ multicast router advertisements
 .Pq unit: seconds .
 The default value is 600.
 Its value must be no less than 4 seconds
-and no greater than 1800 seconds.
+and no greater than 65535 seconds.
 .It Cm \
 (num) The minimum time allowed between sending unsolicited multicast
 router advertisements
@@ -153,7 +153,7 @@ configuration methods, and the medium ro
 The value must be either zero or between
 the value of
 .Cm maxinterval
-and 9000.
+and 65535.
 When
 .Nm rtadvd
 runs on a host, this value must explicitly set 0 on all the
Index: src/usr.sbin/rtadvd/rtadvd.h
diff -u src/usr.sbin/rtadvd/rtadvd.h:1.18 src/usr.sbin/rtadvd/rtadvd.h:1.19
--- src/usr.sbin/rtadvd/rtadvd.h:1.18	Fri Apr 20 16:18:18 2018
+++ src/usr.sbin/rtadvd/rtadvd.h	Fri Apr 20 16:37:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.h,v 1.18 2018/04/20 16:18:18 roy Exp $	*/
+/*	$NetBSD: rtadvd.h,v 1.19 2018/04/20 16:37:17 roy Exp $	*/
 /*	$KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -54,9 +54,9 @@ extern struct sockaddr_in6 sin6_siteloca
 #define	DEF_ADVPREFERREDLIFETIME	604800
 #define	DEF_ADVROUTERLIFETIME		1800
 
-#define	MAXROUTERLIFETIME		9000
+#define	MAXROUTERLIFETIME		65535	/* RFC 8319 */
 #define	MIN_MAXINTERVAL			4
-#define	MAX_MAXINTERVAL			1800
+#define	MAX_MAXINTERVAL			65535	/* RFC 8319 */
 #define	MIN_MININTERVAL			3
 #define	MAXREACHABLETIME		360
 



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:37:17 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.conf.5 rtadvd.h

Log Message:
Update values from RFC 8319


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/rtadvd/rtadvd.conf.5 \
src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:18:18 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.h

Log Message:
Make the #defines more readable


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.h
diff -u src/usr.sbin/rtadvd/rtadvd.h:1.17 src/usr.sbin/rtadvd/rtadvd.h:1.18
--- src/usr.sbin/rtadvd/rtadvd.h:1.17	Fri Apr 20 15:57:23 2018
+++ src/usr.sbin/rtadvd/rtadvd.h	Fri Apr 20 16:18:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.h,v 1.17 2018/04/20 15:57:23 roy Exp $	*/
+/*	$NetBSD: rtadvd.h,v 1.18 2018/04/20 16:18:18 roy Exp $	*/
 /*	$KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -30,11 +30,11 @@
  * SUCH DAMAGE.
  */
 
-#define RTADVD_USER	"_rtadvd"
+#define	RTADVD_USER	"_rtadvd"
 
-#define ALLNODES "ff02::1"
-#define ALLROUTERS_LINK "ff02::2"
-#define ALLROUTERS_SITE "ff05::2"
+#define	ALLNODES	"ff02::1"
+#define	ALLROUTERS_LINK	"ff02::2"
+#define	ALLROUTERS_SITE	"ff05::2"
 
 #define IN6ADDR_SITELOCAL_ALLROUTERS_INIT \
 	{{{ 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
@@ -45,30 +45,30 @@
 extern struct sockaddr_in6 sin6_sitelocal_allrouters;
 
 /* protocol constants and default values */
-#define DEF_MAXRTRADVINTERVAL 600
-#define DEF_ADVLINKMTU 0
-#define DEF_ADVREACHABLETIME 0
-#define DEF_ADVRETRANSTIMER 0
-#define DEF_ADVCURHOPLIMIT 64
-#define DEF_ADVVALIDLIFETIME 2592000
-#define DEF_ADVPREFERREDLIFETIME 604800
-#define DEF_ADVROUTERLIFETIME 1800
-
-#define MAXROUTERLIFETIME 9000
-#define MIN_MAXINTERVAL 4
-#define MAX_MAXINTERVAL 1800
-#define MIN_MININTERVAL 3
-#define MAXREACHABLETIME 360
-
-#define MAX_INITIAL_RTR_ADVERT_INTERVAL  16
-#define MAX_INITIAL_RTR_ADVERTISEMENTS3
-#define MAX_FINAL_RTR_ADVERTISEMENTS  3
-#define MIN_DELAY_BETWEEN_RAS 3
-#define MAX_RA_DELAY_TIME5 /* nsec */
-
-#define PREFIX_FROM_KERNEL 1
-#define PREFIX_FROM_CONFIG 2
-#define PREFIX_FROM_DYNAMIC 3
+#define	DEF_MAXRTRADVINTERVAL		600
+#define	DEF_ADVLINKMTU			0
+#define	DEF_ADVREACHABLETIME		0
+#define	DEF_ADVRETRANSTIMER		0
+#define	DEF_ADVCURHOPLIMIT		64
+#define	DEF_ADVVALIDLIFETIME		2592000
+#define	DEF_ADVPREFERREDLIFETIME	604800
+#define	DEF_ADVROUTERLIFETIME		1800
+
+#define	MAXROUTERLIFETIME		9000
+#define	MIN_MAXINTERVAL			4
+#define	MAX_MAXINTERVAL			1800
+#define	MIN_MININTERVAL			3
+#define	MAXREACHABLETIME		360
+
+#define	MAX_INITIAL_RTR_ADVERT_INTERVAL  16
+#define	MAX_INITIAL_RTR_ADVERTISEMENTS3
+#define	MAX_FINAL_RTR_ADVERTISEMENTS  3
+#define	MIN_DELAY_BETWEEN_RAS 3
+#define	MAX_RA_DELAY_TIME5 /* nsec */
+
+#define	PREFIX_FROM_KERNEL		1
+#define	PREFIX_FROM_CONFIG		2
+#define	PREFIX_FROM_DYNAMIC		3
 
 struct prefix {
 	TAILQ_ENTRY(prefix) next;



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:18:18 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.h

Log Message:
Make the #defines more readable


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:07:48 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c

Log Message:
Lack of timeout is a programming error, so use an assert in it's place.
While here, improve the error reported if malloc fails.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/timer.c
diff -u src/usr.sbin/rtadvd/timer.c:1.17 src/usr.sbin/rtadvd/timer.c:1.18
--- src/usr.sbin/rtadvd/timer.c:1.17	Fri Apr 20 15:59:17 2018
+++ src/usr.sbin/rtadvd/timer.c	Fri Apr 20 16:07:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.17 2018/04/20 15:59:17 roy Exp $	*/
+/*	$NetBSD: timer.c,v 1.18 2018/04/20 16:07:48 roy Exp $	*/
 /*	$KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $	*/
 
 /*
@@ -33,6 +33,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -63,19 +64,15 @@ rtadvd_add_timer(struct rtadvd_timer *(*
 {
 	struct rtadvd_timer *newtimer;
 
+	assert(timeout != NULL);
+
 	if ((newtimer = malloc(sizeof(*newtimer))) == NULL) {
-		logit(LOG_ERR,
-		   "<%s> can't allocate memory", __func__);
+		logit(LOG_ERR, "%s: malloc: %m", __func__);
 		exit(EXIT_FAILURE);
 	}
 
 	memset(newtimer, 0, sizeof(*newtimer));
 
-	if (timeout == NULL) {
-		logit(LOG_ERR,
-		   "<%s> timeout function unspecified", __func__);
-		exit(EXIT_FAILURE);
-	}
 	newtimer->expire = timeout;
 	newtimer->update = update;
 	newtimer->expire_data = timeodata;



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 16:07:48 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c

Log Message:
Lack of timeout is a programming error, so use an assert in it's place.
While here, improve the error reported if malloc fails.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:59:17 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c

Log Message:
Use EXIT_FAILURE instead of an arbtitary number.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/timer.c
diff -u src/usr.sbin/rtadvd/timer.c:1.16 src/usr.sbin/rtadvd/timer.c:1.17
--- src/usr.sbin/rtadvd/timer.c:1.16	Fri Apr 20 13:27:45 2018
+++ src/usr.sbin/rtadvd/timer.c	Fri Apr 20 15:59:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.16 2018/04/20 13:27:45 roy Exp $	*/
+/*	$NetBSD: timer.c,v 1.17 2018/04/20 15:59:17 roy Exp $	*/
 /*	$KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $	*/
 
 /*
@@ -66,7 +66,7 @@ rtadvd_add_timer(struct rtadvd_timer *(*
 	if ((newtimer = malloc(sizeof(*newtimer))) == NULL) {
 		logit(LOG_ERR,
 		   "<%s> can't allocate memory", __func__);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	memset(newtimer, 0, sizeof(*newtimer));
@@ -74,7 +74,7 @@ rtadvd_add_timer(struct rtadvd_timer *(*
 	if (timeout == NULL) {
 		logit(LOG_ERR,
 		   "<%s> timeout function unspecified", __func__);
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 	newtimer->expire = timeout;
 	newtimer->update = update;



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:59:17 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c

Log Message:
Use EXIT_FAILURE instead of an arbtitary number.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:57:23 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.c rtadvd.h

Log Message:
Unicast solicited RA's as per RFC 7772.

This is done by having a secondary timer against rainfo so we
can delay unicasting by the required randomised amount of time
without affecting the unsolicited RA timer.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:57:23 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.c rtadvd.h

Log Message:
Unicast solicited RA's as per RFC 7772.

This is done by having a secondary timer against rainfo so we
can delay unicasting by the required randomised amount of time
without affecting the unsolicited RA timer.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.39 src/usr.sbin/rtadvd/config.c:1.40
--- src/usr.sbin/rtadvd/config.c:1.39	Fri Apr 20 15:29:19 2018
+++ src/usr.sbin/rtadvd/config.c	Fri Apr 20 15:57:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.39 2018/04/20 15:29:19 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.40 2018/04/20 15:57:23 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -113,6 +113,7 @@ free_rainfo(struct rainfo *rai)
 	struct dnssl_domain *dnsd;
 
 	rtadvd_remove_timer(>timer);
+	rtadvd_remove_timer(>timer_sol);
 
 	while ((sol = TAILQ_FIRST(>soliciter))) {
 		TAILQ_REMOVE(>soliciter, sol, next);
@@ -791,7 +792,8 @@ getconfig(const char *intface, int exith
 		return;
 	tmp->timer = rtadvd_add_timer(ra_timeout, ra_timer_update,
   tmp, tmp);
-	ra_timer_set_short_delay(tmp);
+	ra_timer_set_short_delay(tmp, tmp->timer);
+	tmp->timer_sol = rtadvd_add_timer(ra_timeout_sol, NULL, tmp, NULL);
 
 	return;
 

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.64 src/usr.sbin/rtadvd/rtadvd.c:1.65
--- src/usr.sbin/rtadvd/rtadvd.c:1.64	Fri Apr 20 11:31:54 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Apr 20 15:57:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.64 2018/04/20 11:31:54 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.65 2018/04/20 15:57:23 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -166,7 +166,7 @@ static void rs_input(int, struct nd_rout
 struct in6_pktinfo *, struct sockaddr_in6 *);
 static void ra_input(int, struct nd_router_advert *,
 struct in6_pktinfo *, struct sockaddr_in6 *);
-static struct rainfo *ra_output(struct rainfo *);
+static struct rainfo *ra_output(struct rainfo *, bool);
 static int prefix_check(struct nd_opt_prefix_info *, struct rainfo *,
 struct sockaddr_in6 *);
 static int nd6_options(struct nd_opt_hdr *, int, union nd_opts *, uint32_t);
@@ -440,7 +440,7 @@ die(void)
 		rai->mininterval = MIN_DELAY_BETWEEN_RAS;
 		rai->maxinterval = MIN_DELAY_BETWEEN_RAS;
 		rai->leaving_adv = MAX_FINAL_RTR_ADVERTISEMENTS;
-		ra_output(rai);
+		ra_output(rai, false);
 		ra_timer_update(rai, >timer->tm);
 		rtadvd_set_timer(>timer->tm, rai->timer);
 	}
@@ -698,13 +698,16 @@ rtmsg_input(void)
 			ra_timer_update, rai, rai);
 			ra_timer_update(rai, >timer->tm);
 			rtadvd_set_timer(>timer->tm, rai->timer);
+			rtadvd_remove_timer(>timer_sol);
+			rai->timer_sol = rtadvd_add_timer(ra_timeout_sol,
+			NULL, rai, NULL);
 		} else if (prefixchange && rai->ifflags & IFF_UP) {
 			/*
 			 * An advertised prefix has been added or invalidated.
 			 * Will notice the change in a short delay.
 			 */
 			rai->initcounter = 0;
-			ra_timer_set_short_delay(rai);
+			ra_timer_set_short_delay(rai, rai->timer);
 		}
 	}
 
@@ -965,12 +968,20 @@ rs_input(int len, struct nd_router_solic
 	 */
 
 	/* record sockaddr waiting for RA, if possible */
-	sol = malloc(sizeof(*sol));
-	if (sol) {
-		sol->addr = *from;
-		/* XXX RFC2553 need clarification on flowinfo */
-		sol->addr.sin6_flowinfo = 0;
-		TAILQ_INSERT_HEAD(>soliciter, sol, next);
+	TAILQ_FOREACH(sol, >soliciter, next) {
+		if (IN6_ARE_ADDR_EQUAL(>addr.sin6_addr, >sin6_addr))
+			break;
+	}
+	if (sol == NULL) {
+		sol = malloc(sizeof(*sol));
+		if (sol == NULL) {
+			logit(LOG_ERR, "%s: malloc: %m", __func__);
+		} else {
+			sol->addr = *from;
+			/* XXX RFC2553 need clarification on flowinfo */
+			sol->addr.sin6_flowinfo = 0;
+			TAILQ_INSERT_TAIL(>soliciter, sol, next);
+		}
 	}
 
 	/*
@@ -980,14 +991,14 @@ rs_input(int len, struct nd_router_solic
 	if (rai->waiting++)
 		goto done;
 
-	ra_timer_set_short_delay(rai);
+	ra_timer_set_short_delay(rai, rai->timer_sol);
 
 done:
 	free_ndopts();
 }
 
 void
-ra_timer_set_short_delay(struct rainfo *rai)
+ra_timer_set_short_delay(struct rainfo *rai, struct rtadvd_timer *timer)
 {
 	long delay;	/* must not be greater than 100 */
 	struct timespec interval, now, min_delay, tm_tmp, *rest;
@@ -1024,7 +1035,7 @@ ra_timer_set_short_delay(struct rainfo *
 		timespecsub(_delay, _tmp, _delay);
 		timespecadd(_delay, , );
 	}
-	rtadvd_set_timer(, rai->timer);
+	rtadvd_set_timer(, timer);
 }
 
 static void
@@ -1503,7 +1514,8 @@ sock_open(void)
 		exit(EXIT_FAILURE);
 	}
 
-	

CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:29:19 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
Ensure that the soliciter list is initialised and freed correctly, even if it's 
not used yet.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.38 src/usr.sbin/rtadvd/config.c:1.39
--- src/usr.sbin/rtadvd/config.c:1.38	Fri Apr 20 10:39:37 2018
+++ src/usr.sbin/rtadvd/config.c	Fri Apr 20 15:29:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.38 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.39 2018/04/20 15:29:19 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -104,6 +104,7 @@ encode_domain(char *dst, const char *src
 void
 free_rainfo(struct rainfo *rai)
 {
+	struct soliciter *sol;
 	struct prefix *pfx;
 	struct rtinfo *rti;
 	struct rdnss *rdnss;
@@ -113,6 +114,11 @@ free_rainfo(struct rainfo *rai)
 
 	rtadvd_remove_timer(>timer);
 
+	while ((sol = TAILQ_FIRST(>soliciter))) {
+		TAILQ_REMOVE(>soliciter, sol, next);
+		free(sol);
+	}
+
 	while ((pfx = TAILQ_FIRST(>prefix))) {
 		TAILQ_REMOVE(>prefix, pfx, next);
 		free(pfx);
@@ -206,6 +212,7 @@ getconfig(const char *intface, int exith
 	}
 
 	ELM_MALLOC(tmp);
+	TAILQ_INIT(>soliciter);
 	TAILQ_INIT(>prefix);
 	TAILQ_INIT(>route);
 	TAILQ_INIT(>rdnss);



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 15:29:19 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c

Log Message:
Ensure that the soliciter list is initialised and freed correctly, even if it's 
not used yet.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/rtadvd/config.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 13:27:45 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c timer.h

Log Message:
Allow timers to exist but be inactive.
This will be used in a future commit.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/rtadvd/timer.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/rtadvd/timer.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 13:27:45 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: timer.c timer.h

Log Message:
Allow timers to exist but be inactive.
This will be used in a future commit.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/rtadvd/timer.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/rtadvd/timer.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/timer.c
diff -u src/usr.sbin/rtadvd/timer.c:1.15 src/usr.sbin/rtadvd/timer.c:1.16
--- src/usr.sbin/rtadvd/timer.c:1.15	Fri Apr 20 10:39:37 2018
+++ src/usr.sbin/rtadvd/timer.c	Fri Apr 20 13:27:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.15 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: timer.c,v 1.16 2018/04/20 13:27:45 roy Exp $	*/
 /*	$KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $	*/
 
 /*
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -110,6 +111,9 @@ rtadvd_set_timer(struct timespec *tm, st
 	/* upate the next expiration time */
 	if (timespeccmp(>tm, _max, <))
 		tm_max = timer->tm;
+
+	/* enable the timer */
+	timer->enabled = true;
 }
 
 /*
@@ -128,6 +132,8 @@ rtadvd_check_timer(void)
 	tm_max = tm_limit;
 
 	TAILQ_FOREACH_SAFE(tm, _timer, next, tmn) {
+		if (!tm->enabled)
+			continue;
 		if (timespeccmp(>tm, , <=)) {
 			if ((*tm->expire)(tm->expire_data) == NULL)
 continue; /* the timer was removed */
@@ -157,9 +163,10 @@ rtadvd_timer_rest(struct rtadvd_timer *t
 
 	prog_clock_gettime(CLOCK_MONOTONIC, );
 	if (timespeccmp(>tm, , <=)) {
-		logit(LOG_DEBUG,
-		   "<%s> a timer must be expired, but not yet",
-		   __func__);
+		if (timer->enabled)
+			logit(LOG_DEBUG,
+			   "<%s> a timer must be expired, but not yet",
+			   __func__);
 		returnval.tv_sec = 0;
 		returnval.tv_nsec = 0;
 	}

Index: src/usr.sbin/rtadvd/timer.h
diff -u src/usr.sbin/rtadvd/timer.h:1.9 src/usr.sbin/rtadvd/timer.h:1.10
--- src/usr.sbin/rtadvd/timer.h:1.9	Fri Apr 20 10:39:37 2018
+++ src/usr.sbin/rtadvd/timer.h	Fri Apr 20 13:27:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.h,v 1.9 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: timer.h,v 1.10 2018/04/20 13:27:45 roy Exp $	*/
 /*	$KAME: timer.h,v 1.5 2002/05/31 13:30:38 jinmei Exp $	*/
 
 /*
@@ -35,6 +35,7 @@ struct rtadvd_timer {
 	TAILQ_ENTRY(rtadvd_timer) next;
 	struct rainfo *rai;
 	struct timespec tm;
+	bool enabled;
 
 	struct rtadvd_timer *(*expire) (void *); /* expiration function */
 	void *expire_data;



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 11:31:54 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Insist on newer socket options.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.63 src/usr.sbin/rtadvd/rtadvd.c:1.64
--- src/usr.sbin/rtadvd/rtadvd.c:1.63	Fri Apr 20 11:25:39 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Apr 20 11:31:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.63 2018/04/20 11:25:39 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.64 2018/04/20 11:31:54 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1525,35 +1525,19 @@ sock_open(void)
 
 	/* specify to tell receiving interface */
 	on = 1;
-#ifdef IPV6_RECVPKTINFO
 	if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, ,
 		   sizeof(on)) == -1) {
 		logit(LOG_ERR, "%s: IPV6_RECVPKTINFO: %m", __func__);
 		exit(EXIT_FAILURE);
 	}
-#else  /* old adv. API */
-	if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, ,
-		   sizeof(on)) == -1) {
-		logit(LOG_ERR, "%s: IPV6_PKTINFO: %m", __func__);
-		exit(EXIT_FAILURE);
-	}
-#endif
 
 	on = 1;
 	/* specify to tell value of hoplimit field of received IP6 hdr */
-#ifdef IPV6_RECVHOPLIMIT
 	if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, ,
 		   sizeof(on)) == -1) {
 		logit(LOG_ERR, "%s: IPV6_RECVHOPLIMIT: %m", __func__);
 		exit(EXIT_FAILURE);
 	}
-#else  /* old adv. API */
-	if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_HOPLIMIT, ,
-		   sizeof(on)) == -1) {
-		logit(LOG_ERR, "%s: IPV6_HOPLIMIT: %m", __func__);
-		exit(EXIT_FAILURE);
-	}
-#endif
 
 	ICMP6_FILTER_SETBLOCKALL();
 	ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT, );



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 11:25:39 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use pidifle_lock(3)


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 11:25:39 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use pidifle_lock(3)


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.62 src/usr.sbin/rtadvd/rtadvd.c:1.63
--- src/usr.sbin/rtadvd/rtadvd.c:1.62	Fri Apr 20 10:43:38 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Apr 20 11:25:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.62 2018/04/20 10:43:38 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.63 2018/04/20 11:25:39 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -183,6 +183,7 @@ main(int argc, char *argv[])
 	int fflag = 0, logopt;
 	struct passwd *pw;
 	const char *pidfilepath = NULL;
+	pid_t pid;
 
 	/* get command line options and arguments */
 #define OPTIONS "c:dDfM:p:Rs"
@@ -226,10 +227,20 @@ main(int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
-	if (prog_init && prog_init() == -1) {
-		err(EXIT_FAILURE, "init failed");
+	if ((pid = pidfile_lock(pidfilepath)) != 0) {
+		if (pid == -1)
+			logit(LOG_ERR, "pidfile_lock: %m");
+			/* Continue */
+		else {
+			logit(LOG_ERR, "Another instance of `%s' is running "
+			"(pid %d); exiting.", getprogname(), pid);
+			return EXIT_FAILURE;
+		}
 	}
 
+	if (prog_init && prog_init() == -1)
+		err(EXIT_FAILURE, "init failed");
+
 	logopt = LOG_NDELAY | LOG_PID;
 	if (fflag)
 		logopt |= LOG_PERROR;
@@ -260,25 +271,14 @@ main(int argc, char *argv[])
 	while (argc--)
 		getconfig(*argv++, 1);
 
-	if (!fflag)
+	if (!fflag) {
 		prog_daemon(1, 0);
+		if (pidfile_lock(pidfilepath) != 0)
+			logit(LOG_ERR, " pidfile_lock: %m");
+	}
 
 	sock_open();
 
-#ifdef __NetBSD__
-	/* record the current PID */
-	if (pidfile(pidfilepath) == -1) {
-		if (errno == EEXIST) {
-			logit(LOG_ERR, "Another instance of `%s' is running "
-			"(pid %d); exiting.", getprogname(),
-			pidfile_read(pidfilepath));
-			return EXIT_FAILURE;
-		}
-		logit(LOG_ERR, "Failed to open the pid log file `%s' (%m), "
-		"run anyway.", pidfilepath);
-	}
-#endif
-
 	set[0].fd = sock;
 	set[0].events = POLLIN;
 	if (sflag == 0) {



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:43:38 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Punt dead code


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.61 src/usr.sbin/rtadvd/rtadvd.c:1.62
--- src/usr.sbin/rtadvd/rtadvd.c:1.61	Fri Apr 20 10:39:37 2018
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Apr 20 10:43:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.61 2018/04/20 10:39:37 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.62 2018/04/20 10:43:38 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -716,9 +716,6 @@ rtadvd_input(void)
 {
 	ssize_t i;
 	int *hlimp = NULL;
-#ifdef OLDRAWSOCKET
-	struct ip6_hdr *ip;
-#endif
 	struct icmp6_hdr *icp;
 	int ifindex = 0;
 	struct cmsghdr *cm;
@@ -791,17 +788,6 @@ rtadvd_input(void)
 		return;
 	}
 
-#ifdef OLDRAWSOCKET
-	if ((size_t)i < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) {
-		logit(LOG_ERR,
-		   "%s: packet size(%d) is too short",
-		   __func__, i);
-		return;
-	}
-
-	ip = (struct ip6_hdr *)rcvmhdr.msg_iov[0].iov_base;
-	icp = (struct icmp6_hdr *)(ip + 1); /* XXX: ext. hdr? */
-#else
 	if ((size_t)i < sizeof(struct icmp6_hdr)) {
 		logit(LOG_ERR,
 		   "%s: packet size(%zd) is too short",
@@ -810,7 +796,6 @@ rtadvd_input(void)
 	}
 
 	icp = (struct icmp6_hdr *)rcvmhdr.msg_iov[0].iov_base;
-#endif
 
 	switch (icp->icmp6_type) {
 	case ND_ROUTER_SOLICIT:



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:43:38 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Punt dead code


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:39:37 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c config.h dump.c dump.h if.c if.h rrenum.h
rtadvd.c rtadvd.h timer.c timer.h

Log Message:
White space police.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/rtadvd/dump.c \
src/usr.sbin/rtadvd/rtadvd.h
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/rtadvd/dump.h
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/rtadvd/rrenum.h
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/timer.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/rtadvd/timer.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.37 src/usr.sbin/rtadvd/config.c:1.38
--- src/usr.sbin/rtadvd/config.c:1.37	Mon Nov  6 15:15:04 2017
+++ src/usr.sbin/rtadvd/config.c	Fri Apr 20 10:39:37 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: config.c,v 1.37 2017/11/06 15:15:04 christos Exp $	*/
+/*	$NetBSD: config.c,v 1.38 2018/04/20 10:39:37 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
  * Copyright (C) 1998 WIDE Project.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -16,7 +16,7 @@
  * 3. Neither the name of the project nor the names of its contributors
  *may be used to endorse or promote products derived from this software
  *without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -97,7 +97,7 @@ encode_domain(char *dst, const char *src
 		src = p + 1;
 	}
 	*dst++ = '\0';
-	
+
 	return dst - odst;
 }
 
@@ -697,7 +697,7 @@ getconfig(const char *intface, int exith
 		val64 > tmp->maxinterval * 2)
 		{
 			logit(LOG_ERR, "<%s> %s (%lld) on %s is invalid",
-			 __func__, entbuf, (long long)val64, intface);
+			 __func__, entbuf, (long long)val64, intface);
 			goto errexit;
 		}
 		rdnss->lifetime = (uint32_t)val64;
@@ -733,7 +733,7 @@ getconfig(const char *intface, int exith
 		val64 > tmp->maxinterval * 2)
 		{
 			logit(LOG_ERR, "<%s> %s (%lld) on %s is invalid",
-			 __func__, entbuf, (long long)val64, intface);
+			 __func__, entbuf, (long long)val64, intface);
 			goto errexit;
 		}
 		dnssl->lifetime = (uint32_t)val64;
@@ -1123,8 +1123,8 @@ make_packet(struct rainfo *rainfo)
 		packlen += sizeof(struct nd_opt_prefix_info) * rainfo->pfxs;
 	if (rainfo->linkmtu)
 		packlen += sizeof(struct nd_opt_mtu);
-	TAILQ_FOREACH(rti, >route, next) 
-		packlen += sizeof(struct nd_opt_route_info) + 
+	TAILQ_FOREACH(rti, >route, next)
+		packlen += sizeof(struct nd_opt_route_info) +
 			   ((rti->prefixlen + 0x3f) >> 6) * 8;
 
 	TAILQ_FOREACH(rdns, >rdnss, next) {
@@ -1200,7 +1200,7 @@ make_packet(struct rainfo *rainfo)
 		buf += sizeof(struct nd_opt_mtu);
 	}
 
-	TAILQ_FOREACH(pfx, >prefix, next) {	
+	TAILQ_FOREACH(pfx, >prefix, next) {
 		uint32_t vltime, pltime;
 		struct timespec now;
 
@@ -1273,7 +1273,7 @@ make_packet(struct rainfo *rainfo)
 		ndopt_rdnss->nd_opt_rdnss_reserved = 0;
 		ndopt_rdnss->nd_opt_rdnss_lifetime = htonl(rdns->lifetime);
 		buf += sizeof(*ndopt_rdnss);
-	
+
 		TAILQ_FOREACH(rdnsa, >list, next) {
 			CHECKLEN(sizeof(rdnsa->addr));
 			memcpy(buf, >addr, sizeof(rdnsa->addr));
@@ -1290,7 +1290,7 @@ make_packet(struct rainfo *rainfo)
 		ndopt_dnssl->nd_opt_dnssl_reserved = 0;
 		ndopt_dnssl->nd_opt_dnssl_lifetime = htonl(dnsl->lifetime);
 		buf += sizeof(*ndopt_dnssl);
-	
+
 		TAILQ_FOREACH(dnsd, >list, next) {
 			CHECKLEN(dnsd->len);
 			memcpy(buf, dnsd->domain, dnsd->len);

Index: src/usr.sbin/rtadvd/config.h
diff -u src/usr.sbin/rtadvd/config.h:1.9 src/usr.sbin/rtadvd/config.h:1.10
--- src/usr.sbin/rtadvd/config.h:1.9	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/config.h	Fri Apr 20 10:39:37 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: config.h,v 1.9 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: config.h,v 1.10 2018/04/20 10:39:37 roy Exp $	*/
 /*	$KAME: config.h,v 1.9 2003/08/06 04:19:40 ono Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -16,7 +16,7 @@
  * 3. Neither the name of the project nor the names of its contributors
 

CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:39:37 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: config.c config.h dump.c dump.h if.c if.h rrenum.h
rtadvd.c rtadvd.h timer.c timer.h

Log Message:
White space police.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/rtadvd/dump.c \
src/usr.sbin/rtadvd/rtadvd.h
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/rtadvd/dump.h
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/rtadvd/rrenum.h
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/timer.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/rtadvd/timer.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:26:34 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rrenum.c rtadvd.c

Log Message:
Fix some unaligned pointer issues.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2018-04-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Apr 20 10:26:34 UTC 2018

Modified Files:
src/usr.sbin/rtadvd: rrenum.c rtadvd.c

Log Message:
Fix some unaligned pointer issues.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rrenum.c
diff -u src/usr.sbin/rtadvd/rrenum.c:1.20 src/usr.sbin/rtadvd/rrenum.c:1.21
--- src/usr.sbin/rtadvd/rrenum.c:1.20	Mon Nov  6 15:15:04 2017
+++ src/usr.sbin/rtadvd/rrenum.c	Fri Apr 20 10:26:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rrenum.c,v 1.20 2017/11/06 15:15:04 christos Exp $	*/
+/*	$NetBSD: rrenum.c,v 1.21 2018/04/20 10:26:34 roy Exp $	*/
 /*	$KAME: rrenum.c,v 1.14 2004/06/14 05:36:00 itojun Exp $	*/
 
 /*
@@ -147,6 +147,7 @@ do_use_prefix(int len, struct rr_pco_mat
 	struct rr_pco_use *rpu, *rpulim;
 	struct rainfo *rai;
 	struct prefix *pp;
+	struct in6_addr rpm_prefix, rpu_prefix;
 
 	rpu = (struct rr_pco_use *)(rpm + 1);
 	rpulim = (struct rr_pco_use *)((char *)rpm + len);
@@ -201,8 +202,10 @@ do_use_prefix(int len, struct rr_pco_mat
 			logit(LOG_ERR, "<%s> ioctl: %m", __func__);
 
 		/* very adhoc: should be rewritten */
+		memcpy(_prefix, >rpm_prefix, sizeof(rpm_prefix));
+		memcpy(_prefix, >rpu_prefix, sizeof(rpu_prefix));
 		if (rpm->rpm_code == RPM_PCO_CHANGE &&
-		IN6_ARE_ADDR_EQUAL(>rpm_prefix, >rpu_prefix) &&
+		IN6_ARE_ADDR_EQUAL(_prefix, _prefix) &&
 		rpm->rpm_matchlen == rpu->rpu_uselen &&
 		rpu->rpu_uselen == rpu->rpu_keeplen) {
 			if ((rai = if_indextorainfo(ifindex)) == NULL)
@@ -212,7 +215,7 @@ do_use_prefix(int len, struct rr_pco_mat
 struct timespec now;
 
 if (prefix_match(>prefix, pp->prefixlen,
-		 >rpm_prefix,
+		 _prefix,
 		 rpm->rpm_matchlen)) {
 	/* change parameters */
 	pp->validlifetime = ntohl(rpu->rpu_vltime);

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.59 src/usr.sbin/rtadvd/rtadvd.c:1.60
--- src/usr.sbin/rtadvd/rtadvd.c:1.59	Sat Nov 25 02:37:04 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Apr 20 10:26:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.59 2017/11/25 02:37:04 kre Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.60 2018/04/20 10:26:34 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1213,21 +1213,24 @@ prefix_check(struct nd_opt_prefix_info *
 	int inconsistent = 0;
 	char ntopbuf[INET6_ADDRSTRLEN], prefixbuf[INET6_ADDRSTRLEN];
 	struct timespec now;
+	struct in6_addr prefix;
 
 #if 0/* impossible */
 	if (pinfo->nd_opt_pi_type != ND_OPT_PREFIX_INFORMATION)
 		return 0;
 #endif
 
+	memcpy(, >nd_opt_pi_prefix, sizeof(prefix));
+
 	/*
 	 * log if the adveritsed prefix has link-local scope(sanity check?)
 	 */
-	if (IN6_IS_ADDR_LINKLOCAL(>nd_opt_pi_prefix)) {
+	if (IN6_IS_ADDR_LINKLOCAL()) {
 		logit(LOG_INFO,
 		   "%s: link-local prefix %s/%d is advertised "
 		   "from %s on %s",
 		   __func__,
-		   inet_ntop(AF_INET6, >nd_opt_pi_prefix,
+		   inet_ntop(AF_INET6, ,
  prefixbuf, INET6_ADDRSTRLEN),
 		   pinfo->nd_opt_pi_prefix_len,
 		   inet_ntop(AF_INET6, >sin6_addr,
@@ -1235,12 +1238,12 @@ prefix_check(struct nd_opt_prefix_info *
 		   rai->ifname);
 	}
 
-	if ((pp = find_prefix(rai, >nd_opt_pi_prefix,
+	if ((pp = find_prefix(rai, ,
 			  pinfo->nd_opt_pi_prefix_len)) == NULL) {
 		logit(LOG_INFO,
 		   "%s: prefix %s/%d from %s on %s is not in our list",
 		   __func__,
-		   inet_ntop(AF_INET6, >nd_opt_pi_prefix,
+		   inet_ntop(AF_INET6, ,
  prefixbuf, INET6_ADDRSTRLEN),
 		   pinfo->nd_opt_pi_prefix_len,
 		   inet_ntop(AF_INET6, >sin6_addr,
@@ -1268,7 +1271,7 @@ prefix_check(struct nd_opt_prefix_info *
 			   " (decr. in real time) inconsistent on %s:"
 			   " %d from %s, %ld from us",
 			   __func__,
-			   inet_ntop(AF_INET6, >nd_opt_pi_prefix,
+			   inet_ntop(AF_INET6, ,
 	 prefixbuf, INET6_ADDRSTRLEN),
 			   pinfo->nd_opt_pi_prefix_len,
 			   rai->ifname, preferred_time,
@@ -1283,7 +1286,7 @@ prefix_check(struct nd_opt_prefix_info *
 		   " inconsistent on %s:"
 		   " %d from %s, %d from us",
 		   __func__,
-		   inet_ntop(AF_INET6, >nd_opt_pi_prefix,
+		   inet_ntop(AF_INET6, ,
  prefixbuf, INET6_ADDRSTRLEN),
 		   pinfo->nd_opt_pi_prefix_len,
 		   rai->ifname, preferred_time,
@@ -1304,7 +1307,7 @@ prefix_check(struct nd_opt_prefix_info *
 			   " (decr. in real time) inconsistent on %s:"
 			   " %d from %s, %ld from us",
 			   __func__,
-			   inet_ntop(AF_INET6, >nd_opt_pi_prefix,
+			   inet_ntop(AF_INET6, ,
 	 prefixbuf, INET6_ADDRSTRLEN),
 			   pinfo->nd_opt_pi_prefix_len,
 			   rai->ifname, preferred_time,
@@ -1319,7 +1322,7 @@ prefix_check(struct 

CVS commit: src/usr.sbin/rtadvd

2017-11-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Nov 25 02:37:04 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
When sending log messages to stderr, append the \n that syslog does not need.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.58 src/usr.sbin/rtadvd/rtadvd.c:1.59
--- src/usr.sbin/rtadvd/rtadvd.c:1.58	Mon Nov  6 19:12:23 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Sat Nov 25 02:37:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.58 2017/11/06 19:12:23 joerg Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.59 2017/11/25 02:37:04 kre Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1864,6 +1864,7 @@ expandm(char *buf, size_t len, const cha
 		buf[cur] = '\0';
 	}
 	strlcat(buf, fmt, len);
+	strlcat(buf, "\n", len); /* syslog does not need \n, printf does */
 	return buf;
 }
 



CVS commit: src/usr.sbin/rtadvd

2017-11-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Nov 25 02:37:04 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
When sending log messages to stderr, append the \n that syslog does not need.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-11-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Nov  6 19:12:23 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Mark expandm as preserving format strings.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-11-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Nov  6 19:12:23 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Mark expandm as preserving format strings.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.57 src/usr.sbin/rtadvd/rtadvd.c:1.58
--- src/usr.sbin/rtadvd/rtadvd.c:1.57	Mon Nov  6 15:15:04 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Mon Nov  6 19:12:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.57 2017/11/06 15:15:04 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.58 2017/11/06 19:12:23 joerg Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1843,6 +1843,7 @@ ra_timer_update(void *data, struct times
 	   (intmax_t)tm->tv_sec, (intmax_t)tm->tv_nsec);
 }
 
+ __format_arg(3)
 static const char *
 expandm(char *buf, size_t len, const char *fmt)
 {



CVS commit: src/usr.sbin/rtadvd

2017-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  6 15:15:04 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: advcap.c config.c dump.c if.c rrenum.c rtadvd.8
rtadvd.c timer.c
Added Files:
src/usr.sbin/rtadvd: logit.h

Log Message:
Change the meaning of the 'D' flag to print errors to stderr instead of
syslog(3) and exit if poll(2) fails (intended to be used with unit-tests).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/dump.c
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/rtadvd/logit.h
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/advcap.c
diff -u src/usr.sbin/rtadvd/advcap.c:1.16 src/usr.sbin/rtadvd/advcap.c:1.17
--- src/usr.sbin/rtadvd/advcap.c:1.16	Wed Nov 11 02:48:41 2015
+++ src/usr.sbin/rtadvd/advcap.c	Mon Nov  6 10:15:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: advcap.c,v 1.16 2015/11/11 07:48:41 ozaki-r Exp $	*/
+/*	$NetBSD: advcap.c,v 1.17 2017/11/06 15:15:04 christos Exp $	*/
 /*	$KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $	*/
 
 /*
@@ -48,6 +48,8 @@
 #include "pathnames.h"
 #include "prog_ops.h"
 
+#include "logit.h"
+
 #ifndef __UNCONST
 #define __UNCONST(a)		((void *)(unsigned long)(const void *)(a))
 #endif
@@ -137,7 +139,7 @@ getent(char *bp, char *name, char *cp)
 		tf = open(RM = cp, O_RDONLY);
 	}
 	if (tf < 0) {
-		syslog(LOG_INFO, "<%s> open: %m", __func__);
+		logit(LOG_INFO, "<%s> open: %m", __func__);
 		return (-2);
 	}
 	for (;;) {

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.36 src/usr.sbin/rtadvd/config.c:1.37
--- src/usr.sbin/rtadvd/config.c:1.36	Mon Feb 27 00:41:36 2017
+++ src/usr.sbin/rtadvd/config.c	Mon Nov  6 10:15:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.36 2017/02/27 05:41:36 ozaki-r Exp $	*/
+/*	$NetBSD: config.c,v 1.37 2017/11/06 15:15:04 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -67,6 +67,7 @@
 #include "timer.h"
 #include "if.h"
 #include "config.h"
+#include "logit.h"
 #include "prog_ops.h"
 
 #ifndef __arraycount
@@ -180,24 +181,24 @@ getconfig(const char *intface, int exith
 	do {\
 		p = calloc(1, sizeof(*p));\
 		if (p == NULL) {	\
-			syslog(LOG_ERR, "<%s> calloc failed: %m",	\
+			logit(LOG_ERR, "<%s> calloc failed: %m",	\
 			__func__);	\
 			goto errexit;	\
 		}			\
 	} while(/*CONSTCOND*/0)
 
 	if (if_nametoindex(intface) == 0) {
-		syslog(LOG_INFO, "<%s> interface %s not found, ignoring",
+		logit(LOG_INFO, "<%s> interface %s not found, ignoring",
 		   __func__, intface);
 		return;
 	}
 
-	syslog(LOG_DEBUG, "<%s> loading configuration for interface %s",
+	logit(LOG_DEBUG, "<%s> loading configuration for interface %s",
 	   __func__, intface);
 
 	if ((stat = agetent(tbuf, intface)) <= 0) {
 		memset(tbuf, 0, sizeof(tbuf));
-		syslog(LOG_INFO,
+		logit(LOG_INFO,
 		   "<%s> %s isn't defined in the configuration file"
 		   " or the configuration file doesn't exist."
 		   " Treat it as default",
@@ -223,7 +224,7 @@ getconfig(const char *intface, int exith
 		tmp->advlinkopt = 1;
 	if (tmp->advlinkopt) {
 		if ((tmp->sdl = if_nametosdl(intface)) == NULL) {
-			syslog(LOG_ERR,
+			logit(LOG_ERR,
 			   "<%s> can't get information of %s",
 			   __func__, intface);
 			goto errexit;
@@ -232,7 +233,7 @@ getconfig(const char *intface, int exith
 	} else {
 		tmp->ifindex = if_nametoindex(intface);
 		if (tmp->ifindex == 0) {
-			syslog(LOG_ERR,
+			logit(LOG_ERR,
 			   "<%s> can't get information of %s",
 			   __func__, intface);
 			goto errexit;
@@ -242,7 +243,7 @@ getconfig(const char *intface, int exith
 	strlcpy(tmp->ifname, intface, sizeof(tmp->ifname));
 	if ((tmp->phymtu = if_getmtu(intface)) == 0) {
 		tmp->phymtu = IPV6_MMTU;
-		syslog(LOG_WARNING,
+		logit(LOG_WARNING,
 		   "<%s> can't get interface mtu of %s. Treat as %d",
 		   __func__, intface, IPV6_MMTU);
 	}
@@ -252,7 +253,7 @@ getconfig(const char *intface, int exith
 	 */
 	MAYHAVE(val, "maxinterval", DEF_MAXRTRADVINTERVAL);
 	if (val < MIN_MAXINTERVAL || val > MAX_MAXINTERVAL) {
-		syslog(LOG_ERR,
+		logit(LOG_ERR,
 		   "<%s> maxinterval (%d) on %s is invalid "
 		   "(must be between %u and %u)", __func__, val,
 		   intface, MIN_MAXINTERVAL, MAX_MAXINTERVAL);
@@ -261,7 +262,7 @@ getconfig(const char *intface, int exith
 	tmp->maxinterval = val;
 	MAYHAVE(val, "mininterval", tmp->maxinterval/3);
 	if (val < MIN_MININTERVAL || val > (tmp->maxinterval 

CVS commit: src/usr.sbin/rtadvd

2017-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  6 15:15:04 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: advcap.c config.c dump.c if.c rrenum.c rtadvd.8
rtadvd.c timer.c
Added Files:
src/usr.sbin/rtadvd: logit.h

Log Message:
Change the meaning of the 'D' flag to print errors to stderr instead of
syslog(3) and exit if poll(2) fails (intended to be used with unit-tests).


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/dump.c
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/rtadvd/logit.h
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/rtadvd/timer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-10-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 14 19:16:26 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
PR/52618: Shinichi Doyashiki: Don't exit if adding interface to multicast
group fails. This happens with empty vlan interfaces

- make syscalls checks against -1
- fix errors to print %s: instead of <%s>

XXX: if_vlan is the only pseudo interface in net/ that returns such an
error..


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.55 src/usr.sbin/rtadvd/rtadvd.c:1.56
--- src/usr.sbin/rtadvd/rtadvd.c:1.55	Mon Sep 11 10:12:28 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Sat Oct 14 15:16:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.55 2017/09/11 14:12:28 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.56 2017/10/14 19:16:26 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -316,7 +316,7 @@ main(int argc, char *argv[])
 
 		if (do_reconf) { /* SIGHUP */
 			do_reconf = 0;
-			syslog(LOG_INFO, "<%s> reloading config on SIGHUP",
+			syslog(LOG_INFO, "%s: reloading config on SIGHUP",
 			   __func__);
 			argc = if_argc;
 			argv = if_argv;
@@ -334,22 +334,22 @@ main(int argc, char *argv[])
 
 		if (timeout != NULL) {
 			syslog(LOG_DEBUG,
-			"<%s> set timer to %jd:%jd. waiting for "
+			"%s: set timer to %jd:%jd. waiting for "
 			"inputs or timeout", __func__,
 			(intmax_t)timeout->tv_sec,
 			(intmax_t)timeout->tv_nsec);
 		} else {
 			syslog(LOG_DEBUG,
-			"<%s> there's no timer. waiting for inputs",
+			"%s: there's no timer. waiting for inputs",
 			__func__);
 		}
 
 		if ((i = prog_poll(set, 2, timeout ? (timeout->tv_sec * 1000 +
-		(timeout->tv_nsec + 99) / 100) : INFTIM)) < 0)
+		(timeout->tv_nsec + 99) / 100) : INFTIM)) == -1)
 		{
 			/* EINTR would occur upon SIGUSR1 for status dump */
 			if (errno != EINTR)
-syslog(LOG_ERR, "<%s> poll: %m", __func__);
+syslog(LOG_ERR, "%s: poll: %m", __func__);
 			continue;
 		}
 		if (i == 0)	/* timeout */
@@ -394,11 +394,11 @@ die(void)
 	if (waiting) {
 		if (TAILQ_FIRST()) {
 			syslog(LOG_INFO,
-			   "<%s> waiting for expiration of all RA timers",
+			   "%s: waiting for expiration of all RA timers",
 			   __func__);
 			return;
 		}
-		syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
+		syslog(LOG_NOTICE, "%s: gracefully terminated", __func__);
 		free(rcvcmsgbuf);
 		free(sndcmsgbuf);
 		exit(EXIT_SUCCESS);
@@ -406,13 +406,13 @@ die(void)
 	}
 
 	if (TAILQ_FIRST() == NULL) {
-		syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
+		syslog(LOG_NOTICE, "%s: gracefully terminated", __func__);
 		exit(EXIT_SUCCESS);
 		/* NOT REACHED */
 	}
 
 	waiting = 1;
-	syslog(LOG_NOTICE, "<%s> final RA transmission started", __func__);
+	syslog(LOG_NOTICE, "%s: final RA transmission started", __func__);
 
 	TAILQ_FOREACH_SAFE(rai, , next, ran) {
 		if (rai->leaving) {
@@ -467,7 +467,7 @@ rtmsg_input(void)
 
 	msg = buffer.data;
 	if (dflag > 1) {
-		syslog(LOG_DEBUG, "<%s> received a routing message "
+		syslog(LOG_DEBUG, "%s: received a routing message "
 		"(type = %d, len = %d)", __func__, rtmsg_type(msg),
 		rtmsg_len(msg));
 	}
@@ -478,7 +478,7 @@ rtmsg_input(void)
 		 */
 		if (dflag > 1)
 			syslog(LOG_DEBUG,
-			"<%s> received data length is larger than "
+			"%s: received data length is larger than "
 			"1st routing message len. multiple messages? "
 			"read %d bytes, but 1st msg len = %d",
 			__func__, n, rtmsg_len(msg));
@@ -518,7 +518,7 @@ rtmsg_input(void)
 			ifindex = get_ifan_ifindex(next);
 			if (get_ifan_what(next) == IFAN_ARRIVAL) {
 syslog(LOG_DEBUG,
-				   "<%s> interface %s arrived",
+				   "%s: interface %s arrived",
    __func__,
    if_indextoname(ifindex, ifname));
 if (if_argc == 0) {
@@ -543,9 +543,8 @@ rtmsg_input(void)
 		default:
 			/* should not reach here */
 			if (dflag > 1) {
-syslog(LOG_DEBUG,
-   "<%s:%d> unknown rtmsg %d on %s",
-   __func__, __LINE__, type,
+syslog(LOG_DEBUG, "%s: unknown rtmsg %d on %s",
+   __func__, type,
    if_indextoname(ifindex, ifname));
 			}
 			continue;
@@ -554,7 +553,7 @@ rtmsg_input(void)
 		if ((rai = if_indextorainfo(ifindex)) == NULL) {
 			if (dflag > 1) {
 syslog(LOG_DEBUG,
-   "<%s> route changed on "
+   "%s: route changed on "
    "non advertising interface %s (%d)",
    __func__,
    if_indextoname(ifindex, ifname),
@@ -577,7 +576,7 @@ rtmsg_input(void)
 			/* sanity check for plen */
 			/* as RFC2373, prefixlen is at least 4 */
 			if (plen < 4 || plen > 127) {
-syslog(LOG_INFO, "<%s> new 

CVS commit: src/usr.sbin/rtadvd

2017-10-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 14 19:16:26 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
PR/52618: Shinichi Doyashiki: Don't exit if adding interface to multicast
group fails. This happens with empty vlan interfaces

- make syscalls checks against -1
- fix errors to print %s: instead of <%s>

XXX: if_vlan is the only pseudo interface in net/ that returns such an
error..


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 11 14:12:28 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Don't start another copy of rtadvd if one is running.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.54 src/usr.sbin/rtadvd/rtadvd.c:1.55
--- src/usr.sbin/rtadvd/rtadvd.c:1.54	Mon Sep 11 10:12:07 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Mon Sep 11 10:12:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.54 2017/09/11 14:12:07 christos Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.55 2017/09/11 14:12:28 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -265,10 +265,15 @@ main(int argc, char *argv[])
 
 #ifdef __NetBSD__
 	/* record the current PID */
-	if (pidfile(pidfilepath) < 0) {
-		syslog(LOG_ERR,
-		"<%s> failed to open the pid log file, run anyway.",
-		__func__);
+	if (pidfile(pidfilepath) == -1) {
+		if (errno == EEXIST) {
+			syslog(LOG_ERR, "Another instance of `%s' is running "
+			"(pid %d); exiting.", getprogname(),
+			pidfile_read(pidfilepath));
+			return EXIT_FAILURE;
+		}
+		syslog(LOG_ERR, "Failed to open the pid log file `%s' (%m), "
+		"run anyway.", pidfilepath);
 	}
 #endif
 



CVS commit: src/usr.sbin/rtadvd

2017-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 11 14:12:07 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
KNF, fix time printing formats.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.53 src/usr.sbin/rtadvd/rtadvd.c:1.54
--- src/usr.sbin/rtadvd/rtadvd.c:1.53	Tue Apr 11 10:29:23 2017
+++ src/usr.sbin/rtadvd/rtadvd.c	Mon Sep 11 10:12:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.53 2017/04/11 14:29:23 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.54 2017/09/11 14:12:07 christos Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -219,14 +219,13 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 	if (argc == 0) {
-		fprintf(stderr,
-			"usage: rtadvd [-DdfRs] [-c conffile]"
-			" [-M ifname] [-p pidfile] interface ...\n");
-		exit(1);
+		fprintf(stderr, "Ysage: %s [-DdfRs] [-c conffile]"
+		" [-M ifname] [-p pidfile] interface ...\n", getprogname());
+		return EXIT_FAILURE;
 	}
 
 	if (prog_init && prog_init() == -1) {
-		err(1, "init failed");
+		err(EXIT_FAILURE, "init failed");
 	}
 
 	logopt = LOG_NDELAY | LOG_PID;
@@ -248,7 +247,7 @@ main(int argc, char *argv[])
 			RTADVD_USER);
 		else
 			syslog(LOG_ERR, "getpwnam: %s: %m", RTADVD_USER);
-		exit(1);
+		return EXIT_FAILURE;
 	}
 
 	/* timer initialization */
@@ -285,18 +284,18 @@ main(int argc, char *argv[])
 	syslog(LOG_INFO, "dropping privileges to %s", RTADVD_USER);
 	if (prog_chroot(pw->pw_dir) == -1) {
 		syslog(LOG_ERR, "chroot: %s: %m", pw->pw_dir);
-		exit(1);
+		return EXIT_FAILURE;
 	}
 	if (prog_chdir("/") == -1) {
 		syslog(LOG_ERR, "chdir: /: %m");
-		exit(1);
+		return EXIT_FAILURE;
 	}
 	if (prog_setgroups(1, >pw_gid) == -1 ||
 	prog_setgid(pw->pw_gid) == -1 ||
 	prog_setuid(pw->pw_uid) == -1)
 	{
 		syslog(LOG_ERR, "failed to drop privileges: %m");
-		exit(1);
+		return EXIT_FAILURE;
 	}
 
 	signal(SIGINT, set_die);
@@ -330,10 +329,10 @@ main(int argc, char *argv[])
 
 		if (timeout != NULL) {
 			syslog(LOG_DEBUG,
-			"<%s> set timer to %ld:%ld. waiting for "
+			"<%s> set timer to %jd:%jd. waiting for "
 			"inputs or timeout", __func__,
-			(long int)timeout->tv_sec,
-			(long int)timeout->tv_nsec);
+			(intmax_t)timeout->tv_sec,
+			(intmax_t)timeout->tv_nsec);
 		} else {
 			syslog(LOG_DEBUG,
 			"<%s> there's no timer. waiting for inputs",
@@ -355,7 +354,7 @@ main(int argc, char *argv[])
 		if (set[0].revents & POLLIN)
 			rtadvd_input();
 	}
-	exit(0);		/* NOTREACHED */
+	return EXIT_SUCCESS;	/* NOTREACHED */
 }
 
 static void
@@ -397,13 +396,13 @@ die(void)
 		syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
 		free(rcvcmsgbuf);
 		free(sndcmsgbuf);
-		exit(0);
+		exit(EXIT_SUCCESS);
 		/* NOT REACHED */
 	}
 
 	if (TAILQ_FIRST() == NULL) {
 		syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
-		exit(0);
+		exit(EXIT_SUCCESS);
 		/* NOT REACHED */
 	}
 
@@ -432,7 +431,7 @@ die(void)
 		rai->maxinterval = MIN_DELAY_BETWEEN_RAS;
 		rai->leaving_adv = MAX_FINAL_RTR_ADVERTISEMENTS;
 		ra_output(rai);
-		ra_timer_update((void *)rai, >timer->tm);
+		ra_timer_update(rai, >timer->tm);
 		rtadvd_set_timer(>timer->tm, rai->timer);
 	}
 }
@@ -688,7 +687,7 @@ rtmsg_input(void)
 			rtadvd_remove_timer(>timer);
 			rai->timer = rtadvd_add_timer(ra_timeout,
 			ra_timer_update, rai, rai);
-			ra_timer_update((void *)rai, >timer->tm);
+			ra_timer_update(rai, >timer->tm);
 			rtadvd_set_timer(>timer->tm, rai->timer);
 		} else if (prefixchange && rai->ifflags & IFF_UP) {
 			/*
@@ -901,8 +900,6 @@ rtadvd_input(void)
 		__func__, icp->icmp6_type);
 		return;
 	}
-
-	return;
 }
 
 static void
@@ -993,7 +990,6 @@ rs_input(int len, struct nd_router_solic
 
 done:
 	free_ndopts();
-	return;
 }
 
 void
@@ -1196,7 +1192,6 @@ ra_input(int len, struct nd_router_adver
 	
 done:
 	free_ndopts();
-	return;
 }
 
 /* return a non-zero value if the received prefix is inconsitent with ours */
@@ -1212,7 +1207,7 @@ prefix_check(struct nd_opt_prefix_info *
 
 #if 0/* impossible */
 	if (pinfo->nd_opt_pi_type != ND_OPT_PREFIX_INFORMATION)
-		return(0);
+		return 0;
 #endif
 
 	/*
@@ -1242,7 +1237,7 @@ prefix_check(struct nd_opt_prefix_info *
 		   inet_ntop(AF_INET6, >sin6_addr,
  ntopbuf, INET6_ADDRSTRLEN),
 		   rai->ifname);
-		return(0);
+		return 0;
 	}
 
 	preferred_time = ntohl(pinfo->nd_opt_pi_preferred_time);
@@ -1325,7 +1320,7 @@ prefix_check(struct nd_opt_prefix_info *
 		inconsistent++;
 	}
 
-	return(inconsistent);
+	return inconsistent;
 }
 
 struct prefix *
@@ -1341,16 +1336,16 @@ find_prefix(struct rainfo *rai, struct i
 		bytelen = plen / 8;
 		bitlen = plen % 8;
 		bitmask = 0xff << (8 - bitlen);
-		if 

CVS commit: src/usr.sbin/rtadvd

2017-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 11 14:12:28 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Don't start another copy of rtadvd if one is running.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 11 14:12:07 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
KNF, fix time printing formats.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:29:23 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.52 src/usr.sbin/rtadvd/rtadvd.c:1.53
--- src/usr.sbin/rtadvd/rtadvd.c:1.52	Fri Dec 16 09:09:38 2016
+++ src/usr.sbin/rtadvd/rtadvd.c	Tue Apr 11 14:29:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.52 2016/12/16 09:09:38 ozaki-r Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.53 2017/04/11 14:29:23 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1652,10 +1652,26 @@ sock_open(void)
 static void
 rtsock_open(void)
 {
+#ifdef RO_MSGFILTER
+	unsigned char msgfilter[] = {
+		RTM_ADD, RTM_DELETE,
+		RTM_NEWADDR, RTM_DELADDR,
+#ifdef RTM_IFANNOUNCE
+		RTM_IFANNOUNCE,
+#endif
+		RTM_IFINFO,
+	};
+#endif
+
 	if ((rtsock = prog_socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
 		syslog(LOG_ERR, "<%s> socket: %m", __func__);
 		exit(1);
 	}
+#ifdef RO_MSGFILTER
+	if (setsockopt(rtsock, PF_ROUTE, RO_MSGFILTER,
+	, sizeof(msgfilter) == -1))
+		syslog(LOG_ERR, "<%s> RO_MSGFILTER: %m", __func__);
+#endif
 }
 
 struct rainfo *



CVS commit: src/usr.sbin/rtadvd

2017-04-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Apr 11 14:29:23 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Use RO_MSGFILTER.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-02-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Feb 27 05:41:37 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.h

Log Message:
Fix the default value of rltime

According to rtadvd.conf(5), the default value of rltime is 1800 seconds.

PR bin/51994


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.35 src/usr.sbin/rtadvd/config.c:1.36
--- src/usr.sbin/rtadvd/config.c:1.35	Wed Nov 11 07:48:41 2015
+++ src/usr.sbin/rtadvd/config.c	Mon Feb 27 05:41:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.35 2015/11/11 07:48:41 ozaki-r Exp $	*/
+/*	$NetBSD: config.c,v 1.36 2017/02/27 05:41:36 ozaki-r Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -305,7 +305,7 @@ getconfig(const char *intface, int exith
 		goto errexit;
 	}
 
-	MAYHAVE(val, "rltime", tmp->maxinterval * 3);
+	MAYHAVE(val, "rltime", DEF_ADVROUTERLIFETIME);
 	if (val && (val < tmp->maxinterval || val > MAXROUTERLIFETIME)) {
 		syslog(LOG_ERR,
 		   "<%s> router lifetime (%d) on %s is invalid "

Index: src/usr.sbin/rtadvd/rtadvd.h
diff -u src/usr.sbin/rtadvd/rtadvd.h:1.14 src/usr.sbin/rtadvd/rtadvd.h:1.15
--- src/usr.sbin/rtadvd/rtadvd.h:1.14	Fri Jun  5 14:09:20 2015
+++ src/usr.sbin/rtadvd/rtadvd.h	Mon Feb 27 05:41:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.h,v 1.14 2015/06/05 14:09:20 roy Exp $	*/
+/*	$NetBSD: rtadvd.h,v 1.15 2017/02/27 05:41:36 ozaki-r Exp $	*/
 /*	$KAME: rtadvd.h,v 1.30 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -52,6 +52,7 @@ extern struct sockaddr_in6 sin6_siteloca
 #define DEF_ADVCURHOPLIMIT 64
 #define DEF_ADVVALIDLIFETIME 2592000
 #define DEF_ADVPREFERREDLIFETIME 604800
+#define DEF_ADVROUTERLIFETIME 1800
 
 #define MAXROUTERLIFETIME 9000
 #define MIN_MAXINTERVAL 4



CVS commit: src/usr.sbin/rtadvd

2017-02-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Feb 27 05:41:37 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: config.c rtadvd.h

Log Message:
Fix the default value of rltime

According to rtadvd.conf(5), the default value of rltime is 1800 seconds.

PR bin/51994


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/rtadvd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 21:07:18 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd_hostops.c

Log Message:
need  for clock_gettime


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/rtadvd/rtadvd_hostops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd_hostops.c
diff -u src/usr.sbin/rtadvd/rtadvd_hostops.c:1.1 src/usr.sbin/rtadvd/rtadvd_hostops.c:1.2
--- src/usr.sbin/rtadvd/rtadvd_hostops.c:1.1	Wed Nov 11 02:49:59 2015
+++ src/usr.sbin/rtadvd/rtadvd_hostops.c	Tue Jan 10 16:07:17 2017
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "prog_ops.h"
 



CVS commit: src/usr.sbin/rtadvd

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 21:07:18 UTC 2017

Modified Files:
src/usr.sbin/rtadvd: rtadvd_hostops.c

Log Message:
need  for clock_gettime


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/rtadvd/rtadvd_hostops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/rtadvd

2016-06-15 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jun 15 13:57:39 UTC 2016

Modified Files:
src/usr.sbin/rtadvd: dump.c

Log Message:
Omit needless casts.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/rtadvd/dump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/dump.c
diff -u src/usr.sbin/rtadvd/dump.c:1.13 src/usr.sbin/rtadvd/dump.c:1.14
--- src/usr.sbin/rtadvd/dump.c:1.13	Wed Nov 11 07:48:41 2015
+++ src/usr.sbin/rtadvd/dump.c	Wed Jun 15 13:57:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump.c,v 1.13 2015/11/11 07:48:41 ozaki-r Exp $	*/
+/*	$NetBSD: dump.c,v 1.14 2016/06/15 13:57:39 riastradh Exp $	*/
 /*	$KAME: dump.c,v 1.34 2004/06/14 05:35:59 itojun Exp $	*/
 
 /*
@@ -113,11 +113,11 @@ if_dump(void)
 		if (rai->lastsent.tv_sec) {
 			/* note that ctime() appends CR by itself */
 			fprintf(fp, "  Last RA sent: %s",
-ctime((time_t *)>lastsent.tv_sec));
+ctime(>lastsent.tv_sec));
 		}
 		if (rai->timer) {
 			fprintf(fp, "  Next RA will be sent: %s",
-ctime((time_t *)>timer->tm.tv_sec));
+ctime(>timer->tm.tv_sec));
 		}
 		else
 			fprintf(fp, "  RA timer is stopped");



CVS commit: src/usr.sbin/rtadvd

2015-11-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Nov 11 07:49:59 UTC 2015

Added Files:
src/usr.sbin/rtadvd: prog_ops.h rtadvd_hostops.c rtadvd_rumpops.c

Log Message:
Introduce rump.rtadvd

It is used to write ATF tests for RA.

>From s-yamaguchi@IIJ.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.sbin/rtadvd/prog_ops.h \
src/usr.sbin/rtadvd/rtadvd_hostops.c src/usr.sbin/rtadvd/rtadvd_rumpops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/usr.sbin/rtadvd/prog_ops.h
diff -u /dev/null src/usr.sbin/rtadvd/prog_ops.h:1.1
--- /dev/null	Wed Nov 11 07:49:59 2015
+++ src/usr.sbin/rtadvd/prog_ops.h	Wed Nov 11 07:49:59 2015
@@ -0,0 +1,84 @@
+#ifndef _PROG_OPS_H_
+#define _PROG_OPS_H_
+
+#include 
+#include 
+#include 
+
+#ifndef CRUNCHOPS
+struct prog_ops {
+	int (*op_init)(void);
+	int (*op_daemon)(int, int);
+
+	int (*op_sysctl)(const int *, u_int, void *, size_t *,
+			 const void *, size_t);
+	int (*op_ioctl)(int, unsigned long, ...);
+
+	int (*op_socket)(int, int, int);
+	int (*op_open)(const char *, int, ...);
+	int (*op_close)(int);
+	pid_t (*op_getpid)(void);
+
+	ssize_t (*op_read)(int, void *, size_t);
+	ssize_t (*op_write)(int, const void *, size_t);
+
+	int (*op_chdir)(const char *);
+	int (*op_chroot)(const char *);
+
+	int (*op_setuid)(uid_t);
+	int (*op_setgid)(gid_t);
+	int (*op_setgroups)(int, const gid_t *);
+
+	ssize_t (*op_recvmsg)(int, struct msghdr *, int);
+	ssize_t (*op_sendmsg)(int, const struct msghdr *, int);
+
+	int (*op_setsockopt)(int, int, int, const void *, socklen_t);
+	int (*op_poll)(struct pollfd *, u_int, int);
+	int (*op_clock_gettime)(clockid_t, struct timespec *);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_daemon prog_ops.op_daemon
+#define prog_socket prog_ops.op_socket
+#define prog_open prog_ops.op_open
+#define prog_close prog_ops.op_close
+#define prog_getpid prog_ops.op_getpid
+#define prog_read prog_ops.op_read
+#define prog_write prog_ops.op_write
+#define prog_sysctl prog_ops.op_sysctl
+#define prog_ioctl prog_ops.op_ioctl
+#define prog_chdir prog_ops.op_chdir
+#define prog_chroot prog_ops.op_chroot
+#define prog_setuid prog_ops.op_setuid
+#define prog_setgid prog_ops.op_setgid
+#define prog_setgroups prog_ops.op_setgroups
+#define prog_recvmsg prog_ops.op_recvmsg
+#define prog_sendmsg prog_ops.op_sendmsg
+#define prog_setsockopt prog_ops.op_setsockopt
+#define prog_poll prog_ops.op_poll
+#define prog_clock_gettime prog_ops.op_clock_gettime
+#else
+#define prog_init ((int (*)(void))NULL)
+#define prog_daemon daemon
+#define prog_socket socket
+#define prog_open open
+#define prog_close close
+#define prog_getpid getpid
+#define prog_read read
+#define prog_write write
+#define prog_sysctl sysctl
+#define prog_ioctl ioctl
+#define prog_chdir chdir
+#define prog_chroot chroot
+#define prog_setuid setuid
+#define prog_setgid setgid
+#define prog_setgroups setgroups
+#define prog_recvmsg recvmsg
+#define prog_sendmsg sendmsg
+#define prog_setsockopt setsockopt
+#define prog_poll poll
+#define prog_clock_gettime clock_gettime
+#endif
+
+#endif /* _PROG_OPS_H_ */
Index: src/usr.sbin/rtadvd/rtadvd_hostops.c
diff -u /dev/null src/usr.sbin/rtadvd/rtadvd_hostops.c:1.1
--- /dev/null	Wed Nov 11 07:49:59 2015
+++ src/usr.sbin/rtadvd/rtadvd_hostops.c	Wed Nov 11 07:49:59 2015
@@ -0,0 +1,40 @@
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_daemon =		daemon,
+	.op_socket =		socket,
+	.op_open =		open,
+	.op_close =		close,
+	.op_getpid =		getpid,
+
+	.op_read =		read,
+	.op_write =		write,
+
+	.op_sysctl =		sysctl,
+	.op_ioctl =		ioctl,
+
+	.op_chdir =		chdir,
+	.op_chroot =		chroot,
+
+	.op_setuid =		setuid,
+	.op_setgid =		setgid,
+	.op_setgroups =		setgroups,
+
+	.op_recvmsg =		recvmsg,
+	.op_sendmsg =		sendmsg,
+
+	.op_setsockopt =	setsockopt,
+	.op_poll =		poll,
+	.op_clock_gettime =	clock_gettime,
+};
Index: src/usr.sbin/rtadvd/rtadvd_rumpops.c
diff -u /dev/null src/usr.sbin/rtadvd/rtadvd_rumpops.c:1.1
--- /dev/null	Wed Nov 11 07:49:59 2015
+++ src/usr.sbin/rtadvd/rtadvd_rumpops.c	Wed Nov 11 07:49:59 2015
@@ -0,0 +1,45 @@
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_init =		rumpclient_init,
+	.op_daemon =		rumpclient_daemon,
+
+	.op_socket =		rump_sys_socket,
+	.op_open =		rump_sys_open,
+	.op_close =		rump_sys_close,
+	.op_getpid =		rump_sys_getpid,
+
+	.op_read =		rump_sys_read,
+	.op_write =		rump_sys_write,
+
+	.op_sysctl =		rump_sys___sysctl,
+	.op_ioctl =		rump_sys_ioctl,
+
+	.op_chdir =		rump_sys_chdir,
+	.op_chroot =		rump_sys_chroot,
+
+	.op_setuid =		rump_sys_setuid,
+	.op_setgid =		rump_sys_setgid,
+	.op_setgroups =		rump_sys_setgroups,
+
+	

CVS commit: src/usr.sbin/rtadvd

2015-11-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Nov 11 07:49:59 UTC 2015

Added Files:
src/usr.sbin/rtadvd: prog_ops.h rtadvd_hostops.c rtadvd_rumpops.c

Log Message:
Introduce rump.rtadvd

It is used to write ATF tests for RA.

>From s-yamaguchi@IIJ.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.sbin/rtadvd/prog_ops.h \
src/usr.sbin/rtadvd/rtadvd_hostops.c src/usr.sbin/rtadvd/rtadvd_rumpops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.sbin/rtadvd

2015-07-03 Thread David Holland
On Fri, Jun 05, 2015 at 03:41:59PM +, Roy Marples wrote:
  Module Name: src
  Committed By:roy
  Date:Fri Jun  5 15:41:59 UTC 2015
  
  Modified Files:
   src/usr.sbin/rtadvd: advcap.c if.c rrenum.c rtadvd.c
  
  Log Message:
  Use %m in syslog(3) instead of %s strerror(3).

Was this really necessary? Last I remember we considered %m a legacy
mistake and preferred to avoid it.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/usr.sbin/rtadvd

2015-07-03 Thread Roy Marples
On Friday 03 July 2015 17:54:01 you wrote:
 On Fri, Jun 05, 2015 at 03:41:59PM +, Roy Marples wrote:
   Module Name:   src
   Committed By:  roy
   Date:  Fri Jun  5 15:41:59 UTC 2015
   
   Modified Files:
  src/usr.sbin/rtadvd: advcap.c if.c rrenum.c rtadvd.c
   
   Log Message:
   Use %m in syslog(3) instead of %s strerror(3).
 
 Was this really necessary? Last I remember we considered %m a legacy
 mistake and preferred to avoid it.

It made the program smaller, which is a good thing.
There is no mention of syslog %m being considered a legacy mistake in the man 
page. Maybe you have a link to any discussion of this?

Roy


Re: CVS commit: src/usr.sbin/rtadvd

2015-07-03 Thread David Holland
On Fri, Jul 03, 2015 at 08:12:42PM +0100, Roy Marples wrote:
   Modified Files:
 src/usr.sbin/rtadvd: advcap.c if.c rrenum.c rtadvd.c
   
   Log Message:
   Use %m in syslog(3) instead of %s strerror(3).
   
   Was this really necessary? Last I remember we considered %m a legacy
   mistake and preferred to avoid it.
  
  It made the program smaller, which is a good thing.
  There is no mention of syslog %m being considered a legacy mistake
  in the man page. Maybe you have a link to any discussion of this?

I'm not sure I'm going to be able to find it readily. Searching for %m
doesn't work real well, even with grep.

however, here's what it's about. %m is a wart: since it's not part of
printf, it means you can't use printf to implement syslog(3), at least
not without adding a bunch of gross hacks. Or alternatively (like the
gnu folks do) you can quietly add %m support to printf, which is
pretty gross as well.

There is no real reason %m is necessary and we were at least
discussing deprecating it; I don't think anything formal came of that
but still it's probably better not to add new uses of it.

anyone else remember? Christos?

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/usr.sbin/rtadvd

2015-07-03 Thread Roy Marples
On Friday 03 July 2015 19:28:26 David Holland wrote:
 On Fri, Jul 03, 2015 at 08:12:42PM +0100, Roy Marples wrote:
Modified Files:
src/usr.sbin/rtadvd: advcap.c if.c rrenum.c rtadvd.c

Log Message:
Use %m in syslog(3) instead of %s strerror(3).

Was this really necessary? Last I remember we considered %m a legacy
mistake and preferred to avoid it.
   
   It made the program smaller, which is a good thing.
   There is no mention of syslog %m being considered a legacy mistake
   in the man page. Maybe you have a link to any discussion of this?
 
 I'm not sure I'm going to be able to find it readily. Searching for %m
 doesn't work real well, even with grep.
 
 however, here's what it's about. %m is a wart: since it's not part of
 printf, it means you can't use printf to implement syslog(3), at least
 not without adding a bunch of gross hacks.

This I do agree with after implementing a syslog wrapper in dhcpcd.

 Or alternatively (like the
 gnu folks do) you can quietly add %m support to printf, which is
 pretty gross as well.

I'm on the fence about that.
I dislike it's not standard (but hey, we have our own non standard stuff too!) 
but is is convenient.

But aside from not being a standard, but is wrong with %m in printf?

 There is no real reason %m is necessary and we were at least
 discussing deprecating it; I don't think anything formal came of that
 but still it's probably better not to add new uses of it.
 
 anyone else remember? Christos?

Is it necessary? No it's not.
However it *is* a convenience, saves code size and is an accepted standard
http://pubs.opengroup.org/onlinepubs/7908799/xsh/closelog.html

Roy


Re: CVS commit: src/usr.sbin/rtadvd

2015-07-03 Thread Christos Zoulas
In article 20150703192826.ga27...@netbsd.org,
David Holland  dholland-sourcechan...@netbsd.org wrote:

however, here's what it's about. %m is a wart: since it's not part of
printf, it means you can't use printf to implement syslog(3), at least
not without adding a bunch of gross hacks. Or alternatively (like the
gnu folks do) you can quietly add %m support to printf, which is
pretty gross as well.

There is no real reason %m is necessary and we were at least
discussing deprecating it; I don't think anything formal came of that
but still it's probably better not to add new uses of it.

anyone else remember? Christos?

I remember the discussion about %m supported by the glibc printf, and
if we should be adding it or not. The consensus IIRC was not, and that
it is probably a good idea to avoid it in general so that message
format strings are not special. But we did not go as far to forbid
it or to recommend code not to use it.

christos



CVS commit: src/usr.sbin/rtadvd

2015-06-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Jun 15 04:15:33 UTC 2015

Modified Files:
src/usr.sbin/rtadvd: rtadvd.c

Log Message:
Fix regression on sending RA messages

r1.48 dropped hoplimit cmsg but forgot to adjust cmsg buffer length.

Reported by Timo Buhrmester


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/rtadvd/rtadvd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.49 src/usr.sbin/rtadvd/rtadvd.c:1.50
--- src/usr.sbin/rtadvd/rtadvd.c:1.49	Fri Jun  5 15:41:59 2015
+++ src/usr.sbin/rtadvd/rtadvd.c	Mon Jun 15 04:15:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.49 2015/06/05 15:41:59 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.50 2015/06/15 04:15:33 ozaki-r Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1503,8 +1503,7 @@ sock_open(void)
 		exit(1);
 	}
 
-	sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + 
-CMSG_SPACE(sizeof(int));
+	sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo));
 	sndcmsgbuf = malloc(sndcmsgbuflen);
 	if (sndcmsgbuf == NULL) {
 		syslog(LOG_ERR, %s malloc: %m, __func__);



  1   2   >