]> git.ipfire.org Git - people/stevee/network.git/commitdiff
route: Allow to specify MTU along the path to the destination.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Oct 2012 17:14:09 +0000 (17:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Oct 2012 17:14:09 +0000 (17:14 +0000)
functions.constants
functions.firewall
functions.route
hooks/ports/wireless-ap
hooks/zones/switch
man/network-route.8.in

index bb83a16fb26dee21bb769dd7cba93f3fc7d45100..0a9718a5620d2ba9c29a19039fabbe04c21222c5 100644 (file)
@@ -45,7 +45,7 @@ DB_CONNECTION_FILE="${LOG_DIR}/connections.db"
 
 # (Static) route settings.
 NETWORK_CONFIG_ROUTES="${NETWORK_CONFIG_DIR}/routes"
-NETWORK_CONFIG_ROUTES_PARAMS="network gateway unreachable prohibit blackhole"
+NETWORK_CONFIG_ROUTES_PARAMS="network gateway unreachable prohibit blackhole mtu"
 
 # Proper error codes
 EXIT_OK=0
index ba57943975e8d5d25d9029a74127413fd3de52cd..ce42e0f36c87e60e4ebfde6be8c1e80be8fde773 100644 (file)
@@ -62,8 +62,7 @@ function firewall_start() {
                # created, we will add a custom policy to every single
                # zone.
 
-               # XXX TODO
-               #policy_zone_add ${zone}
+               policy_zone_add ${zone}
        done
 
        # Load the new ruleset.
index fca8543701295f23536badcecc960a3d37e3927d..d72a1071ef017607bf2d5afb5defa73057b6e2db 100644 (file)
@@ -46,6 +46,9 @@ function route_add() {
                        --blackhole)
                                blackhole="true"
                                ;;
+                       --mtu=*)
+                               mtu=$(cli_get_val ${1})
+                               ;;
                        *)
                                network=${1}
                                ;;
@@ -104,6 +107,11 @@ function route_add() {
                fi
        fi
 
+       if isset mtu && ! isinteger mtu; then
+               error "MTU must be an integer number: ${mtu}"
+               return ${EXIT_ERROR}
+       fi
+
        local line
        list_append line "network=\"${network}\""
 
@@ -121,6 +129,11 @@ function route_add() {
                fi
        done
 
+       # Add MTU (if set).
+       if isset mtu; then
+               list_append line "mtu=\"${mtu}\""
+       fi
+
        # Write line to file.
        print "${line}" >> ${NETWORK_CONFIG_ROUTES}
 
@@ -180,8 +193,8 @@ function route_list() {
                return ${EXIT_OK}
        fi
 
-       local format="%-40s %-20s"
-       print "${format}" "NETWORK/HOST" "GATEWAY"
+       local format="%-40s %-20s %-4s"
+       print "${format}" "NETWORK/HOST" "GATEWAY" "MTU"
 
        local ${NETWORK_CONFIG_ROUTES_PARAMS}
        local line
@@ -203,7 +216,12 @@ function route_list() {
                        [ "${protocol}" = "${proto}" ] || continue
                fi
 
-               print "${format}" "${network}" "${gateway}"
+               # Print something when no MTU was set.
+               if ! isset mtu; then
+                       mtu="-"
+               fi
+
+               print "${format}" "${network}" "${gateway}" "${mtu}"
        done < ${NETWORK_CONFIG_ROUTES}
 }
 
@@ -250,6 +268,9 @@ function route_parse_line() {
                        blackhole=*)
                                blackhole=$(cli_get_val ${arg})
                                ;;
+                       mtu=*)
+                               mtu=$(cli_get_val ${arg})
+                               ;;
                esac
        done <<< "$(args $@)"
 
@@ -274,6 +295,11 @@ function route_parse_line() {
                [ ${counter} -eq 1 ] || return ${EXIT_ERROR}
        fi
 
+       # mtu must be an integer number.
+       if isset mtu; then
+               isinteger mtu || return ${EXIT_ERROR}
+       fi
+
        return ${EXIT_OK}
 }
 
@@ -303,7 +329,7 @@ function route_apply() {
 
                # Add the route.
                route_entry_add ${network} --table="static" --proto="static" \
-                       --type="${type}" --gateway="${gateway}"
+                       --type="${type}" --gateway="${gateway}" --mtu="${mtu}"
                local ret=$?
 
                if [ ${ret} -ne ${EXIT_OK} ]; then
@@ -321,6 +347,7 @@ function route_entry_add() {
        local proto
        local table
        local type="unicast"
+       local mtu
 
        local command
 
@@ -338,6 +365,9 @@ function route_entry_add() {
                        --proto=*)
                                proto=$(cli_get_val ${1})
                                ;;
+                       --mtu=*)
+                               mtu=$(cli_get_val ${1})
+                               ;;
                        *)
                                if isset network; then
                                        warning "Unrecognized argument: ${1}"
@@ -352,6 +382,9 @@ function route_entry_add() {
        # Validate input.
        assert isoneof type unicast broadcast unreachable prohibit blackhole
        assert ip_is_network ${network}
+       if isset mtu; then
+               assert isinteger mtu
+       fi
 
        # Detect the protocol of the given network.
        local protocol=$(ip_detect_protocol ${network})
@@ -391,7 +424,12 @@ function route_entry_add() {
                list_append command "proto ${proto}"
        fi
 
-       cmd "${command}"
+       # Add MTU.
+       if isset mtu; then
+               list_append command "mtu ${mtu}"
+       fi
+
+       cmd_quiet "${command}"
 }
 
 function route_table_create() {
index 33e0f975f9b29123e862191002f4798d316af42e..391e682800257520c6b13dba49cc00658abbef67 100755 (executable)
@@ -149,7 +149,6 @@ function _edit() {
 
 function _up() {
        local port=${1}
-
        assert isset port
 
        config_read $(port_file ${port})
index d00116f99be966a1455707914e3020fcdbccdec5..f1718e730c97fd4740248ae2aee3c46d961a8236 100755 (executable)
@@ -128,6 +128,7 @@ function _status() {
        #       cli_print_fmt1 2 "Topology change count" \
        #               "$(stp_bridge_get_topology_change_count ${zone})"
        #       cli_space
+               :
        else
                cli_print 2 "Disabled"
                cli_space
index baaf12f4e4e856030d1b1a36e32b44e18019c99b..de4393993bd3b0e9e1969b1eb946864f77fb4853 100644 (file)
@@ -4,7 +4,7 @@
 network-route \- Network Route Configuration Control Program
 
 .SH SYNOPSIS
-\fBnetwork [OPTIONS] route add <network> [--gateway=..., --unreachable, --prohibit, --blackhole]\fR
+\fBnetwork [OPTIONS] route add <network> <--gateway=..., --unreachable, --prohibit, --blackhole> [--mtu=N]\fR
 .P
 \fBnetwork [OPTIONS] route remove <network>\fR
 .P
@@ -18,7 +18,7 @@ It is possible to create and remove static routes.
 .SH COMMANDS
 The \fBnetwork route\fR command offers various sub commands:
 
-\fBadd <network> [--gateway=..., --unreachable, --prohibit, --blackhole]\fR
+\fBadd <network> <--gateway=..., --unreachable, --prohibit, --blackhole> [--mtu=N]\fR
 .RS 4
 A new route may be added by the \fBadd\fR command.
 It is always required to pass a valid network prefix (\fB<network>\fR), which
@@ -30,6 +30,9 @@ prefix is.
 .PP
 Use \fB--unreachable\fR, \fB--prohibit\fR, \fB--blackhole\fR can be used to create
 of that type. See \fBROUTE TYPES\fR below for more information about these options.
+.PP
+The optional \fB--mtu\fR parameter defines the MTU along the path to the
+destination and must be an integer number.
 .RE
 .PP
 
@@ -41,11 +44,12 @@ A route can be removed with this command.
 .RE
 .PP
 
-\fBlist [--ipv6|--ipv4]\fR
+\fBlist [--protocol=ipv6|ipv4]\fR
 .RS 4
 Shows a list of all configured routes.
 .PP
-Pass the protocol as shown above to filter.
+Pass the protocol option to filter the output only for the given
+protocol.
 .RE
 .PP