示例#1
0
// 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
}
示例#2
0
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)
}
示例#3
0
文件: bridge.go 项目: wdxxs2z/docker
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)
}
示例#4
0
// 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)
}