From: Roy Marples Date: Mon, 14 Apr 2008 13:47:20 +0000 (+0000) Subject: Move MTU configuration to dhcpcd.sh. However, if the MTU is too small for dhcpcd... X-Git-Tag: v4.0.2~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=207e004634b7a55dd65de9ef63a9663abfada403;p=thirdparty%2Fdhcpcd.git Move MTU configuration to dhcpcd.sh. However, if the MTU is too small for dhcpcd, dhcpcd will increase it to the minimum. --- diff --git a/configure.c b/configure.c index e491089a..0f11b3c1 100644 --- a/configure.c +++ b/configure.c @@ -453,7 +453,6 @@ configure(struct interface *iface, const struct dhcp_message *dhcp, const struct dhcp_lease *lease, const struct options *options, int up) { - unsigned short mtu; struct in_addr addr; struct in_addr net; struct in_addr brd; @@ -476,12 +475,6 @@ configure(struct interface *iface, const struct dhcp_message *dhcp, /* If we aren't up, then reset the interface as much as we can */ if (!up) { - /* Restore the original MTU value */ - if (iface->initial_mtu != iface->mtu) { - set_mtu(iface->name, iface->initial_mtu); - iface->mtu = iface->initial_mtu; - } - /* If we haven't created an info file, do so now */ if (!lease->frominfo) { if (write_info(iface, dhcp, lease, options, 0) == -1) @@ -510,16 +503,6 @@ configure(struct interface *iface, const struct dhcp_message *dhcp, return 0; } - if (options->options & DHCPCD_MTU) - if (get_option_uint16(&mtu, dhcp, DHCP_MTU) == 0) - if (mtu != iface->mtu && mtu >= MTU_MIN) { - if (set_mtu(iface->name, mtu) == 0) - iface->mtu = mtu; - else - logger(LOG_ERR, "set_mtu: %s", - strerror(errno)); - } - /* This also changes netmask */ if (!(options->options & DHCPCD_INFORM) || !has_address(iface->name, &addr, &net)) { diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 90d4ed20..f32e59ef 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -29,7 +29,7 @@ .Nd an RFC 2131 compliant DHCP client .Sh SYNOPSIS .Nm -.Op Fl dknpAEGHMOLNRSTY +.Op Fl dknpAEGHOLNRSTY .Op Fl c , -script Ar script .Op Fl h , -hostname Ar hostname .Op Fl i , -classid Ar classid @@ -275,9 +275,6 @@ Don't request a hostname. If the current hostname is blank, localhost or (none) then the hostnam will be looked up in DNS and set to that. .It Fl L , -noipv4ll Don't use IPv4LL at all. -.It Fl M , -nomtu -Don't set the MTU of the -.Ar interface . .It Fl N , -nontp Don't touch .Pa /etc/ntpd.conf diff --git a/dhcpcd.c b/dhcpcd.c index feb2f6ca..1548d310 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -75,7 +75,6 @@ static const struct option longopts[] = { {"nohostname", no_argument, NULL, 'H'}, {"clientid", optional_argument, NULL, 'I'}, {"noipv4ll", no_argument, NULL, 'L'}, - {"nomtu", no_argument, NULL, 'M'}, {"nontp", no_argument, NULL, 'N'}, {"nooptions", no_argument, NULL, 'O'}, {"nodns", no_argument, NULL, 'R'}, @@ -138,7 +137,7 @@ read_pid(const char *pidfile) static void usage(void) { - printf("usage: "PACKAGE" [-adknpEGHMNORSTY] [-c script] [-h hostname] [-i classID]\n" + printf("usage: "PACKAGE" [-adknpEGHNORSTY] [-c script] [-h hostname] [-i classID]\n" " [-l leasetime] [-m metric] [-o option] [-r ipaddress]\n" " [-s ipaddress] [-t timeout] [-u userclass] [-F none | ptr | both]\n" " [-I clientID] \n"); @@ -185,7 +184,7 @@ main(int argc, char **argv) /* Don't set any optional arguments here so we retain POSIX * compatibility with getopt */ while ((opt = getopt_long(argc, argv, EXTRA_OPTS - "c:dh:i:kl:m:no:pr:s:t:u:xAEF:GHI:LMNORSTY", + "c:dh:i:kl:m:no:pr:s:t:u:xAEF:GHI:LNORSTY", longopts, &option_index)) != -1) { switch (opt) { @@ -393,9 +392,6 @@ main(int argc, char **argv) case 'L': options->options &= ~DHCPCD_IPV4LL; break; - case 'M': - options->options &= ~DHCPCD_MTU; - break; case 'N': dontp = 0; break; diff --git a/dhcpcd.h b/dhcpcd.h index 23b184eb..3685a5a6 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -55,7 +55,6 @@ extern char *dhcpcd_skiproutes; #define DHCPCD_ARP (1 << 0) #define DHCPCD_DOMAIN (1 << 2) #define DHCPCD_GATEWAY (1 << 3) -#define DHCPCD_MTU (1 << 4) #define DHCPCD_LASTLEASE (1 << 7) #define DHCPCD_INFORM (1 << 8) #define DHCPCD_REQUEST (1 << 9) @@ -82,8 +81,6 @@ struct options { time_t timeout; int metric; int options; - - int dohostname; int domscsr; struct in_addr request_address; diff --git a/dhcpcd.sh b/dhcpcd.sh index caaa4f37..86dea122 100755 --- a/dhcpcd.sh +++ b/dhcpcd.sh @@ -115,6 +115,13 @@ restore_conf() mv -f "$1"-pre."${INTERFACE}" "$1" } +make_mtu() +{ + if [ -n "${MTU}" ]; then + ifconfig "${INTERFACE}" mtu "${MTU}" + fi +} + make_nis_conf() { [ -z "${NISDOMAIN}" -a -z "${NISSERVER}" ] && return 0 local cf=/etc/yp.conf."${INTERFACE}" prefix= x= pidfile= @@ -253,6 +260,7 @@ if [ "${state}" = "down" ]; then exit $? fi +make_mtu make_resolv_conf make_hostname make_nis_conf diff --git a/net.c b/net.c index 5f7e363b..3d225915 100644 --- a/net.c +++ b/net.c @@ -364,7 +364,6 @@ read_interface(const char *ifname, _unused int metric) iface->family = family; iface->arpable = !(ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)); - iface->mtu = iface->initial_mtu = mtu; /* 0 is a valid fd, so init to -1 */ iface->fd = -1; diff --git a/net.h b/net.h index eaa6b75e..c60c672b 100644 --- a/net.h +++ b/net.h @@ -114,8 +114,6 @@ struct interface char leasefile[PATH_MAX]; char infofile[PATH_MAX]; - unsigned short initial_mtu; - unsigned short mtu; struct in_addr addr; struct in_addr net; struct rt *routes;