From: Michael Tremer Date: Fri, 3 Aug 2012 10:28:16 +0000 (+0000) Subject: vlan: Check if the kernel has got VLAN support. X-Git-Tag: 005~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8357a7ff047c1563f96c7a5c7c3953c564b12b5a;p=network.git vlan: Check if the kernel has got VLAN support. --- diff --git a/functions.device b/functions.device index ffff8a75..ab1eae15 100644 --- a/functions.device +++ b/functions.device @@ -140,6 +140,10 @@ function device_has_virtuals() { function device_get_virtuals() { local device=${1} + # If no 8021q module has been loaded into the kernel, + # we cannot do anything. + [ -r "/proc/net/vlan/config" ] || return ${EXIT_OK} + local dev spacer1 id spacer2 parent while read dev spacer1 id spacer2 parent; do [ "${parent}" = "${device}" ] && echo "${dev}" diff --git a/functions.virtual b/functions.virtual index bf13809e..ba037ba8 100644 --- a/functions.virtual +++ b/functions.virtual @@ -144,6 +144,9 @@ function virtual_remove() { function virtual_get_parent() { local device=${1} + # Nothing to do, if 8021q module is not loaded. + [ -r "/proc/net/vlan/config" ] || return ${EXIT_OK} + local dev spacer1 id spacer2 parent while read dev spacer1 id spacer2 parent; do if [ "${device}" = "${dev}" ]; then @@ -158,6 +161,9 @@ function virtual_get_parent() { function virtual_get_id() { local device=${1} + # Nothing to do, if 8021q module is not loaded. + [ -r "/proc/net/vlan/config" ] || return ${EXIT_OK} + local dev spacer1 id spacer2 parent while read dev spacer1 id spacer2 parent; do if [ "${device}" = "${dev}" ]; then @@ -176,7 +182,8 @@ function virtual_get_by_parent_and_vid() { assert isset parent assert isset vid - assert [ -e "/proc/net/vlan/config" ] + # Nothing to do, if 8021q module is not loaded. + [ -r "/proc/net/vlan/config" ] || return ${EXIT_OK} local dev spacer1 id spacer2 par while read dev spacer1 id spacer2 par; do