def _get_match_arp_reply(self, arp_tpa, arp_spa, network_id=None): parser = self.get_datapath().ofproto_parser match = parser.OFPMatch() match.set_dl_type(ether.ETH_TYPE_ARP) match.set_arp_tpa(utils.ipv4_text_to_int(str(arp_tpa))) match.set_arp_spa(utils.ipv4_text_to_int(str(arp_spa))) match.set_arp_opcode(arp.ARP_REPLY) if network_id is not None: match.set_metadata(network_id) return match
def _get_dnat_egress_match(self, floatingip): _, vm_ip, _, local_network_id = self._get_vm_port_info(floatingip) parser = self.parser match = parser.OFPMatch() match.set_dl_type(ether.ETH_TYPE_IP) match.set_metadata(local_network_id) match.set_ipv4_src(utils.ipv4_text_to_int(vm_ip)) return match
def _get_match(self): parser = self.datapath.ofproto_parser match = parser.OFPMatch() match.set_dl_type(ether.ETH_TYPE_ARP) match.set_arp_tpa(utils.ipv4_text_to_int(str(self.interface_ip))) match.set_arp_opcode(arp.ARP_REQUEST) if self.network_id is not None: match.set_metadata(self.network_id) return match
def _get_match_gratuitous_arp(self, destination_ip, network_id=None): request_ip = utils.ipv4_text_to_int(str(destination_ip)) parser = self.get_datapath().ofproto_parser match = parser.OFPMatch() match.set_dl_type(ether.ETH_TYPE_ARP) match.set_arp_spa(request_ip) match.set_arp_tpa(request_ip) match.set_arp_opcode(arp.ARP_REQUEST) if network_id is not None: match.set_metadata(network_id) return match
def add_arp_flow(self): # need to get iface number from ovs ofproto = self.datapath.ofproto match = self.parser.OFPMatch(in_port=self.mpls_port_id) match.set_dl_type(ether.ETH_TYPE_ARP) match.set_arp_tpa(utils.ipv4_text_to_int(self.interface_ip)) match.set_arp_opcode(arp.ARP_REQUEST) actions = [ self.parser.OFPActionSetField(arp_op=arp.ARP_REPLY), self.parser.NXActionRegMove(src_field='arp_sha', dst_field='arp_tha', n_bits=48), self.parser.NXActionRegMove(src_field='arp_sha', dst_field='eth_dst', n_bits=48), self.parser.NXActionRegMove(src_field='arp_spa', dst_field='arp_tpa', n_bits=32), self.parser.OFPActionSetField(eth_src=self.mac_address), self.parser.OFPActionSetField(arp_sha=self.mac_address), self.parser.OFPActionSetField(arp_spa=self.interface_ip), self.parser.NXActionRegLoad(dst='in_port', ofs_nbits=nicira_ext.ofs_nbits(0, 31), value=0), self.parser.OFPActionOutput(self.mpls_port_id, ofproto.OFPCML_NO_BUFFER) ] inst = [ self.parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions) ] self.mod_flow( inst=inst, match=match, table_id=const.INGRESS_CLASSIFICATION_DISPATCH_TABLE, )