Improve is_ipv6_enabled() (thx stanv@).
Check if module ipv6 is loaded, but disabled by sysctl configuration. Also add optional argument to check ipv6 per interface.
This commit is contained in:
parent
39af5f3d6e
commit
535e489ef1
@ -52,9 +52,25 @@ valid_ipv4addr()
|
||||
|
||||
|
||||
### IPv6 helpers
|
||||
# argument (interface name) is optional
|
||||
is_ipv6_enabled()
|
||||
{
|
||||
[ -e /proc/net/if_inet6 ]
|
||||
local iface="${1-}"
|
||||
|
||||
# Check if module ipv6 is not loaded or disabled
|
||||
[ -e /proc/net/if_inet6 ] || return 1
|
||||
|
||||
# Check if ipv6 disabled by sysctl
|
||||
if [ -n "$iface" -a -e /proc/sys/net/ipv6/conf/"$iface"/disable_ipv6 ]; then
|
||||
[ "$(cat /proc/sys/net/ipv6/conf/"$iface"/disable_ipv6)" = '0' ] &&
|
||||
return 0 || return 1
|
||||
fi
|
||||
if [ -e /proc/sys/net/ipv6/conf/all/disable_ipv6 ]; then
|
||||
[ "$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6)" = '0' ] &&
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
valid_ipv6addr()
|
||||
|
Loading…
x
Reference in New Issue
Block a user