// AddSlaveIfc adds network interface to network bridge. // It is equivalent of running: ip link set ${ifc name} master ${bridge name} // It returns error if the network interface could not be added to the bridge. func (br *Bridge) AddSlaveIfc(ifc *net.Interface) error { if err := netlink.NetworkSetMaster(ifc, br.ifc); err != nil { return err } br.slaveIfcs = append(br.slaveIfcs, *ifc) return nil }
func SetInterfaceMaster(name, master string) error { iface, err := net.InterfaceByName(name) if err != nil { return err } masterIface, err := net.InterfaceByName(master) if err != nil { return err } return netlink.NetworkSetMaster(iface, masterIface) }
func attachVlanInterface(name, bridgeName string) error { int1, err := net.InterfaceByName(name) if err != nil { return err } int2, err := net.InterfaceByName(bridgeName) if err != nil { return err } return dnetlink.NetworkSetMaster(int1, int2) }
// AddToBridge adds network interfaces to network bridge. // It is equivalent of running: ip link set ${netIfc name} master ${netBridge name} // It returns error when it fails to add the network interface to bridge. func AddToBridge(netIfc, netBridge *net.Interface) error { return netlink.NetworkSetMaster(netIfc, netBridge) }