def _verify_flowmod(self, flowmod): match_fields = flowmod.match.items() if valve_of.is_flowdel(flowmod): if self.table_id != valve_of.ofp.OFPTT_ALL: for match_type, match_field in match_fields: assert match_type in self.match_types, ( f'{match_type} match in table {self.name}') else: # TODO: ACL builder should not use ALL table. if self.table_id == valve_of.ofp.OFPTT_ALL: return assert not (flowmod.priority == 0 and match_fields), ( f'default flow cannot have matches on table {self.name}: {flowmod}' ) for match_type, match_field in match_fields: assert match_type in self.match_types, ( f'{match_type} match in table {self.name}') config_mask = self.match_types[match_type] flow_mask = isinstance(match_field, tuple) assert config_mask or (not config_mask and not flow_mask), ( f'{match_type} configured mask {config_mask} but flow mask ' f'{flow_mask} in table {self.name} ({flowmod})') if self.exact_match and match_fields: assert len(self.match_types) == len(match_fields), ( f'exact match table {self.name} matches {self.match_types} ' f'do not match flow matches {match_fields} ({flowmod})' )
def _verify_flowmod(self, flowmod): match_fields = flowmod.match.items() if valve_of.is_flowdel(flowmod): if self.table_id != valve_of.ofp.OFPTT_ALL: for match_type, match_field in match_fields: assert match_type in self.match_types, ( '%s match in table %s' % (match_type, self.name)) else: # TODO: ACL builder should not use ALL table. if self.table_id == valve_of.ofp.OFPTT_ALL: return assert not (flowmod.priority == 0 and match_fields), ( 'default flow cannot have matches on table %s: %s' % (self.name, flowmod)) for match_type, match_field in match_fields: assert match_type in self.match_types, ( '%s match in table %s' % (match_type, self.name)) config_mask = self.match_types[match_type] flow_mask = isinstance(match_field, tuple) assert config_mask or (not config_mask and not flow_mask), ( '%s configured mask %s but flow mask %s in table %s (%s)' % (match_type, config_mask, flow_mask, self.name, flowmod)) if self.exact_match and match_fields: assert len(self.match_types) == len(match_fields), ( 'exact match table %s matches %s do not match flow matches %s (%s)' % (self.name, self.match_types, match_fields, flowmod))
def test_port_mirror(self): """Test addition of port mirroring does not cause a del VLAN.""" reload_ofmsgs = self.update_config(self.MORE_CONFIG, reload_type='warm')[self.DP_ID] for ofmsg in reload_ofmsgs: if valve_of.is_flowdel(ofmsg): if ofmsg.table_id == valve_of.ofp.OFPTT_ALL and ofmsg.match: self.assertNotIn('vlan_vid', ofmsg.match, ofmsg)
def _verify_flowmod(self, flowmod): if valve_of.is_flowdel(flowmod): return if flowmod.priority == 0: assert not flowmod.match.items(), ( 'default flow cannot have matches') elif self.match_types: match_fields = list(flowmod.match.items()) for match_type, match_field in match_fields: assert match_type in self.match_types, ( '%s match in table %s' % (match_type, self.name)) config_mask = self.match_types[match_type] flow_mask = isinstance(match_field, tuple) assert config_mask or (not config_mask and not flow_mask), ( '%s configured mask %s but flow mask %s in table %s (%s)' % (match_type, config_mask, flow_mask, self.name, flowmod)) if self.exact_match: assert len(self.match_types) == len(match_fields), ( 'exact match table matches %s do not match flow matches %s (%s)' % (self.match_types, match_fields, flowmod))
def _verify_flowmod(self, flowmod): if valve_of.is_flowdel(flowmod): return if flowmod.priority == 0: assert not flowmod.match.items(), ( 'default flow cannot have matches') elif self.match_types: match_fields = list(flowmod.match.items()) for match_type, match_field in match_fields: assert match_type in self.match_types, ( '%s match in table %s' % (match_type, self.name)) config_mask = self.match_types[match_type] flow_mask = isinstance(match_field, tuple) assert config_mask or (not config_mask and not flow_mask), ( '%s configured mask %s but flow mask %s in table %s (%s)' % ( match_type, config_mask, flow_mask, self.name, flowmod)) if self.exact_match: assert len(self.match_types) == len(match_fields), ( 'exact match table matches %s do not match flow matches %s (%s)' % ( self.match_types, match_fields, flowmod))