def push_host_vlan_tagged_packets_drop_rules(self, sw, host_vlan_tagged_drop_table): for h_id in self.network_graph.host_ids: # Get concerned only with hosts that are directly connected to this sw h_obj = self.network_graph.get_node_object(h_id) if h_obj.sw.node_id != sw: continue # Get a vanilla flow flow = self.create_base_flow(sw, host_vlan_tagged_drop_table, 100) action_list = [] if self.network_graph.controller == "ryu": flow["match"]["in_port"] = h_obj.switch_port.port_number flow["match"]["vlan_vid"] = self.network_graph.graph.node[sw][ "sw"].synthesis_tag elif self.network_graph.controller == "onos": flow_match = Match(is_wildcard=True) flow_match["ethernet_type"] = 0x0800 flow_match["in_port"] = int(h_obj.switch_port.port_number) flow_match["vlan_id"] = self.network_graph.graph.node[sw][ "sw"].synthesis_tag flow["selector"]["criteria"] = flow_match.generate_match_raw( self.network_graph.controller, flow["selector"]["criteria"]) # Make and push the flow self.populate_flow_action_instruction(flow, action_list, True) self.push_flow(sw, flow)
def push_loop_preventing_drop_rules(self, sw, table_number): for h_id in self.network_graph.host_ids: # Get concerned only with hosts that are directly connected to this sw h_obj = self.network_graph.get_node_object(h_id) if h_obj.sw.node_id != sw: continue # Get a vanilla flow flow = self.create_base_flow(sw, table_number, 100) action_list = [] # Compile match with in_port and destination mac address if self.network_graph.controller == "ryu": flow["match"]["in_port"] = h_obj.switch_port.port_number flow["match"]["eth_dst"] = h_obj.mac_addr elif self.network_graph.controller == "onos": flow_match = Match(is_wildcard=True) flow_match["ethernet_type"] = 0x0800 mac_int = int(h_obj.mac_addr.replace(":", ""), 16) flow_match["ethernet_destination"] = int(mac_int) flow_match["in_port"] = int(h_obj.switch_port.port_number) flow["selector"]["criteria"] = flow_match.generate_match_raw( self.network_graph.controller, flow["selector"]["criteria"]) # Make and push the flow self.populate_flow_action_instruction(flow, action_list, True) self.push_flow(sw, flow)