summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-03-05 11:13:06 +0000
committerRoy Marples <roy@marples.name>2012-03-05 11:13:06 +0000
commiteb0faa896202e162e8dd25a02a29f75357855027 (patch)
tree19d5fe304b818f0c80d2a73f7629cd324b290cd1
parentc37989c4aa92fa076d8a7602811de5e8c60b9679 (diff)
downloaddhcpcd-eb0faa896202e162e8dd25a02a29f75357855027.tar.xz
Use sysfs if we don't have ifconfig(8) on Linux.
Thanks to Dave Reisner.
-rw-r--r--dhcpcd-hooks/10-mtu15
1 files changed, 13 insertions, 2 deletions
diff --git a/dhcpcd-hooks/10-mtu b/dhcpcd-hooks/10-mtu
index 639697c9..f04274e7 100644
--- a/dhcpcd-hooks/10-mtu
+++ b/dhcpcd-hooks/10-mtu
@@ -2,12 +2,23 @@
mtu_dir="$state_dir/mtu"
+set_mtu()
+{
+ local mtu=$1
+
+ if [ -w /sys/class/net/$interface/mtu ]; then
+ echo "$mtu" >/sys/class/net/$interface/mtu
+ else
+ ifconfig "$interface" mtu "$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 ifconfig "$interface" mtu "$new_interface_mtu"; then
+ if set_mtu "$new_interface_mtu"; then
syslog info "$interface: MTU set to $new_interface_mtu"
# Save the MTU so we can restore it later
if [ ! -e "$mtu_dir/$interface" ]; then
@@ -21,7 +32,7 @@ elif [ -e "$mtu_dir/$interface" ]; then
# No MTU in this state, so restore the prior MTU
mtu=$(cat "$mtu_dir/$interface")
syslog info "$interface: MTU restored to $mtu"
- ifconfig "$interface" mtu "$mtu"
+ set_mtu "$mtu"
rm "$mtu_dir/$interface"
fi
fi