Ejemplo n.º 1
0
 def _control_plane_arp_handler(self, pkt_meta):
     ofmsgs = []
     pkt_meta.reparse_ip(ether.ETH_TYPE_ARP)
     arp_pkt = pkt_meta.pkt.get_protocol(arp.arp)
     if arp_pkt is None:
         return ofmsgs
     src_ip = ipaddress.IPv4Address(btos(arp_pkt.src_ip))
     dst_ip = ipaddress.IPv4Address(btos(arp_pkt.dst_ip))
     vlan = pkt_meta.vlan
     if vlan.from_connected_to_vip(src_ip, dst_ip):
         opcode = arp_pkt.opcode
         port = pkt_meta.port
         eth_src = pkt_meta.eth_src
         vid = self._vlan_vid(vlan, port)
         if opcode == arp.ARP_REQUEST:
             ofmsgs.extend(
                 self._add_host_fib_route(vlan, src_ip))
             ofmsgs.extend(self._update_nexthop(
                 vlan, port, eth_src, src_ip))
             arp_reply = valve_packet.arp_reply(
                 vid, vlan.faucet_mac, eth_src, dst_ip, src_ip)
             ofmsgs.append(
                 valve_of.packetout(port.number, arp_reply.data))
             self.logger.info(
                 'Responded to ARP request for %s from %s (%s) on VLAN %u' % (
                     dst_ip, src_ip, eth_src, vlan.vid))
         elif (opcode == arp.ARP_REPLY and
               pkt_meta.eth_dst == vlan.faucet_mac):
             ofmsgs.extend(
                 self._update_nexthop(vlan, port, eth_src, src_ip))
             self.logger.info(
                 'ARP response %s (%s) on VLAN %u' % (
                     src_ip, eth_src, vlan.vid))
     return ofmsgs
Ejemplo n.º 2
0
 def _control_plane_arp_handler(self, pkt_meta, arp_pkt):
     src_ip = ipaddr.IPv4Address(arp_pkt.src_ip)
     dst_ip = ipaddr.IPv4Address(arp_pkt.dst_ip)
     vlan = pkt_meta.vlan
     opcode = arp_pkt.opcode
     ofmsgs = []
     if vlan.from_connected_to_vip(src_ip, dst_ip):
         in_port = pkt_meta.port.number
         vid = self._vlan_vid(vlan, in_port)
         eth_src = pkt_meta.eth_src
         if opcode == arp.ARP_REQUEST:
             arp_reply = valve_packet.arp_reply(
                 self.faucet_mac, eth_src, vid, dst_ip, src_ip)
             ofmsgs.extend(
                 self._add_host_fib_route(vlan, src_ip))
             ofmsgs.append(
                 valve_of.packetout(in_port, arp_reply.data))
             self.logger.info(
                 'Responded to ARP request for %s from %s (%s)',
                 dst_ip, src_ip, eth_src)
         elif (opcode == arp.ARP_REPLY and
               pkt_meta.eth_dst == self.faucet_mac):
             ofmsgs.extend(
                 self._update_nexthop(vlan, in_port, eth_src, src_ip))
             self.logger.info(
                 'ARP response %s (%s)', src_ip, eth_src)
     return ofmsgs
Ejemplo n.º 3
0
 def _control_plane_arp_handler(self, pkt_meta, arp_pkt):
     src_ip = ipaddress.IPv4Address(btos(arp_pkt.src_ip))
     dst_ip = ipaddress.IPv4Address(btos(arp_pkt.dst_ip))
     vlan = pkt_meta.vlan
     opcode = arp_pkt.opcode
     ofmsgs = []
     if vlan.from_connected_to_vip(src_ip, dst_ip):
         port = pkt_meta.port
         eth_src = pkt_meta.eth_src
         if opcode == arp.ARP_REQUEST:
             ofmsgs.extend(self._add_host_fib_route(vlan, src_ip))
             ofmsgs.extend(self._update_nexthop(vlan, port, eth_src,
                                                src_ip))
             vid = self._vlan_vid(vlan, port)
             arp_reply = valve_packet.arp_reply(vid, self.faucet_mac,
                                                eth_src, dst_ip, src_ip)
             ofmsgs.append(valve_of.packetout(port.number, arp_reply.data))
             self.logger.info(
                 'Responded to ARP request for %s from %s (%s)', dst_ip,
                 src_ip, eth_src)
         elif (opcode == arp.ARP_REPLY
               and pkt_meta.eth_dst == self.faucet_mac):
             ofmsgs.extend(self._update_nexthop(vlan, port, eth_src,
                                                src_ip))
             self.logger.info('ARP response %s (%s)', src_ip, eth_src)
     return ofmsgs
Ejemplo n.º 4
0
    def control_plane_arp_handler(self, in_port, vlan, eth_src, eth_dst,
                                  arp_pkt):
        ofmsgs = []
        opcode = arp_pkt.opcode
        src_ip = ipaddr.IPv4Address(arp_pkt.src_ip)
        dst_ip = ipaddr.IPv4Address(arp_pkt.dst_ip)

        if (opcode == arp.ARP_REQUEST and vlan.ip_in_controller_subnet(src_ip)
                and vlan.ip_in_controller_subnet(dst_ip)):
            vid = self._vlan_vid(vlan, in_port)
            arp_reply = valve_packet.arp_reply(self.faucet_mac, eth_src, vid,
                                               dst_ip, src_ip)
            ofmsgs.append(valve_of.packetout(in_port, arp_reply.data))
            ofmsgs.extend(self._add_host_fib_route(vlan, src_ip))
            self.logger.info('Responded to ARP request for %s from %s', src_ip,
                             dst_ip)
        elif (opcode == arp.ARP_REPLY and eth_dst == self.faucet_mac
              and vlan.ip_in_controller_subnet(src_ip)
              and vlan.ip_in_controller_subnet(dst_ip)):
            self.logger.info('ARP response %s for %s', eth_src, src_ip)
            ofmsgs.extend(self._update_nexthop(vlan, eth_src, src_ip))
        return ofmsgs
Ejemplo n.º 5
0
    def control_plane_arp_handler(self, in_port, vlan, eth_src, eth_dst, arp_pkt):
        ofmsgs = []
        opcode = arp_pkt.opcode
        src_ip = ipaddr.IPv4Address(arp_pkt.src_ip)
        dst_ip = ipaddr.IPv4Address(arp_pkt.dst_ip)

        if (opcode == arp.ARP_REQUEST and
                vlan.ip_in_controller_subnet(src_ip) and
                vlan.ip_in_controller_subnet(dst_ip)):
            vid = self._vlan_vid(vlan, in_port)
            arp_reply = valve_packet.arp_reply(
                self.faucet_mac, eth_src, vid, dst_ip, src_ip)
            ofmsgs.append(valve_of.packetout(in_port, arp_reply.data))
            self.logger.info(
                'Responded to ARP request for %s from %s', src_ip, dst_ip)
        elif (opcode == arp.ARP_REPLY and
              eth_dst == self.faucet_mac and
              vlan.ip_in_controller_subnet(src_ip) and
              vlan.ip_in_controller_subnet(dst_ip)):
            self.logger.info('ARP response %s for %s', eth_src, src_ip)
            ofmsgs.extend(self._update_nexthop(vlan, eth_src, src_ip))
        return ofmsgs