network_linux.go
func (v *veth) attach(n *configs.Network) (err error) {
	bridge, err := net.InterfaceByName(n.Bridge)
	if err != nil {
		return err
	}
	host, err := net.InterfaceByName(n.HostInterfaceName)
	if err != nil {
		return err
	}
	if err := netlink.AddToBridge(host, bridge); err != nil {
		return err
	}
	if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
		return err
	}
	if n.HairpinMode {
		if err := netlink.SetHairpinMode(host, true); err != nil {
			return err
		}
	}
	if err := netlink.NetworkLinkUp(host); err != nil {
		return err
	}

	return nil
}
func (v *veth) attach(n *configs.Network) (err error) {
	bridge, err := net.InterfaceByName(n.Bridge)
	if err != nil {
		return err
	}
	host, err := net.InterfaceByName(n.HostInterfaceName)
	if err != nil {
		return err
	}
	if err := netlink.AddToBridge(host, bridge); err != nil {
		return err
	}
	if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
		return err
	}
	if n.HairpinMode {
		if err := netlink.SetHairpinMode(host, true); err != nil {
			return err
		}
	}
	if err := netlink.NetworkLinkUp(host); err != nil {
		return err
	}

	return nil
}
func ( v * veth ) attach ( n * configs . Network ) ( err error ) { bridge , err := net . InterfaceByName ( n . Bridge ) if err != nil { return err } host , err := net . InterfaceByName ( n . HostInterfaceName ) if err != nil { return err } if err := netlink . AddToBridge ( host , bridge ) ; err != nil { return err } if err := netlink . NetworkSetMTU ( host , n . Mtu ) ; err != nil { return err } if n . HairpinMode { if err := netlink . SetHairpinMode ( host , true ) ; err != nil { return err } } if err := netlink . NetworkLinkUp ( host ) ; err != nil { return err } return nil }
// attach a container network interface to an external network
attach a container network interface to an external network