From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RJ6Oh-0003cU-0i for garchives@archives.gentoo.org; Wed, 26 Oct 2011 16:32:11 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1DBAF21C1BF; Wed, 26 Oct 2011 16:31:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D318E21C1BF for ; Wed, 26 Oct 2011 16:31:57 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 455DC1B402C for ; Wed, 26 Oct 2011 16:31:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id ABB0D80042 for ; Wed, 26 Oct 2011 16:31:56 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: Subject: [gentoo-commits] proj/openrc:master commit in: net/, doc/ X-VCS-Repository: proj/openrc X-VCS-Files: doc/net.example.Linux.in net/Makefile net/macvlan.sh X-VCS-Directories: net/ doc/ X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: f94e8836333f6dea142d9a7b29610fcc8d6b12a3 Date: Wed, 26 Oct 2011 16:31:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 863dc324fa6c8675c6207a65fbb59e15 commit: f94e8836333f6dea142d9a7b29610fcc8d6b12a3 Author: Stef Simoens scarlet be> AuthorDate: Tue Sep 27 21:55:22 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Wed Oct 26 16:28:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3Df94e8836 Add macvlan support X-Gentoo-Bug: 384029 X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=3D384029 --- doc/net.example.Linux.in | 12 ++++++++ net/Makefile | 2 +- net/macvlan.sh | 69 ++++++++++++++++++++++++++++++++++++++++= ++++++ 3 files changed, 82 insertions(+), 1 deletions(-) diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in index 952f8eb..b841613 100644 --- a/doc/net.example.Linux.in +++ b/doc/net.example.Linux.in @@ -581,6 +581,18 @@ # NOTE: depend functions only work in /etc/conf.d/net # and not in profile configs such as /etc/conf.d/net.foo =20 +# MAC-VLAN support +# The following configuration can be used to create a new interface 'mac= vlan0' +# linked to 'eth0' +#macvlan_macvlan0=3D"eth0" + +# MAC-VLAN mode (private, vepa, bridge, passtru) +#mode_macvlan0=3D"private" + +# IP address, MAC address, ... are configured as a normal interface +#config_macvlan0=3D"192.168.20.20/24" +#mac_macvlan0=3D"00:50:06:20:20:20" + #-----------------------------------------------------------------------= ------ # Bonding # For link bonding/trunking on 2.4 kernels, or kernels without sysfs diff --git a/net/Makefile b/net/Makefile index 664800d..e87d3dd 100644 --- a/net/Makefile +++ b/net/Makefile @@ -13,7 +13,7 @@ SRCS-Linux=3D iwconfig.sh.in INC-Linux=3D adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.s= h \ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ - vlan.sh + vlan.sh macvlan.sh =20 SRCS-NetBSD=3D INC-NetBSD=3D ifwatchd.sh diff --git a/net/macvlan.sh b/net/macvlan.sh new file mode 100644 index 0000000..92bcf1f --- /dev/null +++ b/net/macvlan.sh @@ -0,0 +1,69 @@ +# 2011-09-22 Stef Simoens +# based on vlan.sh & tuntap.sh +# Copyright (c) 2007-2008 Roy Marples +# All rights reserved. Released under the 2-clause BSD license. + +_ip() +{ + if [ -x /bin/ip ]; then + echo /bin/ip + else + echo /sbin/ip + fi +} + +macvlan_depend() +{ + program $(_ip) + after interface + before dhcp macchanger +} + +_is_macvlan() +{ + [ -n "$(export RC_SVCNAME=3D"net.${IFACE}"; service_get_value macvlan)"= ] +} + +_check_macvlan() +{ + if [ ! -d /sys/module/macvlan ]; then + modprobe macvlan + if [ ! -d /sys/module/macvlan ]; then + eerror "MAC-VLAN support is not present in this kernel" + return 1 + fi + fi +} + +macvlan_pre_start() +{ + # MAC-VLAN needs an existing interface to link to + local macvlan=3D + eval macvlan=3D\$macvlan_${IFVAR} + [ -z "${macvlan}" ] && return 0 + + _check_macvlan || return 1 + + # optional mode, default to "private" + local mode=3D + eval mode=3D\$mode_${IFVAR} + [ -z "${mode}" ] && mode=3D"private" + + ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}" + e=3D"$(ip link add link "${macvlan}" name "${IFACE}" type macvlan mode = "${mode}" 2>&1 1>/dev/null)" + if [ -n "${e}" ]; then + eend 1 "${e}" + else + eend 0 && service_set_value macvlan "${macvlan}" + fi +} + + +macvlan_post_stop() +{ + _is_macvlan || return 0 + + ebegin "Removing MAC-VLAN ${IFACE}" + ip link delete "${IFACE}" type macvlan >/dev/null + eend $? +}