func networkLinkMacVlan(dev_type string, mcvln *MacVlanLink) error {
	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK)

	masterDevIfc, err := net.InterfaceByName(mcvln.MasterDev)
	if err != nil {
		return err
	}

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	wb.AddData(msg)

	nest1 := newRtAttr(syscall.IFLA_LINKINFO, nil)
	newRtAttrChild(nest1, IFLA_INFO_KIND, nonZeroTerminated(dev_type))

	nest2 := newRtAttrChild(nest1, IFLA_INFO_DATA, nil)
	macVlanData := make([]byte, 4)
	native.PutUint32(macVlanData, mcvln.Mode())
	newRtAttrChild(nest2, IFLA_MACVLAN_MODE, macVlanData)
	wb.AddData(nest1)

	wb.AddData(uint32Attr(syscall.IFLA_LINK, uint32(masterDevIfc.Index)))
	wb.AddData(newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(mcvln.SlaveDev)))

	if err := s.Send(wb); err != nil {
		return err
	}
	return s.HandleAck(wb.Seq)
}
func networkLinkMacVlan(dev_type string, mcvln *MacVlanLink) error {
	s, err := getNetlinkSocket()
	if err != nil {
		return err
	}
	defer s.Close()

	wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK)

	masterDevIfc, err := net.InterfaceByName(mcvln.MasterDev)
	if err != nil {
		return err
	}

	msg := newIfInfomsg(syscall.AF_UNSPEC)
	wb.AddData(msg)

	nest1 := newRtAttr(syscall.IFLA_LINKINFO, nil)
	newRtAttrChild(nest1, IFLA_INFO_KIND, nonZeroTerminated(dev_type))

	nest2 := newRtAttrChild(nest1, IFLA_INFO_DATA, nil)
	macVlanData := make([]byte, 4)
	native.PutUint32(macVlanData, mcvln.Mode())
	newRtAttrChild(nest2, IFLA_MACVLAN_MODE, macVlanData)
	wb.AddData(nest1)

	wb.AddData(uint32Attr(syscall.IFLA_LINK, uint32(masterDevIfc.Index)))
	wb.AddData(newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(mcvln.SlaveDev)))

	if err := s.Send(wb); err != nil {
		return err
	}
	return s.HandleAck(wb.Seq)
}
func networkLinkMacVlan ( dev_type string , mcvln * MacVlanLink ) error { s , err := getNetlinkSocket ( ) if err != nil { return err } defer s . Close ( ) wb := newNetlinkRequest ( syscall . RTM_NEWLINK , syscall . NLM_F_CREATE | syscall . NLM_F_EXCL | syscall . NLM_F_ACK ) masterDevIfc , err := net . InterfaceByName ( mcvln . MasterDev ) if err != nil { return err } msg := newIfInfomsg ( syscall . AF_UNSPEC ) wb . AddData ( msg ) nest1 := newRtAttr ( syscall . IFLA_LINKINFO , nil ) newRtAttrChild ( nest1 , IFLA_INFO_KIND , nonZeroTerminated ( dev_type ) ) nest2 := newRtAttrChild ( nest1 , IFLA_INFO_DATA , nil ) macVlanData := make ( [ ] byte , 4 ) native . PutUint32 ( macVlanData , mcvln . Mode ( ) ) newRtAttrChild ( nest2 , IFLA_MACVLAN_MODE , macVlanData ) wb . AddData ( nest1 ) wb . AddData ( uint32Attr ( syscall . IFLA_LINK , uint32 ( masterDevIfc . Index ) ) ) wb . AddData ( newRtAttr ( syscall . IFLA_IFNAME , zeroTerminated ( mcvln . SlaveDev ) ) ) if err := s . Send ( wb ) ; err != nil { return err } return s . HandleAck ( wb . Seq ) }
// Add MAC VLAN network interface with masterDev as its upper device
// This is identical to running:
// ip link add name $name link $masterdev type macvlan mode $mode
Add MAC VLAN network interface with masterDev as its upper device This is identical to running : ip link add name $name link $masterdev type macvlan mode $mode