summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-12-03 19:04:58 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2014-03-01 22:24:37 +0100
commit0b4246c76c37d45666f1a5b739bb3d1e1a371ea8 (patch)
tree9cfe5754d9a27f0a2df27608f3f5d71a1d1d7752
parent6d83ce0798af47143a9698847f05b272e3fcb7e0 (diff)
downloadnetctl-0b4246c76c37d45666f1a5b739bb3d1e1a371ea8.tar.gz
netctl-0b4246c76c37d45666f1a5b739bb3d1e1a371ea8.tar.xz
Add macvlan connection support
-rw-r--r--docs/examples/macvlan-dhcp10
-rw-r--r--docs/examples/macvlan-static16
-rw-r--r--docs/netctl.profile.5.txt21
-rw-r--r--src/lib/connections/macvlan31
4 files changed, 78 insertions, 0 deletions
diff --git a/docs/examples/macvlan-dhcp b/docs/examples/macvlan-dhcp
new file mode 100644
index 0000000..cacbc68
--- /dev/null
+++ b/docs/examples/macvlan-dhcp
@@ -0,0 +1,10 @@
+Description='Virtual LAN with a static MAC on interface eth0 using DHCP'
+Interface=mac0
+Connection=macvlan
+# The variable name is plural, but needs precisely one interface
+BindsToInterfaces=eth0
+# MACVAN Mode
+Mode="bride"
+# Optional static MAC Address for MACVLAN interface
+MACAddress="12:34:56:78:9a:bc"
+IP=dhcp
diff --git a/docs/examples/macvlan-static b/docs/examples/macvlan-static
new file mode 100644
index 0000000..9fa1e59
--- /dev/null
+++ b/docs/examples/macvlan-static
@@ -0,0 +1,16 @@
+Description='Virtual LAN with random MAC address on interface eth0'
+Interface=mac0
+Connection=macvlan
+# The variable name is plural, but needs precisely one interface
+BindsToInterfaces=eth0
+# MACVAN Mode
+Mode="bridge"
+# Optional static MAC Address for MACVLAN interface
+MACAddress=""
+IP=static
+Address="192.168.0.100/24"
+Gateway="192.168.0.1"
+DNS=("192.168.0.2")
+Hostname="myhost"
+DNSDomain="mydomain.com"
+DNSSearch="mydomain.com"
diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt
index 9bdbb91..d1b6447 100644
--- a/docs/netctl.profile.5.txt
+++ b/docs/netctl.profile.5.txt
@@ -54,6 +54,8 @@ AVAILABLE CONNECTION TYPES
For TUN/TAP interfaces.
+vlan+::
For VLANs on ethernet-like connections.
++macvlan+::
+ For MACVLANs on ethernet-like connections.
GENERAL OPTIONS
@@ -458,6 +460,25 @@ type must set a vlan identifier using 'VLANID='. See *ip*(8) for
details.
+OPTIONS FOR `macvlan' CONNECTIONS
+---------------------------------
+The name of the macvlan interface is specified in 'Interface'. The
+underlying physical interface is specified in 'BindsToInterfaces'.
+Hence, for macvlan profiles, 'BindsToInterfaces' contains the name of a
+single network interface.
+
+All options for connections of the `ethernet' type are understood for
+connections of the `macvlan' type. Next to the *ip options*, the
+following are understood for connections of the `macvlan' type:
+
+'Mode='::
+ Either `bridge', `vepa', `private', or `passthru'. See *ip*(8) for
+ details.
+
+'MACAddress='::
+ Optional static MAC address for the `macvlan' type link.
+
+
SPECIAL QUOTING RULES
---------------------
Configuration files for *wpa_supplicant* use non-standard quoting.
diff --git a/src/lib/connections/macvlan b/src/lib/connections/macvlan
new file mode 100644
index 0000000..11e7017
--- /dev/null
+++ b/src/lib/connections/macvlan
@@ -0,0 +1,31 @@
+# Contributed by: Walter F Dworak <preparationh67@gmail.com>
+
+. "$CONN_DIR/ethernet"
+
+macvlan_up() {
+ if [[ ${#BindsToInterfaces[@]} -ne 1 ]]; then
+ report_error "No unique physical device for MACVLAN interface '$Interface' specified"
+ return 1
+ fi
+ if is_interface "$Interface"; then
+ report_error "Interface '$Interface' already exists"
+ return 1
+ elif [[ $Mode != @(bridge|passthru|private|vepa) ]]; then
+ report_error "Invalid mode '$Mode' for MACVLAN interface '$Interface'"
+ return 1
+ else
+ bring_interface_up "$BindsToInterfaces"
+ interface_add macvlan "$Interface" "$BindsToInterfaces" mode "$Mode"
+ if [[ $MACAddress ]]; then
+ ip link set dev "$Interface" address "$MACAddress" || return 1
+ fi
+ fi
+ ethernet_up
+}
+
+macvlan_down() {
+ ethernet_down
+ interface_delete "$Interface"
+}
+
+# vim: ft=sh ts=4 et sw=4: