Disable path MTU discovery by default. It's useless for TFTP.

This commit is contained in:
Peter Anvin 2005-10-13 11:16:40 -07:00
parent 7976458c8b
commit 25d63c415a

View file

@ -187,7 +187,7 @@ read_remap_rules(const char *file)
} }
#endif #endif
static inline void static void
set_socket_nonblock(int fd, int flag) set_socket_nonblock(int fd, int flag)
{ {
int err; int err;
@ -206,6 +206,16 @@ set_socket_nonblock(int fd, int flag)
} }
} }
static void
pmtu_discovery_off(int fd)
{
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
int pmtu = IP_PMTUDISC_DONT;
setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu));
#endif
}
/* /*
* Receive packet with synchronous timeout; timeout is adjusted * Receive packet with synchronous timeout; timeout is adjusted
* to account for time spent waiting. * to account for time spent waiting.
@ -508,6 +518,9 @@ main(int argc, char **argv)
close(1); close(2); close(1); close(2);
} }
/* Disable path MTU discovery */
pmtu_discovery_off(0);
/* This means we don't want to wait() for children */ /* This means we don't want to wait() for children */
#ifdef SA_NOCLDWAIT #ifdef SA_NOCLDWAIT
set_signal(SIGCHLD, SIG_IGN, SA_NOCLDSTOP|SA_NOCLDWAIT); set_signal(SIGCHLD, SIG_IGN, SA_NOCLDSTOP|SA_NOCLDWAIT);
@ -701,6 +714,10 @@ main(int argc, char **argv)
syslog(LOG_ERR, "connect: %m"); syslog(LOG_ERR, "connect: %m");
exit(EX_IOERR); exit(EX_IOERR);
} }
/* Disable path MTU discovery */
pmtu_discovery_off(0);
tp = (struct tftphdr *)buf; tp = (struct tftphdr *)buf;
tp_opcode = ntohs(tp->th_opcode); tp_opcode = ntohs(tp->th_opcode);
if (tp_opcode == RRQ || tp_opcode == WRQ) if (tp_opcode == RRQ || tp_opcode == WRQ)