public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/netifrc:master commit in: /, net/, doc/
@ 2015-11-08 14:30 Robin H. Johnson
  0 siblings, 0 replies; only message in thread
From: Robin H. Johnson @ 2015-11-08 14:30 UTC (permalink / raw
  To: gentoo-commits

commit:     2ce8b833812e5db9de7cf1543dd6499b4077db21
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  8 14:29:50 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 14:29:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=2ce8b833

New interace type: HSR.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 TODO                     |  1 -
 doc/net.example.Linux.in |  6 ++++++
 net/hsr.sh               | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/TODO b/TODO
index 64f62e2..023bbb4 100644
--- a/TODO
+++ b/TODO
@@ -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 $?
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-08 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-08 14:30 [gentoo-commits] proj/netifrc:master commit in: /, net/, doc/ Robin H. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox