Skip to content

Commit

Permalink
Fixing OF1.2 VLAN matching translation according to spec. OFVID_PRESE…
Browse files Browse the repository at this point in the history
…NT was expected (as in OF1.3), but spec is not specifying it. fixes #14.
  • Loading branch information
Marc Sune committed May 23, 2014
1 parent 0f40601 commit adace3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/xdpd/openflow/openflow12/of12_translation_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,20 @@ of12_translation_utils::of12_map_flow_entry_matches(
try {
uint16_t value = ofmatch.get_vlan_vid_value();
uint16_t mask = ofmatch.get_vlan_vid_mask();
enum of1x_vlan_present vlan_present = OF1X_MATCH_VLAN_NONE;
enum of1x_vlan_present vlan_present=OF1X_MATCH_VLAN_NONE;

if ((value == rofl::openflow12::OFPVID_PRESENT) && (mask == rofl::openflow12::OFPVID_PRESENT)){
vlan_present = OF1X_MATCH_VLAN_ANY;
} else
if (value & rofl::openflow12::OFPVID_PRESENT) {
}else if (value == rofl::openflow12::OFPVID_NONE && mask==0xFFFF){
vlan_present = OF1X_MATCH_VLAN_NONE;
}else if (value /*&& mask == 0xFFFF*/){
vlan_present = OF1X_MATCH_VLAN_SPECIFIC;
}else{
//Invalid
assert(0);
}

match = of1x_init_vlan_vid_match(ofmatch.get_vlan_vid_value() & ~openflow::OFPVID_PRESENT,
ofmatch.get_vlan_vid_mask(),
vlan_present);
match = of1x_init_vlan_vid_match(value, mask, vlan_present);
of1x_add_match_to_entry(entry, match);
} catch(...) {}

Expand Down
14 changes: 8 additions & 6 deletions src/xdpd/openflow/openflow13/of13_translation_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,20 @@ of13_translation_utils::of13_map_flow_entry_matches(
try {
uint16_t value = ofmatch.get_vlan_vid_value();
uint16_t mask = ofmatch.get_vlan_vid_mask();
enum of1x_vlan_present vlan_present = OF1X_MATCH_VLAN_NONE;
enum of1x_vlan_present vlan_present=OF1X_MATCH_VLAN_NONE;

if ((value == rofl::openflow13::OFPVID_PRESENT) && (mask == rofl::openflow13::OFPVID_PRESENT)){
vlan_present = OF1X_MATCH_VLAN_ANY;
} else
if (value & rofl::openflow13::OFPVID_PRESENT) {
}else if (value == rofl::openflow13::OFPVID_NONE && mask==0xFFFF){
vlan_present = OF1X_MATCH_VLAN_NONE;
}else if (value && value&rofl::openflow13::OFPVID_PRESENT /*&& mask == 0xFFFF*/){
vlan_present = OF1X_MATCH_VLAN_SPECIFIC;
}else{
//Invalid
assert(0);
}

match = of1x_init_vlan_vid_match(ofmatch.get_vlan_vid_value() & ~openflow::OFPVID_PRESENT,
ofmatch.get_vlan_vid_mask(),
vlan_present);
match = of1x_init_vlan_vid_match(value, mask, vlan_present);
of1x_add_match_to_entry(entry, match);
} catch(...) {}

Expand Down

0 comments on commit adace3a

Please sign in to comment.