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

Stop readTablePropXM() from Attempting to Read XM Payloads #131

Merged
merged 3 commits into from
Apr 16, 2018

Conversation

kent-h
Copy link
Contributor

@kent-h kent-h commented Apr 13, 2018

Fixes #130

…ad is false, only Class, Type, and Length will be read. Also, XM.Value & XM.Mask will contain the zero value.

if err != nil {
return
if hasPayload {
Copy link
Member

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
    }
}

Copy link
Contributor Author

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) {
Copy link
Member

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.

@ybubnov
Copy link
Member

ybubnov commented Apr 14, 2018

Awesome, thanks for the PR!

…perly implement the io.ReaderFrom interface. Also changed usages of XM.readFrom(hasPayload=true) to use XM.ReadFrom().
@ybubnov ybubnov merged commit da2bd39 into netrack:master Apr 16, 2018
@kent-h kent-h deleted the bug/table-feature-prop-oxm-payload branch April 17, 2018 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants