summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2017-07-12 16:56:48 +0000
committerflorian <florian@openbsd.org>2017-07-12 16:56:48 +0000
commit78ea0465c53597d6fce281ea5c6721ddcdebc317 (patch)
tree3bdf5994a0b0b461f3df6aa199238f1f4d708890
parentGet rid of ICMPV6CTL_ND6_DRLIST and ICMPV6CTL_ND6_PRLIST sysctls (diff)
downloadwireguard-openbsd-78ea0465c53597d6fce281ea5c6721ddcdebc317.tar.xz
wireguard-openbsd-78ea0465c53597d6fce281ea5c6721ddcdebc317.zip
Remove defunct code, the kernel no longer provides
ICMPV6CTL_ND6_DRLIST and ICMPV6CTL_ND6_PRLIST sysctls since it no longer tracks that information. We can no longer flush or list the prefix list or the default router list. Pointed out by & OK mpi
-rw-r--r--usr.sbin/ndp/ndp.818
-rw-r--r--usr.sbin/ndp/ndp.c236
2 files changed, 8 insertions, 246 deletions
diff --git a/usr.sbin/ndp/ndp.8 b/usr.sbin/ndp/ndp.8
index b880445596d..29e71650d19 100644
--- a/usr.sbin/ndp/ndp.8
+++ b/usr.sbin/ndp/ndp.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ndp.8,v 1.41 2017/04/15 11:42:09 bluhm Exp $
+.\" $OpenBSD: ndp.8,v 1.42 2017/07/12 16:56:48 florian Exp $
.\" $KAME: ndp.8,v 1.28 2002/07/17 08:46:33 itojun 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 $Mdocdate: April 15 2017 $
+.Dd $Mdocdate: July 12 2017 $
.Dt NDP 8
.Os
.Sh NAME
@@ -36,9 +36,9 @@
.Nd control/diagnose IPv6 Neighbor Discovery Protocol (NDP)
.Sh SYNOPSIS
.Nm ndp
-.Op Fl nrt
-.Op Fl a | c | p
-.Op Fl H | P | R
+.Op Fl nt
+.Op Fl a | c
+.Op Fl H
.Op Fl A Ar wait
.Op Fl d Ar hostname
.Op Fl f Ar filename
@@ -154,14 +154,6 @@ unless the interface is configured for inet6 autoconfiguration.
.El
.It Fl n
Do not try to resolve numeric addresses to hostnames.
-.It Fl P
-Flush all the entries in the prefix list.
-.It Fl p
-Show the prefix list.
-.It Fl R
-Flush all the entries in the default router list.
-.It Fl r
-Show the default router list.
.It Xo
.Fl s Ar nodename ether_addr
.Op Cm temp
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index cd3f8989ea4..d3c3b91a456 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ndp.c,v 1.81 2017/04/15 11:58:51 bluhm Exp $ */
+/* $OpenBSD: ndp.c,v 1.82 2017/07/12 16:56:48 florian Exp $ */
/* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */
/*
@@ -135,10 +135,6 @@ void usage(void);
int rtmsg(int);
int rtget(struct sockaddr_in6 **, struct sockaddr_dl **);
void ifinfo(char *, int, char **);
-void rtrlist(void);
-void plist(void);
-void pfx_flush(void);
-void rtr_flush(void);
void harmonize_rtr(void);
static char *sec2str(time_t);
static void ts_print(const struct timeval *);
@@ -162,7 +158,7 @@ main(int argc, char *argv[])
pid = getpid();
thiszone = gmt2local(0);
rdomain = getrtable();
- while ((ch = getopt(argc, argv, "acd:f:i:nprstA:HPRV:")) != -1) {
+ while ((ch = getopt(argc, argv, "acd:f:i:nstA:HV:")) != -1) {
switch (ch) {
case 'a':
case 'c':
@@ -170,7 +166,6 @@ main(int argc, char *argv[])
case 'r':
case 'H':
case 'P':
- case 'R':
case 's':
if (mode) {
usage();
@@ -243,23 +238,9 @@ main(int argc, char *argv[])
usage();
file(arg);
break;
- case 'p':
- if (argc != 0) {
- usage();
- /*NOTREACHED*/
- }
- plist();
- break;
case 'i':
ifinfo(arg, argc, argv);
break;
- case 'r':
- if (argc != 0) {
- usage();
- /*NOTREACHED*/
- }
- rtrlist();
- break;
case 's':
if (argc < 2 || argc > 4)
usage();
@@ -271,20 +252,6 @@ main(int argc, char *argv[])
}
harmonize_rtr();
break;
- case 'P':
- if (argc != 0) {
- usage();
- /*NOTREACHED*/
- }
- pfx_flush();
- break;
- case 'R':
- if (argc != 0) {
- usage();
- /*NOTREACHED*/
- }
- rtr_flush();
- break;
case 0:
if (argc != 1) {
usage();
@@ -800,7 +767,7 @@ ndp_ether_aton(char *a, u_char *n)
void
usage(void)
{
- printf("usage: ndp [-nrt] [-a | -c | -p] [-H | -P | -R] ");
+ printf("usage: ndp [-nt] [-a | -c] [-H] ");
printf("[-A wait] [-d hostname]\n");
printf("\t[-f filename] [-i interface [flag ...]]\n");
printf("\t[-s nodename ether_addr [temp] [proxy]] ");
@@ -990,203 +957,6 @@ ifinfo(char *ifname, int argc, char **argv)
close(s);
}
-#ifndef ND_RA_FLAG_RTPREF_MASK /* XXX: just for compilation on *BSD release */
-#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
-#endif
-
-void
-rtrlist(void)
-{
- int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST };
- char *buf;
- struct in6_defrouter *p, *ep;
- size_t l;
- struct timeval now;
-
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
- /*NOTREACHED*/
- }
- if (l == 0)
- return;
- buf = malloc(l);
- if (buf == NULL) {
- err(1, "malloc");
- /*NOTREACHED*/
- }
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
- /*NOTREACHED*/
- }
-
- ep = (struct in6_defrouter *)(buf + l);
- for (p = (struct in6_defrouter *)buf; p < ep; p++) {
- int rtpref;
-
- if (getnameinfo((struct sockaddr *)&p->rtaddr,
- p->rtaddr.sin6_len, host_buf, sizeof(host_buf), NULL, 0,
- (nflag ? NI_NUMERICHOST : 0)) != 0)
- strlcpy(host_buf, "?", sizeof(host_buf));
-
- printf("%s if=%s", host_buf,
- if_indextoname(p->if_index, ifix_buf));
- printf(", flags=%s%s",
- p->flags & ND_RA_FLAG_MANAGED ? "M" : "",
- p->flags & ND_RA_FLAG_OTHER ? "O" : "");
- rtpref = ((p->flags & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff;
- printf(", pref=%s", rtpref_str[rtpref]);
-
- gettimeofday(&now, 0);
- if (p->expire == 0)
- printf(", expire=Never\n");
- else
- printf(", expire=%s\n",
- sec2str(p->expire - now.tv_sec));
- }
- free(buf);
-}
-
-void
-plist(void)
-{
- int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
- char *buf, *p, *ep;
- struct in6_prefix pfx;
- size_t l;
- struct timeval now;
- const int niflags = NI_NUMERICHOST;
- int ninflags = nflag ? NI_NUMERICHOST : 0;
- char namebuf[NI_MAXHOST];
-
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
- /*NOTREACHED*/
- }
- if (l == 0)
- return;
- buf = malloc(l);
- if (buf == NULL) {
- err(1, "malloc");
- /*NOTREACHED*/
- }
- if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
- err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
- /*NOTREACHED*/
- }
-
- ep = buf + l;
- for (p = buf; p < ep; ) {
- memcpy(&pfx, p, sizeof(pfx));
- p += sizeof(pfx);
-
- if (getnameinfo((struct sockaddr *)&pfx.prefix,
- pfx.prefix.sin6_len, namebuf, sizeof(namebuf),
- NULL, 0, niflags) != 0)
- strlcpy(namebuf, "?", sizeof(namebuf));
- printf("%s/%d if=%s\n", namebuf, pfx.prefixlen,
- if_indextoname(pfx.if_index, ifix_buf));
-
- gettimeofday(&now, 0);
- /*
- * meaning of fields, especially flags, is very different
- * by origin. notify the difference to the users.
- */
- printf("flags=%s%s%s%s%s",
- pfx.raflags.onlink ? "L" : "",
- pfx.raflags.autonomous ? "A" : "",
- (pfx.flags & NDPRF_ONLINK) != 0 ? "O" : "",
- (pfx.flags & NDPRF_DETACHED) != 0 ? "D" : "",
- (pfx.flags & NDPRF_HOME) != 0 ? "H" : ""
- );
- if (pfx.vltime == ND6_INFINITE_LIFETIME)
- printf(" vltime=infinity");
- else
- printf(" vltime=%lu", (unsigned long)pfx.vltime);
- if (pfx.pltime == ND6_INFINITE_LIFETIME)
- printf(", pltime=infinity");
- else
- printf(", pltime=%lu", (unsigned long)pfx.pltime);
- if (pfx.expire == 0)
- printf(", expire=Never");
- else if (pfx.expire >= now.tv_sec)
- printf(", expire=%s",
- sec2str(pfx.expire - now.tv_sec));
- else
- printf(", expired");
- printf(", ref=%d", pfx.refcnt);
- printf("\n");
- /*
- * "advertising router" list is meaningful only if the prefix
- * information is from RA.
- */
- if (pfx.advrtrs) {
- int j;
- struct sockaddr_in6 sin6;
-
- printf(" advertised by\n");
- for (j = 0; j < pfx.advrtrs && p <= ep; j++) {
- struct in6_nbrinfo *nbi;
-
- memcpy(&sin6, p, sizeof(sin6));
- p += sizeof(sin6);
-
- if (getnameinfo((struct sockaddr *)&sin6,
- sin6.sin6_len, namebuf, sizeof(namebuf),
- NULL, 0, ninflags) != 0)
- strlcpy(namebuf, "?", sizeof(namebuf));
- printf(" %s", namebuf);
-
- nbi = getnbrinfo(&sin6.sin6_addr,
- pfx.if_index, 0);
- if (nbi) {
- switch (nbi->state) {
- case ND6_LLINFO_REACHABLE:
- case ND6_LLINFO_STALE:
- case ND6_LLINFO_DELAY:
- case ND6_LLINFO_PROBE:
- printf(" (reachable)\n");
- break;
- default:
- printf(" (unreachable)\n");
- }
- } else
- printf(" (no neighbor state)\n");
- }
- } else
- printf(" No advertising router\n");
- }
- free(buf);
-}
-
-void
-pfx_flush(void)
-{
- char dummyif[IFNAMSIZ+8];
- int s;
-
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
- strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
- if (ioctl(s, SIOCSPFXFLUSH_IN6, (caddr_t)&dummyif) < 0)
- err(1, "ioctl(SIOCSPFXFLUSH_IN6)");
- close(s);
-}
-
-void
-rtr_flush(void)
-{
- char dummyif[IFNAMSIZ+8];
- int s;
-
- if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- err(1, "socket");
- strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
- if (ioctl(s, SIOCSRTRFLUSH_IN6, (caddr_t)&dummyif) < 0)
- err(1, "ioctl(SIOCSRTRFLUSH_IN6)");
-
- close(s);
-}
-
void
harmonize_rtr(void)
{