diff --git a/nl/nl_linux.go b/nl/nl_linux.go index 8dbd92b..16253e1 100644 --- a/nl/nl_linux.go +++ b/nl/nl_linux.go @@ -149,10 +149,12 @@ func (a *RtAttr) Serialize() []byte { length := a.Len() buf := make([]byte, rtaAlignOf(length)) + next := 4 if a.Data != nil { - copy(buf[4:], a.Data) - } else { - next := 4 + copy(buf[next:], a.Data) + next += rtaAlignOf(len(a.Data)) + } + if len(a.children) > 0 { for _, child := range a.children { childBuf := child.Serialize() copy(buf[next:], childBuf)