summaryrefslogtreecommitdiffstats
path: root/src/lib/connections/macvlan
blob: 11e70173713139914d687300c27836d9b727e177 (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>

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