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 bug in IP wildcarding. #172

Merged
merged 3 commits into from
Aug 28, 2014
Merged

Fix bug in IP wildcarding. #172

merged 3 commits into from
Aug 28, 2014

Conversation

jnfoster
Copy link
Member

This pull requests fixes a bug in the calculation of IP masks in OpenFlow 0x01.

    According to the OpenFlow specification, the mask on nw_src and nw_dst
    fields is not a description of how many bits to match, but rather a
    description of how many bits to mask. Hence, /0 is exact match and /32
    is a total wildcard.

    We had this backwards in the OpenFlow0x01 controller.

    This pull requests fixes the bug.
@seliopou
Copy link
Collaborator

Whitespace.

@seliopou
Copy link
Collaborator

The line-wrapping introduced more whitespace errors. There are also tabs:

$ git diff --check master..HEAD
lib/SDN_OpenFlow0x01.ml:54: tab in indent.
+        if m = 32l then
lib/SDN_OpenFlow0x01.ml:55: tab in indent.
+          None
lib/SDN_OpenFlow0x01.ml:56: tab in indent.
+        else
lib/SDN_OpenFlow0x01.ml:57: tab in indent.
+          Some (Int32.sub 32l m) in
lib/SDN_OpenFlow0x01.ml:63: tab in indent.
+        if m = 32l then
lib/SDN_OpenFlow0x01.ml:64: tab in indent.
+          None
lib/SDN_OpenFlow0x01.ml:65: tab in indent.
+        else
lib/SDN_OpenFlow0x01.ml:66: tab in indent.
+          Some (Int32.sub 32l m) in
lib/SDN_OpenFlow0x01.ml:132: trailing whitespace.
+      | AL.Modify (AL.SetEthTyp _) -> 
lib/SDN_OpenFlow0x01.ml:133: tab in indent.
+        raise (Invalid_argument "cannot set Ethernet type")
lib/SDN_OpenFlow0x01.ml:134: trailing whitespace.
+      | AL.Modify (AL.SetIPProto _) -> 
lib/SDN_OpenFlow0x01.ml:135: tab in indent.
+        raise (Invalid_argument "cannot set IP protocol")
lib/SDN_OpenFlow0x01.ml:147: trailing whitespace.
+  : Core.action list = 
lib/SDN_OpenFlow0x01.ml:151: trailing whitespace.
+  | _ -> 

Adding the pre-commit hook will notify you of stuff like this before you commit:

$ cp .git/hooks/pre-commit{.sample,}

seliopou added a commit that referenced this pull request Aug 28, 2014
@seliopou seliopou merged commit 53e51e5 into master Aug 28, 2014
@seliopou seliopou deleted the mask-more-bugfix branch August 28, 2014 14:42
@jnfoster
Copy link
Member Author

By the way: @mcanini @fugitifduck I only fixed 1.0 since it's the code I'm most familiar with. Do you know if 1.3 and 1.4 might also have the same bug?

-N

@fugitifduck
Copy link
Contributor

@jnfoster I think, line 20 of OpenFlow0x0(4|5)_Core.ml is code like in 0x01.

But, starting from 0x02, nwsrc is include in Oxm, and the mask is a CIDR mask (where /32 is exact and /0 is wildcard).
It can also be arbitrary masking... (currently not implemented i think)

@jnfoster
Copy link
Member Author

Cool. So, just to make sure I understand, they switched to CIDR conventions so there shouldn't be a bug in our 1.3/1.4 code?

@fugitifduck
Copy link
Contributor

I think (p52 of OF1.3.3 spec)

@jnfoster
Copy link
Member Author

Excellent. Thanks!

@mcanini
Copy link
Contributor

mcanini commented Sep 5, 2014

@jnfoster

Actually I am not sure that this won't be a bug in 1.3/1.4 too.

Quoting the specs (1.3.3): "Each 1-bit in oxm_mask constrains the OXM TLV to match only packets in which the corresponding bit of the field equals the the corresponding bit in oxm_value. Each 0-bit in oxm_mask places no constraint on the corresponding bit in the field."

So, in my interpretation, something link 192.168.1.0/24 means that the mask has to be
24 MSB set to 1 followed by 8 LSB set to 0.

@mcanini
Copy link
Contributor

mcanini commented Sep 5, 2014

So, after a bit of investigation, indeed it seems that the bug affects OF1.3/1.4 too.
@fugitifduck is implementing the fix. Thanks!

@jnfoster
Copy link
Member Author

jnfoster commented Sep 5, 2014

Fantastic! Great to hear.

-N

On Fri, Sep 5, 2014 at 10:58 AM, Marco Canini notifications@github.com
wrote:

So, after a bit of investigation, indeed it seems that the bug affects
OF1.3/1.4 too.
@fugitifduck https://github.com/fugitifduck is implementing the fix.
Thanks!


Reply to this email directly or view it on GitHub
#172 (comment)
.

@fugitifduck fugitifduck mentioned this pull request Sep 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants