[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
This commit is contained in:
chantra 2015-10-24 16:06:04 -07:00
parent 8e810149a2
commit 0e48f7d3e5

View File

@ -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)