示例#1
0
    def shortest_forwarding(self, msg, eth_type, ip_src, ip_dst):
        datapath = msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        src_sw = dst_sw = None

        src_location = self.get_host_location(ip_src)
        dst_location = self.get_host_location(ip_dst)
        if src_location:
            src_sw = src_location[0]
        if dst_location:
            dst_sw = dst_location[0]

        path_dict = self.get_path(self.graph, src_sw)
        if path_dict:
            if dst_sw:
                path = path_dict[src_sw][dst_sw]
                path.insert(0, src_sw)

                flow_info = (eth_type, ip_src, ip_dst, msg.match['in_port'])
                utils.install_flow(self.datapaths, self.link_to_port,
                                   self.access_table, path, flow_info,
                                   msg.buffer_id, msg.data)
            else:
                if isinstance(msg, parser.OFPPacketIn):
                    self.network_aware.raise_sbp_packet_in_event(
                        msg, ofproto_v1_3.OFPP_LOCAL, msg.data)
        else:
            # Reflesh the topology database.
            self.network_aware.get_topology(None)
示例#2
0
    def shortest_forwarding(self, msg, eth_type, ip_src, ip_dst):
        datapath = msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        src_sw = dst_sw = None

        src_location = self.get_host_location(ip_src)
        dst_location = self.get_host_location(ip_dst)
        if src_location:
            src_sw = src_location[0]
        if dst_location:
            dst_sw = dst_location[0]

        path_dict = self.get_path(self.graph, src_sw)
        if path_dict:
            if dst_sw:
                path = path_dict[src_sw][dst_sw]
                path.insert(0, src_sw)

                flow_info = (eth_type, ip_src, ip_dst, msg.match['in_port'])
                utils.install_flow(self.datapaths, self.link_to_port,
                                   self.access_table, path, flow_info,
                                   msg.buffer_id, msg.data)
            else:
                if isinstance(msg, parser.OFPPacketIn):
                    self.network_aware.raise_sbp_packet_in_event(
                        msg, ofproto_v1_3.OFPP_LOCAL, msg.data)
        else:
            # Reflesh the topology database.
            self.network_aware.get_topology(None)
示例#3
0
    def shortest_forwarding(self, msg, eth_type, ip_src, ip_dst):
        ofproto = msg.datapath.ofproto
        parser = msg.datapath.ofproto_parser
        src_sw = dst_sw = outer_port = data = None
        in_port = msg.match['in_port']

        src_location = self.router.get_host_location(ip_src)
        dst_location = self.router.get_host_location(ip_dst)
        if src_location:
            src_sw, in_port = src_location
        else:
            src_sw, in_port = self.network.vport[in_port]

        if dst_location:
            dst_sw = dst_location[0]
        else:
            for i in msg.instructions:
                if isinstance(i, parser.OFPInstructionActions):
                    for action in i.actions:
                        if isinstance(action, parser.OFPActionOutput):
                            vport = action.port
                            dst_sw, outer_port = self.network.vport[vport]
                            break

        path_dict = self.router.get_path(self.router.graph, src_sw)
        if path_dict:
            if dst_sw:
                path = path_dict[src_sw][dst_sw]
                path.insert(0, src_sw)
                self.logger.debug(
                    " PATH[%s --> %s]:%s" % (ip_src, ip_dst, path))

                flow_info = (eth_type, ip_src, ip_dst, in_port)
                if (eth_type, ip_src, ip_dst) in self.buffer:
                    data = self.buffer[(eth_type, ip_src, ip_dst)]
                    del self.buffer[(eth_type, ip_src, ip_dst)]
                utils.install_flow(self.router.datapaths,
                                   self.router.link_to_port,
                                   self.router.access_table, path, flow_info,
                                   ofproto.OFP_NO_BUFFER, data,
                                   outer_port=outer_port)
                # we should save pakact_out data by buffer.id.
        else:
            self.network.get_topology(None)