]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Only apply interface MTU on DHCP messages, or static IPv4 configuration.
authorRoy Marples <roy@marples.name>
Mon, 27 Jul 2015 09:31:35 +0000 (09:31 +0000)
committerRoy Marples <roy@marples.name>
Mon, 27 Jul 2015 09:31:35 +0000 (09:31 +0000)
dhcpcd-hooks/10-mtu

index f8657cbdf6ed6ac6ba6900a48a2684b776480e40..f563624cafb699d025829e46d3dbc734032fed56 100644 (file)
@@ -13,26 +13,31 @@ set_mtu()
        fi
 }
 
-if [ "$reason" = PREINIT -a -e "$mtu_dir/$interface" ]; then
-       rm "$mtu_dir/$interface"
-elif [ -n "$new_interface_mtu" ] && $if_up; then
-       # The smalled MTU dhcpcd can work with is 576
-       if [ "$new_interface_mtu" -ge 576 ]; then
-               if set_mtu "$new_interface_mtu"; then
-                       syslog info "MTU set to $new_interface_mtu"
-                       # Save the MTU so we can restore it later
-                       if [ ! -e "$mtu_dir/$interface" ]; then
-                               mkdir -p "$mtu_dir"
-                               echo "$ifmtu" > "$mtu_dir/$interface"
+# Only set interface MTU on either a DHCP option recieved or a static
+# configuration for IPv4 which is wrapped in the DHCP setup.
+# IPv6 MTU is done via routing.
+if [ "$ifsuffix" = ".dhcp" ]; then
+       if [ "$reason" = PREINIT -a -e "$mtu_dir/$interface" ]; then
+               rm "$mtu_dir/$interface"
+       elif [ -n "$new_interface_mtu" ] && $if_up; then
+               # The smalled MTU dhcpcd can work with is 576
+               if [ "$new_interface_mtu" -ge 576 ]; then
+                       if set_mtu "$new_interface_mtu"; then
+                               syslog info "MTU set to $new_interface_mtu"
+                               # Save the MTU so we can restore it later
+                               if [ ! -e "$mtu_dir/$interface" ]; then
+                                       mkdir -p "$mtu_dir"
+                                       echo "$ifmtu" > "$mtu_dir/$interface"
+                               fi
                        fi
                fi
-       fi
-elif [ -e "$mtu_dir/$interface" ]; then
-       if $if_up || $if_down; then
-               # No MTU in this state, so restore the prior MTU
-               mtu=$(cat "$mtu_dir/$interface")
-               syslog info "MTU restored to $mtu"
-               set_mtu "$mtu"
-               rm "$mtu_dir/$interface"
+       elif [ -e "$mtu_dir/$interface" ]; then
+               if $if_up || $if_down; then
+                       # No MTU in this state, so restore the prior MTU
+                       mtu=$(cat "$mtu_dir/$interface")
+                       syslog info "MTU restored to $mtu"
+                       set_mtu "$mtu"
+                       rm "$mtu_dir/$interface"
+               fi
        fi
 fi