prepare_interface() {
local iface="$1"
local config="$2"
+ local vifmac="$3"
# if we're called for the bridge interface itself, don't bother trying
# to create any interfaces here. The scripts have already done that, otherwise
[ "br-$config" = "$iface" -o -e "$iface" ] && return 0;
ifconfig "$iface" 2>/dev/null >/dev/null && {
- # make sure the interface is removed from any existing bridge and brought down
- ifconfig "$iface" down
+ # make sure the interface is removed from any existing bridge and deconfigured
+ ifconfig "$iface" 0.0.0.0
unbridge "$iface"
+
+ # Change interface MAC address if requested
+ [ -n "$vifmac" ] && {
+ ifconfig "$iface" down
+ ifconfig "$iface" hw ether "$vifmac" up
+ }
}
# Setup VLAN interfaces
$DEBUG brctl setfd "br-$config" 0
$DEBUG ifconfig "br-$config" up
$DEBUG brctl addif "br-$config" "$iface"
- $DEBUG brctl stp "br-$config" ${stp:-off}
+ $DEBUG brctl stp "br-$config" ${stp:-0}
# Creating the bridge here will have triggered a hotplug event, which will
# result in another setup_interface() call, so we simply stop processing
# the current event at this point.
uci_set_state network "$config" device "$device"
}
+setup_interface_none() {
+ env -i ACTION="ifup" INTERFACE="$2" DEVICE="$1" PROTO=none /sbin/hotplug-call "iface" &
+}
+
setup_interface_static() {
local iface="$1"
local config="$2"
setup_interface() {
local iface="$1"
local config="$2"
+ local vifmac="$4"
local proto
local macaddr
}
proto="${3:-$(config_get "$config" proto)}"
- prepare_interface "$iface" "$config" || return 0
+ prepare_interface "$iface" "$config" "$vifmac" || return 0
[ "$iface" = "br-$config" ] && {
# need to bring up the bridge and wait a second for
config_get mtu "$config" mtu
config_get macaddr "$config" macaddr
grep "$iface:" /proc/net/dev > /dev/null && \
+ $DEBUG ifconfig "$iface" down && \
$DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
set_interface_ifname "$config" "$iface"
lock -u "/var/lock/dhcp-$iface"
fi
;;
+ none)
+ setup_interface_none "$iface" "$config"
+ ;;
*)
if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
eval "setup_interface_$proto '$iface' '$config' '$proto'"