]> git.ipfire.org Git - people/arne_f/network.git/blobdiff - hooks/zones/bridge.configs/ipv4-static
network: Fix duplicate check.
[people/arne_f/network.git] / hooks / zones / bridge.configs / ipv4-static
index 9ea7288d133dc246097cf0dd18136e358286f159..c9462d5e141ac6083c1ac86bd7a6fe5494faab66 100755 (executable)
@@ -78,13 +78,26 @@ function _up() {
        config_read $(zone_dir ${zone})/configs/${config}
 
        if ! zone_has_ipv4 ${zone} ${ADDRESS}/${PREFIX}; then
+               if ipv4_detect_duplicate ${zone} ${ADDRESS}; then
+                       error_log "Duplicate address detected on zone '${zone}' (${ADDRESS})."
+                       error_log "Cannot continue."
+                       exit ${EXIT_ERROR}
+               fi
+
                ip addr add ${ADDRESS}/${PREFIX} dev ${zone}
-       else
-               warning "Do not set IPv4 address '${ADDRESS}/${PREFIX}' because it was already configured on zone '${zone}'."
+
+               # Announce our new address to the neighbours
+               ipv4_update_neighbours ${zone} ${ADDRESS}
        fi
 
        if zone_is_nonlocal ${zone} && [ -n "${GATEWAY}" ]; then
-               : # XXX to be done
+               # Save configuration
+               red_db_set ${zone} type "${HOOK}"
+               red_db_set ${zone} local-ip-address ${ADDRESS}/${PREFIX}
+               red_db_set ${zone} remote-ip-address ${GATEWAY}
+               
+               red_db_set ${zone} active 1
+               red_routing_update ${zone}
        fi
 
        exit ${EXIT_OK}