From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2558D139694 for ; Fri, 9 Jun 2017 23:55:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7B14121C0A2; Fri, 9 Jun 2017 23:55:11 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C67521C07D for ; Fri, 9 Jun 2017 23:55:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 70832341B10 for ; Fri, 9 Jun 2017 23:55:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1413F7470 for ; Fri, 9 Jun 2017 23:55:09 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1485265552.1f76981467f9bbf1f2e22eb154fbb133ba333773.robbat2@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/iproute2.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 1f76981467f9bbf1f2e22eb154fbb133ba333773 X-VCS-Branch: master Date: Fri, 9 Jun 2017 23:55:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 1211f287-87e8-454e-9953-65cb0480d785 X-Archives-Hash: e75cfead4f1607e59f2454e425732e03 commit: 1f76981467f9bbf1f2e22eb154fbb133ba333773 Author: Sergey Popov pinkbyte ru> AuthorDate: Tue Jan 24 09:18:21 2017 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Tue Jan 24 13:45:52 2017 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1f769814 Support for creating interfaces through iproute2 link command Original idea and patch by Joseph Glanville orionvm.com.au> https://gist.github.com/josephglanville/2757336 net/iproute2.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/net/iproute2.sh b/net/iproute2.sh index 32ea5a4..55c9592 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -392,6 +392,20 @@ iproute2_pre_start() eend $? || return 1 _up fi + local link= + eval link=\$iplink_${IFVAR} + if [ -n "${link}" ]; then + local ipproto='' + [ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6' + [ "${tunnel##mode ip6gretap}" != "${tunnel}" ] && ipproto='-6' + [ "${tunnel##mode ip6tnl}" != "${tunnel}" ] && ipproto='-6' + + ebegin "Creating interface ${IFVAR}" + veinfo ip ${ipproto} link add "${IFACE}" ${link} + ip ${ipproto} link add "${IFACE}" ${link} + eend $? || return 1 + _up + fi # MTU support local mtu= @@ -417,6 +431,13 @@ iproute2_pre_start() return 0 } +_iproute2_link_delete() { + ebegin "Destroying interface $1" + veinfo ip link del dev "$1" + ip link del dev "$1" + eend $? +} + _iproute2_ipv6_tentative() { [ -n "$(LC_ALL=C ip -family inet6 addr show dev ${IFACE} tentative)" ] && return 0 @@ -499,6 +520,8 @@ iproute2_post_stop() ip tunnel del "${IFACE}" eend $? fi + [ -n "$(ip link show "${IFACE}" type gretap 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}" + [ -n "$(ip link show "${IFACE}" type vxlan 2>/dev/null)" ] && _iproute2_link_delete "${IFACE}" fi }