-
Notifications
You must be signed in to change notification settings - Fork 24
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
Stop readTablePropXM() from Attempting to Read XM Payloads #131
Stop readTablePropXM() from Attempting to Read XM Payloads #131
Conversation
…ad is false, only Class, Type, and Length will be read. Also, XM.Value & XM.Mask will contain the zero value.
… too many table props to be read.
|
||
if err != nil { | ||
return | ||
if hasPayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to determine if OXM has payload by analyzing its length? So the caller won't need to pas hasPayload
flag?
I mean precisely this:
if length != 0 {
m, err := encoding.ReadFrom(r, &xm.Value)
n += m
if err != nil {
return err
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible. The Length when hasPayload == false
indicates the length that a hypothetical payload for the given XM type should be.
ofp/match.go
Outdated
@@ -294,7 +293,7 @@ func readAllXM(r io.Reader, xms *[]XM) (int64, error) { | |||
|
|||
// ReadFrom implements io.ReaderFrom interface. It deserializes | |||
// the OpenFlow extensible match from the given reader. | |||
func (xm *XM) ReadFrom(r io.Reader) (n int64, err error) { | |||
func (xm *XM) ReadFrom(r io.Reader, hasPayload bool) (n int64, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to determine the necessity to read payload by the length field of OXM. If it is not possible for some reason, I would recommend to create another method for passing this flag:
func (xm *XM) readFrom(r io.Reader, hasPayload bool) (int64, error) { /* ... */ }
func (xm *XM) ReadFrom(r io.Reader) (int64, error) {
return xm.readFrom(r, true)
}
This is necessary to make XM
implement io.ReaderFrom interface.
Awesome, thanks for the PR! |
…perly implement the io.ReaderFrom interface. Also changed usages of XM.readFrom(hasPayload=true) to use XM.ReadFrom().
Fixes #130