Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Introduce rump.rtadvd



details:   https://anonhg.NetBSD.org/src/rev/8d37eae05f50
branches:  trunk
changeset: 811688:8d37eae05f50
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Nov 11 07:48:41 2015 +0000

description:
Introduce rump.rtadvd

It is used to write ATF tests for RA.

>From s-yamaguchi@IIJ.

diffstat:

 distrib/sets/lists/base/mi       |   3 +-
 distrib/sets/lists/debug/mi      |   3 +-
 usr.sbin/rtadvd/Makefile         |  25 +++++++----
 usr.sbin/rtadvd/advcap.c         |  11 ++--
 usr.sbin/rtadvd/config.c         |  27 ++++++------
 usr.sbin/rtadvd/dump.c           |   5 +-
 usr.sbin/rtadvd/if.c             |  17 ++++---
 usr.sbin/rtadvd/prog_ops.h       |  84 ++++++++++++++++++++++++++++++++++++++++
 usr.sbin/rtadvd/rrenum.c         |  13 +++--
 usr.sbin/rtadvd/rtadvd.c         |  55 ++++++++++++++-----------
 usr.sbin/rtadvd/rtadvd_hostops.c |  40 +++++++++++++++++++
 usr.sbin/rtadvd/rtadvd_rumpops.c |  45 +++++++++++++++++++++
 usr.sbin/rtadvd/timer.c          |   9 ++-
 13 files changed, 263 insertions(+), 74 deletions(-)

diffs (truncated from 835 to 300 lines):

diff -r 85d51221af27 -r 8d37eae05f50 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Wed Nov 11 06:53:36 2015 +0000
+++ b/distrib/sets/lists/base/mi        Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1116 2015/11/08 20:00:22 christos Exp $
+# $NetBSD: mi,v 1.1117 2015/11/11 07:48:41 ozaki-r Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -1828,6 +1828,7 @@
 ./usr/sbin/rpc.yppasswdd                       base-nis-bin            yp
 ./usr/sbin/rpcbind                             base-rpcbind-bin
 ./usr/sbin/rtadvd                              base-router-bin         use_inet6
+./usr/sbin/rump.rtadvd                         base-router-bin         use_inet6,rump
 ./usr/sbin/rtquery                             base-netutil-bin
 ./usr/sbin/rtsold                              base-obsolete           obsolete
 ./usr/sbin/rump.arp                            base-netutil-bin        rump
diff -r 85d51221af27 -r 8d37eae05f50 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Wed Nov 11 06:53:36 2015 +0000
+++ b/distrib/sets/lists/debug/mi       Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.133 2015/11/08 20:00:22 christos Exp $
+# $NetBSD: mi,v 1.134 2015/11/11 07:48:41 ozaki-r Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -1199,6 +1199,7 @@
 ./usr/libdata/debug/usr/sbin/rpc.yppasswdd.debug       comp-nis-debug          yp,debug
 ./usr/libdata/debug/usr/sbin/rpcbind.debug     comp-rpcbind-debug      debug
 ./usr/libdata/debug/usr/sbin/rtadvd.debug      comp-router-debug       use_inet6,debug
+./usr/libdata/debug/usr/sbin/rump.rtadvd.debug comp-router-debug       use_inet6,debug,rump
 ./usr/libdata/debug/usr/sbin/rtquery.debug     comp-netutil-debug      debug
 ./usr/libdata/debug/usr/sbin/rtsold.debug      comp-obsolete           obsolete
 ./usr/libdata/debug/usr/sbin/rump.arp.debug    comp-netutil-debug      debug,rump
diff -r 85d51221af27 -r 8d37eae05f50 usr.sbin/rtadvd/Makefile
--- a/usr.sbin/rtadvd/Makefile  Wed Nov 11 06:53:36 2015 +0000
+++ b/usr.sbin/rtadvd/Makefile  Wed Nov 11 07:48:41 2015 +0000
@@ -1,24 +1,31 @@
-# $NetBSD: Makefile,v 1.17 2012/08/10 12:10:30 joerg Exp $
+# $NetBSD: Makefile,v 1.18 2015/11/11 07:48:41 ozaki-r Exp $
 
 WARNS?=        4
 
 .include <bsd.own.mk>
 
-USE_FORT?= yes # network server
-
-PROG=  rtadvd
-SRCS=  rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
+USE_FORT?=     yes     # network server
 
-CPPFLAGS+=-DINET6
-MAN=   rtadvd.8 rtadvd.conf.5
-LDADD+=        -lutil
-DPADD+=        ${LIBUTIL}
+RUMPPRG=       rtadvd
+SRCS=          rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
+MAN=           rtadvd.8 rtadvd.conf.5
+
+CPPFLAGS+=     -DINET6
+LDADD+=                -lutil
+DPADD+=                ${LIBUTIL}
 
 .if ${MKSHARE} != "no"
 FILESDIR=      /usr/share/examples/rtadvd
 FILES= rtadvd.conf
 .endif
 
+.PATH: ${.CURDIR}/../../lib/libc/net
+RUMPSRCS=      getifaddrs.c getnameinfo.c if_indextoname.c if_nametoindex.c
+.if (${MKRUMP} != "no")
+CPPFLAGS+=     -DRUMP_ACTION
+.endif
+
+
 .include <bsd.prog.mk>
 
 .if defined(HAVE_GCC) || defined(HAVE_LLVM)
diff -r 85d51221af27 -r 8d37eae05f50 usr.sbin/rtadvd/advcap.c
--- a/usr.sbin/rtadvd/advcap.c  Wed Nov 11 06:53:36 2015 +0000
+++ b/usr.sbin/rtadvd/advcap.c  Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advcap.c,v 1.15 2015/06/05 15:41:59 roy Exp $  */
+/*     $NetBSD: advcap.c,v 1.16 2015/11/11 07:48:41 ozaki-r Exp $      */
 /*     $KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $        */
 
 /*
@@ -46,6 +46,7 @@
 #include <errno.h>
 #include <string.h>
 #include "pathnames.h"
+#include "prog_ops.h"
 
 #ifndef __UNCONST
 #define __UNCONST(a)           ((void *)(unsigned long)(const void *)(a))
@@ -159,7 +160,7 @@
                                break;
                        }
                        if (cp >= bp + BUFSIZ) {
-                               write(2,"Remcap entry too long\n", 23);
+                               prog_write(2,"Remcap entry too long\n", 23);
                                break;
                        } else
                                *cp++ = c;
@@ -195,7 +196,7 @@
        p = tbuf + strlen(tbuf) - 2;    /* before the last colon */
        while (*--p != ':')
                if (p < tbuf) {
-                       write(2, "Bad remcap entry\n", 18);
+                       prog_write(2, "Bad remcap entry\n", 18);
                        return (0);
                }
        p++;
@@ -208,7 +209,7 @@
                q++;
        *q = 0;
        if (++hopcount > MAXHOP) {
-               write(2, "Infinite tc= loop\n", 18);
+               prog_write(2, "Infinite tc= loop\n", 18);
                return (0);
        }
        if (getent(tcbuf, tcname, remotefile) != 1) {
@@ -218,7 +219,7 @@
                ;
        l = p - holdtbuf + strlen(q);
        if (l > BUFSIZ) {
-               write(2, "Remcap entry too long\n", 23);
+               prog_write(2, "Remcap entry too long\n", 23);
                q[BUFSIZ - (p-holdtbuf)] = 0;
        }
        strcpy(p, q);
diff -r 85d51221af27 -r 8d37eae05f50 usr.sbin/rtadvd/config.c
--- a/usr.sbin/rtadvd/config.c  Wed Nov 11 06:53:36 2015 +0000
+++ b/usr.sbin/rtadvd/config.c  Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.c,v 1.34 2015/06/05 14:09:20 roy Exp $  */
+/*     $NetBSD: config.c,v 1.35 2015/11/11 07:48:41 ozaki-r 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 "prog_ops.h"
 
 #ifndef __arraycount
 #define __arraycount(__x)      (sizeof(__x) / sizeof(__x[0]))
@@ -445,7 +446,7 @@
                makeentry(entbuf, sizeof(entbuf), i, "vltimedecr");
                if (agetflag(entbuf)) {
                        struct timespec now;
-                       clock_gettime(CLOCK_MONOTONIC, &now);
+                       prog_clock_gettime(CLOCK_MONOTONIC, &now);
                        pfx->vltimeexpire =
                                now.tv_sec + pfx->validlifetime;
                }
@@ -465,7 +466,7 @@
                makeentry(entbuf, sizeof(entbuf), i, "pltimedecr");
                if (agetflag(entbuf)) {
                        struct timespec now;
-                       clock_gettime(CLOCK_MONOTONIC, &now);
+                       prog_clock_gettime(CLOCK_MONOTONIC, &now);
                        pfx->pltimeexpire =
                                now.tv_sec + pfx->preflifetime;
                }
@@ -502,13 +503,13 @@
                struct in6_ndireq ndi;
                int s;
 
-               if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+               if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
                        syslog(LOG_ERR, "<%s> socket: %m", __func__);
                        goto errexit;
                }
                memset(&ndi, 0, sizeof(ndi));
                strncpy(ndi.ifname, intface, IFNAMSIZ);
-               if (ioctl(s, SIOCGIFINFO_IN6, &ndi) < 0) {
+               if (prog_ioctl(s, SIOCGIFINFO_IN6, &ndi) < 0) {
                        syslog(LOG_INFO, "<%s> ioctl:SIOCGIFINFO_IN6 at %s: %m",
                             __func__, intface);
                }
@@ -517,11 +518,11 @@
                ndi.ndi.chlim = tmp->hoplimit;
                ndi.ndi.retrans = tmp->retranstimer;
                ndi.ndi.basereachable = tmp->reachabletime;
-               if (ioctl(s, SIOCSIFINFO_IN6, &ndi) < 0) {
+               if (prog_ioctl(s, SIOCSIFINFO_IN6, &ndi) < 0) {
                        syslog(LOG_INFO, "<%s> ioctl:SIOCSIFINFO_IN6 at %s: %m",
                             __func__, intface);
                }
-               close(s);
+               prog_close(s);
        }
 #endif
 
@@ -1027,12 +1028,12 @@
 #if 0
        int s;
 
-       if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+       if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
                syslog(LOG_ERR, "<%s> socket: %m", __func__);
                exit(1);
        }
 
-       if (ioctl(s, SIOCGIFPREFIX_IN6, ipr) < 0) {
+       if (prog_ioctl(s, SIOCGIFPREFIX_IN6, ipr) < 0) {
                syslog(LOG_INFO, "<%s> ioctl:SIOCGIFPREFIX: %m", __func__);
 
                ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
@@ -1049,11 +1050,11 @@
                       "This should not happen if I am router", __func__,
                       inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf,
                                 sizeof(ntopbuf)), ipr->ipr_origin);
-               close(s);
+               prog_close(s);
                return 1;
        }
 
-       close(s);
+       prog_close(s);
        return 0;
 #else
        ipr->ipr_vltime = DEF_ADVVALIDLIFETIME;
@@ -1218,7 +1219,7 @@
                        vltime = 0;
                else {
                        if (pfx->vltimeexpire || pfx->pltimeexpire)
-                               clock_gettime(CLOCK_MONOTONIC, &now);
+                               prog_clock_gettime(CLOCK_MONOTONIC, &now);
                        if (pfx->vltimeexpire == 0)
                                vltime = pfx->validlifetime;
                        else
@@ -1313,7 +1314,7 @@
        size_t size;
 
        size = sizeof(value);
-       if (sysctl(mib, __arraycount(mib), &value, &size, NULL, 0)
+       if (prog_sysctl(mib, __arraycount(mib), &value, &size, NULL, 0)
            < 0) {
                syslog(LOG_ERR, "<%s>: failed to get ip6 sysctl(%d): %m",
                       __func__, code);
diff -r 85d51221af27 -r 8d37eae05f50 usr.sbin/rtadvd/dump.c
--- a/usr.sbin/rtadvd/dump.c    Wed Nov 11 06:53:36 2015 +0000
+++ b/usr.sbin/rtadvd/dump.c    Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dump.c,v 1.12 2015/06/05 14:09:20 roy Exp $    */
+/*     $NetBSD: dump.c,v 1.13 2015/11/11 07:48:41 ozaki-r Exp $        */
 /*     $KAME: dump.c,v 1.34 2004/06/14 05:35:59 itojun Exp $   */
 
 /*
@@ -59,6 +59,7 @@
 #include "timer.h"
 #include "if.h"
 #include "dump.h"
+#include "prog_ops.h"
 
 static FILE *fp;
 
@@ -101,7 +102,7 @@
        char prefixbuf[INET6_ADDRSTRLEN];
        struct timespec now;
 
-       clock_gettime(CLOCK_MONOTONIC, &now); /* XXX: unused in most cases */
+       prog_clock_gettime(CLOCK_MONOTONIC, &now); /* XXX: unused in most cases */
        TAILQ_FOREACH(rai, &ralist, next) {
                fprintf(fp, "%s:\n", rai->ifname);
 
diff -r 85d51221af27 -r 8d37eae05f50 usr.sbin/rtadvd/if.c
--- a/usr.sbin/rtadvd/if.c      Wed Nov 11 06:53:36 2015 +0000
+++ b/usr.sbin/rtadvd/if.c      Wed Nov 11 07:48:41 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.23 2015/06/05 15:41:59 roy Exp $      */
+/*     $NetBSD: if.c,v 1.24 2015/11/11 07:48:41 ozaki-r Exp $  */
 /*     $KAME: if.c,v 1.36 2004/11/30 22:32:01 suz Exp $        */
 
 /*
@@ -55,6 +55,7 @@
 
 #include "rtadvd.h"
 #include "if.h"
+#include "prog_ops.h"
 
 #ifndef RT_ROUNDUP
 #define RT_ROUNDUP(a)                                                         \
@@ -111,17 +112,17 @@
        struct ifreq ifr;
        int s, mtu;
 
-       if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+       if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
                return 0;
 
        memset(&ifr, 0, sizeof(ifr));
        ifr.ifr_addr.sa_family = AF_INET6;
        strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
-       if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
+       if (prog_ioctl(s, SIOCGIFMTU, &ifr) != -1)
                mtu = ifr.ifr_mtu;



Home | Main Index | Thread Index | Old Index