summaryrefslogtreecommitdiffstats
path: root/dhcpcd/dhcpcd-hooks/10-mtu
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-01-30 13:29:46 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-01-30 16:23:03 +0100
commitf2ed769880271654297a4be420f26ab94d39666b (patch)
tree4cbfc23184993e8ef11bb1d60b307cbb3644a259 /dhcpcd/dhcpcd-hooks/10-mtu
parentarphole: New test (diff)
downloadrtems-libbsd-f2ed769880271654297a4be420f26ab94d39666b.tar.bz2
DHCPCD(8): Import
Import DHCPCD(8) from: http://roy.marples.name/projects/dhcpcd/ The upstream sources can be obtained via: fossil clone http://roy.marples.name/projects/dhcpcd The imported version is 2014-01-29 19:46:44 [6b209507bb].
Diffstat (limited to 'dhcpcd/dhcpcd-hooks/10-mtu')
-rw-r--r--dhcpcd/dhcpcd-hooks/10-mtu38
1 files changed, 38 insertions, 0 deletions
diff --git a/dhcpcd/dhcpcd-hooks/10-mtu b/dhcpcd/dhcpcd-hooks/10-mtu
new file mode 100644
index 00000000..f8657cbd
--- /dev/null
+++ b/dhcpcd/dhcpcd-hooks/10-mtu
@@ -0,0 +1,38 @@
+# Configure the MTU for the interface
+
+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 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
+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