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: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.

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.

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-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

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-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.

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.

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: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.

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.

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-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-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-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

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.

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-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: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: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 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: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 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.

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: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: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-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-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-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-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-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-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

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-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__);



CVS commit: src/usr.sbin/rtadvd

2015-06-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun  5 14:09:21 UTC 2015

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

Log Message:
Use clock_gettime(2) instead of gettimeofday(2) so we can use a monotonic
clock rather than the wall clock.
Use timespec rather than timeval structs to make this transition easier.
Kill custom timeval comparison functions in favor of timespeccmp(3).


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/rtadvd/dump.c \
src/usr.sbin/rtadvd/timer.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/rtadvd/rtadvd.h
cvs rdiff -u -r1.7 -r1.8 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.33 src/usr.sbin/rtadvd/config.c:1.34
--- src/usr.sbin/rtadvd/config.c:1.33	Thu Jan 24 19:55:28 2013
+++ src/usr.sbin/rtadvd/config.c	Fri Jun  5 14:09:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.33 2013/01/24 19:55:28 christos Exp $	*/
+/*	$NetBSD: config.c,v 1.34 2015/06/05 14:09:20 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -444,8 +444,8 @@ getconfig(const char *intface, int exith
 
 		makeentry(entbuf, sizeof(entbuf), i, vltimedecr);
 		if (agetflag(entbuf)) {
-			struct timeval now;
-			gettimeofday(now, 0);
+			struct timespec now;
+			clock_gettime(CLOCK_MONOTONIC, now);
 			pfx-vltimeexpire =
 now.tv_sec + pfx-validlifetime;
 		}
@@ -464,8 +464,8 @@ getconfig(const char *intface, int exith
 
 		makeentry(entbuf, sizeof(entbuf), i, pltimedecr);
 		if (agetflag(entbuf)) {
-			struct timeval now;
-			gettimeofday(now, 0);
+			struct timespec now;
+			clock_gettime(CLOCK_MONOTONIC, now);
 			pfx-pltimeexpire =
 now.tv_sec + pfx-preflifetime;
 		}
@@ -958,7 +958,7 @@ void
 invalidate_prefix(struct prefix *prefix)
 {
 	char ntopbuf[INET6_ADDRSTRLEN];
-	struct timeval timo;
+	struct timespec timo;
 	struct rainfo *rai = prefix-rainfo;
 
 	if (prefix-timer) {	/* sanity check */
@@ -981,7 +981,7 @@ invalidate_prefix(struct prefix *prefix)
 		delete_prefix(prefix);
 	}
 	timo.tv_sec = prefix_timo;
-	timo.tv_usec = 0;
+	timo.tv_nsec = 0;
 	rtadvd_set_timer(timo, prefix-timer);
 }
 
@@ -1200,7 +1200,7 @@ make_packet(struct rainfo *rainfo)
 
 	TAILQ_FOREACH(pfx, rainfo-prefix, next) {	
 		uint32_t vltime, pltime;
-		struct timeval now;
+		struct timespec now;
 
 		CHECKLEN(sizeof(*ndopt_pi));
 		ndopt_pi = (struct nd_opt_prefix_info *)buf;
@@ -1218,7 +1218,7 @@ make_packet(struct rainfo *rainfo)
 			vltime = 0;
 		else {
 			if (pfx-vltimeexpire || pfx-pltimeexpire)
-gettimeofday(now, NULL);
+clock_gettime(CLOCK_MONOTONIC, now);
 			if (pfx-vltimeexpire == 0)
 vltime = pfx-validlifetime;
 			else

Index: src/usr.sbin/rtadvd/dump.c
diff -u src/usr.sbin/rtadvd/dump.c:1.11 src/usr.sbin/rtadvd/dump.c:1.12
--- src/usr.sbin/rtadvd/dump.c:1.11	Tue Jul  9 09:34:59 2013
+++ src/usr.sbin/rtadvd/dump.c	Fri Jun  5 14:09:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump.c,v 1.11 2013/07/09 09:34:59 roy Exp $	*/
+/*	$NetBSD: dump.c,v 1.12 2015/06/05 14:09:20 roy Exp $	*/
 /*	$KAME: dump.c,v 1.34 2004/06/14 05:35:59 itojun Exp $	*/
 
 /*
@@ -99,9 +99,9 @@ if_dump(void)
 	struct dnssl_domain *dnsd;
 	char *p, len;
 	char prefixbuf[INET6_ADDRSTRLEN];
-	struct timeval now;
+	struct timespec now;
 
-	gettimeofday(now, NULL); /* XXX: unused in most cases */
+	clock_gettime(CLOCK_MONOTONIC, now); /* XXX: unused in most cases */
 	TAILQ_FOREACH(rai, ralist, next) {
 		fprintf(fp, %s:\n, rai-ifname);
 
@@ -198,7 +198,7 @@ if_dump(void)
 pfx-autoconfflg ? A : ,
 );
 			if (pfx-timer) {
-struct timeval *rest;
+struct timespec *rest;
 
 rest = rtadvd_timer_rest(pfx-timer);
 if (rest) { /* XXX: what if not? */
Index: src/usr.sbin/rtadvd/timer.c
diff -u src/usr.sbin/rtadvd/timer.c:1.11 src/usr.sbin/rtadvd/timer.c:1.12
--- src/usr.sbin/rtadvd/timer.c:1.11	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/timer.c	Fri Jun  5 14:09:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.11 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: timer.c,v 1.12 2015/06/05 14:09:20 roy Exp $	*/
 /*	$KAME: timer.c,v 1.11 2005/04/14 06:22:35 suz Exp $	*/
 
 /*
@@ -33,6 +33,7 @@
 #include sys/queue.h
 #include sys/time.h
 
+#include limits.h
 #include unistd.h
 #include syslog.h
 #include stdlib.h
@@ -41,13 +42,8 @@
 #include timer.h
 
 struct rtadvd_timer_head_t ra_timer = TAILQ_HEAD_INITIALIZER(ra_timer);
-
-#define MILLION 100
-#define TIMEVAL_EQUAL(t1,t2) ((t1)-tv_sec == (t2)-tv_sec \
- (t1)-tv_usec == (t2)-tv_usec)
-
-static struct timeval tm_limit = {0x7fff, 0x7fff};
-static struct timeval tm_max;
+static struct 

CVS commit: src/usr.sbin/rtadvd

2015-06-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun  5 14:15:41 UTC 2015

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

Log Message:
Set the hoplimit of 255 as specified in RFC 4861 section 4.2
using the IPV6_MULTICAST_HOPS socket option rather than using CMSG
when constructing each message.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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.47 src/usr.sbin/rtadvd/rtadvd.c:1.48
--- src/usr.sbin/rtadvd/rtadvd.c:1.47	Fri Jun  5 14:09:20 2015
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Jun  5 14:15:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.47 2015/06/05 14:09:20 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.48 2015/06/05 14:15:41 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1518,6 +1518,14 @@ sock_open(void)
 		exit(1);
 	}
 
+	/* RFC 4861 Section 4.2 */
+	on = 255;
+	if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, on,
+		   sizeof(on)) == -1) {
+		syslog(LOG_ERR, %s IPV6_MULTICAST_HOPS: %m, __func__);
+		exit(1);
+	}
+
 	/* specify to tell receiving interface */
 	on = 1;
 #ifdef IPV6_RECVPKTINFO
@@ -1693,17 +1701,6 @@ ra_output(struct rainfo *rai)
 	memset(pi-ipi6_addr, 0, sizeof(pi-ipi6_addr));	/*XXX*/
 	pi-ipi6_ifindex = rai-ifindex;
 
-	/* specify the hop limit of the packet */
-	{
-		int hoplimit = 255;
-
-		cm = CMSG_NXTHDR(sndmhdr, cm);
-		cm-cmsg_level = IPPROTO_IPV6;
-		cm-cmsg_type = IPV6_HOPLIMIT;
-		cm-cmsg_len = CMSG_LEN(sizeof(int));
-		memcpy(CMSG_DATA(cm), hoplimit, sizeof(int));
-	}
-
 	syslog(LOG_DEBUG,
 	   %s send RA on %s, # of waitings = %d,
 	   __func__, rai-ifname, rai-waiting); 



CVS commit: src/usr.sbin/rtadvd

2015-06-05 Thread Roy Marples
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).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.48 -r1.49 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/advcap.c
diff -u src/usr.sbin/rtadvd/advcap.c:1.14 src/usr.sbin/rtadvd/advcap.c:1.15
--- src/usr.sbin/rtadvd/advcap.c:1.14	Thu Dec 13 15:36:35 2012
+++ src/usr.sbin/rtadvd/advcap.c	Fri Jun  5 15:41:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: advcap.c,v 1.14 2012/12/13 15:36:35 roy Exp $	*/
+/*	$NetBSD: advcap.c,v 1.15 2015/06/05 15:41:59 roy Exp $	*/
 /*	$KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $	*/
 
 /*
@@ -136,8 +136,7 @@ getent(char *bp, char *name, char *cp)
 		tf = open(RM = cp, O_RDONLY);
 	}
 	if (tf  0) {
-		syslog(LOG_INFO,
-		   %s open: %s, __func__, strerror(errno));
+		syslog(LOG_INFO, %s open: %m, __func__);
 		return (-2);
 	}
 	for (;;) {

Index: src/usr.sbin/rtadvd/if.c
diff -u src/usr.sbin/rtadvd/if.c:1.22 src/usr.sbin/rtadvd/if.c:1.23
--- src/usr.sbin/rtadvd/if.c:1.22	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/if.c	Fri Jun  5 15:41:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.22 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: if.c,v 1.23 2015/06/05 15:41:59 roy Exp $	*/
 /*	$KAME: if.c,v 1.36 2004/11/30 22:32:01 suz Exp $	*/
 
 /*
@@ -134,8 +134,7 @@ if_getflags(int ifindex, int oifflags)
 	int s;
 
 	if ((s = socket(AF_INET6, SOCK_DGRAM, 0))  0) {
-		syslog(LOG_ERR, %s socket: %s, __func__,
-		   strerror(errno));
+		syslog(LOG_ERR, %s socket: %m, __func__);
 		return (oifflags  ~IFF_UP);
 	}
 

Index: src/usr.sbin/rtadvd/rrenum.c
diff -u src/usr.sbin/rtadvd/rrenum.c:1.17 src/usr.sbin/rtadvd/rrenum.c:1.18
--- src/usr.sbin/rtadvd/rrenum.c:1.17	Fri Jun  5 14:09:20 2015
+++ src/usr.sbin/rtadvd/rrenum.c	Fri Jun  5 15:41:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rrenum.c,v 1.17 2015/06/05 14:09:20 roy Exp $	*/
+/*	$NetBSD: rrenum.c,v 1.18 2015/06/05 15:41:59 roy Exp $	*/
 /*	$KAME: rrenum.c,v 1.14 2004/06/14 05:36:00 itojun Exp $	*/
 
 /*
@@ -165,8 +165,7 @@ do_use_prefix(int len, struct rr_pco_mat
 		irr-irr_useprefix.sin6_addr = in6addr_any;
 		if (ioctl(s, rrcmd2pco[rpm-rpm_code], irr)  0 
 		errno != EADDRNOTAVAIL)
-			syslog(LOG_ERR, %s ioctl: %s, __func__,
-			   strerror(errno));
+			syslog(LOG_ERR, %s ioctl: %m, __func__);
 		return;
 	}
 
@@ -197,8 +196,7 @@ do_use_prefix(int len, struct rr_pco_mat
 
 		if (ioctl(s, rrcmd2pco[rpm-rpm_code], irr)  0 
 		errno != EADDRNOTAVAIL)
-			syslog(LOG_ERR, %s ioctl: %s, __func__,
-			   strerror(errno));
+			syslog(LOG_ERR, %s ioctl: %m, __func__);
 
 		/* very adhoc: should be rewritten */
 		if (rpm-rpm_code == RPM_PCO_CHANGE 
@@ -252,8 +250,7 @@ do_pco(struct icmp6_router_renum *rr, in
 		return 1;
 
 	if (s == -1  (s = socket(AF_INET6, SOCK_DGRAM, 0))  0) {
-		syslog(LOG_ERR, %s socket: %s, __func__,
-		   strerror(errno));
+		syslog(LOG_ERR, %s socket: %m, __func__);
 		exit(1);
 	}
 
@@ -283,8 +280,7 @@ do_pco(struct icmp6_router_renum *rr, in
 	if (errno == ENXIO)
 		return 0;
 	else if (errno) {
-		syslog(LOG_ERR, %s if_indextoname: %s, __func__,
-		   strerror(errno));
+		syslog(LOG_ERR, %s if_indextoname: %m, __func__);
 		return 1;
 	}
 	return 0;

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.48 src/usr.sbin/rtadvd/rtadvd.c:1.49
--- src/usr.sbin/rtadvd/rtadvd.c:1.48	Fri Jun  5 14:15:41 2015
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Jun  5 15:41:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.48 2015/06/05 14:15:41 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.49 2015/06/05 15:41:59 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -336,8 +336,7 @@ main(int argc, char *argv[])
 		{
 			/* EINTR would occur upon SIGUSR1 for status dump */
 			if (errno != EINTR)
-syslog(LOG_ERR, %s poll: %s,
-__func__, strerror(errno));
+syslog(LOG_ERR, %s poll: %m, __func__);
 			continue;
 		}
 		if (i == 0)	/* timeout */
@@ -1500,7 +1499,7 @@ sock_open(void)
 CMSG_SPACE(sizeof(int));
 	rcvcmsgbuf = malloc(rcvcmsgbuflen);
 	if (rcvcmsgbuf == NULL) {
-		syslog(LOG_ERR, %s not enough core, __func__);
+		syslog(LOG_ERR, %s malloc: %m, __func__);
 		exit(1);
 	}
 
@@ -1508,13 +1507,12 @@ sock_open(void)
 CMSG_SPACE(sizeof(int));
 	sndcmsgbuf = malloc(sndcmsgbuflen);
 	if (sndcmsgbuf == NULL) {
-		syslog(LOG_ERR, %s not enough core, __func__);
+		syslog(LOG_ERR, %s malloc: %m, __func__);
 		exit(1);
 	}
 
 	if ((sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6))  0) {
-		syslog(LOG_ERR, %s socket: %s, __func__,
-		

CVS commit: src/usr.sbin/rtadvd

2014-02-27 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Feb 27 17:43:02 UTC 2014

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

Log Message:
Expect long long to be larger than uint32_t and use llabs after casting
the uint32_t.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 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.45 src/usr.sbin/rtadvd/rtadvd.c:1.46
--- src/usr.sbin/rtadvd/rtadvd.c:1.45	Sun Jan 26 08:31:17 2014
+++ src/usr.sbin/rtadvd/rtadvd.c	Thu Feb 27 17:43:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.45 2014/01/26 08:31:17 plunky Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.46 2014/02/27 17:43:02 joerg Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1249,7 +1249,7 @@ prefix_check(struct nd_opt_prefix_info *
 		preferred_time += now.tv_sec;
 
 		if (!pp-timer  rai-clockskew 
-		abs(preferred_time - pp-pltimeexpire)  rai-clockskew) {
+		llabs((long long)preferred_time - pp-pltimeexpire)  rai-clockskew) {
 			syslog(LOG_INFO,
 			   %s preferred lifetime for %s/%d
 			(decr. in real time) inconsistent on %s:
@@ -1285,7 +1285,7 @@ prefix_check(struct nd_opt_prefix_info *
 		valid_time += now.tv_sec;
 
 		if (!pp-timer  rai-clockskew 
-		abs(valid_time - pp-vltimeexpire)  rai-clockskew) {
+		llabs((long long)valid_time - pp-vltimeexpire)  rai-clockskew) {
 			syslog(LOG_INFO,
 			   %s valid lifetime for %s/%d
 			(decr. in real time) inconsistent on %s:



CVS commit: src/usr.sbin/rtadvd

2014-01-26 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sun Jan 26 08:31:17 UTC 2014

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

Log Message:
spelling correction - recieved - received


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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.44 src/usr.sbin/rtadvd/rtadvd.c:1.45
--- src/usr.sbin/rtadvd/rtadvd.c:1.44	Tue Jul  9 09:34:59 2013
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun Jan 26 08:31:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.44 2013/07/09 09:34:59 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.45 2014/01/26 08:31:17 plunky Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1080,7 +1080,7 @@ ra_input(int len, struct nd_router_adver
 	}
 	if (rai-leaving) {
 		syslog(LOG_DEBUG,
-		   %s recieved RA on re-configuring interface (%s),
+		   %s received RA on re-configuring interface (%s),
 			__func__, rai-ifname);
 		goto done;
 	}



CVS commit: src/usr.sbin/rtadvd

2013-06-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 28 07:59:32 UTC 2013

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

Log Message:
If we die and there are no timers, just exit.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/usr.sbin/rtadvd/rtadvd.c:1.43
--- src/usr.sbin/rtadvd/rtadvd.c:1.42	Thu Jun 27 15:46:40 2013
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Jun 28 07:59:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.42 2013/06/27 15:46:40 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.43 2013/06/28 07:59:32 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -362,6 +362,12 @@ die(void)
 		/* NOT REACHED */
 	}
 
+	if (TAILQ_FIRST(ralist) == NULL) {
+		syslog(LOG_NOTICE, %s gracefully terminated, __func__);
+		exit(0);
+		/* NOT REACHED */
+	}
+
 	waiting = 1;
 	syslog(LOG_NOTICE, %s final RA transmission started, __func__);
 



CVS commit: src/usr.sbin/rtadvd

2013-06-27 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Jun 27 15:46:40 UTC 2013

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

Log Message:
Check valid lengths of RDNSS and DNSSL options when rtadvd receives RA/RS.
rtadvd doesn't actually look into the option itself, but it may do in the
future to warn about consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/usr.sbin/rtadvd/rtadvd.c:1.42
--- src/usr.sbin/rtadvd/rtadvd.c:1.41	Fri Dec 14 09:48:31 2012
+++ src/usr.sbin/rtadvd/rtadvd.c	Thu Jun 27 15:46:40 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.41 2012/12/14 09:48:31 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.42 2013/06/27 15:46:40 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1379,7 +1379,13 @@ nd6_options(struct nd_opt_hdr *hdr, int 
 		if ((hdr-nd_opt_type == ND_OPT_MTU 
 		(optlen != sizeof(struct nd_opt_mtu))) ||
 		((hdr-nd_opt_type == ND_OPT_PREFIX_INFORMATION 
-		optlen != sizeof(struct nd_opt_prefix_info {
+		optlen != sizeof(struct nd_opt_prefix_info))) ||
+		(hdr-nd_opt_type == ND_OPT_RDNSS 
+		((optlen  (int)sizeof(struct nd_opt_rdnss) ||
+		(optlen - sizeof(struct nd_opt_rdnss)) % 16 != 0))) ||
+		(hdr-nd_opt_type == ND_OPT_DNSSL 
+		optlen  (int)sizeof(struct nd_opt_dnssl)))
+		{
 			syslog(LOG_INFO, %s invalid option length,
 			__func__);
 			continue;
@@ -1388,6 +1394,8 @@ nd6_options(struct nd_opt_hdr *hdr, int 
 		switch (hdr-nd_opt_type) {
 		case ND_OPT_TARGET_LINKADDR:
 		case ND_OPT_REDIRECTED_HEADER:
+		case ND_OPT_RDNSS:
+		case ND_OPT_DNSSL:
 			break;	/* we don't care about these options */
 		case ND_OPT_SOURCE_LINKADDR:
 		case ND_OPT_MTU:



CVS commit: src/usr.sbin/rtadvd

2013-05-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri May 17 07:53:05 UTC 2013

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

Log Message:
Fix typo. Reported in PR/47823.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/rtadvd/rrenum.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.15 src/usr.sbin/rtadvd/rrenum.c:1.16
--- src/usr.sbin/rtadvd/rrenum.c:1.15	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/rrenum.c	Fri May 17 07:53:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rrenum.c,v 1.15 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: rrenum.c,v 1.16 2013/05/17 07:53:05 skrll Exp $	*/
 /*	$KAME: rrenum.c,v 1.14 2004/06/14 05:36:00 itojun Exp $	*/
 
 /*
@@ -310,7 +310,7 @@ do_rr(size_t len, struct icmp6_router_re
 		if (len  sizeof(struct rr_pco_match)) {
 		tooshort:
 			syslog(LOG_ERR, %s pkt too short. left len = %zd. 
-			   gabage at end of pkt?, __func__, len);
+			   garbage at end of pkt?, __func__, len);
 			return 1;
 		}
 		rpmlen = rpm-rpm_len  3;



CVS commit: src/usr.sbin/rtadvd

2013-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 24 17:44:59 UTC 2013

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

Log Message:
make it static const


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/usr.sbin/rtadvd/config.c:1.32
--- src/usr.sbin/rtadvd/config.c:1.31	Fri Dec 14 04:48:31 2012
+++ src/usr.sbin/rtadvd/config.c	Thu Jan 24 12:44:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.31 2012/12/14 09:48:31 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.32 2013/01/24 17:44:59 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1308,7 +1308,7 @@ make_packet(struct rainfo *rainfo)
 static int
 getinet6sysctl(int code)
 {
-	int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
+	static const int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
 	int value;
 	size_t size;
 



CVS commit: src/usr.sbin/rtadvd

2013-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 24 19:55:28 UTC 2013

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

Log Message:
fix previous.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/usr.sbin/rtadvd/config.c:1.33
--- src/usr.sbin/rtadvd/config.c:1.32	Thu Jan 24 12:44:59 2013
+++ src/usr.sbin/rtadvd/config.c	Thu Jan 24 14:55:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.32 2013/01/24 17:44:59 christos Exp $	*/
+/*	$NetBSD: config.c,v 1.33 2013/01/24 19:55:28 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -1308,11 +1308,10 @@ make_packet(struct rainfo *rainfo)
 static int
 getinet6sysctl(int code)
 {
-	static const int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 };
+	const int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, code };
 	int value;
 	size_t size;
 
-	mib[3] = code;
 	size = sizeof(value);
 	if (sysctl(mib, __arraycount(mib), value, size, NULL, 0)
 	 0) {



CVS commit: src/usr.sbin/rtadvd

2012-12-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Dec 14 09:48:31 UTC 2012

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

Log Message:
Intsead of forcing out each RA at shutdown and sleeping we now use
the existing timer model and wait for each RA to expire itself after
sending the required number of transmissions.

This allows for a faster and saner shutdown.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.40 -r1.41 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.30 src/usr.sbin/rtadvd/config.c:1.31
--- src/usr.sbin/rtadvd/config.c:1.30	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/config.c	Fri Dec 14 09:48:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.30 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.31 2012/12/14 09:48:31 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -738,8 +738,6 @@ getconfig(const char *intface, int exith
 
 	}
 
-	/* If we are advertising an existing RA configuration,
-	 * expire it */
 	TAILQ_FOREACH(rai, ralist, next) {
 		if (rai-ifindex == tmp-ifindex) {
 			TAILQ_REMOVE(ralist, rai, next);
@@ -759,6 +757,7 @@ getconfig(const char *intface, int exith
 dnssl-lifetime = 0;
 			rai-leaving_for = tmp;
 			tmp-leaving = rai;
+			rai-initcounter = MAX_INITIAL_RTR_ADVERTISEMENTS;
 			rai-mininterval = MIN_DELAY_BETWEEN_RAS;
 			rai-maxinterval = MIN_DELAY_BETWEEN_RAS;
 			rai-leaving_adv = MAX_FINAL_RTR_ADVERTISEMENTS;

Index: src/usr.sbin/rtadvd/rtadvd.c
diff -u src/usr.sbin/rtadvd/rtadvd.c:1.40 src/usr.sbin/rtadvd/rtadvd.c:1.41
--- src/usr.sbin/rtadvd/rtadvd.c:1.40	Thu Dec 13 15:40:05 2012
+++ src/usr.sbin/rtadvd/rtadvd.c	Fri Dec 14 09:48:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.40 2012/12/13 15:40:05 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.41 2012/12/14 09:48:31 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -153,7 +153,7 @@ struct sockaddr_in6 sin6_sitelocal_allro
 };
 
 static void set_die(int);
-static void die(void); // XXX __dead;
+static void die(void);
 static void set_reconf(int);
 static void sock_open(void);
 static void rtsock_open(void);
@@ -260,6 +260,7 @@ main(int argc, char *argv[])
 	} else
 		set[1].fd = -1;
 
+	signal(SIGINT, set_die);
 	signal(SIGTERM, set_die);
 	signal(SIGHUP, set_reconf);
 	signal(SIGUSR1, rtadvd_set_dump_file);
@@ -342,44 +343,53 @@ set_die(__unused int sig)
 static void
 die(void)
 {
-	struct rainfo *rai;
+	static int waiting;
+	struct rainfo *rai, *ran;
 	struct rdnss *rdnss;
 	struct dnssl *dnssl;
-	int i;
-	const int retrans = MAX_FINAL_RTR_ADVERTISEMENTS;
 
-	if (dflag  1) {
-		syslog(LOG_DEBUG, %s cease to be an advertising router\n,
-		__func__);
-	}
-
-	TAILQ_FOREACH(rai, ralist, next) {
+	if (waiting) {
+		if (TAILQ_FIRST(ralist)) {
+			syslog(LOG_INFO,
+			   %s waiting for expiration of all RA timers,
+			   __func__);
+			return;
+		}
+		syslog(LOG_NOTICE, %s gracefully terminated, __func__);
+		free(rcvcmsgbuf);
+		free(sndcmsgbuf);
+		exit(0);
+		/* NOT REACHED */
+	}
+
+	waiting = 1;
+	syslog(LOG_NOTICE, %s final RA transmission started, __func__);
+
+	TAILQ_FOREACH_SAFE(rai, ralist, next, ran) {
+		if (rai-leaving) {
+			TAILQ_REMOVE(ralist, rai, next);
+			TAILQ_INSERT_HEAD(ralist, rai-leaving, next);
+			rai-leaving-leaving = rai-leaving;
+			rai-leaving-leaving_for = rai-leaving;
+			free_rainfo(rai);
+			continue;
+		}
 		rai-lifetime = 0;
 		TAILQ_FOREACH(rdnss, rai-rdnss, next)
 			rdnss-lifetime = 0;
 		TAILQ_FOREACH(dnssl, rai-dnssl, next)
 			dnssl-lifetime = 0;
 		make_packet(rai);
+		rai-leaving = rai;
+		rai-leaving_for = rai;
+		rai-initcounter = MAX_INITIAL_RTR_ADVERTISEMENTS;
+		rai-mininterval = MIN_DELAY_BETWEEN_RAS;
+		rai-maxinterval = MIN_DELAY_BETWEEN_RAS;
+		rai-leaving_adv = MAX_FINAL_RTR_ADVERTISEMENTS;
+		ra_output(rai);
+		ra_timer_update((void *)rai, rai-timer-tm);
+		rtadvd_set_timer(rai-timer-tm, rai-timer);
 	}
-	for (i = 0; i  retrans; i++) {
-		TAILQ_FOREACH(rai, ralist, next)
-			ra_output(rai);
-		sleep(MIN_DELAY_BETWEEN_RAS);
-	}
-
-#ifdef __VALGRIND__
-	while ((rai = TAILQ_FIRST(ralist))) {
-		TAILQ_REMOVE(ralist, rai, next);
-		if (rai-leaving)
-			free_rainfo(rai-leaving);
-		free_rainfo(rai);
-	}
-	free(rcvcmsgbuf);
-	free(sndcmsgbuf);
-#endif
-
-	exit(0);
-	/*NOTREACHED*/
 }
 
 static void
@@ -401,6 +411,11 @@ rtmsg_input(void)
 
 	memset(buffer, 0, sizeof(buffer));
 	n = read(rtsock, buffer, sizeof(buffer));
+
+	/* We read the buffer first to clear the FD */
+	if (do_die)
+		return;
+
 	msg = buffer.data;
 	if (dflag  1) {
 		syslog(LOG_DEBUG, %s received a routing message 
@@ -668,6 +683,10 @@ rtadvd_input(void)
 	if ((i = recvmsg(sock, rcvmhdr, 0))  0)
 		return;
 
+	/* We read the buffer first to clear 

CVS commit: src/usr.sbin/rtadvd

2012-12-13 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Dec 13 15:36:36 UTC 2012

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

Log Message:
Remove the iflist array and store ifflags in rainfo.

Add support for SIGHUP to re-read the configuration for each interface.
If an invalid configuration is found, we continue to use the old one;
otherwise we expire the current one and then start advertising the new one.

Specififed interfaces don't have to exist at startup.
If specified interfaces arrive, load their config and start advertising.
If they depart, remove their rainfo structure and continue.

Fixes PR/43881 and PR/47311


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/rtadvd/advcap.c
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/rtadvd/dump.c src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/rtadvd/rrenum.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/rtadvd/rtadvd.8
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/rtadvd/rtadvd.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/rtadvd/rtadvd.h
cvs rdiff -u -r1.10 -r1.11 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.13 src/usr.sbin/rtadvd/advcap.c:1.14
--- src/usr.sbin/rtadvd/advcap.c:1.13	Sat Dec 10 19:14:29 2011
+++ src/usr.sbin/rtadvd/advcap.c	Thu Dec 13 15:36:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: advcap.c,v 1.13 2011/12/10 19:14:29 roy Exp $	*/
+/*	$NetBSD: advcap.c,v 1.14 2012/12/13 15:36:35 roy Exp $	*/
 /*	$KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $	*/
 
 /*
@@ -47,6 +47,10 @@
 #include string.h
 #include pathnames.h
 
+#ifndef __UNCONST
+#define __UNCONST(a)		((void *)(unsigned long)(const void *)(a))
+#endif
+
 #ifndef BUFSIZ
 #define	BUFSIZ		1024
 #endif

Index: src/usr.sbin/rtadvd/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.29 src/usr.sbin/rtadvd/config.c:1.30
--- src/usr.sbin/rtadvd/config.c:1.29	Tue Dec 11 16:37:23 2012
+++ src/usr.sbin/rtadvd/config.c	Thu Dec 13 15:36:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.29 2012/12/11 16:37:23 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.30 2012/12/13 15:36:36 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -39,6 +39,9 @@
 #include net/if.h
 #include net/route.h
 #include net/if_dl.h
+#ifdef __FreeBSD__
+#include net/if_var.h
+#endif
 
 #include netinet/in.h
 #include netinet/in_var.h
@@ -57,6 +60,7 @@
 #include search.h
 #include unistd.h
 #include ifaddrs.h
+#include inttypes.h
 
 #include rtadvd.h
 #include advcap.h
@@ -64,6 +68,10 @@
 #include if.h
 #include config.h
 
+#ifndef __arraycount
+#define __arraycount(__x)	(sizeof(__x) / sizeof(__x[0]))
+#endif
+
 static time_t prefix_timo = (60 * 120);	/* 2 hours.
 	 * XXX: should be configurable. */
 static struct rtadvd_timer *prefix_timeout(void *);
@@ -92,11 +100,56 @@ encode_domain(char *dst, const char *src
 }
 
 void
-getconfig(const char *intface)
+free_rainfo(struct rainfo *rai)
+{
+	struct prefix *pfx;
+	struct rtinfo *rti;
+	struct rdnss *rdnss;
+	struct rdnss_addr *rdnsa;
+	struct dnssl *dnssl;
+	struct dnssl_domain *dnsd;
+
+	rtadvd_remove_timer(rai-timer);
+
+	while ((pfx = TAILQ_FIRST(rai-prefix))) {
+		TAILQ_REMOVE(rai-prefix, pfx, next);
+		free(pfx);
+	}
+
+	while ((rti = TAILQ_FIRST(rai-route))) {
+		TAILQ_REMOVE(rai-route, rti, next);
+		free(rti);
+	}
+
+	while ((rdnss = TAILQ_FIRST(rai-rdnss))) {
+		TAILQ_REMOVE(rai-rdnss, rdnss, next);
+		while ((rdnsa = TAILQ_FIRST(rdnss-list))) {
+			TAILQ_REMOVE(rdnss-list, rdnsa, next);
+			free(rdnsa);
+		}
+		free(rdnss);
+	}
+
+	while ((dnssl = TAILQ_FIRST(rai-dnssl))) {
+		TAILQ_REMOVE(rai-dnssl, dnssl, next);
+		while ((dnsd = TAILQ_FIRST(dnssl-list))) {
+			TAILQ_REMOVE(dnssl-list, dnsd, next);
+			free(dnsd);
+		}
+		free(dnssl);
+	}
+
+	free(rai-sdl);
+	free(rai-ra_data);
+	free(rai);
+}
+
+void
+getconfig(const char *intface, int exithard)
 {
 	int stat, c, i;
 	char tbuf[BUFSIZ];
-	struct rainfo *tmp;
+	struct rainfo *tmp, *rai;
 	int32_t val;
 	int64_t val64;
 	char buf[BUFSIZ];
@@ -104,6 +157,8 @@ getconfig(const char *intface)
 	char *addr, *flagstr, *ap;
 	static int forwarding = -1;
 	char entbuf[256], abuf[256];
+	struct rdnss *rdnss;
+	struct dnssl *dnssl;
 
 #define MUSTHAVE(var, cap)	\
 do {\
@@ -111,7 +166,7 @@ getconfig(const char *intface)
 	if ((t = agetnum(cap))  0) {	\
 		fprintf(stderr, rtadvd: need %s for interface %s\n,	\
 			cap, intface);	\
-		exit(1);		\
+		goto errexit;		\
 	}\
 	var = t;			\
  } while (0)
@@ -120,16 +175,24 @@ getconfig(const char *intface)
 	if ((var = agetnum(cap))  0)	\
 		var = 

CVS commit: src/usr.sbin/rtadvd

2012-12-13 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Dec 13 15:40:06 UTC 2012

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

Log Message:
Remove debug stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.39 src/usr.sbin/rtadvd/rtadvd.c:1.40
--- src/usr.sbin/rtadvd/rtadvd.c:1.39	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/rtadvd.c	Thu Dec 13 15:40:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.39 2012/12/13 15:36:36 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.40 2012/12/13 15:40:05 roy Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -364,9 +364,10 @@ die(void)
 	for (i = 0; i  retrans; i++) {
 		TAILQ_FOREACH(rai, ralist, next)
 			ra_output(rai);
-		//sleep(MIN_DELAY_BETWEEN_RAS);
+		sleep(MIN_DELAY_BETWEEN_RAS);
 	}
 
+#ifdef __VALGRIND__
 	while ((rai = TAILQ_FIRST(ralist))) {
 		TAILQ_REMOVE(ralist, rai, next);
 		if (rai-leaving)
@@ -375,6 +376,7 @@ die(void)
 	}
 	free(rcvcmsgbuf);
 	free(sndcmsgbuf);
+#endif
 
 	exit(0);
 	/*NOTREACHED*/



CVS commit: src/usr.sbin/rtadvd

2012-12-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Dec 13 21:49:38 UTC 2012

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

Log Message:
Formatting nit.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 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.23 src/usr.sbin/rtadvd/rtadvd.8:1.24
--- src/usr.sbin/rtadvd/rtadvd.8:1.23	Thu Dec 13 15:36:36 2012
+++ src/usr.sbin/rtadvd/rtadvd.8	Thu Dec 13 21:49:38 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: rtadvd.8,v 1.23 2012/12/13 15:36:36 roy Exp $
+.\	$NetBSD: rtadvd.8,v 1.24 2012/12/13 21:49:38 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.
@@ -159,7 +159,7 @@ Only statically configured prefixes, if 
 Use
 .Dv SIGHUP
 to reload the configuration file
-.Pa /etc/rtadvd.conf.
+.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,



CVS commit: src/usr.sbin/rtadvd

2012-12-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Dec 11 16:37:23 UTC 2012

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

Log Message:
Add support for the noifprefix keyword which stops rtadvd(8) gathing prefix
information from the interface if no addrs are present in rtadvd.conf(5).


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.17 -r1.18 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/config.c
diff -u src/usr.sbin/rtadvd/config.c:1.28 src/usr.sbin/rtadvd/config.c:1.29
--- src/usr.sbin/rtadvd/config.c:1.28	Wed Aug  8 04:05:26 2012
+++ src/usr.sbin/rtadvd/config.c	Tue Dec 11 16:37:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.28 2012/08/08 04:05:26 msaitoh Exp $	*/
+/*	$NetBSD: config.c,v 1.29 2012/12/11 16:37:23 roy Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -396,7 +396,7 @@ getconfig(const char *intface)
 now.tv_sec + pfx-preflifetime;
 		}
 	}
-	if (TAILQ_FIRST(tmp-prefix) == NULL)
+	if (TAILQ_FIRST(tmp-prefix) == NULL  !agetflag(noifprefix))
 		get_prefix(tmp);
 
 	MAYHAVE(val64, mtu, 0);

Index: src/usr.sbin/rtadvd/rtadvd.conf.5
diff -u src/usr.sbin/rtadvd/rtadvd.conf.5:1.17 src/usr.sbin/rtadvd/rtadvd.conf.5:1.18
--- src/usr.sbin/rtadvd/rtadvd.conf.5:1.17	Sat Apr 21 12:27:30 2012
+++ src/usr.sbin/rtadvd/rtadvd.conf.5	Tue Dec 11 16:37:23 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: rtadvd.conf.5,v 1.17 2012/04/21 12:27:30 roy Exp $
+.\	$NetBSD: rtadvd.conf.5,v 1.18 2012/12/11 16:37:23 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 April 5, 2012
+.Dd December 11, 2012
 .Dt RTADVD.CONF 5
 .Os
 .Sh NAME
@@ -175,13 +175,30 @@ which will be attached to router adverti
 These items can be omitted, then
 .Nm rtadvd
 will automatically get appropriate prefixes from the kernel's routing table,
-and advertise the prefixes with the default parameters.
+and advertise the prefixes with the default parameters, unless the
+.Cm noifprefix
+flag is specified.
 Keywords other than
 .Cm clockskew
+and
+.Cm noifprefix
 can be augmented with a number, like
 .Dq Li prefix2 ,
 to specify multiple prefixes.
 .Bl -tag -width indent
+.It Cm \noifprefix
+(bool) Specified whether
+.Nm rtadvd
+should gather prefix information from the interface if no
+.Cm addr
+is specified.
+If no
+.Cm addr
+is given, and
+.Cm noifprefix
+is set,
+.Nm rtadvd
+will send RA packets with no prefix information.
 .It Cm \clockskew
 (num) Time skew to adjust link propagation delays and clock skews
 between routers on the link



CVS commit: src/usr.sbin/rtadvd

2012-08-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug  8 04:05:26 UTC 2012

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

Log Message:
Fix a bug that incorrect RA packet is sent if rtadvd.conf exists.
Fixes PR#46580 reported by Takahiro HAYASHI.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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.27 src/usr.sbin/rtadvd/config.c:1.28
--- src/usr.sbin/rtadvd/config.c:1.27	Sun Dec 11 20:44:44 2011
+++ src/usr.sbin/rtadvd/config.c	Wed Aug  8 04:05:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.27 2011/12/11 20:44:44 christos Exp $	*/
+/*	$NetBSD: config.c,v 1.28 2012/08/08 04:05:26 msaitoh Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -290,7 +290,7 @@ getconfig(const char *intface)
 	MAYHAVE(val, clockskew, 0);
 	tmp-clockskew = val;
 
-	tmp-pfxs++;
+	tmp-pfxs = 0;
 	TAILQ_INIT(tmp-prefix);
 	for (i = -1; i  MAXPREFIX; i++) {
 		struct prefix *pfx;
@@ -763,6 +763,7 @@ get_prefix(struct rainfo *rai)
 
 		/* link into chain */
 		TAILQ_INSERT_TAIL(rai-prefix, pp, next);
+		rai-pfxs++;
 	}
 
 	freeifaddrs(ifap);



CVS commit: src/usr.sbin/rtadvd

2011-12-11 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Dec 11 15:25:52 UTC 2011

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

Log Message:
Use __dead. No prototype for main.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/usr.sbin/rtadvd/rtadvd.c:1.37
--- src/usr.sbin/rtadvd/rtadvd.c:1.36	Sat Dec 10 19:14:29 2011
+++ src/usr.sbin/rtadvd/rtadvd.c	Sun Dec 11 15:25:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtadvd.c,v 1.36 2011/12/10 19:14:29 roy Exp $	*/
+/*	$NetBSD: rtadvd.c,v 1.37 2011/12/11 15:25:52 joerg Exp $	*/
 /*	$KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -144,9 +144,8 @@ struct sockaddr_in6 sin6_sitelocal_allro
 	.sin6_addr =	IN6ADDR_SITELOCAL_ALLROUTERS_INIT,
 };
 
-int main(int, char *[]);
 static void set_die(int);
-static void die(void);
+static void die(void) __dead;
 static void sock_open(void);
 static void rtsock_open(void);
 static void rtadvd_input(void);



CVS commit: src/usr.sbin/rtadvd

2011-12-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 11 20:44:44 UTC 2011

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

Log Message:
- sprinkle const
- malloc + memset - calloc
- free + malloc - realloc
- syslog(%s, strerror(errno)) - syslog(%m)


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/rtadvd/config.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/rtadvd/config.h
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/rtadvd/if.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/rtadvd/if.h
cvs rdiff -u -r1.37 -r1.38 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.26 src/usr.sbin/rtadvd/config.c:1.27
--- src/usr.sbin/rtadvd/config.c:1.26	Sat Dec 10 14:14:29 2011
+++ src/usr.sbin/rtadvd/config.c	Sun Dec 11 15:44:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.c,v 1.26 2011/12/10 19:14:29 roy Exp $	*/
+/*	$NetBSD: config.c,v 1.27 2011/12/11 20:44:44 christos Exp $	*/
 /*	$KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $	*/
 
 /*
@@ -92,8 +92,7 @@ encode_domain(char *dst, const char *src
 }
 
 void
-getconfig(intface)
-	char *intface;
+getconfig(const char *intface)
 {
 	int stat, c, i;
 	char tbuf[BUFSIZ];
@@ -123,14 +122,13 @@ getconfig(intface)
  } while (0)
 #define	ELM_MALLOC(p,error_action)	\
 	do {\
-		p = malloc(sizeof(*p));	\
+		p = calloc(1, sizeof(*p));\
 		if (p == NULL) {	\
-			syslog(LOG_ERR, %s malloc failed: %s,	\
-			__func__, strerror(errno));			\
+			syslog(LOG_ERR, %s calloc failed: %m,	\
+			__func__);	\
 			error_action;	\
 		}			\
-		memset(p, 0, sizeof(*p));\
-	} while(0)
+	} while(/*CONSTCOND*/0)
 
 
 	if ((stat = agetent(tbuf, intface)) = 0) {
@@ -143,7 +141,6 @@ getconfig(intface)
 	}
 
 	ELM_MALLOC(tmp, exit(1));
-	memset(tmp, 0, sizeof(*tmp));
 
 	/* check if we are allowed to forward packets (if not determined) */
 	if (forwarding  0) {
@@ -304,13 +301,12 @@ getconfig(intface)
 			continue;
 
 		/* allocate memory to store prefix information */
-		if ((pfx = malloc(sizeof(struct prefix))) == NULL) {
+		if ((pfx = calloc(1, sizeof(*pfx))) == NULL) {
 			syslog(LOG_ERR,
-			   %s can't allocate enough memory,
+			   %s can't allocate memory: %m,
 			   __func__);
 			exit(1);
 		}
-		memset(pfx, 0, sizeof(*pfx));
 
 		TAILQ_INSERT_TAIL(tmp-prefix, pfx, next);
 		tmp-pfxs++;
@@ -433,15 +429,14 @@ getconfig(intface)
 		int s;
 
 		if ((s = socket(AF_INET6, SOCK_DGRAM, 0))  0) {
-			syslog(LOG_ERR, %s socket: %s, __func__,
-			   strerror(errno));
+			syslog(LOG_ERR, %s socket: %m, __func__);
 			exit(1);
 		}
 		memset(ndi, 0, sizeof(ndi));
 		strncpy(ndi.ifname, intface, IFNAMSIZ);
 		if (ioctl(s, SIOCGIFINFO_IN6, ndi)  0) {
-			syslog(LOG_INFO, %s ioctl:SIOCGIFINFO_IN6 at %s: %s,
-			 __func__, intface, strerror(errno));
+			syslog(LOG_INFO, %s ioctl:SIOCGIFINFO_IN6 at %s: %m,
+			 __func__, intface);
 		}
 
 		/* reflect the RA info to the host variables in kernel */
@@ -449,8 +444,8 @@ getconfig(intface)
 		ndi.ndi.retrans = tmp-retranstimer;
 		ndi.ndi.basereachable = tmp-reachabletime;
 		if (ioctl(s, SIOCSIFINFO_IN6, ndi)  0) {
-			syslog(LOG_INFO, %s ioctl:SIOCSIFINFO_IN6 at %s: %s,
-			 __func__, intface, strerror(errno));
+			syslog(LOG_INFO, %s ioctl:SIOCSIFINFO_IN6 at %s: %m,
+			 __func__, intface);
 		}
 		close(s);
 	}
@@ -730,13 +725,12 @@ get_prefix(struct rainfo *rai)
 		}
 
 		/* allocate memory to store prefix info. */
-		if ((pp = malloc(sizeof(*pp))) == NULL) {
+		if ((pp = calloc(1, sizeof(*pp))) == NULL) {
 			syslog(LOG_ERR,
 			   %s can't get allocate buffer for prefix,
 			   __func__);
 			exit(1);
 		}
-		memset(pp, 0, sizeof(*pp));
 
 		/* set prefix, sweep bits outside of prefixlen */
 		pp-prefixlen = plen;
@@ -797,12 +791,11 @@ add_prefix(struct rainfo *rai, struct in
 	struct prefix *prefix;
 	char ntopbuf[INET6_ADDRSTRLEN];
 
-	if ((prefix = malloc(sizeof(*prefix))) == NULL) {
+	if ((prefix = calloc(1, sizeof(*prefix))) == NULL) {
 		syslog(LOG_ERR, %s memory allocation failed,
 		   __func__);
 		return;		/* XXX: error or exit? */
 	}
-	memset(prefix, 0, sizeof(*prefix));
 	prefix-prefix = ipr-ipr_prefix.sin6_addr;
 	prefix-prefixlen = ipr-ipr_plen;
 	prefix-validlifetime = ipr-ipr_vltime;
@@ -924,14 +917,12 @@ init_prefix(struct in6_prefixreq *ipr)
 	int s;
 
 	if ((s = socket(AF_INET6, SOCK_DGRAM, 0))  0) {
-		syslog(LOG_ERR, %s socket: %s, __func__,
-		   strerror(errno));
+		syslog(LOG_ERR, %s socket: %m, __func__);
 		exit(1);
 	}
 
 	if (ioctl(s, SIOCGIFPREFIX_IN6, ipr)  0) {
-		syslog(LOG_INFO, %s ioctl:SIOCGIFPREFIX %s, __func__,
-		   strerror(errno));
+		syslog(LOG_INFO, %s ioctl:SIOCGIFPREFIX: %m, __func__);
 
 		ipr-ipr_vltime = DEF_ADVVALIDLIFETIME;
 		ipr-ipr_pltime = DEF_ADVPREFERREDLIFETIME;
@@ 

CVS commit: src/usr.sbin/rtadvd

2011-12-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Dec 12 01:11:33 UTC 2011

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

Log Message:
Use RT_ADVANCE when available.
Fixes PR/44838


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/rtadvd/if.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/if.c
diff -u src/usr.sbin/rtadvd/if.c:1.20 src/usr.sbin/rtadvd/if.c:1.21
--- src/usr.sbin/rtadvd/if.c:1.20	Sun Dec 11 20:44:44 2011
+++ src/usr.sbin/rtadvd/if.c	Mon Dec 12 01:11:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.20 2011/12/11 20:44:44 christos Exp $	*/
+/*	$NetBSD: if.c,v 1.21 2011/12/12 01:11:33 roy Exp $	*/
 /*	$KAME: if.c,v 1.36 2004/11/30 22:32:01 suz Exp $	*/
 
 /*
@@ -50,13 +50,11 @@
 #include rtadvd.h
 #include if.h
 
-#define ROUNDUP(a, size) \
-	(((a)  ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a))
-
-#define NEXT_SA(ap) (ap) = (struct sockaddr *) \
-	((char *)(ap) + ((ap)-sa_len ? ROUNDUP((ap)-sa_len,\
-		 sizeof(u_long)) :\
-			  			 sizeof(u_long)))
+#ifndef RT_ROUNDUP
+#define RT_ROUNDUP(a)			   \
+	((a)  0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+#define RT_ADVANCE(x, n) (x += RT_ROUNDUP((n)-sa_len))
+#endif
 
 struct if_msghdr **iflist;
 int iflist_init_ok;
@@ -75,7 +73,7 @@ get_rtaddrs(int addrs, struct sockaddr *
 	for (i = 0; i  RTAX_MAX; i++) {
 		if (addrs  (1  i)) {
 			rti_info[i] = sa;
-			NEXT_SA(sa);
+			RT_ADVANCE(sa, sa);
 		}
 		else
 			rti_info[i] = NULL;



CVS commit: src/usr.sbin/rtadvd

2011-04-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Apr 28 12:12:47 UTC 2011

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

Log Message:
Sort sections.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.21 src/usr.sbin/rtadvd/rtadvd.8:1.22
--- src/usr.sbin/rtadvd/rtadvd.8:1.21	Sun Mar  5 23:47:08 2006
+++ src/usr.sbin/rtadvd/rtadvd.8	Thu Apr 28 12:12:47 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: rtadvd.8,v 1.21 2006/03/05 23:47:08 rpaulo Exp $
+.\	$NetBSD: rtadvd.8,v 1.22 2011/04/28 12:12:47 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.
@@ -171,8 +171,6 @@
 will transmit router advertisement with router lifetime 0
 to all the interfaces
 .Pq in accordance with RFC 2461 6.2.5 .
-.Sh EXIT STATUS
-.Ex -std rtadvd
 .Sh FILES
 .Bl -tag -width /var/run/rtadvd.dumpXX -compact
 .It Pa /etc/rtadvd.conf
@@ -185,6 +183,8 @@
 .Nm
 dumps its internal state.
 .El
+.Sh EXIT STATUS
+.Ex -std rtadvd
 .Sh SEE ALSO
 .Xr rtadvd.conf 5 ,
 .Xr rtsol 8



CVS commit: src/usr.sbin/rtadvd

2009-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 31 22:32:51 UTC 2009

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

Log Message:
add -DROUTEINFO


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/usr.sbin/rtadvd/Makefile:1.14
--- src/usr.sbin/rtadvd/Makefile:1.13	Wed Apr 22 11:23:07 2009
+++ src/usr.sbin/rtadvd/Makefile	Sat Oct 31 18:32:51 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2009/04/22 15:23:07 lukem Exp $
+# $NetBSD: Makefile,v 1.14 2009/10/31 22:32:51 christos Exp $
 
 WARNS?=	2	# XXX -Wcast-qual -Wsign-compare
 
@@ -9,7 +9,7 @@
 PROG=	rtadvd
 SRCS=	rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
 
-CPPFLAGS+=-DINET6
+CPPFLAGS+=-DINET6 -DROUTEINFO
 MAN=	rtadvd.8 rtadvd.conf.5
 LDADD+=	-lutil
 DPADD+=	${LIBUTIL}