diff --git a/netdev.sh b/netdev.sh index 45eefac..166def3 100755 --- a/netdev.sh +++ b/netdev.sh @@ -7,20 +7,25 @@ header_eb() { } header_if() { - echo "define INTERFACE $1" + local if="${1:?missing if}" + echo "define INTERFACE $if" } header_addr() { - echo "define ADDR $1" + local addr="${1:?missing addr}" + echo "define ADDR $addr" } header_vlan() { - echo "define VLAN $1" - echo "define PARENT $2" + local vlan="${1:?missing vlan}" + local parent="${2:?missing parent}" + echo "define VLAN $vlan" + echo "define PARENT $parent" } header_vrf() { - echo "define VRF $1" + local vrf="${1:?missing vrf}" + echo "define VRF $vrf" } header_path() { @@ -44,12 +49,13 @@ h_if_addr() { } linkdel() { - h_if "$1" + local if="${1:?missing if}" + h_if "$if" echo 'ip link del $INTERFACE' } ifbundle() { - local if="$1" + local if="${1:?missing if}" [ -r "rc/bundle.interface.$if/type" ] || install -Dm644 <(echo bundle) rc/bundle.interface."$if"/type shift 1 for sname in $@; do @@ -58,7 +64,7 @@ ifbundle() { } new_link() { - local if="$1" + local if="${1:?missing if}" local sname="interface.$if.link" @@ -75,7 +81,7 @@ new_link() { } new_forward() { - local if="$1" + local if="${1:?missing if}" local sname="sysctl.net-ipv6-conf-$if-forwarding" ifbundle "$if" "$sname" @@ -106,8 +112,8 @@ EOF } new_if_slave() { - local master="$1" - local slave="$2" + local master="${1:?missing master}" + local slave="${2:?missing slave}" local sname="interface.$master.slave.$slave" ifbundle "$master" "$sname" @@ -135,7 +141,7 @@ EOF } new_if_bridge() { - local if="$1" + local if="${1:?missing if}" local sname="interface.$if.create" ifbundle "$if" "$sname" @@ -151,8 +157,46 @@ new_if_bridge() { new_link "$if" } +bridge_stp() { + local if="${1:?missing if}" + local state="${2:-1}" + + local sname="interface.$if.stp" + ifbundle "$if" "$sname" + + install -Dm644 <( + h_if "$if" + cat <