summaryrefslogtreecommitdiffstats
path: root/rc.inet1
diff options
context:
space:
mode:
authorDarren 'Tadgy' Austin <darren@afterdark.org.uk>2019-11-13 22:10:37 +0000
committerDarren 'Tadgy' Austin <darren@afterdark.org.uk>2019-11-13 22:10:37 +0000
commit13dbfe19e521b9821dba0fee36a9e0ed8ab07fb6 (patch)
tree2d3492c3dd3c35cbedbc33cdf3da786cecd8937a /rc.inet1
parent247bad13e843f349d062b86dafeec8fd3b8162e7 (diff)
downloadslacknetsetup-13dbfe19e521b9821dba0fee36a9e0ed8ab07fb6.tar.xz
Remove BONDOPTS, VLANOPTS and BROPTS and replace with generic IFOPTS.
Previously we had an xOPTS variable for each type of interface that could be configured. I've replaced this with a generic IFOPTS option which can be used to supply interface type specific options to 'ip'. As the option is now generic, it can be applied to physical interfaces too; so interfaces such as eth0 can have options applied just like a virtual interface.
Diffstat (limited to 'rc.inet1')
-rw-r--r--rc.inet141
1 files changed, 26 insertions, 15 deletions
diff --git a/rc.inet1 b/rc.inet1
index 5e31c08..b9374ce 100644
--- a/rc.inet1
+++ b/rc.inet1
@@ -154,12 +154,12 @@ br_open() {
debug_log "/sbin/ip link set dev $BRIF up"
/sbin/ip link set dev $BRIF up
done
- while read -r -d \| BROPT; do
- if [ -n "$BROPT" ]; then
- debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bridge $BROPT"
- /sbin/ip link set dev ${IFNAME[$1]} type bridge $BROPT
+ while read -r -d \| IFOPT; do
+ if [ -n "$IFOPT" ]; then
+ debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bridge $IFOPT"
+ /sbin/ip link set dev ${IFNAME[$1]} type bridge $IFOPT
fi
- done <<<"${BROPTS[$i]}|" # The | on the end is required.
+ done <<<"${IFOPTS[$i]}|" # The | on the end is required.
debug_log "/sbin/ip link set dev ${IFNAME[$1]} up"
/sbin/ip link set dev ${IFNAME[$1]} up
}
@@ -199,12 +199,14 @@ bond_create() {
debug_log "/sbin/ip link set dev $BONDIF up"
/sbin/ip link set dev $BONDIF up
done
- while read -r -d \| BONDOPT; do
- if [ -n "$BONDOPT" ]; then
- debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bond $BONDOPT"
- /sbin/ip link set dev ${IFNAME[$1]} type bond $BONDOPT
+ # This has to be done *after* the interface is brought up because the
+ # 'primary <interface>' option has to occur after the interface is active.
+ while read -r -d \| IFOPT; do
+ if [ -n "$IFOPT" ]; then
+ debug_log "/sbin/ip link set dev ${IFNAME[$1]} type bond $IFOPT"
+ /sbin/ip link set dev ${IFNAME[$1]} type bond $IFOPT
fi
- done <<<"${BONDOPTS[$1]}|" # The | on the end is required.
+ done <<<"${IFOPTS[$1]}|" # The | on the end is required.
}
# Function to destroy a bond.
@@ -277,12 +279,21 @@ if_up() {
((IF_UP == 1)) && /sbin/ip link set dev $IFACE down
return
fi
- while read -r -d \| VLANOPT; do
- if [ -n "$VLANOPT" ]; then
- debug_log "/sbin/ip link set dev ${1} type vlan $VLANOPT"
- /sbin/ip link set dev ${1} type vlan $VLANOPT
+ while read -r -d \| IFOPT; do
+ if [ -n "$IFOPT" ]; then
+ debug_log "/sbin/ip link set dev ${1} type vlan $IFOPT"
+ /sbin/ip link set dev ${1} type vlan $IFOPT
fi
- done <<<"${VLANOPTS[$i]}|" # The | on the end is required.
+ done <<<"${IFOPTS[$i]}|" # The | on the end is required.
+ elif [ -z "${BONDNICS[$i]}" ] && [ -z "${BRNICS[$i]}" ]; then
+ # Only apply IFOPTS for a physical interface if it's not been handled
+ # by a higher level interface.
+ while read -r -d \| IFOPT; do
+ if [ -n "$IFOPT" ]; then
+ debug_log "/sbin/ip link set dev ${1} $IFOPT"
+ /sbin/ip link set dev ${1} $IFOPT
+ fi
+ done <<<"${IFOPTS[$i]}|" # The | on the end is required.
fi
# Set hardware address:
if [ -n "${HWADDR[$i]}" ]; then