summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSalah Coronya <salah.coronya@gmail.com>2011-12-11 22:06:30 -0600
committerWilliam Hubbs <williamh@gentoo.org>2011-12-12 21:40:39 -0600
commita38a5071f3ddcde7f18514d4d669d2bc0fde2736 (patch)
tree0682cfa5b999e908ea319e43d2ec4279c8ad3130 /net
parent2569eb644e6e8e010a44a693e7dfa86e73c0d750 (diff)
downloadopenrc-a38a5071f3ddcde7f18514d4d669d2bc0fde2736.tar.gz
openrc-a38a5071f3ddcde7f18514d4d669d2bc0fde2736.tar.bz2
openrc-a38a5071f3ddcde7f18514d4d669d2bc0fde2736.tar.xz
Tuntap: add iproute2 support
This patch was modified by William Hubbs <williamh@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
Diffstat (limited to 'net')
-rw-r--r--net/tuntap.sh24
1 files changed, 17 insertions, 7 deletions
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 \