]> git.ipfire.org Git - network.git/commitdiff
vlan: Check if the kernel has got VLAN support.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Aug 2012 10:28:16 +0000 (10:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Aug 2012 10:28:16 +0000 (10:28 +0000)
functions.device
functions.virtual

index ffff8a75ec8d8529964ae24975ccb7d4cd0b46f6..ab1eae15e57dfddb61be58fd3f870a3376fa88a9 100644 (file)
@@ -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}"
index bf13809e384ad4fbe23d481130b5b986fdc08513..ba037ba8de30e08640a3f28f4f21487387598f90 100644 (file)
@@ -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