From 9f8d5e7e60735540ef6c19a0236605abf4caeff6 Mon Sep 17 00:00:00 2001 From: Hubert Krauze Date: Wed, 9 Dec 2015 12:47:37 +0100 Subject: [PATCH] Add link.Attrs().Flags during creating link --- link_linux.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/link_linux.go b/link_linux.go index 0826285..738131b 100644 --- a/link_linux.go +++ b/link_linux.go @@ -328,6 +328,27 @@ func LinkAdd(link Link) error { req := nl.NewNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK) msg := nl.NewIfInfomsg(syscall.AF_UNSPEC) + // TODO: make it shorter + if base.Flags&net.FlagUp != 0 { + msg.Change = syscall.IFF_UP + msg.Flags = syscall.IFF_UP + } + if base.Flags&net.FlagBroadcast != 0 { + msg.Change |= syscall.IFF_BROADCAST + msg.Flags |= syscall.IFF_BROADCAST + } + if base.Flags&net.FlagLoopback != 0 { + msg.Change |= syscall.IFF_LOOPBACK + msg.Flags |= syscall.IFF_LOOPBACK + } + if base.Flags&net.FlagPointToPoint != 0 { + msg.Change |= syscall.IFF_POINTOPOINT + msg.Flags |= syscall.IFF_POINTOPOINT + } + if base.Flags&net.FlagMulticast != 0 { + msg.Change |= syscall.IFF_MULTICAST + msg.Flags |= syscall.IFF_MULTICAST + } req.AddData(msg) if base.ParentIndex != 0 {