Mercurial > hg > dhcpcd
changeset 79:ee2c527a6b84 draft
Add --nomtu/-M option. Also, if MTU is used we restore it to how it was at when we exist, don't get an MTU from the server or get an invalid MTU from the server.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 04 Apr 2007 14:28:07 +0000 |
| parents | 3e35e39a5fa3 |
| children | ea8c5f1f0382 |
| files | ChangeLog configure.c dhcpcd.8 dhcpcd.c dhcpcd.h interface.c interface.h |
| diffstat | 7 files changed, 48 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Apr 03 07:03:04 2007 +0000 +++ b/ChangeLog Wed Apr 04 14:28:07 2007 +0000 @@ -1,3 +1,6 @@ +We now restore the starting MTU value when we exit OR we don't receive a +a valid MTU value from the dhcp server. +--nomtu / -M now stops the MTU from being used. You can now build dhcpcd without support for writing ntp, nis and info files which makes the binary a few k smaller. Support OpenNTP as well as NTP.
--- a/configure.c Tue Apr 03 07:03:04 2007 +0000 +++ b/configure.c Wed Apr 04 14:28:07 2007 +0000 @@ -535,6 +535,13 @@ iface->previous_routes = NULL; } + /* Restore the original MTU value */ + if (iface->mtu && iface->previous_mtu != iface->mtu) + { + set_mtu (iface->name, iface->mtu); + iface->previous_mtu = iface->mtu; + } + /* Only reset things if we had set them before */ if (iface->previous_address.s_addr != 0) { @@ -551,8 +558,21 @@ return 0; } - if (dhcp->mtu) - set_mtu (iface->name, dhcp->mtu); + /* Set the MTU requested. + If the DHCP server no longer sends one OR it's invalid then we restore + the original MTU */ + if (options->domtu) + { + unsigned short mtu = iface->mtu; + if (dhcp->mtu) + mtu = dhcp->mtu; + + if (mtu != iface->previous_mtu) + { + if (set_mtu (iface->name, mtu) == 0) + iface->previous_mtu = mtu; + } + } if (add_address (iface->name, dhcp->address, dhcp->netmask, dhcp->broadcast) < 0 && errno != EEXIST)
--- a/dhcpcd.8 Tue Apr 03 07:03:04 2007 +0000 +++ b/dhcpcd.8 Wed Apr 04 14:28:07 2007 +0000 @@ -216,6 +216,11 @@ uses the default client identifier (MAC address of the network interface) if it is not specified. .TP +.BI \-M +Prevents +.B dhcpcd +from setting the \fIMTU\fR provided by the DHCP server. +.TP .BI \-N Prevents .B dhcpcd
--- a/dhcpcd.c Tue Apr 03 07:03:04 2007 +0000 +++ b/dhcpcd.c Wed Apr 04 14:28:07 2007 +0000 @@ -95,7 +95,7 @@ static void usage () { - printf ("usage: "PACKAGE" [-adknpGHNRY] [-c script] [-h hostame] [-i classID]\n" + printf ("usage: "PACKAGE" [-adknpGHMNRY] [-c script] [-h hostame] [-i classID]\n" " [-l leasetime] [-m metric] [-s ipaddress] [-t timeout]\n" " [-u userclass] [-F [none | ptr | both]] [-I clientID]\n"); } @@ -131,6 +131,7 @@ {"nogateway", no_argument, NULL, 'G'}, {"sethostname", no_argument, NULL, 'H'}, {"clientid", required_argument, NULL, 'I'}, + {"nomtu", no_argument, NULL, 'M'}, {"nontp", no_argument, NULL, 'N'}, {"nodns", no_argument, NULL, 'R'}, {"nonis", no_argument, NULL, 'Y'}, @@ -156,6 +157,7 @@ options.doarp = false; options.dodns = true; + options.domtu = true; options.donis = true; options.dontp = true; options.dogateway = true; @@ -166,7 +168,7 @@ memset (options.hostname, 0, sizeof (options.hostname)); options.timeout = DEFAULT_TIMEOUT; - while ((ch = getopt_long(argc, argv, "ac:dh:i:kl:m:nps:t:u:F:GHI:NRY", longopts, + while ((ch = getopt_long(argc, argv, "ac:dh:i:kl:m:nps:t:u:F:GHI:MNRY", longopts, &option_index)) != -1) switch (ch) { @@ -298,6 +300,9 @@ else sprintf(options.clientid, "%s", optarg); break; + case 'M': + options.domtu = false; + break; case 'N': options.dontp = false; break;
--- a/dhcpcd.h Tue Apr 03 07:03:04 2007 +0000 +++ b/dhcpcd.h Wed Apr 04 14:28:07 2007 +0000 @@ -52,11 +52,13 @@ bool doarp; bool dodns; - bool dontp; - bool donis; + bool dodomainname; bool dogateway; bool dohostname; - bool dodomainname; + bool domtu; + bool donis; + bool dontp; + int signal; bool persistent; bool daemonise;
--- a/interface.c Tue Apr 03 07:03:04 2007 +0000 +++ b/interface.c Wed Apr 04 14:28:07 2007 +0000 @@ -135,6 +135,7 @@ unsigned char hwaddr[16]; int hwlen = 0; sa_family_t family; + unsigned short mtu; #ifndef __linux__ struct ifaddrs *ifap; @@ -254,6 +255,7 @@ return NULL; } } + mtu = ifr.ifr_mtu; strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) @@ -283,6 +285,7 @@ iface->family = family; iface->arpable = ! (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)); + iface->mtu = iface->previous_mtu = mtu; logger (LOG_INFO, "hardware address = %s", hwaddr_ntoa (iface->hwaddr, iface->hwlen));
--- a/interface.h Tue Apr 03 07:03:04 2007 +0000 +++ b/interface.h Wed Apr 04 14:28:07 2007 +0000 @@ -65,6 +65,7 @@ unsigned char hwaddr[20]; int hwlen; bool arpable; + unsigned short mtu; int fd; int buffer_length; @@ -75,10 +76,11 @@ char infofile[PATH_MAX]; + unsigned short previous_mtu; struct in_addr previous_address; struct in_addr previous_netmask; route_t *previous_routes; - + long start_uptime; } interface_t;
