]> git.ipfire.org Git - network.git/commitdiff
Fix setting local routes on zone's routing tables.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 31 Oct 2011 19:40:29 +0000 (19:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 31 Oct 2011 19:40:29 +0000 (19:40 +0000)
functions.ipv4
functions.routing

index 678b1e7334287d76094bc62631802b8d40e6a9be..d074ca940ab35408876d6be8e446d445b5ec20a3 100644 (file)
@@ -57,3 +57,19 @@ function ipv4_update_neighbours() {
        arping -q -A -c 1 -I ${device} ${address}
        ( sleep 2; arping -q -U -c 1 -I ${device} ${address} ) >/dev/null 2>&1 </dev/null &
 }
+
+function ipv4_get_netaddress() {
+       local address=${1}
+       assert isset address
+
+       local prefix=$(ip_get_prefix ${address})
+       assert isset prefix
+
+       local NETWORK
+       eval $(ipcalc --network ${address})
+       assert isset NETWORK
+
+       echo "${NETWORK}/${prefix}"
+
+       return ${EXIT_OK}
+}
index 05cd1b29062e6d6cbf3e0330111ddca438a69791..986596acbd0048439d5afd097978cda0b74904fa 100644 (file)
@@ -211,12 +211,17 @@ function routing_update() {
        cmd ip route flush table ${table}
 
        local local_ip_address=$(routing_db_get ${zone} ${proto} local-ip-address)
+       local remote_ip_address=$(routing_db_get ${zone} ${proto} remote-ip-address)
 
        # XXX does not work.
-       #log DEBUG "Adding route for subnet ${local_ip_address} to table ${table}"
-       #cmd ip route add table ${table} ${local_ip_address} dev ${zone}
-
-       local remote_ip_address=$(routing_db_get ${zone} ${proto} remote-ip-address)
+       case "${proto}" in
+               ipv4)
+                       local net_address=$(ipv4_get_netaddress ${local_ip_address})
+
+                       log DEBUG "Adding route for subnet ${local_ip_address} to table ${table}"
+                       cmd ip route add table ${table} ${net_address} dev ${zone}
+                       ;;
+       esac
 
        if isset remote_ip_address; then
                log DEBUG "Adding default route for table ${table}"