Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Introduce rump.ping6
details: https://anonhg.NetBSD.org/src/rev/48a380e10fe3
branches: trunk
changeset: 339728:48a380e10fe3
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Aug 06 14:45:54 2015 +0000
description:
Introduce rump.ping6
We use ping6 frequently in ATF tests so let's have rump-ified one.
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/debug/mi | 3 +-
sbin/ping6/Makefile | 30 +++++++++-----
sbin/ping6/ping6.c | 94 +++++++++++++++++++++++---------------------
sbin/ping6/ping6_hostops.c | 55 ++++++++++++++++++++++++++
sbin/ping6/ping6_rumpops.c | 60 ++++++++++++++++++++++++++++
sbin/ping6/prog_ops.h | 86 +++++++++++++++++++++++++++++++++++++++++
7 files changed, 274 insertions(+), 57 deletions(-)
diffs (truncated from 626 to 300 lines):
diff -r 89aa0eab8d09 -r 48a380e10fe3 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Thu Aug 06 10:22:34 2015 +0000
+++ b/distrib/sets/lists/base/mi Thu Aug 06 14:45:54 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1107 2015/08/03 09:51:40 ozaki-r Exp $
+# $NetBSD: mi,v 1.1108 2015/08/06 14:45:54 ozaki-r Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -549,6 +549,7 @@
./sbin/rump.modstat base-sysutil-root rump
./sbin/rump.modunload base-sysutil-root rump
./sbin/rump.ping base-netutil-root rump
+./sbin/rump.ping6 base-netutil-root inet6,rump
./sbin/rump.raidctl base-sysutil-root rump
./sbin/rump.route base-netutil-root rump
./sbin/rump.sysctl base-sysutil-root rump
diff -r 89aa0eab8d09 -r 48a380e10fe3 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Thu Aug 06 10:22:34 2015 +0000
+++ b/distrib/sets/lists/debug/mi Thu Aug 06 14:45:54 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.123 2015/08/03 09:51:40 ozaki-r Exp $
+# $NetBSD: mi,v 1.124 2015/08/06 14:45:54 ozaki-r Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
@@ -396,6 +396,7 @@
./usr/libdata/debug/sbin/rump.modstat.debug comp-sysutil-debug debug,rump
./usr/libdata/debug/sbin/rump.modunload.debug comp-sysutil-debug debug,rump
./usr/libdata/debug/sbin/rump.ping.debug comp-netutil-debug debug,rump
+./usr/libdata/debug/sbin/rump.ping6.debug comp-netutil-debug inet6,debug,rump
./usr/libdata/debug/sbin/rump.raidctl.debug comp-sysutil-debug debug,rump
./usr/libdata/debug/sbin/rump.route.debug comp-netutil-debug debug,rump
./usr/libdata/debug/sbin/rump.sysctl.debug comp-sysutil-debug debug,rump
diff -r 89aa0eab8d09 -r 48a380e10fe3 sbin/ping6/Makefile
--- a/sbin/ping6/Makefile Thu Aug 06 10:22:34 2015 +0000
+++ b/sbin/ping6/Makefile Thu Aug 06 14:45:54 2015 +0000
@@ -1,16 +1,24 @@
-# $NetBSD: Makefile,v 1.14 2011/08/14 12:09:35 christos Exp $
+# $NetBSD: Makefile,v 1.15 2015/08/06 14:45:54 ozaki-r Exp $
+
+.include <bsd.own.mk>
-USE_FORT?= yes # setuid
-PROG= ping6
-MAN= ping6.8
+USE_FORT?= yes # setuid
+RUMPPRG= ping6
+MAN= ping6.8
+
+BINOWN= root
+BINMODE= 4555
-BINOWN= root
-BINMODE=4555
+CPPFLAGS+= -DINET6
+CPPFLAGS+= -DIPSEC
+
+LDADD+= -lipsec -lm
+DPADD+= ${LIBIPSEC} ${LIBM}
-CPPFLAGS+=-DINET6
-CPPFLAGS+=-DIPSEC
-
-LDADD+= -lipsec -lm
-DPADD+= ${LIBIPSEC} ${LIBM}
+.PATH: ${.CURDIR}/../../lib/libc/net
+RUMPSRCS= getnameinfo.c
+.if (${MKRUMP} != "no")
+CPPFLAGS+= -DRUMP_ACTION
+.endif
.include <bsd.prog.mk>
diff -r 89aa0eab8d09 -r 48a380e10fe3 sbin/ping6/ping6.c
--- a/sbin/ping6/ping6.c Thu Aug 06 10:22:34 2015 +0000
+++ b/sbin/ping6/ping6.c Thu Aug 06 14:45:54 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ping6.c,v 1.87 2015/05/15 08:02:39 kefren Exp $ */
+/* $NetBSD: ping6.c,v 1.88 2015/08/06 14:45:54 ozaki-r Exp $ */
/* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
/*
@@ -77,7 +77,7 @@
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ping6.c,v 1.87 2015/05/15 08:02:39 kefren Exp $");
+__RCSID("$NetBSD: ping6.c,v 1.88 2015/08/06 14:45:54 ozaki-r Exp $");
#endif
#endif
@@ -139,6 +139,8 @@
#include <md5.h>
+#include "prog_ops.h"
+
struct tv32 {
u_int32_t tv32_sec;
u_int32_t tv32_usec;
@@ -332,6 +334,10 @@
#define ADDOPTS "AE"
#endif /*IPSEC_POLICY_IPSEC*/
#endif
+
+ if (prog_init && prog_init() == -1)
+ err(EXIT_FAILURE, "init failed");
+
while ((ch = getopt(argc, argv,
"a:b:c:dfHg:h:I:i:l:mnNop:qRS:s:tvwWx:X:" ADDOPTS)) != -1) {
#undef ADDOPTS
@@ -403,7 +409,7 @@
options |= F_SO_DEBUG;
break;
case 'f':
- if (getuid()) {
+ if (prog_getuid()) {
errno = EPERM;
errx(1, "Must be superuser to flood ping");
}
@@ -435,7 +441,7 @@
intval = strtod(optarg, &e);
if (*optarg == '\0' || *e != '\0')
errx(1, "illegal timing interval %s", optarg);
- if (intval < 1 && getuid()) {
+ if (intval < 1 && prog_getuid()) {
errx(1, "%s: only root may use interval < 1s",
strerror(EPERM));
}
@@ -452,7 +458,7 @@
options |= F_INTERVAL;
break;
case 'l':
- if (getuid()) {
+ if (prog_getuid()) {
errno = EPERM;
errx(1, "Must be superuser to preload");
}
@@ -624,7 +630,7 @@
(void)memcpy(&dst, res->ai_addr, res->ai_addrlen);
- if ((s = socket(res->ai_family, res->ai_socktype,
+ if ((s = prog_socket(res->ai_family, res->ai_socktype,
res->ai_protocol)) < 0)
err(1, "socket");
@@ -652,7 +658,7 @@
if (gres->ai_next && (options & F_VERBOSE))
warnx("gateway resolves to multiple addresses");
- if (setsockopt(s, IPPROTO_IPV6, IPV6_NEXTHOP,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_NEXTHOP,
gres->ai_addr, gres->ai_addrlen)) {
err(1, "setsockopt(IPV6_NEXTHOP)");
}
@@ -668,33 +674,33 @@
int opton = 1;
#ifdef IPV6_RECVHOPOPTS
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_RECVHOPOPTS)");
#else /* old adv. API */
- if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPOPTS, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_HOPOPTS, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_HOPOPTS)");
#endif
#ifdef IPV6_RECVDSTOPTS
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_RECVDSTOPTS)");
#else /* old adv. API */
- if (setsockopt(s, IPPROTO_IPV6, IPV6_DSTOPTS, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_DSTOPTS, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_DSTOPTS)");
#endif
#ifdef IPV6_RECVRTHDRDSTOPTS
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_RECVRTHDRDSTOPTS)");
#endif
}
/* revoke root privilege */
- seteuid(getuid());
- setuid(getuid());
+ prog_seteuid(prog_getuid());
+ prog_setuid(prog_getuid());
if ((options & F_FLOOD) && (options & F_INTERVAL))
errx(1, "-f and -i incompatible options");
@@ -733,25 +739,25 @@
hold = 1;
if (options & F_SO_DEBUG)
- (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
+ (void)prog_setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
sizeof(hold));
optval = IPV6_DEFHLIM;
if (IN6_IS_ADDR_MULTICAST(&dst.sin6_addr))
- if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
&optval, sizeof(optval)) == -1)
err(1, "IPV6_MULTICAST_HOPS");
#ifdef IPV6_USE_MIN_MTU
if (mflag != 1) {
optval = mflag > 1 ? 0 : 1;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_USE_MIN_MTU,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_USE_MIN_MTU,
&optval, sizeof(optval)) == -1)
err(1, "setsockopt(IPV6_USE_MIN_MTU)");
}
#ifdef IPV6_RECVPATHMTU
else {
optval = 1;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPATHMTU,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RECVPATHMTU,
&optval, sizeof(optval)) == -1)
err(1, "setsockopt(IPV6_RECVPATHMTU)");
}
@@ -770,18 +776,18 @@
if (options & F_AUTHHDR) {
optval = IPSEC_LEVEL_REQUIRE;
#ifdef IPV6_AUTH_TRANS_LEVEL
- if (setsockopt(s, IPPROTO_IPV6, IPV6_AUTH_TRANS_LEVEL,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_AUTH_TRANS_LEVEL,
&optval, sizeof(optval)) == -1)
err(1, "setsockopt(IPV6_AUTH_TRANS_LEVEL)");
#else /* old def */
- if (setsockopt(s, IPPROTO_IPV6, IPV6_AUTH_LEVEL,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_AUTH_LEVEL,
&optval, sizeof(optval)) == -1)
err(1, "setsockopt(IPV6_AUTH_LEVEL)");
#endif
}
if (options & F_ENCRYPT) {
optval = IPSEC_LEVEL_REQUIRE;
- if (setsockopt(s, IPPROTO_IPV6, IPV6_ESP_TRANS_LEVEL,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_ESP_TRANS_LEVEL,
&optval, sizeof(optval)) == -1)
err(1, "setsockopt(IPV6_ESP_TRANS_LEVEL)");
}
@@ -801,7 +807,7 @@
} else {
ICMP6_FILTER_SETPASSALL(&filt);
}
- if (setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
+ if (prog_setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
sizeof(filt)) < 0)
err(1, "setsockopt(ICMP6_FILTER)");
}
@@ -812,11 +818,11 @@
int opton = 1;
#ifdef IPV6_RECVRTHDR
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDR, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RECVRTHDR, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_RECVRTHDR)");
#else /* old adv. API */
- if (setsockopt(s, IPPROTO_IPV6, IPV6_RTHDR, &opton,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_RTHDR, &opton,
sizeof(opton)))
err(1, "setsockopt(IPV6_RTHDR)");
#endif
@@ -825,7 +831,7 @@
/*
optval = 1;
if (IN6_IS_ADDR_MULTICAST(&dst.sin6_addr))
- if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
+ if (prog_setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&optval, sizeof(optval)) == -1)
err(1, "IPV6_MULTICAST_LOOP");
*/
@@ -929,7 +935,7 @@
int dummy;
socklen_t len = sizeof(src);
- if ((dummy = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ if ((dummy = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
err(1, "UDP socket");
src.sin6_family = AF_INET6;
@@ -938,42 +944,42 @@
src.sin6_scope_id = dst.sin6_scope_id;
if (pktinfo &&
- setsockopt(dummy, IPPROTO_IPV6, IPV6_PKTINFO,
+ prog_setsockopt(dummy, IPPROTO_IPV6, IPV6_PKTINFO,
(void *)pktinfo, sizeof(*pktinfo)))
err(1, "UDP setsockopt(IPV6_PKTINFO)");
if (hoplimit != -1 &&
Home |
Main Index |
Thread Index |
Old Index