From 0e48f7d3e50e4b0ec6b36816dfc71b36e84b323c Mon Sep 17 00:00:00 2001 From: chantra Date: Sat, 24 Oct 2015 16:06:04 -0700 Subject: [PATCH] [nl] Fix RtAttr.Serialize to serialize both Data and Children The function was only serializing the Data if it was not nil. It was correctly setting the size of the payload as RtAttr.Len correctly accounted for it. This resulted in the children payload being zeroed. Fixes #57 --- nl/nl_linux.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)