Skip to content

Commit

Permalink
Fix openflow15 GroupMod.MarshalBinary (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Ankudinov <[email protected]>
  • Loading branch information
xelez-work authored Aug 19, 2024
1 parent f8e71bf commit 76daa7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion openflow15/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func (g *GroupMod) MarshalBinary() (data []byte, err error) {
return
}
data = append(data, bytes...)
g.BucketArrayLen += bkt.Len()
}

for _, p := range g.Properties {
Expand Down
13 changes: 13 additions & 0 deletions openflow15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ func validateOpenflowMessage(m util.Message, n util.Message) error {
return err
}

// check that marshalling doesn't change internal state
x2, err := n.MarshalBinary()
if err != nil {
fmt.Printf("Second MarshalBinary failed with error code: %v", err)
return err
}

// Debug block
if false { // set to true if you want to write second pass message to be
// written to the pcap file as well.
Expand All @@ -112,6 +119,12 @@ func validateOpenflowMessage(m util.Message, n util.Message) error {
myErr.s = "MarshalBinary bytes don't match with original"
return myErr
}

if bytes.Equal(x, x2) == false {
var myErr MyError
myErr.s = "Results of first and second run of MarshalBinary are different"
return myErr
}
return nil
}

Expand Down

0 comments on commit 76daa7d

Please sign in to comment.