summaryrefslogtreecommitdiffstats
path: root/src/lib/connections/macvlan
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/connections/macvlan')
-rw-r--r--src/lib/connections/macvlan31
1 files changed, 31 insertions, 0 deletions
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: