summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-05-04 19:16:26 +0000
committerhrs <hrs@FreeBSD.org>2013-05-04 19:16:26 +0000
commitd9d71436d975a7ec598297c564219c530aa41138 (patch)
treeaa5ae7e9839ddc5bfbdcadec3937869568f4e33f /sbin
parentbf7b6b6227253281ec4cfedd2f8c95e19532acb3 (diff)
downloadFreeBSD-src-d9d71436d975a7ec598297c564219c530aa41138.zip
FreeBSD-src-d9d71436d975a7ec598297c564219c530aa41138.tar.gz
Use FF02:0:0:0:0:2:FF00::/104 prefix for IPv6 Node Information Group
Address. Although KAME implementation used FF02:0:0:0:0:2::/96 based on older versions of draft-ietf-ipngwg-icmp-name-lookup, it has been changed in RFC 4620. The kernel always joins the /104-prefixed address, and additionally does /96-prefixed one only when net.inet6.icmp6.nodeinfo_oldmcprefix=1. The default value of the sysctl is 1. ping6(8) -N flag now uses /104-prefixed one. When this flag is specified twice, it uses /96-prefixed one instead. Reviewed by: ume Based on work by: Thomas Scheffler PR: conf/174957 MFC after: 2 weeks
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping6/ping6.815
-rw-r--r--sbin/ping6/ping6.c29
2 files changed, 35 insertions, 9 deletions
diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8
index b720aef..0d1e5f0 100644
--- a/sbin/ping6/ping6.8
+++ b/sbin/ping6/ping6.8
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 20, 2010
+.Dd May 5, 2013
.Dt PING6 8
.Os
.Sh NAME
@@ -215,8 +215,8 @@ unicast and multicast packets.
Numeric output only.
No attempt will be made to lookup symbolic names from addresses in the reply.
.It Fl N
-Probe node information multicast group
-.Pq Li ff02::2:xxxx:xxxx .
+Probe node information multicast group address
+.Pq Li ff02::2:ffxx:xxxx .
.Ar host
must be string hostname of the target
(must not be a numeric IPv6 address).
@@ -227,6 +227,15 @@ Since node information multicast group is a link-local multicast group,
outgoing interface needs to be specified by
.Fl I
option.
+.Pp
+When specified twice, the address
+.Pq Li ff02::2:xxxx:xxxx
+is used instead.
+The former is in RFC 4620, the latter is in an old Internet Draft
+draft-ietf-ipngwg-icmp-name-lookup.
+Note that KAME-derived implementations including
+.Fx
+use the latter.
.It Fl o
Exit successfully after receiving one reply packet.
.It Fl p Ar pattern
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 8c3e16b..01e29a1 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -287,7 +287,7 @@ void pr_retip(struct ip6_hdr *, u_char *);
void summary(void);
void tvsub(struct timeval *, struct timeval *);
int setpolicy(int, char *);
-char *nigroup(char *);
+char *nigroup(char *, int);
void usage(void);
int
@@ -306,6 +306,7 @@ main(int argc, char *argv[])
struct addrinfo hints;
int cc, i;
int ch, hold, packlen, preload, optval, ret_ga;
+ int nig_oldmcprefix = -1;
u_char *datap;
char *e, *target, *ifname = NULL, *gateway = NULL;
int ip6optlen = 0;
@@ -490,6 +491,7 @@ main(int argc, char *argv[])
break;
case 'N':
options |= F_NIGROUP;
+ nig_oldmcprefix++;
break;
case 'o':
options |= F_ONCE;
@@ -605,7 +607,7 @@ main(int argc, char *argv[])
}
if (options & F_NIGROUP) {
- target = nigroup(argv[argc - 1]);
+ target = nigroup(argv[argc - 1], nig_oldmcprefix);
if (target == NULL) {
usage();
/*NOTREACHED*/
@@ -2723,7 +2725,7 @@ setpolicy(int so __unused, char *policy)
#endif
char *
-nigroup(char *name)
+nigroup(char *name, int nig_oldmcprefix)
{
char *p;
char *q;
@@ -2733,6 +2735,7 @@ nigroup(char *name)
size_t l;
char hbuf[NI_MAXHOST];
struct in6_addr in6;
+ int valid;
p = strchr(name, '.');
if (!p)
@@ -2748,7 +2751,7 @@ nigroup(char *name)
*q = tolower(*(unsigned char *)q);
}
- /* generate 8 bytes of pseudo-random value. */
+ /* generate 16 bytes of pseudo-random value. */
memset(&ctxt, 0, sizeof(ctxt));
MD5Init(&ctxt);
c = l & 0xff;
@@ -2756,9 +2759,23 @@ nigroup(char *name)
MD5Update(&ctxt, (unsigned char *)name, l);
MD5Final(digest, &ctxt);
- if (inet_pton(AF_INET6, "ff02::2:0000:0000", &in6) != 1)
+ if (nig_oldmcprefix) {
+ /* draft-ietf-ipngwg-icmp-name-lookup */
+ valid = inet_pton(AF_INET6, "ff02::2:0000:0000", &in6);
+ } else {
+ /* RFC 4620 */
+ valid = inet_pton(AF_INET6, "ff02::2:ff00:0000", &in6);
+ }
+ if (valid != 1)
return NULL; /*XXX*/
- bcopy(digest, &in6.s6_addr[12], 4);
+
+ if (nig_oldmcprefix) {
+ /* draft-ietf-ipngwg-icmp-name-lookup */
+ bcopy(digest, &in6.s6_addr[12], 4);
+ } else {
+ /* RFC 4620 */
+ bcopy(digest, &in6.s6_addr[13], 3);
+ }
if (inet_ntop(AF_INET6, &in6, hbuf, sizeof(hbuf)) == NULL)
return NULL;
OpenPOWER on IntegriCloud