-
Notifications
You must be signed in to change notification settings - Fork 474
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
flow_table: check_for_overlapping_entries does not do overlap checking #142
Comments
I implemented overlap checking and added the functionality to the For reference, I looked at the Open vSwitch implementation, the Openflow spec, and the "Intersection" section in the paper Header Space Analysis: Static Checking For Networks. |
noxrepo#142 pointed out that the existing check for overlapping entries was broken. This is an untested attempt at fixing it.
@MurphyMc: I see you were faster, great. I added my implementation to the ofp_match() class, I think it makes more sense there as there already is the matches_with_wildcards function there. One question though: Adresses like "10.1.2.3/8" obviously don't make sense. But assuming an ofp_match were to contain such an address with 24 wildcard bits, is it ever normalized to "10.0.0.0/8" in POX? If not, will the .in_network() work correctly in all cases? |
Thanks for finding this. There were a number of things in the flow table and the switch which I had been surprised were so easy, but never specifically worked through myself. I think a number have been addressed over time (when I rewrote so much of the switch and when we did a bunch of OFTest conformance testing), but I guess there are still some lurking (and I guess OFTest didn't catch this case!). I just threw together my own attempt at it too, though I haven't tested it all. From a quick glance at yours, I see a couple potential problems, which are probably pretty easily fixed. They may not come up in the case of the software switch, for example, which should pretty much always do things the same way, but for full generality...
I put mine as a static method in the flow table, but I think putting it in ofp_match, as you did, and as the existing overlap-checking stuff is, may make more sense. Also, I used a loop, but that's probably mostly because I am lazy. I also fixed the weird else/if in the calling function. Maybe the best result is a combination of both of ours? As for your .in_network() point, yeah, you're right. I think cases like that will cause a runtime exception because .in_network() doesn't call parse_cidr() with allow_host=True. You know, IPAddr should just have like a .get_network(<bits/mask>) or .apply_netmask(<bits/mask>) or something which returns just the network part as an IPAddr(). That's a relatively common piece of functionality and it'd be nice to hide the bitwise stuff inside lib.addresses. And, to the point, the result could be used as the argument to .in_network(). |
Yes, your version seems more generic/future-proof.
FYI, normally I'm using an older version of POX (the one modified for STS) and there are a lot of differences between the two. So I'm not sure if all my observations about the current eel branch are accurate. |
I tweaked yours a little bit. Take a look at https://github.com/MurphyMc/pox/commits/fix_overlap and see what you think. |
Were you ever able to check out the most recent proposed patch? I know it was a while ago, but it'd be nice to merge a working version. |
Sorry for the late reply. Unfortunately I forgot to backport your proposed changes into my branch. So the version I've been using for the past 6 months is this one: https://github.com/jmiserez/pox/blob/hb/pox/openflow/libopenflow_01.py#L820 I used it within the context of the software switch as well as directly like this:
and I haven't had any issues with it. Besides all renamed but semantically equivalent code, I noticed the following changes:
https://github.com/jmiserez/pox/commits/hb/pox/openflow/libopenflow_01.py |
Before reading your new list, I realized I never responded to your point 2 above (from April 26 last year). Sorry about that! I wrote up the response first off, but now that I've read the rest, I'll move it down to point 5 below...
And yes, it did diverge a long time ago. The fact that STS never got resynced with mainline was really too bad, because there were many, many bugs that got fixed and improvements that were made (especially to the switch). Some of it has been hand-backported. And some of it... I think has been simply reproduced by duplicate effort since then (e.g. I think supporting table entry timeouts?). And some has probably been missed altogether. :( |
Additional on #2 above: The 1.0 spec says of flow_mod with command=add and overlap_check: "Two flow entries overlap if a single packet may match both, and both entries have the same priority." This probably influenced my implementation. |
The current implementation for the overlap checking in flow tables is wrong.
In flow_table.py:328, for two flows with the same priorities the following is checked:
However, this is wrong when wildcards are considered. E.g. for two flows with src/dst (10..., 10.1.2.3) and (10.1.2.3, 10...), neither contains the other but there is still a single packet (10.1.2.3, 10.1.2.3) that matches both. This can be verified with a simple testcase as below. Just set the pox repository path and execute it.
The correct check would involve checking if they have the same bit value at every bit that is not wildcarded in either of the two flows. See also the OVS implementation (here, and here]
Tested on branch eel, commit 3d8eac7:
Output:
The text was updated successfully, but these errors were encountered: