]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Move MTU configuration to dhcpcd.sh. However, if the MTU is too small for dhcpcd...
authorRoy Marples <roy@marples.name>
Mon, 14 Apr 2008 13:47:20 +0000 (13:47 +0000)
committerRoy Marples <roy@marples.name>
Mon, 14 Apr 2008 13:47:20 +0000 (13:47 +0000)
configure.c
dhcpcd.8.in
dhcpcd.c
dhcpcd.h
dhcpcd.sh
net.c
net.h

index e491089a3140ccc046083d6af0495e7d25fa51a2..0f11b3c19473764960f02e11d44c1456617dea1d 100644 (file)
@@ -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)) {
index 90d4ed20612bad3094e9afd175d77c59bdeecb81..f32e59ef3c92c8fb3238434d9ce387cb40aed0c6 100644 (file)
@@ -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
index feb2f6cac8dd87788116c974daec9d5a1261ac6c..1548d3102afa776421cf60f683f558c6d0c79a39 100644 (file)
--- 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] <interface>\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;
index 23b184ebca76a6e1b5a79d397d517920fadfc31d..3685a5a6cebff7f814d24552f5d387b636eeb473 100644 (file)
--- 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;
index caaa4f37d242a253c540e7621fa4fedf2adf347f..86dea1228277a64313b474dfc143db932dce0f8f 100755 (executable)
--- 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 5f7e363b63c42dccca3fa858090f29dbb2c9a977..3d225915edc7d4a395fd85b786bb6bc34c588d68 100644 (file)
--- 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 eaa6b75eeece2519d684f78069f30eea413dd348..c60c672b89e36532ec9c7fd486697bd4ebdd54a2 100644 (file)
--- 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;