From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: net/, doc/
Date: Wed, 26 Oct 2011 16:31:56 +0000 (UTC) [thread overview]
Message-ID: <f94e8836333f6dea142d9a7b29610fcc8d6b12a3.WilliamH@gentoo> (raw)
commit: f94e8836333f6dea142d9a7b29610fcc8d6b12a3
Author: Stef Simoens <stef.simoens <AT> scarlet <DOT> be>
AuthorDate: Tue Sep 27 21:55:22 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Oct 26 16:28:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f94e8836
Add macvlan support
X-Gentoo-Bug: 384029
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=384029
---
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
+# MAC-VLAN support
+# The following configuration can be used to create a new interface 'macvlan0'
+# linked to 'eth0'
+#macvlan_macvlan0="eth0"
+
+# MAC-VLAN mode (private, vepa, bridge, passtru)
+#mode_macvlan0="private"
+
+# IP address, MAC address, ... are configured as a normal interface
+#config_macvlan0="192.168.20.20/24"
+#mac_macvlan0="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= iwconfig.sh.in
INC-Linux= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
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
SRCS-NetBSD=
INC-NetBSD= 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 <stef@bgs.org>
+# based on vlan.sh & tuntap.sh
+# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
+# 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="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=
+ eval macvlan=\$macvlan_${IFVAR}
+ [ -z "${macvlan}" ] && return 0
+
+ _check_macvlan || return 1
+
+ # optional mode, default to "private"
+ local mode=
+ eval mode=\$mode_${IFVAR}
+ [ -z "${mode}" ] && mode="private"
+
+ ebegin "Creating MAC-VLAN ${IFACE} to ${macvlan}"
+ e="$(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 $?
+}
next reply other threads:[~2011-10-26 16:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-26 16:31 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-12-13 4:12 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=f94e8836333f6dea142d9a7b29610fcc8d6b12a3.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