Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 2009 00:54:12 +0300
From:      pluknet <pluknet@gmail.com>
To:        Doug Barton <dougb@freebsd.org>
Cc:        freebsd-net@freebsd.org
Subject:   Re: ping6 and a do-not-fragment option
Message-ID:  <a31046fc0912101354g21afe649r278d0f70095af546@mail.gmail.com>
In-Reply-To: <4B21576C.7030605@FreeBSD.org>
References:  <20091210190305.GT45152@gerbil.cluepon.net> <4B21576C.7030605@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
2009/12/10 Doug Barton <dougb@freebsd.org>:
> Richard A Steenbergen wrote:
>> Hi,
>>
>> I just noticed, while trying to do a little debugging, that ping6
>> doesn't seem to have a way to specify "do not fragment" like ping does
>> for IPv4. Obviously the way this is implemented has been changed, since
>> there is no longer a DF-bit in IPv6, but it looks like there is already
>> an IPV6_DONTFRAG setsockopt() available for exactly this purpose. It
>> looks like IPV6_DONTFRAG got added at a later date (from RFC3542),
>> perhaps after ping6 was initially written.
>>
>> It seems like the correct fix would be to add a cli option to ping6
>> (perhaps 'D', since it's available and matches the command in ping) to
>> call this setsockopt() and implement a "do not fragment" option.
>>
>
> Sounds good, we look forward to reviewing your patches. :)
>

Sure, there might be compatibility issues in between KAME or something else..

-- 
wbr,
pluknet

[-- Attachment #2 --]
diff -urpN ping6.orig/ping6.8 ping6/ping6.8
--- ping6.orig/ping6.8	2009-12-10 23:38:37.000000000 +0300
+++ ping6/ping6.8	2009-12-11 00:18:17.000000000 +0300
@@ -40,9 +40,9 @@ packets to network hosts
 .Sh SYNOPSIS
 .Nm
 .\" without ipsec, or new ipsec
-.Op Fl dfHmnNoqrRtvwW
+.Op Fl DdfHmnNoqrRtvwW
 .\" old ipsec
-.\" .Op Fl AdEfmnNqRtvwW
+.\" .Op Fl ADdEfmnNqRtvwW
 .Bk -words
 .Op Fl a Ar addrtype
 .Ek
@@ -141,6 +141,8 @@ Stop after sending
 .Ar count
 .Tn ECHO_RESPONSE
 packets.
+.It Fl D
+Disable IPv6 fragmentation.
 .It Fl d
 Set the
 .Dv SO_DEBUG
diff -urpN ping6.orig/ping6.c ping6/ping6.c
--- ping6.orig/ping6.c	2009-12-10 23:38:37.000000000 +0300
+++ ping6/ping6.c	2009-12-11 00:20:47.000000000 +0300
@@ -191,6 +191,7 @@ struct tv32 {
 #define F_ONCE		0x200000
 #define F_AUDIBLE	0x400000
 #define F_MISSED	0x800000
+#define F_DONTFRAG	0x1000000
 #define F_NOUSERDATA	(F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES)
 u_int options;
 
@@ -349,7 +350,7 @@ main(argc, argv)
 #endif /*IPSEC_POLICY_IPSEC*/
 #endif
 	while ((ch = getopt(argc, argv,
-	    "a:b:c:dfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
+	    "a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwW" ADDOPTS)) != -1) {
 #undef ADDOPTS
 		switch (ch) {
 		case 'a':
@@ -415,6 +416,9 @@ main(argc, argv)
 				errx(1,
 				    "illegal number of packets -- %s", optarg);
 			break;
+		case 'D':
+			options |= F_DONTFRAG;
+			break;
 		case 'd':
 			options |= F_SO_DEBUG;
 			break;
@@ -743,8 +747,12 @@ main(argc, argv)
 		*((u_int32_t *)&nonce[i]) = arc4random();
 #endif
 
+	optval = 1;
+	if (options & F_DONTFRAG)
+		if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG,
+		    &optval, sizeof(optval)) == -1)
+			err(1, "IPV6_DONTFRAG");
 	hold = 1;
-
 	if (options & F_SO_DEBUG)
 		(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
 		    sizeof(hold));
@@ -2780,7 +2788,7 @@ usage()
 	    "A"
 #endif
 	    "usage: ping6 [-"
-	    "d"
+	    "Dd"
 #if defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC)
 	    "E"
 #endif

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a31046fc0912101354g21afe649r278d0f70095af546>