Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openflow15 GroupMod.MarshalBinary to correctly handle marshaling twice. #58

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion openflow15/group.go
Original file line number Diff line number Diff line change
@@ -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 {
13 changes: 13 additions & 0 deletions openflow15_test.go
Original file line number Diff line number Diff line change
@@ -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.
@@ -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
}