public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: net/, doc/
Date: Tue, 13 Dec 2011 04:12:59 +0000 (UTC)	[thread overview]
Message-ID: <a38a5071f3ddcde7f18514d4d669d2bc0fde2736.WilliamH@gentoo> (raw)

commit:     a38a5071f3ddcde7f18514d4d669d2bc0fde2736
Author:     Salah Coronya <salah.coronya <AT> gmail <DOT> com>
AuthorDate: Mon Dec 12 04:06:30 2011 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Dec 13 03:40:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=a38a5071

Tuntap: add iproute2 support

This patch was modified by William Hubbs <williamh <AT> gentoo.org> to
document the new usage in net.example.

X-Gentoo-Bug: 394281
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=394281

---
 doc/net.example.Linux.in |    5 ++++-
 net/tuntap.sh            |   24 +++++++++++++++++-------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
index 7bae8d7..a86eebc 100644
--- a/doc/net.example.Linux.in
+++ b/doc/net.example.Linux.in
@@ -790,7 +790,7 @@
 
 #-----------------------------------------------------------------------------
 # TUN/TAP
-# For TUN/TAP support emerge net-misc/openvpn or sys-apps/usermode-utilities
+# For TUN/TAP support install iproute2, openvpn or usermode-utilities
 #
 # You must specify if we're a tun or tap device. Then you can give it any
 # name you like - such as vpn
@@ -801,6 +801,9 @@
 #tuntap_tap0="tap"
 #config_tap0="192.168.0.1/24"
 
+# Use something like this to pass custom options to iproute2 during
+# tunnel creation. This sets the user and group ownership of the node.
+#iproute2_tun1="user foo group bar"
 # For passing custom options to tunctl use something like the following.  This
 # example sets the owner to adm
 #tunctl_tun1="-u adm"

diff --git a/net/tuntap.sh b/net/tuntap.sh
index ac505ab..45a80fe 100644
--- a/net/tuntap.sh
+++ b/net/tuntap.sh
@@ -6,7 +6,7 @@ tuntap_depend()
 	before bridge interface macchanger
 }
 
-_config_vars="$_config_vars tunctl"
+_config_vars="$_config_vars iproute2 openvpn tunctl"
 
 _is_tuntap()
 {
@@ -44,28 +44,36 @@ tuntap_pre_start()
 	# Set the base metric to 1000
 	metric=1000
 
-	local o_opts= t_opts= do_openvpn=false do_tunctl=false
+	local i_opts= o_opts= t_opts=
+	local do_iproute2=false do_openvpn=false do_tunctl=false
+	eval i_opts=\$iproute2_${IFVAR}
 	eval o_opts=\$openvpn_${IFVAR}
 	eval t_opts=\$tunctl_${IFVAR}
 
-	if [ -n "${o_opts}" ] && type openvpn >/dev/null 2>&1; then
+	if [ -n "${i_opts}" ] && type ip >/dev/null 2>&1; then
+		do_iproute2=true
+	elif [ -n "${o_opts}" ] && type openvpn >/dev/null 2>&1; then
 		do_openvpn=true
 	elif [ -n "${t_opts}" ] && type tunctl >/dev/null 2>&1; then
 		do_tunctl=true
+	elif type ip >/dev/null 2>&1; then
+		do_iproute2=true
 	elif type openvpn >/dev/null 2>&1; then
 		do_openvpn=true
 	elif type tunctl >/dev/null 2>&1; then
 		do_tunctl=true
 	fi
 
-	if ${do_openvpn}; then
+	if ${do_iproute2}; then
+		ip tuntap add dev "${IFACE}" mode "${tuntap}" ${i_opts}
+	elif ${do_openvpn}; then
 		openvpn --mktun --dev-type "${tuntap}" --dev "${IFACE}" \
 			${o_opts} >/dev/null
 	elif ${do_tunctl}; then
 		tunctl ${t_opts} -t "${IFACE}" >/dev/null
 	else
-		eerror "Neither openvpn nor tunctl has been found, please install"
-		eerror "either \"openvpn\" or \"usermode-utilities\"."
+		eerror "Neither iproute2, openvpn nor tunctl has been found, please install"
+		eerror "either \"iproute2\" \"openvpn\" or \"usermode-utilities\"."
 	fi
 	eend $? && _up && service_set_value tuntap "${tuntap}"
 }
@@ -75,7 +83,9 @@ tuntap_post_stop()
 	_is_tuntap || return 0
 
 	ebegin "Destroying Tun/Tap interface ${IFACE}"
-	if type tunctl >/dev/null 2>&1; then
+	if type ip > /dev/null 2>&1; then
+		ip tuntap del dev ${IFACE} mode $(service_get_value tuntap)
+	elif type tunctl >/dev/null 2>&1; then
 		tunctl -d "${IFACE}" >/dev/null
 	else
 		openvpn --rmtun \



             reply	other threads:[~2011-12-13  4:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13  4:12 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-11-05 23:22 [gentoo-commits] proj/openrc:master commit in: net/, doc/ William Hubbs
2012-07-20 17:20 Robin H. Johnson
2011-12-13  8:21 Robin H. Johnson
2011-10-26 16:31 William Hubbs
2011-04-19 17:49 Robin H. Johnson
2011-04-19 17:19 Robin H. Johnson
2011-02-22  2:59 Robin H. Johnson
2011-02-21  9:44 Robin H. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a38a5071f3ddcde7f18514d4d669d2bc0fde2736.WilliamH@gentoo \
    --to=williamh@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox