]> git.ipfire.org Git - network.git/commitdiff
Fix setting of default routes.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jul 2011 17:38:46 +0000 (17:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Jul 2011 17:38:46 +0000 (17:38 +0000)
functions.routing

index ac5c4da71013c993822829163ed0fe8f87aecb40..3a52ce4a4a18a4253698b1c121f24eedb9154037 100644 (file)
@@ -35,11 +35,14 @@ function routing_default_update() {
        local proto
        local weight
        local zone
+       local cmd
 
        for proto in ${IP_SUPPORTED_PROTOCOLS}; do
                # Clear routes
                routes=""
 
+               cmd="ip $([ "${proto}" = "ipv6" ] && echo "-6") route"
+
                for zone in ${zones}; do
                        # Skip if zone is not up
                        routing_db_exists ${zone} ${proto} || continue
@@ -48,7 +51,11 @@ function routing_default_update() {
                                gateway=$(routing_db_get ${zone} ${proto} remote-ip-address)
                                weight=$(routing_db_get ${zone} ${proto} weight)
 
-                               routes="${routes} nexthop via ${gateway}"
+                               if device_is_ppp ${zone}; then
+                                       routes="${routes} dev ${zone}"
+                               else
+                                       routes="${routes} nexthop via ${gateway}"
+                               fi
 
                                if [ -n "${weight}" ]; then
                                        routes="${routes} weight ${weight}"
@@ -58,22 +65,30 @@ function routing_default_update() {
                        fi
                done
 
-               if [ -z "${routes}" ]; then
-                       log INFO "Removing default route for ${proto}."
+               # Remove too much spaces.
+               routes=$(echo ${routes})
 
-                       if routing_has_default; then
-                               ip route del default
-                       fi
+               # Remove all default routes.
+               while ${cmd} | grep -q "^default"; do
+                       ${cmd} del default
+               done
+
+               if [ -z "${routes}" ]; then
+                       log INFO "Removed default route for ${proto}."
                        return ${EXIT_OK}
                fi
 
-               # Remove too much spaces.
-               routes=$(echo ${routes})
-
                log INFO "Setting default route for ${proto}: ${routes}"
 
-               ip $([ "${proto}" = "ipv6" ] && echo "-6") route replace default ${routes}
+               ${cmd} add default ${routes}
                assert [ $? -eq 0 ]
+
+               case "${proto}" in
+                       ipv6)
+                               # Apply radvd configuration.
+                               radvd_update
+                               ;;
+               esac
        done
 }