summaryrefslogtreecommitdiffstats
path: root/src/lib/connections/bridge
blob: f33295d9c8be15648837e061b00f83494dd2849c (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
32
33
34
35
36
37
38
39
40
41
42
# Contributed by: Thomas Bächler <thomas@archlinux.org>

. "$SUBR_DIR/ip"

: ${BRCTL:=brctl}

bridge_up() {
    if is_interface "$Interface"; then
        if [[ ! -d "/sys/class/net/$Interface/brif" ]]; then
            report_error "Interface '$Interface' already exists and is not a bridge"
            return 1
        fi
    else
        $BRCTL addbr "$Interface"
    fi

    for member in "${BindsToInterfaces[@]}"; do
        ip link set "$member" promisc on up
        ip addr flush dev "$member"
        $BRCTL addif "$Interface" "$member"
    done
    # Set options
    [[ "$FwdDelay" ]] && $BRCTL setfd "$Interface" "$FwdDelay"
    [[ "$MaxAge" ]] && $BRCTL setmaxage "$Interface" "$MaxAge"

    bring_interface_up "$Interface"
    ip_set
}

bridge_down() {
    for member in "${BindsToInterfaces[@]}"; do
      ip link set "$member" promisc off down
      $BRCTL delif "$Interface" "$member"
    done

    ip_unset
    bring_interface_down "$Interface"
    $BRCTL delbr "$Interface"
}


# vim: set ts=4 et sw=4: