From: Michael Tremer Date: Sun, 5 May 2013 18:26:59 +0000 (+0200) Subject: ipv6: Replace configuration with new sysctl commands. X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fnetwork.git;a=commitdiff_plain;h=9f742d4999a5725f1588c1952f3075e5701c1c07 ipv6: Replace configuration with new sysctl commands. --- diff --git a/functions.ipv6 b/functions.ipv6 index 38a74170..6e0d1516 100644 --- a/functions.ipv6 +++ b/functions.ipv6 @@ -21,120 +21,35 @@ IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv6" -function ipv6_init() { - log INFO "Initializing IPv6 networking." - - # Enable forwarding on all devices - #ipv6_device_forwarding_disable all - #ipv6_device_forwarding_disable default - - # Disable autoconfiguration on all devices per default - #ipv6_device_autoconf_disable all - #ipv6_device_autoconf_disable default - - # XXX do we need this? - #local device - #for device in $(devices_get_all); do - # ipv6_device_forwarding_disable ${device} - # ipv6_device_autoconf_disable ${device} - #done -} - -init_register ipv6_init - function ipv6_device_autoconf_enable() { - local device=${1} + local device="${1}" + assert device_exists "${device}" - assert isset device - - # Allow setting default and all settings - if ! isoneof device all default; then - assert device_exists ${device} - fi - - local val - for val in accept_ra accept_redirects; do - echo 1 > /proc/sys/net/ipv6/conf/${device}/${val} - done + sysctl_set "net.ipv6.conf.${device}.accept_ra" 1 + sysctl_set "net.ipv6.conf.${device}.autoconf" 1 } function ipv6_device_autoconf_disable() { - local device=${1} - - assert isset device - - # Allow setting default and all settings - if ! isoneof device all default; then - assert device_exists ${device} - fi - - local val - for val in accept_ra accept_redirects; do - echo 0 > /proc/sys/net/ipv6/conf/${device}/${val} - done -} - -function ipv6_device_forwarding_enable() { - local device=${1} - - assert isset device - - # Allow setting default and all settings - if ! isoneof device all default; then - assert device_exists ${device} - fi + local device="${1}" + assert device_exists "${device}" - echo 1 > /proc/sys/net/ipv6/conf/${device}/forwarding -} - -function ipv6_device_forwarding_disable() { - local device=${1} - - assert isset device - - # Allow setting default and all settings - if ! isoneof device all default; then - assert device_exists ${device} - fi - - echo 0 > /proc/sys/net/ipv6/conf/${device}/forwarding + sysctl_set "net.ipv6.conf.${device}.accept_ra" 0 + sysctl_set "net.ipv6.conf.${device}.autoconf" 0 } # Enable IPv6 RFC3041 privacy extensions if desired function ipv6_device_privacy_extensions_enable() { - local device=${1} - local type=${2} - - assert isset device - assert device_exists ${device} - - # Default value is rfc3041 - if [ -z "${type}" ]; then - type="rfc3041" - fi + local device="${1}" + assert device_exists "${device}" - assert isset type - - case "${type}" in - rfc3041) - echo 2 > /proc/sys/net/ipv6/conf/${device}/use_tempaddr - ;; - *) - error_log "Given type '${type}' is not supported." - return ${EXIT_ERROR} - ;; - esac - - return ${EXIT_OK} + sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 2 } function ipv6_device_privacy_extensions_disable() { - local device=${1} - - assert isset device - assert device_exists ${device} + local device="${1}" + assert device_exists "${device}" - echo 0 > /proc/sys/net/ipv6/conf/${device}/use_tempaddr + sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 0 } function ipv6_is_valid() {