commit:     15cd79dc46303988464d962ad6bf59050feba801
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  8 14:16:08 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Nov  8 14:29:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=15cd79dc

New interface type: dummy.

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

 TODO                     |  1 -
 doc/net.example.Linux.in |  9 +++++++++
 net/dummy.sh             | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/TODO b/TODO
index f8d8902..64f62e2 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:
-  - Dummy: ip link add dev dummy1 type dummy
   - 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: ...

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index f71385d..1eaebac 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -150,6 +150,15 @@
 
 ##############################################################################
 # OPTIONAL MODULES
+#-----------------------------------------------------------------------------
+# IPROUTE2 INTERFACE TYPES
+# The type_$iface variable maps to the link type parameter in iproute2.
+# If you need to use additional interface types, you should try to use that
+# parameter. Supported interface types are listed below. Please note that some
+# interface types may mandate a specific naming scheme.
+#
+# Dummy network interface:
+#type_dummy0=dummy
 
 #-----------------------------------------------------------------------------
 # WIRELESS (802.11 support)

diff --git a/net/dummy.sh b/net/dummy.sh
new file mode 100644
index 0000000..3050216
--- /dev/null
+++ b/net/dummy.sh
@@ -0,0 +1,41 @@
+# Copyright (c) 2015 Gentoo Foundation
+# All rights reserved. Released under the 2-clause BSD license.
+
+dummy_depend()
+{
+       program ip
+       after interface
+       before dhcp macchanger
+}
+
+_is_dummy() {
+       is_interface_type dummy
+}
+
+dummy_pre_start()
+{
+       local dummy=
+       eval dummy=\$type_${IFVAR}
+       [ "${dummy}" = "dummy" ] || return 0
+
+       ebegin "Creating dummy interface ${IFACE}"
+       cmd="ip link add name "${IFACE}" type dummy"
+       veinfo $cmd
+       if $cmd ; then
+               eend 0 && _up && set_interface_type dummy
+       else
+               eend 1
+       fi
+}
+
+
+dummy_post_stop()
+{
+       _is_dummy || return 0
+
+       ebegin "Removing dummy ${IFACE}"
+       cmd="ip link delete "${IFACE}" type dummy"
+       veinfo "$cmd"
+       $cmd
+       eend $?
+}

Reply via email to