diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2015-11-08 06:29:50 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2015-11-08 06:29:50 -0800 |
commit | 2ce8b833812e5db9de7cf1543dd6499b4077db21 (patch) | |
tree | 48d7d95ba7e056029415e0f6648730042f1ec7cb | |
parent | New interface type: dummy. (diff) | |
download | netifrc-2ce8b833812e5db9de7cf1543dd6499b4077db21.tar.gz netifrc-2ce8b833812e5db9de7cf1543dd6499b4077db21.tar.bz2 netifrc-2ce8b833812e5db9de7cf1543dd6499b4077db21.zip |
New interace type: HSR.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | doc/net.example.Linux.in | 6 | ||||
-rw-r--r-- | net/hsr.sh | 56 |
3 files changed, 62 insertions, 1 deletions
@@ -12,7 +12,6 @@ - add vlan3 - _ifindex (eth0=0,vlan2=1,vlan3=2) Now your routing table has entries for both vlan2 and vlan3 with a metric of 2. - Support many more device types easily: - - HSR: ip link add name hsr0 type hsr slave1 dummy3 slave2 dummy4 - VXLAN: ip link add link dummy2 name vxlan199 type vxlan id 199 dev dummy2 group 224.2.0.199 dstport 4789 - IPVLAN: ... - IFB: ip link add ifb0 type ifb diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in index 1eaebac..6059301 100644 --- a/doc/net.example.Linux.in +++ b/doc/net.example.Linux.in @@ -159,6 +159,12 @@ # # Dummy network interface: #type_dummy0=dummy +# +# HSR: High-availability Seamless Redundancy +#type_hsr0=hsr +#hsr_slave1=eth0 +#hsr_slave2=eth1 +#hsr_supervision=99 # Byte value #----------------------------------------------------------------------------- # WIRELESS (802.11 support) diff --git a/net/hsr.sh b/net/hsr.sh new file mode 100644 index 0000000..94ecc01 --- /dev/null +++ b/net/hsr.sh @@ -0,0 +1,56 @@ +# Copyright (c) 2015 Gentoo Foundation +# All rights reserved. Released under the 2-clause BSD license. + +hsr_depend() +{ + program ip + after interface + before dhcp macchanger +} + +_is_hsr() { + is_interface_type hsr +} + +hsr_pre_start() +{ + local hsr= + eval hsr=\$type_${IFVAR} + [ "${hsr}" = "hsr" ] || return 0 + eval hsr_slave1=\$hsr_slave1_${IFVAR} + eval hsr_slave2=\$hsr_slave2_${IFVAR} + eval hsr_supervision=\$hsr_supervision_${IFVAR} + if [ -z "${hsr_slave1}" ] || [ -z "${hsr_slave2}" ]; then + eerror "HSR interfaces require two slave interfaces to be set" + return 1 + fi + if ! ( IFACE=${hsr_slave1} _exists ); then + eerror "HSR slave1 ${hsr_slave1} does not exist" + return 1 + fi + if ! ( IFACE=${hsr_slave2} _exists ); then + eerror "HSR slave2 ${hsr_slave2} does not exist" + return 1 + fi + + ebegin "Creating HSR interface ${IFACE}" + cmd="ip link add name "${IFACE}" type hsr slave1 ${hsr_slave1} slave2 ${hsr_slave2} ${hsr_supervision:+supervision }${hsr_supervision}" + veinfo $cmd + if $cmd ; then + eend 0 && _up && set_interface_type hsr + else + eend 1 + fi +} + + +hsr_post_stop() +{ + _is_hsr || return 0 + + ebegin "Removing HSR ${IFACE}" + cmd="ip link delete "${IFACE}" type hsr" + veinfo "$cmd" + $cmd + eend $? +} |