Add length flag to set initial MTU.
Subsystems (2)
PATCH 1/2 Add length flag to set initial MTU.
Signed-off-by John Heffner <[email protected]>
--- tracepath.c | 10 ++++++++-- tracepath6.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-)
tracepath.c +8 -2
@@ -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 (); }
tracepath6.c +8 -2
@@ -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 (); }
Signature · 1 line
1.5.0.2.gc260-dirty
PATCH 2/2 Use PMTUDISC_PROBE mode if it exists.
Signed-off-by John Heffner <[email protected]>
--- tracepath.c | 10 ++++++++-- tracepath6.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-)
tracepath.c +8 -2
@@ -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 ); }
tracepath6.c +8 -2
@@ -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 ); }
Signature · 1 line
1.5.0.2.gc260-dirty