Ejemplo n.º 1
0
// RemoveSlaveIfc removes network interface from the network bridge.
// It is equivalent of running: ip link set dev ${netIfc name} nomaster
// It returns error if the network interface is not in the bridge or
// it could not be removed from the bridge.
func (br *Bridge) RemoveSlaveIfc(ifc *net.Interface) error {
	if err := netlink.NetworkSetNoMaster(ifc); err != nil {
		return err
	}

	for index, i := range br.slaveIfcs {
		// I could reflect.DeepEqual(), but there is not point to import reflect for one operation
		if i.Name == ifc.Name && bytes.Equal(i.HardwareAddr, ifc.HardwareAddr) {
			br.slaveIfcs = append(br.slaveIfcs[:index], br.slaveIfcs[index+1:]...)
		}
	}

	return nil
}
Ejemplo n.º 2
0
// AddToBridge adds network interfaces to network bridge.
// It is equivalent of running: ip link set dev ${netIfc name} nomaster
// It returns error when it fails to remove the network interface from the bridge.
func RemoveFromBridge(netIfc *net.Interface) error {
	return netlink.NetworkSetNoMaster(netIfc)
}