summaryrefslogtreecommitdiffstats
path: root/src/lib/connections/macvlan
blob: 25a97fb1d5548aad0ae5b03f58d441634047bfb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Contributed by: Walter F Dworak <preparationh67@gmail.com>

. "$SUBR_DIR/connections/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: