mirror of
https://github.com/vishvananda/netlink
synced 2025-03-10 15:28:12 +00:00
[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:
parent
8e810149a2
commit
0e48f7d3e5
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user