netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [iputils] Add length flag to set initial MTU.
@ 2007-03-24  0:07 John Heffner
  2007-03-24  0:07 ` [PATCH 2/2] [iputils] Use PMTUDISC_PROBE mode if it exists John Heffner
  0 siblings, 1 reply; 2+ messages in thread
From: John Heffner @ 2007-03-24  0:07 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: netdev, John Heffner

Signed-off-by: John Heffner <jheffner@psc.edu>
---
 tracepath.c  |   10 ++++++++--
 tracepath6.c |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/tracepath.c b/tracepath.c
index c3f6f74..1f901ba 100644
--- a/tracepath.c
+++ b/tracepath.c
@@ -265,7 +265,7 @@ static void usage(void) __attribute((noreturn));
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: tracepath [-n] <destination>[/<port>]\n");
+	fprintf(stderr, "Usage: tracepath [-n] [-l <len>] <destination>[/<port>]\n");
 	exit(-1);
 }
 
@@ -279,11 +279,17 @@ main(int argc, char **argv)
 	char *p;
 	int ch;
 
-	while ((ch = getopt(argc, argv, "nh?")) != EOF) {
+	while ((ch = getopt(argc, argv, "nh?l:")) != EOF) {
 		switch(ch) {
 		case 'n':	
 			no_resolve = 1;
 			break;
+		case 'l':
+			if ((mtu = atoi(optarg)) <= overhead) {
+				fprintf(stderr, "Error: length must be >= %d\n", overhead);
+				exit(1);
+			}
+			break;
 		default:
 			usage();
 		}
diff --git a/tracepath6.c b/tracepath6.c
index 23d6a8c..d65230d 100644
--- a/tracepath6.c
+++ b/tracepath6.c
@@ -280,7 +280,7 @@ static void usage(void) __attribute((noreturn));
 
 static void usage(void)
 {
-	fprintf(stderr, "Usage: tracepath6 [-n] [-b] <destination>[/<port>]\n");
+	fprintf(stderr, "Usage: tracepath6 [-n] [-b] [-l <len>] <destination>[/<port>]\n");
 	exit(-1);
 }
 
@@ -297,7 +297,7 @@ int main(int argc, char **argv)
 	int gai;
 	char pbuf[NI_MAXSERV];
 
-	while ((ch = getopt(argc, argv, "nbh?")) != EOF) {
+	while ((ch = getopt(argc, argv, "nbh?l:")) != EOF) {
 		switch(ch) {
 		case 'n':	
 			no_resolve = 1;
@@ -305,6 +305,12 @@ int main(int argc, char **argv)
 		case 'b':	
 			show_both = 1;
 			break;
+		case 'l':
+			if ((mtu = atoi(optarg)) <= overhead) {
+				fprintf(stderr, "Error: length must be >= %d\n", overhead);
+				exit(1);
+			}
+			break;
 		default:
 			usage();
 		}
-- 
1.5.0.2.gc260-dirty


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] [iputils] Use PMTUDISC_PROBE mode if it exists.
  2007-03-24  0:07 [PATCH 1/2] [iputils] Add length flag to set initial MTU John Heffner
@ 2007-03-24  0:07 ` John Heffner
  0 siblings, 0 replies; 2+ messages in thread
From: John Heffner @ 2007-03-24  0:07 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: netdev, John Heffner

Signed-off-by: John Heffner <jheffner@psc.edu>
---
 tracepath.c  |   10 ++++++++--
 tracepath6.c |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/tracepath.c b/tracepath.c
index 1f901ba..a562d88 100644
--- a/tracepath.c
+++ b/tracepath.c
@@ -24,6 +24,10 @@
 #include <sys/uio.h>
 #include <arpa/inet.h>
 
+#ifndef IP_PMTUDISC_PROBE
+#define IP_PMTUDISC_PROBE	3
+#endif
+
 struct hhistory
 {
 	int	hops;
@@ -322,8 +326,10 @@ main(int argc, char **argv)
 	}
 	memcpy(&target.sin_addr, he->h_addr, 4);
 
-	on = IP_PMTUDISC_DO;
-	if (setsockopt(fd, SOL_IP, IP_MTU_DISCOVER, &on, sizeof(on))) {
+	on = IP_PMTUDISC_PROBE;
+	if (setsockopt(fd, SOL_IP, IP_MTU_DISCOVER, &on, sizeof(on)) &&
+	    (on = IP_PMTUDISC_DO,
+	     setsockopt(fd, SOL_IP, IP_MTU_DISCOVER, &on, sizeof(on)))) {
 		perror("IP_MTU_DISCOVER");
 		exit(1);
 	}
diff --git a/tracepath6.c b/tracepath6.c
index d65230d..6f13a51 100644
--- a/tracepath6.c
+++ b/tracepath6.c
@@ -30,6 +30,10 @@
 #define SOL_IPV6 IPPROTO_IPV6
 #endif
 
+#ifndef IPV6_PMTUDISC_PROBE
+#define IPV6_PMTUDISC_PROBE	3
+#endif
+
 int overhead = 48;
 int mtu = 128000;
 int hops_to = -1;
@@ -369,8 +373,10 @@ int main(int argc, char **argv)
 		mapped = 1;
 	}
 
-	on = IPV6_PMTUDISC_DO;
-	if (setsockopt(fd, SOL_IPV6, IPV6_MTU_DISCOVER, &on, sizeof(on))) {
+	on = IPV6_PMTUDISC_PROBE;
+	if (setsockopt(fd, SOL_IPV6, IPV6_MTU_DISCOVER, &on, sizeof(on)) &&
+	    (on = IPV6_PMTUDISC_DO,
+	     setsockopt(fd, SOL_IPV6, IPV6_MTU_DISCOVER, &on, sizeof(on)))) {
 		perror("IPV6_MTU_DISCOVER");
 		exit(1);
 	}
-- 
1.5.0.2.gc260-dirty


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-24  0:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-24  0:07 [PATCH 1/2] [iputils] Add length flag to set initial MTU John Heffner
2007-03-24  0:07 ` [PATCH 2/2] [iputils] Use PMTUDISC_PROBE mode if it exists John Heffner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).