From 76daa7d6db803b8722bf3db691ce7ba94d5ba631 Mon Sep 17 00:00:00 2001 From: xelez-work <164175990+xelez-work@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:54:09 +0200 Subject: [PATCH] Fix openflow15 GroupMod.MarshalBinary (#58) Signed-off-by: Aleksandr Ankudinov --- openflow15/group.go | 1 - openflow15_test.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openflow15/group.go b/openflow15/group.go index d312364..1deb15d 100644 --- a/openflow15/group.go +++ b/openflow15/group.go @@ -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 { diff --git a/openflow15_test.go b/openflow15_test.go index 4805d33..e7e5622 100644 --- a/openflow15_test.go +++ b/openflow15_test.go @@ -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 }