Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Introduce rump.ndp
details: https://anonhg.NetBSD.org/src/rev/b1759f393ea3
branches: trunk
changeset: 339686:b1759f393ea3
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Aug 03 09:51:40 2015 +0000
description:
Introduce rump.ndp
ndp(8) uses RTM that requires that getpid(2) works correctly. Unfortunately
supporting getpid(2) in librumphijack will be tricky so that we rump-ify
ndp(8) as well as arp(8).
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/debug/mi | 3 +-
usr.sbin/ndp/Makefile | 24 +++++++----
usr.sbin/ndp/ndp.c | 92 +++++++++++++++++++++++---------------------
usr.sbin/ndp/ndp_hostops.c | 55 ++++++++++++++++++++++++++
usr.sbin/ndp/ndp_rumpops.c | 59 ++++++++++++++++++++++++++++
usr.sbin/ndp/prog_ops.h | 74 ++++++++++++++++++++++++++++++++++++
7 files changed, 256 insertions(+), 54 deletions(-)
diffs (truncated from 601 to 300 lines):
diff -r d83f2f94a52e -r b1759f393ea3 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Mon Aug 03 05:43:01 2015 +0000
+++ b/distrib/sets/lists/base/mi Mon Aug 03 09:51:40 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1106 2015/08/02 11:09:05 jmcneill Exp $
+# $NetBSD: mi,v 1.1107 2015/08/03 09:51:40 ozaki-r Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -1821,6 +1821,7 @@
./usr/sbin/rtquery base-netutil-bin
./usr/sbin/rtsold base-obsolete obsolete
./usr/sbin/rump.arp base-netutil-bin rump
+./usr/sbin/rump.ndp base-netutil-bin inet6,rump
./usr/sbin/rump.envstat base-sysutil-bin rump
./usr/sbin/rump.powerd base-sysutil-bin rump
./usr/sbin/rump.traceroute base-netutil-bin rump
diff -r d83f2f94a52e -r b1759f393ea3 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Mon Aug 03 05:43:01 2015 +0000
+++ b/distrib/sets/lists/debug/mi Mon Aug 03 09:51:40 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.122 2015/07/29 06:07:35 ozaki-r Exp $
+# $NetBSD: mi,v 1.123 2015/08/03 09:51:40 ozaki-r Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
@@ -1203,6 +1203,7 @@
./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
+./usr/libdata/debug/usr/sbin/rump.ndp.debug comp-netutil-debug inet6,debug,rump
./usr/libdata/debug/usr/sbin/rump.envstat.debug comp-sysutil-debug debug,rump
./usr/libdata/debug/usr/sbin/rump.powerd.debug comp-sysutil-debug debug,rump
./usr/libdata/debug/usr/sbin/rump.traceroute.debug comp-netutil-debug debug,rump
diff -r d83f2f94a52e -r b1759f393ea3 usr.sbin/ndp/Makefile
--- a/usr.sbin/ndp/Makefile Mon Aug 03 05:43:01 2015 +0000
+++ b/usr.sbin/ndp/Makefile Mon Aug 03 09:51:40 2015 +0000
@@ -1,17 +1,23 @@
-# $NetBSD: Makefile,v 1.9 2013/06/21 12:50:50 uwe Exp $
+# $NetBSD: Makefile,v 1.10 2015/08/03 09:51:40 ozaki-r Exp $
.include <bsd.own.mk>
-USE_FORT?= yes # network client
+USE_FORT?= yes # network client
-TCPDUMP= ${NETBSDSRCDIR}/external/bsd/tcpdump/dist
-.PATH: ${TCPDUMP}
+TCPDUMP= ${NETBSDSRCDIR}/external/bsd/tcpdump/dist
+.PATH: ${TCPDUMP}
+
+RUMPPRG= ndp
+SRCS= ndp.c gmt2local.c
+MAN= ndp.8
-PROG= ndp
-SRCS= ndp.c gmt2local.c
-MAN= ndp.8
+CPPFLAGS+= -DINET6
+CPPFLAGS+= -I. -I${TCPDUMP}
-CPPFLAGS+=-DINET6
-CPPFLAGS+=-I. -I${TCPDUMP}
+.PATH: ${.CURDIR}/../../lib/libc/net
+RUMPSRCS= getifaddrs.c getnameinfo.c if_indextoname.c
+.if (${MKRUMP} != "no")
+CPPFLAGS+= -DRUMP_ACTION
+.endif
.include <bsd.prog.mk>
diff -r d83f2f94a52e -r b1759f393ea3 usr.sbin/ndp/ndp.c
--- a/usr.sbin/ndp/ndp.c Mon Aug 03 05:43:01 2015 +0000
+++ b/usr.sbin/ndp/ndp.c Mon Aug 03 09:51:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ndp.c,v 1.44 2015/06/16 23:04:14 christos Exp $ */
+/* $NetBSD: ndp.c,v 1.45 2015/08/03 09:51:40 ozaki-r Exp $ */
/* $KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $ */
/*
@@ -104,7 +104,9 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
+
#include "gmt2local.h"
+#include "prog_ops.h"
static pid_t pid;
static int nflag;
@@ -159,8 +161,6 @@
{
int ch;
- pid = getpid();
- thiszone = gmt2local(0L);
while ((ch = getopt(argc, argv, "acd:f:Ii:nprstA:HPR")) != -1)
switch (ch) {
case 'a':
@@ -210,6 +210,12 @@
argc -= optind;
argv += optind;
+ if (prog_init && prog_init() == -1)
+ err(1, "init failed");
+
+ pid = prog_getpid();
+ thiszone = gmt2local(0L);
+
switch (mode) {
case 'a':
case 'c':
@@ -301,7 +307,7 @@
getsocket(void)
{
if (my_s < 0) {
- my_s = socket(PF_ROUTE, SOCK_RAW, 0);
+ my_s = prog_socket(PF_ROUTE, SOCK_RAW, 0);
if (my_s < 0)
err(1, "socket");
}
@@ -534,12 +540,12 @@
mib[3] = AF_INET6;
mib[4] = NET_RT_FLAGS;
mib[5] = RTF_LLINFO;
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ if (prog_sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
err(1, "sysctl(PF_ROUTE estimate)");
if (needed > 0) {
if ((buf = malloc(needed)) == NULL)
err(1, "malloc");
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
+ if (prog_sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
err(1, "sysctl(PF_ROUTE, NET_RT_FLAGS)");
lim = buf + needed;
} else
@@ -716,20 +722,20 @@
static struct in6_nbrinfo nbi;
int s;
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
err(1, "socket");
(void)memset(&nbi, 0, sizeof(nbi));
(void)if_indextoname(ifindex, nbi.ifname);
nbi.addr = *addr;
- if (ioctl(s, SIOCGNBRINFO_IN6, &nbi) < 0) {
+ if (prog_ioctl(s, SIOCGNBRINFO_IN6, &nbi) < 0) {
if (warning)
warn("ioctl(SIOCGNBRINFO_IN6)");
- (void)close(s);
+ (void)prog_close(s);
return(NULL);
}
- (void)close(s);
+ (void)prog_close(s);
return(&nbi);
}
@@ -839,12 +845,12 @@
l = rtm->rtm_msglen;
rtm->rtm_seq = ++seq;
rtm->rtm_type = cmd;
- if (write(my_s, &m_rtmsg, (size_t)l) == -1) {
+ if (prog_write(my_s, &m_rtmsg, (size_t)l) == -1) {
if (errno != ESRCH || cmd != RTM_DELETE)
err(1, "writing to routing socket");
}
do {
- l = read(my_s, &m_rtmsg, sizeof(m_rtmsg));
+ l = prog_read(my_s, &m_rtmsg, sizeof(m_rtmsg));
} while (l > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != pid));
if (l < 0)
warn("read from routing socket");
@@ -861,11 +867,11 @@
u_int8_t nullbuf[8];
#endif
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
+ if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
err(1, "socket");
(void)memset(&nd, 0, sizeof(nd));
(void)strlcpy(nd.ifname, ifname, sizeof(nd.ifname));
- if (ioctl(s, SIOCGIFINFO_IN6, &nd) < 0)
+ if (prog_ioctl(s, SIOCGIFINFO_IN6, &nd) < 0)
err(1, "ioctl(SIOCGIFINFO_IN6)");
#define ND nd.ndi
newflags = ND.flags;
@@ -933,10 +939,10 @@
ND.flags = newflags;
#ifdef SIOCSIFINFO_IN6
- if (ioctl(s, SIOCSIFINFO_IN6, &nd) < 0)
+ if (prog_ioctl(s, SIOCSIFINFO_IN6, &nd) < 0)
err(1, "ioctl(SIOCSIFINFO_IN6)");
#else
- if (ioctl(s, SIOCSIFINFO_FLAGS, &nd) < 0)
+ if (prog_ioctl(s, SIOCSIFINFO_FLAGS, &nd) < 0)
err(1, "ioctl(SIOCSIFINFO_FLAGS)");
#endif
#undef SETFLAG
@@ -946,7 +952,7 @@
if (!ND.initialized)
errx(1, "%s: not initialized yet", ifname);
- if (ioctl(s, SIOCGIFINFO_IN6, &nd) < 0)
+ if (prog_ioctl(s, SIOCGIFINFO_IN6, &nd) < 0)
err(1, "ioctl(SIOCGIFINFO_IN6)");
(void)printf("linkmtu=%d", ND.linkmtu);
(void)printf(", maxmtu=%d", ND.maxmtu);
@@ -1011,7 +1017,7 @@
(void)putc('\n', stdout);
#undef ND
- (void)close(s);
+ (void)prog_close(s);
}
#ifndef ND_RA_FLAG_RTPREF_MASK /* XXX: just for compilation on *BSD release */
@@ -1028,7 +1034,7 @@
size_t l;
struct timeval tim;
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
+ if (prog_sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
@@ -1039,7 +1045,7 @@
err(1, "malloc");
/*NOTREACHED*/
}
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
+ if (prog_sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
/*NOTREACHED*/
}
@@ -1074,13 +1080,13 @@
int s, i;
struct timeval time;
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+ if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
err(1, "socket");
/* NOTREACHED */
}
(void)memset(&dr, 0, sizeof(dr));
(void)strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy */
- if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {
+ if (prog_ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {
err(1, "ioctl(SIOCGDRLST_IN6)");
/* NOTREACHED */
}
@@ -1109,7 +1115,7 @@
sec2str(DR.expire - time.tv_sec));
}
#undef DR
- (void)close(s);
+ (void)prog_close(s);
#endif
}
@@ -1126,7 +1132,7 @@
int ninflags = nflag ? NI_NUMERICHOST : 0;
char namebuf[NI_MAXHOST];
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
+ if (prog_sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
@@ -1135,7 +1141,7 @@
err(1, "malloc");
/*NOTREACHED*/
}
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
+ if (prog_sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
/*NOTREACHED*/
}
@@ -1233,13 +1239,13 @@
(void)gettimeofday(&time, 0);
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+ if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
err(1, "socket");
/* NOTREACHED */
}
(void)memset(&pr, 0, sizeof(pr));
(void)strlcpy(pr.ifname, "lo0", sizeof(pr.ifname)); /* dummy */
- if (ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) {
+ if (prog_ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) {
err(1, "ioctl(SIOCGPRLST_IN6)");
/* NOTREACHED */
}
@@ -1380,7 +1386,7 @@
(void)printf(" No advertising router\n");
}
Home |
Main Index |
Thread Index |
Old Index