]> git.ipfire.org Git - people/stevee/network.git/blob - hooks/mtu
network: New package.
[people/stevee/network.git] / hooks / mtu
1 #!/bin/sh
2 ########################################################################
3 # Begin $NETWORK_DEVICES/services/mtu
4 #
5 # Description : Sets MTU per interface
6 #
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Jim Gifford - jim@linuxfromscratch.org
9 #
10 # Version : 00.00
11 #
12 # Notes : This sets the maximum amount of bytes that can be
13 # transmitted within a packet. By default, this
14 # value is set to 1500.
15 #
16 ########################################################################
17
18 . /lib/network/hook-header
19
20 HOOK_NAME=mtu
21 HOOK_TYPE=zone
22
23 DEFAULT_MTU=1500
24
25 function usage() {
26 echo "Usage: ${0} {pre-up|post-up|pre-down|post-down|config} [interface]"
27 }
28
29 case "${action}" in
30 help)
31 ;;
32
33 info)
34 echo "HOOK_NAME=$HOOK_NAME"
35 echo "HOOK_TYPE=$HOOK_TYPE"
36 ;;
37
38 status)
39 check_config zone MTU
40 mtu=$(cat /sys/class/net/${zone}/mtu 2>/dev/null)
41 [ "$MTU" = "$mtu" ]
42 exit $?
43 ;;
44
45 pre-up)
46 ;;
47
48 post-up)
49 check_config zone MTU
50 message="Setting the MTU for ${zone} to ${MTU}..."
51 echo "${MTU}" > "/sys/class/net/${zone}/mtu"
52 evaluate_retval standard
53 ;;
54
55 pre-down)
56 check_config zone MTU
57 message="Resetting MTU for ${zone} to 1500..."
58 echo ${DEFAULT_MTU} > "/sys/class/net/${zone}/mtu"
59 evaluate_retval standard
60 ;;
61
62 post-down)
63 ;;
64
65 config)
66 MTU=$1
67 check_config zone MTU
68 cat << EOF >> ${CONFIG_ZONES}/${zone}/${HOOK_NAME}
69 HOOK="${HOOK_NAME}"
70 MTU="${MTU}"
71 EOF
72 exit $?
73 ;;
74
75 discover)
76 exit ${EXIT_ERROR}
77 ;;
78
79 *)
80 usage
81 exit 1
82 ;;
83 esac
84
85 # End $NETWORK_DEVICES/services/mtu