summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rc.inet123
-rw-r--r--rc.inet1.conf4
2 files changed, 11 insertions, 16 deletions
diff --git a/rc.inet1 b/rc.inet1
index 6b88d2a..64dbb05 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -73,27 +73,20 @@ lo_down() {
# INTERFACE FUNCTIONS #
#######################
-# Function to determine if virtual interfaces are defined
-virtif_determine() {
- if [ -n "${VIRTIFNAME}" ]; then
- virtifcount=$(($(echo ${VIRTIFNAME[@]} | wc -w) - 1))
- else
- return 1
- fi
-}
-
# Function to create virtual interfaces
virtif_create() {
- # argument is 'i' - the position of this interface in the IFNAME array.
- for i in $(seq 0 ${virtifcount}); do
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ # this loop goes from i=0 to i=number_of_configured_virtual_interfaces_minus_one
+ # which means it doesn't do anything if there are none.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
/sbin/ip tuntap add dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]} user ${VIRTIFUSER[$i]} group ${VIRTIFGROUP[$i]}
done
}
# Function to destory virtual interfaces
virtif_destroy() {
- # argument is 'i' - the position of this interface in the IFNAME array.
- for i in $(seq 0 ${virtifcount}); do
+ # argument is 'i' - the position of this interface in the VIRTIFNAME array.
+ for i in $(seq 0 $((${#VIRTIFNAME[@]} - 1))); do
/sbin/ip tuntap del dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]}
done
}
@@ -296,7 +289,7 @@ gateway_down() {
# Function to start the network:
start() {
lo_up
- virtif_determine && virtif_create
+ virtif_create
for i in "${IFNAME[@]}" ; do
if_up $i
done
@@ -309,7 +302,7 @@ stop() {
for i in "${IFNAME[@]}" ; do
if_down $i
done
- virtif_determine && virtif_destroy
+ virtif_destroy
lo_down
}
diff --git a/rc.inet1.conf b/rc.inet1.conf
index 11e68ab..58766d2 100644
--- a/rc.inet1.conf
+++ b/rc.inet1.conf
@@ -63,7 +63,9 @@ DEBUG_ETH_UP="no"
# Virtual interfaces to create - these are created before any address
# configuration or bridge setup is done, so you may use these interfaces
# as IFNAME or BRNICS values. These can be tun or tap interfaces:
-# adjust VIRTIFNAME and VIRTIFTYPE accordingly
+# adjust VIRTIFNAME and VIRTIFTYPE accordingly.
+# Starting with VIRTIFNAME[0] is mandatory, and each next one must be
+# incremented by one, so VIRTIFNAME[1], VIRTIFNAME[2], and so on.
#
# Virtual tap interface example
#VIRTIFNAME[0]="tap0"