Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion openflow15/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (g *GroupMod) UnmarshalBinary(data []byte) (err error) {
g.CommandBucketId = binary.BigEndian.Uint32(data[n:])
n += 4

for n < g.Header.Length {
for n < g.BucketArrayLen+24 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unrelated to the rest of the PR?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properties (including experimenter ones) are encoded after buckets. But because of n < g.Header.Length here we're trying to decode property as a bucket and fail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not feel the change is necessary. GroupMod.Heander.Length should describe the size of this complete message including the buckets. If not, it may be some issue when marshaling the message, e.g., a bug of OVS to encoding the message, or a bug to read bytes from the OpenFlow connection.

Copy link
Copy Markdown

@xelez-work xelez-work Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GroupMod.Header.Length should describe the size of this complete message including the buckets

That is true, but because there can be data after the buckets this is not correct. In current code version we're trying to decode experimental fields as buckets and it fails.

bkt := new(Bucket)
err = bkt.UnmarshalBinary(data[n:])
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions openflow15/openflow15.go
Original file line number Diff line number Diff line change
Expand Up @@ -1509,14 +1509,12 @@ func (p *PropExperimenter) Len() uint16 {
n += 8
l := uint16(len(p.Data) * 4)
n += l
//n += uint16((8 - (l % 8)) % 8) // pad to make multiple of 8
n += uint16(8 - (l % 8)) // pad to make multiple of 8
return n
}

func (p *PropExperimenter) MarshalBinary() (data []byte, err error) {
data = make([]byte, int(p.Len()))
p.Header.Length = 8 + uint16(len(p.Data)*4)
p.Header.Length = p.Header.Len() + 8 + uint16(len(p.Data)*4)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is easier to use p.Header.Length = p.Len().

b, err := p.Header.MarshalBinary()
if err != nil {
return
Expand Down Expand Up @@ -1547,7 +1545,7 @@ func (p *PropExperimenter) UnmarshalBinary(data []byte) (err error) {
p.ExpType = binary.BigEndian.Uint32(data[n:])
n += 4

for n < p.Header.Length+p.Header.Len() {
for n < p.Header.Length {
d := binary.BigEndian.Uint32(data[n:])
p.Data = append(p.Data, d)
n += 4
Expand Down