diff --git a/link.go b/link.go index 0869ab3..24f480d 100644 --- a/link.go +++ b/link.go @@ -157,9 +157,17 @@ func (l *LinkService) Get(index uint32) (LinkMessage, error) { } // Set sets interface attributes according to the LinkMessage information. +// +// ref: https://lwn.net/Articles/236919/ +// We explicitly use RTM_NEWLINK to set link attributes instead of +// RTM_SETLINK because: +// - using RTM_SETLINK is actually an old rtnetlink API, not supporting most +// attributes common today +// - using RTM_NEWLINK is the prefered way to create AND update links +// - RTM_NEWLINK is backward compatible to RTM_SETLINK func (l *LinkService) Set(req *LinkMessage) error { flags := netlink.Request | netlink.Acknowledge - _, err := l.c.Execute(req, unix.RTM_SETLINK, flags) + _, err := l.c.Execute(req, unix.RTM_NEWLINK, flags) if err != nil { return err }