WO2016176853A1 - 一种路由查询方法和网络设备 - Google Patents

一种路由查询方法和网络设备 Download PDF

Info

Publication number
WO2016176853A1
WO2016176853A1 PCT/CN2015/078442 CN2015078442W WO2016176853A1 WO 2016176853 A1 WO2016176853 A1 WO 2016176853A1 CN 2015078442 W CN2015078442 W CN 2015078442W WO 2016176853 A1 WO2016176853 A1 WO 2016176853A1
Authority
WO
WIPO (PCT)
Prior art keywords
matching table
entry
address information
matching
external
Prior art date
Application number
PCT/CN2015/078442
Other languages
English (en)
French (fr)
Inventor
胡农达
冯强
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201580001178.0A priority Critical patent/CN106416150B/zh
Priority to PCT/CN2015/078442 priority patent/WO2016176853A1/zh
Publication of WO2016176853A1 publication Critical patent/WO2016176853A1/zh

Links

Images

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a route query method and a network device.
  • packet-switched technology also known as "packet switching”
  • the communication data is first segmented and encapsulated into a single data packet at the source host node and injected into the network, and then transmitted and routed through the network device, and finally the data packet arrives at the destination host node, restored and merged into Original communication data.
  • network devices such as switches and routers, independently route and forward each data packet, that is, when a data packet arrives at the input port of the network device, the network device based on the address information in the data packet, such as the destination.
  • MAC English: Media Access Control, Chinese: Media Access Control
  • destination IP English: Internet Protocol, Chinese: Internet Protocol
  • routing of data packets is implemented by querying a lookup table: one or more "lookup tables” (eg, routing tables or forwarding tables) are stored in the network device, each lookup table. Contains one or more entries, each of which contains information such as address information and output port number, and matches by matching the address information in the data packet with the address information in the lookup table to determine matching entries and matching from The output port number is extracted from the table entry to determine the output port.
  • This type of routing is called “table lookup routing.”
  • a learned forwarding table is stored in the switch, and the entries in the table include information such as a MAC address and an output port number; when the switch receives a data packet, Extracting the destination MAC address from the data packet and comparing it with the destination MAC address of each entry in the forwarding table to determine the matching entry (the destination MAC address is equal to the MAC address in the entry), thereby obtaining Output port number.
  • each route stores a "routing table" learned through a routing protocol, and the entries in the table include a network address, a network mask, an output port number, and a next hop. Information such as the network address; when the router receives a packet, it extracts the destination IP address from the packet and performs mask-based matching to confirm Match the entries to get information such as the output port number and the next hop network address.
  • network devices In the emerging software-defined network (Software Defined Networking, SDN for short), network devices also implement routing and other processing of data packets by looking up a lookup table called a "flow table".
  • the lookup table In order to perform fine-grained data stream processing, the lookup table usually contains more matching fields than the forwarding table of the layer 2 switch and the routing table of the router, and the exact matching table and the universal matching table coexist.
  • Figure 1 and Figure 2 show the logical structure of the exact match table and the universal match table respectively.
  • the matching table performs a mask-based universal matching, that is, a part of the data packet is equal to the corresponding part in the matching domain, and the matching is successful, and the remaining part may be ignored in the matching process, and the neglecting rule is determined by the mask in the matching domain. .
  • the performance of table lookup routing is usually the bottleneck of its performance. Therefore, it is very important to accelerate the lookup table routing.
  • the cache-based table lookup route acceleration method is an important table lookup acceleration technology.
  • FIG. 3 shows a general structure of a network device performing table lookup routing in the case where an exact match table and a universal match table coexist in the prior art.
  • the on-chip exact matching table caches the most frequently used exact matching entries.
  • the internal table lookup is performed first, and the exact matching table is searched. If the hit is performed, the external table is not queried. Directly output the result to achieve table lookup routing acceleration; the lookup table routing acceleration technology can speed up the routing of those packets that ultimately match the exact matching entry, but for the packet that ultimately matches the universal matching entry, The routing process is not accelerated.
  • FIG. 4 shows another general structure of a network device performing software table lookup routing in the case where an exact match table and a universal match table coexist.
  • the exact match table is used as a cache for the generic match table.
  • the lookup table routing process is shown in Figure 5.
  • the exact match table lookup is performed first. If it hits, the exact match result is directly returned; otherwise, the universal match table lookup is performed, and if it hits, the universal match result is returned.
  • the lookup table acceleration technology has the following disadvantages: 1.
  • the universal matching entry may be extended to a large number of exact matching entries, thereby occupying a large amount of space for accurately matching the table; 2.
  • When deleting the universal matching In the case of an entry, the entries extended to the exact match table are deleted synchronously, but it is difficult to distinguish "what exact entries are derived and which are originally", which may result in accidental deletion.
  • the invention provides a route query method, which can realize the search acceleration of the exact match table and the universal match table at the same time, and can save internal storage space and can avoid accidental deletion of the entry.
  • a first aspect of the present invention provides a route query method, including:
  • the internal matching table Detecting, in the internal matching table, an entry that matches the address information and the destination address information, where the internal matching table includes an exact matching table and a universal matching table;
  • the internal matching table does not have an entry matching the address information and the destination address information, detecting whether the external matching table has an entry that matches the address information and the destination address information, where the external matching table includes an exact Match table and universal match table;
  • the exact matching table of the external matching table does not have an entry whose address information matches the destination address information, and the universal matching table of the external matching table has an entry that matches the address information with the destination address information, And detecting, by the address table information of the matching entry in the universal matching table of the external matching table, address information of the exact matching table of the external matching table;
  • the universal matching table of the external matching table is matched to The entry is saved to the generic match table of the internal match table.
  • the detecting, by the internal matching table, whether the address information matches the destination address information includes:
  • the detecting, by the internal matching table, whether the address information matches the destination address information includes:
  • the forwarding of the output port indicated by the data packet matched by the matching entry in the internal matching table includes:
  • the data packet is matched by the exact matching table in the internal matching table.
  • the data packet is forwarded by an output port indicated by the matching entry in the exact matching table of the internal matching table;
  • the data packet is forwarded by an output port indicated by the matching entry in the universal matching table of the internal matching table.
  • the detecting the external matching table whether the address information and the destination address exist include:
  • the common matching table of the external matching table is detected whether the address information matches the destination address information. Entry.
  • the detecting the external matching table whether the address information exists and the destination The entries matching the address information include:
  • the forwarding of the output port indicated by the data packet matched by the matching entry in the external matching table includes:
  • the data packet is matched by the exact matching table in the external matching table.
  • the exact matching table of the external matching table has an entry that matches the destination address information, and the universal matching table of the external matching table does not have an entry that matches the destination information, the The data packet is forwarded by an output port indicated by the matching entry in the exact matching table of the external matching table;
  • the data packet is forwarded through an output port indicated by the matching entry in the universal matching table of the external matching table.
  • the method further includes:
  • the matched matching entries in the exact matching table of the external matching table are saved in an exact matching table of the internal matching table.
  • the detecting the matching entry in the exact matching table of the external matching table Before the address information contains the address information of the exact matching table of the external matching table, it also includes:
  • performing the detecting whether the address information of the matched entry in the exact matching table of the external matching table includes The step of accurately matching the address information of the table to the external matching table;
  • the method further includes: if the matched entry in the exact match table of the external matching table is detected When the address information includes the address information of the exact matching table of the external matching table, the matching entry in the exact matching table of the external matching table is marked as detected.
  • the method further includes:
  • the eighth possible implementation manner further includes:
  • a second aspect of the present invention provides a network device, including:
  • a packet receiving module configured to receive a data packet through an input port, and parse the data packet to obtain a destination address information thereof;
  • An internal table lookup engine module for detecting whether an internal matching table has address information and the destination An entry matching the address information, where the internal matching table includes an exact matching table and a universal matching table;
  • a forwarding module configured to: if an entry that matches the address information of the internal matching table and the destination address information is detected, pass the data packet to an output port indicated by the matching entry in the internal matching table Forward
  • the external table lookup engine module is configured to: if it is detected that the internal matching table does not have an entry matching the address information and the destination address information, detecting whether the external matching table has an entry that matches the address information and the destination address information
  • the external matching table includes an exact matching table and a universal matching table
  • the forwarding module is further configured to:
  • a first detecting module configured to: if an exact matching table of the external matching table is detected, there is no entry in which the address information matches the destination address information, and the universal matching table of the external matching table has address information and the destination If the address information matches the entry, the address information of the matched entry in the universal matching table of the external matching table is detected to include the address information of the exact matching table of the external matching table;
  • a processing module configured to: if the address information of the matched entry in the universal matching table of the external matching table does not include the address information of the exact matching table of the external matching table, the universal matching table is used The matching entry in the matching table is saved in the universal matching table of the internal matching table.
  • the internal table lookup engine module is specifically configured to:
  • the exact matching table of the internal matching table does not have an entry that matches the destination address information, detecting whether the universal matching table of the internal matching table has an entry that matches the address information and the destination address information. .
  • the internal table lookup engine module is specifically configured to:
  • the forwarding module is further configured to:
  • the data packet is passed through an exact matching table in the internal matching table. Output port forwarding indicated by the matching entry in the table;
  • the data packet is forwarded by an output port indicated by the matching entry in the exact matching table of the internal matching table;
  • the data packet is forwarded by an output port indicated by the matching entry in the universal matching table of the internal matching table.
  • the external table lookup engine module is specifically configured to:
  • the external table lookup engine module is specifically configured to:
  • the forwarding module is further specifically configured to:
  • the data packet is matched by the exact matching table in the external matching table.
  • the exact matching table of the external matching table has an entry that matches the destination address information, and the universal matching table of the external matching table does not have an entry that matches the destination information, the The data packet is forwarded by an output port indicated by the matching entry in the exact matching table of the external matching table;
  • the universal matching table of the external matching table has address information and matches the destination address information And the exact matching table of the external matching table does not have an entry whose address information matches the destination address information, and the data packet is matched to the table matched in the universal matching table of the external matching table.
  • the output port indicated by the item is forwarded.
  • the processing module is further configured to:
  • the matching entry in the exact matching table of the external matching table is saved to the internal matching table. Match the table.
  • the method further includes:
  • a second detecting module configured to detect whether the matched item in the exact matching table of the external matching table is marked as detected, and if the matching item in the exact matching table of the external matching table is detected is not If the identifier is detected, the first detecting module is configured to detect whether the address information of the matched entry in the exact matching table of the external matching table includes the address information of the exact matching table of the external matching table;
  • a marking module configured to mark the accuracy of the external matching table if the address information of the matching entry in the exact matching table of the external matching table is detected to include the address information of the exact matching table of the external matching table The matching entry in the matching table is detected.
  • the seventh possible implementation manner further includes:
  • a matching table update module configured to receive an add instruction for an exact match table input of the external match table, save the added entry to an exact match table of the external match table, and delete the internal match table An entry in the universal matching table that matches the added entry;
  • the eighth possible implementation manner further includes:
  • a matching table update module configured to receive an add instruction for the universal lookup match table input of the external match table, save the added entry to the universal match table of the external match table, and delete the internal match table a universal matching table and an entry in the universal matching table of the external matching table that matches the added entry;
  • a third aspect of the present invention also provides a network device, where the network device includes a network port, a memory, and a processor, wherein the memory stores a set of programs, and the processor is configured to invoke a program stored in the memory, such that The network device performs some or all of the steps of a route query method provided by the first aspect.
  • a fourth aspect of the present invention provides a computer storage medium storing a program for causing a computer to execute, including some or all of the steps of a route query method provided by the first aspect.
  • the present invention first detects whether the internal matching table has an entry that matches the address information with the destination address information of the data packet, and the internal matching table includes an exact matching table and a universal matching table, and if the internal matching table exists, the address information matches the destination address information.
  • the entry of the entry is forwarded by the output port indicated by the entry, and the search acceleration of the exact match table and the universal match table is realized at the same time;
  • the internal matching table does not exist, it is detected whether the external matching table has an entry whose address information matches the destination address information, if the exact matching table of the external matching table does not exist and the universal matching table has the address information and the destination address information.
  • Matching entries directly save the matched entries to the universal matching table of the internal matching table. It does not need to be extended to match the matching entries, which saves internal storage space and avoids The accidental deletion of the entry is exempted.
  • Figure 1 shows a schematic diagram of an exact match table
  • Figure 2 shows a schematic diagram of a universal matching table
  • FIG. 3 is a schematic structural diagram of a network device in the prior art
  • FIG. 5 is a schematic diagram of a method for table lookup routing in the prior art
  • FIG. 6 is a schematic diagram of a route query method according to a first embodiment of the present invention.
  • FIG. 7 is a schematic diagram of an external precision matching table updating method according to a second embodiment of the present invention.
  • FIG. 8 is a schematic diagram of an external universal matching table updating method according to a third embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a network device according to a fourth embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of another network device according to a fifth embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of still another network device according to a sixth embodiment of the present invention.
  • the route query method provided by the embodiment of the present invention is applied to a network device, such as a Layer 2 switch, a Layer 3 switch, or a router.
  • the network device includes at least one input port, and each of the input ports. Having an independent internal matching table, each of the input ports also has an independent or shared external matching table, wherein the internal matching table is used to cache entries that are hit in the external matching table;
  • the internal matching table includes an exact matching table and a universal matching table.
  • the external matching table includes an exact matching table and a universal matching table.
  • exact matching table of the internal matching table is simply referred to as an “internal exact matching table”, which will be internal.
  • the universal matching table of the matching table is simply referred to as “internal universal matching table”, and the exact matching table of the external matching table is simply referred to as “external exact matching table”, and the universal matching table of the external matching table is simply referred to as “external universal matching table”.
  • the first embodiment of the present invention provides a route query method. As shown in FIG. 6, the method in this embodiment may include:
  • step S601 the data packet is received through the input port, and the data packet is parsed to obtain the destination address information. It can be understood that how to parse the data packet to obtain the destination address information is understandable by those skilled in the art, and details are not described herein.
  • the destination address information may be a destination IP address of the data packet.
  • Step S602 detecting whether there is an entry in the internal matching table that matches the address information and the destination address information; if it is detected that the internal matching table has an entry matching the address information and the destination address information, step S603 is performed; If it is detected that the internal matching table does not have an entry that matches the destination address information, step S604 is performed;
  • the correspondence between the input port and the internal matching table may be an internal port corresponding to one input port; or an internal matching table corresponding to multiple input ports, etc.; it should be noted that the common technology in the art It is to be understood that a number of variations and modifications may be made without departing from the spirit and scope of the invention.
  • the network device may detect, by the internal exact matching table, whether an address information matching the destination address information exists, and if the internal exact matching table exists, the address information matches the destination address information.
  • step S603 is performed.
  • each entry of the internal exact match table includes at least a destination IP address and an output port number, and the network device can obtain the destination IP address of the data packet, and query the internal exact match table by using a hash. If the entry with the same IP address and the destination IP address is queried, step S603 is performed; the internal exact match table is exemplified in Table 1, and the destination IP address of the data packet is 10.10.10.8, and the network device queries the internal exact match. The table can be queried to the same entry as the IP address and the destination IP address, that is, the entry 3, step S603 is performed;
  • the network device may further detect whether the internal universal matching table has address information matching the destination address information. If the internal common matching table has an entry that matches the address information and the destination address information, step S603 is performed.
  • each entry of the internal universal matching table includes at least a network address, a mask, and an output. The port number, the network device can obtain the destination IP address of the data packet, query the internal universal matching table through the TCAM, and if the mask matches the entry matching the destination IP address, step S603 is performed;
  • the mask is used to identify whether two IP addresses belong to the same subnet. It is a set of 32-bit binary values. The value on each bit represents a different meaning: if it is "1", it means the network is a network. Bit; if "0", it means that the bit is the host bit; if the destination IP address of the packet and the mask are calculated by bitwise AND, the result is the same as the network address of the entry, then the mask is based on the mask. If the entry matching the destination IP address is matched, step S603 is performed.
  • the internal common matching table is exemplified in Table 2. Assume that the destination IP address of the data packet is 10.10.10.8, and the network device queries the internal universal matching table. If the result of the bitwise AND calculation of the mask of the destination IP address and the entry 1 is the same as the network address of the entry 1, the step S603 is performed.
  • the network device may simultaneously detect whether the internal precision matching table and the internal universal matching table have an entry whose address information matches the destination address information, if the internal exact matching table and the If the internal universal matching table has an entry whose address information matches the destination address information, the data packet is forwarded through an output port indicated by the matched entry in the internal exact matching table; that is, if the internal If both the exact match table and the internal universal match table have entries matching the address information and the destination address information, the result matched by the internal exact match table shall prevail.
  • the internal exact match table is shown in Table 1, and the internal universal match table is used. Take Table 2 as an example. If the destination IP address is still 10.10.10.8, the matching result is the entry 3 of the internal exact match table, that is, the output port number is “3”.
  • the data packet is passed through Output port forwarding indicated by the matched entry in the internal exact match table;
  • the data packet is passed through The output port indicated by the matched entry in the internal universal matching table is forwarded.
  • the on-chip cache stores the exact match table and the universal match table respectively, the search for the exact match table is accelerated, and the lookup of the universal match table is accelerated.
  • Step S603 forwarding the data packet by an output port indicated by the matching entry in the internal matching table.
  • Step S604 detecting whether there is an entry in the external matching table that the address information matches the destination address information; if it is detected that the external exact matching table has an entry matching the address information and the destination address information, step S605 is performed; If the external universal matching table is detected, the address information and the location are detected. If the destination address information matches the entry, step S607 is performed;
  • the corresponding relationship between the input port and the external matching table may be an input port corresponding to an external matching table; or a plurality of input ports corresponding to an external matching table, etc.; it should be noted that the common technology in the art It is to be understood that a number of variations and modifications may be made without departing from the spirit and scope of the invention. Step S605, saving the entry to the internal exact match table;
  • the network device may be continuous Routing the plurality of data packets, if, when the first data packet is received, storing the matching entries in the external exact matching table into the internal exact matching table, when receiving the multiple data packets In the subsequent data packets, the results can be matched in the internal exact matching table, which improves the efficiency of the table lookup;
  • the network device may also detect the number of hits of the entry within a preset duration, and if the number of hits reaches a preset number of thresholds, The entry is saved in the internal exact match table. It should be noted that the preset number of times threshold may be adjusted according to actual conditions, and the present invention is not limited.
  • Step S606 forwarding the data packet by an output port indicated by the matching entry in the external matching table
  • step S605 there is no strict sequential execution order between step S605 and step S606, and can be performed simultaneously.
  • Step S607 detecting whether the address information of the entry contains the address information of the external exact match table; if it is detected that the address information of the entry does not include the address information of the external exact match table, step S608 is performed;
  • the address information of the entry is detected. Address information of the external exact matching table
  • the network device can match the table in the external universal matching table.
  • the entry is extended to the exact match entry, and the entry in the external exact match table is the same as the address information of the extended exact match entry. If yes, the address information of the entry includes the
  • the address information of the external exact matching table is shown in Table 2 as an example.
  • the external exact matching table is exemplified in Table 1. Assume that the matching entry in the external universal matching table is the entry 1 of the table. When the entry is extended to the exact match entry, the address information of each entry is 10.10.10.1 to 10.10.10.254, and the address information of the entry 3 of the external exact match table is 10.10.10.8, indicating that the entry is matched.
  • the address information includes the address information of the external exact matching table.
  • the match table can determine that the output port of the packet is 1, but the external exact match table records the output port of 10.10.10.8 as 3, which violates the "exact match result takes precedence over the universal match knot.
  • the selection logic therefore, does not save the matching entry to the internal universal matching table;
  • the network device may perform a bitwise AND operation on each IP address in the external exact matching table and the mask of the matching entry in the external universal matching table, if the existence is equal to the
  • the operation result of the network address indicates that the address information of the entry contains the address information of the external exact matching table;
  • the external universal matching table is exemplified in Table 2, and the external exact matching table is exemplified in Table 1, assuming that the network device is The matching entry in the external universal matching table is entry 1, that is, the network address is 10.10.10.0, and the IP address of the external exact matching table is bitwise ANDed with the mask 255.255.255.0, and there are 10.10.10.8 and 255.255.
  • the result of the bitwise AND operation of .255.0 is equal to 10.10.10.0, indicating that the address information of the entry contains the address information of the external exact match table.
  • the network device may first detect whether the entry is marked as detected, and if the entry is not identified as detected, whether the address information of the entry includes the address information of the external exact match table, and if When it is detected that the address information of the entry contains the address information of the external exact match table, the entry is marked as detected. Specifically, when the network device matches the entry in the external universal matching table, it may first detect whether the matched entry is marked as detected. If it is marked as detected, the address information of the matched entry is included.
  • the step of the external exact matching table does not perform the step of detecting whether the address information of the entry includes the address information of the external exact matching table, and avoids repeatedly checking the table; if the entry is not identified as having been And detecting, performing the step of detecting whether the address information of the entry includes the address information of the external exact matching table, and if the address information packet of the entry is detected When the address information of the external exact matching table is included, the entry is marked as detected;
  • the network device may first detect the external exact matching table. If the external exact matching table does not have an entry matching the address information and the destination address information, the external universal matching table is detected; or the network device can simultaneously detect the external exact matching. Table and external generic match table;
  • the network device may also detect Whether the matched number of hits in the preset duration reaches the preset number threshold, and if so, whether the address information of the entry includes the address information of the external exact match table;
  • the manner in which the network device marks the entry is not limited in the present invention.
  • Step S608 saving the entry to the internal universal matching table.
  • the entry is directly saved in the internal universal matching table, and the extended storage entry is not needed, thereby saving internal storage space. At the same time, it also avoids accidental deletion.
  • the network device may also match the The table entry is extended to match the exact entry, and the extended exact match entry is saved to the internal exact match table;
  • Step S609 forwarding the data packet by an output port indicated by the matching entry in the external matching table.
  • the network device first detects whether the internal matching table has an entry that matches the address information with the destination address information of the data packet, where the internal matching table includes an exact matching table and an internal matching table, if an internal matching table is used. Achieving simultaneous search acceleration for exact match tables and universal match tables;
  • the external matching table is further checked whether there is an entry whose address information matches the destination address information, and if the external exact matching table does not have an entry matching the address information and the destination address information, and the external universal matching is performed. If an entry with the address information matching the destination address information exists, the matching entry is saved to the internal universal matching table, and the table does not need to be extended to the exact matching entry.
  • the internal storage space also avoids accidental deletion.
  • the embodiment of the present invention provides an external accurate matching table updating method and an external universal matching table updating method.
  • the method ensures that the change can be implemented correctly, and on the other hand, it ensures that the result of the table lookup that does not violate the selection logic of "the exact match result takes precedence over the general match result" is not generated.
  • the second embodiment of the present invention provides an external precision matching table updating method. As shown in FIG. 7, the method may include:
  • Step S701 receiving an update instruction for inputting an external exact match table
  • Step S702 if the update instruction is an add instruction for the external exact match table, save the added entry to the external exact match table, and delete the added entry in the internal universal match table. Matching entries;
  • the network device may perform bitwise AND operation on the address information of the added entry and the mask of each entry in the internal universal matching table. If the operation result is the same as the network address of the entry, the entry is Deleted in the internal universal matching table;
  • Step S703 if the update instruction is a deletion instruction for the target entry in the external exact match table, deleting the target entry in the external exact match table and the internal exact match table;
  • Step S704 if the update instruction is a modification instruction for the target entry in the external exact match table, modify the target entry in the external exact match table, and delete the internal exact match table.
  • the network device can delete, add, or modify multiple entries at a time, and the present invention is not limited.
  • the third embodiment of the present invention provides an external universal matching table updating method. As shown in FIG. 8, the method may include:
  • Step S801 receiving an update instruction input to an external universal matching table
  • Step S802 if the update instruction is an add instruction for the external universal matching table, then Saving the added entry into the external universal matching table, and deleting the internal universal matching table and the entry in the external universal matching table that matches the added entry;
  • the network device can compare the network address of the entry added to the external universal matching table with the network address of each entry in the internal universal matching table, and if the network address set of the added entry is an entry in the internal universal matching table A subset of the network address set is deleted from the internal universal matching table; it is assumed that the network address of the entry added by the external universal matching table is 10.10.10.0, and the internal universal matching table has a network address of 10.10.0.0.
  • the table entry because the network address set represented by 10.10.10.0 is a subset of the network address set represented by 10.10.0.0, the 10.10.0.0 is deleted from the internal universal matching table; it is assumed that the network address of the added entry is 10.10.10.0 and the output port is 3.
  • the output port corresponding to 10.10.0.0 in the internal universal matching table is 2.
  • 10.10.0.0 is not deleted from the internal universal matching table, when a destination IP address is received, it is 10.10.10.8.
  • the data packet is queried for the internal universal matching table, and the output port of the data packet is determined to be 2, but the output port of the data packet is actually 3, which causes the output port to be determined incorrectly. Problem, if you remove 10.10.0.0 from the internal universal match table, you can avoid this problem;
  • Step S803 if the update instruction is a deletion instruction for the target entry in the external universal matching table, deleting the target entry in the external universal matching table and the internal universal matching table;
  • Step S804 if the update instruction is a modification instruction for the target entry in the external universal matching table, modifying the target entry in the external universal matching table, and deleting the internal universal matching table and modifying The entry of the previous and modified target entry matches.
  • FIG. 9 is a schematic structural diagram of a network device according to a fourth embodiment of the present invention.
  • the network device in the embodiment of the present invention may include at least a packet receiving module 91, an internal table lookup engine module 92, and a forwarding module. 93.
  • a packet receiving module 91 configured to receive a data packet through an input port, and parse the data packet to obtain a destination address information thereof;
  • the internal table lookup engine module 92 is configured to detect whether an internal matching table has an entry whose address information matches the destination address information;
  • the forwarding module 93 is configured to detect, if the internal matching table exists, address information and the destination The entry matching the address information, and forwarding the data packet by an output port indicated by the matching entry in the internal matching table;
  • the external look-up table engine module 94 is configured to: if it is detected that the internal matching table does not have an entry matching the address information and the destination address information, detecting whether the external matching table has a table in which the address information matches the destination address information item;
  • the forwarding module 93 is further configured to:
  • the first detecting module 95 is configured to: if it is detected that the external exact matching table does not exist, the address information matches the destination address information, and the external universal matching table of the external matching table has the address information and the destination address If the information matching the entry, detecting whether the address information of the matched entry in the external universal matching table includes the address information of the external exact matching table;
  • the processing module 96 is configured to: if the address information of the matched entry in the external universal matching table does not include the address information of the external exact matching table, save the matched entry in the external universal matching table to The internal universal matching table.
  • the internal look-up engine module 92 may be specifically configured to:
  • the internal exact matching table does not have an entry matching the address information and the destination address information, detecting whether the corresponding internal universal matching table has an entry that matches the address information and the destination address information;
  • the external lookup engine module 94 is triggered to detect whether the external matching table has address information and the destination. The address information matches the entry.
  • the internal table lookup engine module may be specifically configured to:
  • the forwarding module 93 If the internal precision matching table and the internal universal matching table have an entry whose address information matches the destination address information, triggering the forwarding module 93 to match the data packet to the internal precision matching table.
  • the output port indicated by the entry is forwarded;
  • the forwarding module 93 is triggered.
  • the data packet is forwarded by an output port indicated by the matching entry in the internal exact match table;
  • the forwarding module 93 is triggered.
  • the data packet is forwarded by an output port indicated by the matching entry in the internal universal matching table;
  • the external lookup engine module 94 is triggered to detect whether the external matching table corresponding to the input port exists. An entry whose address information matches the destination address information.
  • external look-up engine module 94 can be specifically used to:
  • the external exact matching table does not have an entry matching the address information and the destination address information, detecting whether the corresponding external universal matching table has an entry that matches the address information and the destination address information;
  • the forwarding module 93 triggering, by the forwarding module 93, the data packet to pass the output indicated by the entry matched in the external universal matching table.
  • the port forwarding may be triggered to detect whether the address information of the entry includes the address information of the external exact matching table.
  • trigger processing Module 96 saves the entry to the internal generic match table.
  • external look-up engine module 94 can also be specifically used to:
  • the forwarding module 93 is further specifically configured to:
  • the data packet is passed through Output port forwarding indicated by the matched entry in the external exact match table;
  • the packet is passed.
  • the output port indicated by the matched entry in the external universal matching table is forwarded.
  • the processing module 96 is further configured to:
  • FIG. 10 is a schematic structural diagram of another network device according to a fifth embodiment of the present invention.
  • the network device 9 may further include a second detecting module 97 and a marking module 98. :
  • the second detecting module 97 is configured to detect whether the matched item in the external universal matching table is marked as detected, and if it is detected that the matched item in the external universal matching table is not identified as being detected,
  • the first detecting module 95 is configured to detect whether the address information of the matched entry in the external universal matching table includes the address information of the external exact matching table.
  • the tagging module 98 is configured to: if the address information of the matched entry in the external universal matching table is detected to include the address information of the external exact matching table, mark the matched entry in the external universal matching table It has been tested.
  • network device 9 as shown in FIG. 10 may further include:
  • a matching table update module 99 configured to receive an add instruction for the external exact match table input, And saving the added entry to the external exact match table, and deleting the entry in the internal universal match table that matches the added entry; and/or,
  • FIG. 11 is a schematic structural diagram of still another network device according to a sixth embodiment of the present invention.
  • the network device 11 may include: at least one processor 111, such as a CPU, at least one network port 112, at least one User interface 113, memory 114, at least one communication bus 115.
  • the communication bus 115 is used to implement connection communication between these components.
  • the memory 114 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
  • the memory 114 may also be at least one storage device located away from the processor 111.
  • a set of program codes is stored in the memory 114, and the processor 111 is configured to call program code stored in the memory 114 for performing the following operations:
  • the external exact matching table does not have an entry matching the address information and the destination address information, and the external universal matching table has an entry that matches the address information with the destination address information, detecting the external universal matching table Whether the address information of the matched entry contains the address information of the external exact match table;
  • the processor 111 by calling the program code stored in the memory 114, to detect whether the internal matching table has an address information matching the destination address information, may be:
  • the processor 111 by using the program code stored in the memory 114, to detect whether the internal matching table corresponding to the input port has an address information matching the destination address information may be:
  • the internal exact match table and the internal universal match table have an entry that matches the address information and the destination address information, performing the step of indicating that the data packet is matched by the entry in the internal match table Step of forwarding the output port;
  • the data packet is passed through Output port forwarding indicated by the matched entry in the internal exact match table;
  • the data packet is passed through Output port forwarding indicated by the matched entry in the internal universal matching table;
  • the detecting whether the external matching table has an address matching the address information and the destination address information is performed. A step of.
  • the program that the processor 111 calls the program code stored in the memory 114 to detect whether the external matching table has the address information and the destination address information may be:
  • the external exact matching table does not have an entry matching the address information and the destination address information, detecting whether the corresponding external universal matching table has an entry that matches the address information and the destination address information;
  • the external universal matching table has an entry that matches the address information with the destination address information, performing the outputting of the data packet by the entry indicated by the matching entry in the external matching table Port forwarding, at the same time, the step of detecting whether the address information of the matched entry in the external universal matching table includes the address information of the external exact matching table is performed;
  • the program that the processor 111 calls the program code stored in the memory 114 to detect whether the external matching table has the address information and the destination address information may be:
  • the data packet is passed through Output port forwarding indicated by the matched entry in the external exact match table;
  • the packet is passed.
  • the output port indicated by the matched entry in the external universal matching table is forwarded.
  • the processor 111 may further perform the following operations:
  • the matched entry in the external universal matching table is saved into the internal exact match table.
  • processor 111 can also perform the following operations
  • the matched matching entry in the external universal matching table is marked as detected.
  • processor 111 can also perform the following operations:
  • the embodiment of the present invention further provides a computer storage medium.
  • the computer storage medium stores a program, and the program includes some or all of the steps in the method described in connection with FIG. 6 to FIG. 8 in the embodiment of the present invention.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Abstract

本发明实施例公开了一种路由查询方法,包括:通过输入端口接收数据包,解析所述数据包获得其目的地址信息;检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项;若不存在,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,若存在,则将该数据包通过匹配到的表项指示的输出端口转发;若外部精确匹配表不存在且外部通用匹配表存在匹配的表项,则检测该表项的地址信息是否包含外部精确匹配表的地址信息;若不包含,则将该表项保存到内部通用匹配表中。相应地,本发明实施例还公开了一种网络设备。采用本发明,可以实现同时对精确匹配表和通用匹配表进行查找加速,并且,可以节约内部存储空间,同时也可以避免表项的误删。

Description

一种路由查询方法和网络设备 技术领域
本发明涉及通信技术领域,尤其涉及一种路由查询方法和网络设备。
背景技术
当前的计算机网络,比如以太网和因特网,一般采用包交换技术(又称“分组交换”)对数据进行传输。在包交换网络中,通信数据首先在源主机节点被切分和封装成一个个数据包并注入网络,然后经过网络设备的路由和转发进行传输,最终数据包到达目的主机节点,恢复和合并成原有通信数据。在该过程中,网络设备,比如交换机和路由器,对每一个数据包进行独立的路由和转发,即当一个数据包到达网络设备的输入端口时,网络设备基于数据包中的地址信息,比如目的MAC(英文:Media Access Control,中文:介质访问控制)地址或目的IP(英文:Internet Protocol,中文:互联网协议)地址,确定该数据包的输出端口,并将该数据包从输入端口交换到输出端口。
在当前的大部分网络设备中,对数据包的路由是通过查询查找表实现的:在网络设备中存储有一张或多张“查找表”(比如,路由表或转发表),每个查找表包含一个或多个表项,每个表项包含地址信息和输出端口号等信息,通过提取数据包中的地址信息和查找表中的地址信息进行匹配,以确定匹配的表项,并从匹配的表项中提取输出端口号以确定输出端口。这种路由方式称为“查表路由”。
比如,由二层交换机构建的以太网中,交换机中存放着一张学习得到的“转发表”,该表的表项中包含MAC地址和输出端口号等信息;当交换机接收到一个数据包时,从数据包中提取目的MAC地址,并将它与转发表中每个表项的目的MAC地址进行比较,以确定匹配的表项(目的MAC地址与表项中的MAC地址相等),从而得到输出端口号。又如,由路由器构建的IP网络中,每个路由中都存放着通过路由协议学习得到的“路由表”,该表的表项中包含网络地址、网络掩码、输出端口号和下一跳网络地址等信息;当路由器接收到一个数据包时,从数据包中提取目的IP地址,并执行基于掩码的匹配,以确 定匹配的表项,从而得到输出端口号和下一跳网络地址等信息。
近年来新兴起的软件定义网络(全称:Software Defined Networking,简称:SDN)中,网络设备也通过查找一种称为“流表”的查找表来实现对数据包的路由和其他处理。为了执行细粒度的数据流处理,与二层交换机的转发表和路由器的路由表相比,该查找表通常包含更多的匹配字段,并且精确匹配表和通用匹配表并存。图1和图2分别示出了精确匹配表和通用匹配表的逻辑结构,对于精确匹配表,执行精确匹配,即数据包中的地址信息需要与该匹配域完全相等才能作为匹配成功;对于通用匹配表,执行基于掩码的通用匹配,即数据包的一部分与该匹配域中的对应部分相等即为匹配成功,其余部分可以在匹配过程中忽略,该忽略规则由匹配域中的掩码决定。对于网络设备,查表路由的性能通常是其性能的瓶颈,因此对查表路由进行加速十分重要,基于缓存的查表路由加速方法是一种重要的查表加速技术。
图3示出了一种现有技术中在精确匹配表和通用匹配表并存的情况下,网络设备执行查表路由的一般结构。在该结构下,利用片内精确匹配表缓存最近经常使用的精确匹配表项,执行查表路由时,首先执行内部查表,对精确匹配表进行查找,如果命中,则不再查询外部表,直接输出结果,以实现查表路由加速;该查表路由加速技术,虽然能对最终匹配精确匹配表项的那些数据包的路由进行加速,但对于最终匹配通用匹配表项的数据包而言,其路由过程没有加速。
图4示出了另一种现有技术中在精确匹配表和通用匹配表并存的情况下,网络设备执行软件查表路由的一般结构。在该结构下,将精确匹配表作为通用匹配表的缓存。其查表路由过程如图5所示:当一个数据包到达时,首先执行精确匹配表查找,如果命中,直接返回精确匹配结果;否则,再执行通用匹配表查找,如果命中,返回通用匹配结果,并结合数据包中的流信息,将该通用匹配结果表项扩展为精确匹配表项后存入精确匹配表中;通过将命中的通用匹配结果表项扩展为精确匹配表项后存入精确匹配表中,对于后续与当前数据包属于同一个流的数据包,只要执行精确匹配表查找就能完成路由,因此实现了路由加速。该查表路由加速技术存在以下缺点:1、通用匹配表项可能扩展为大量精确匹配表项,从而占用大量的精确匹配表的空间;2、当删除通用匹配 表项时,要同步删除扩展到精确匹配表中的表项,但是由于难以区分“哪些精确表项是扩展得到的,哪些是原本有的”,所以可能导致误删。
发明内容
本发明提供了一种路由查询方法,可以实现同时对精确匹配表和通用匹配表的进行查找加速,并且,可以节约内部存储空间以及可以避免表项的误删。
本发明第一方面提供了一种路由查询方法,包括:
通过输入端口接收数据包,解析所述数据包获得其目的地址信息;
检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述内部匹配表包括精确匹配表和通用匹配表;
若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述外部匹配表包括精确匹配表和通用匹配表;
若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息不包含所述外部匹配表的精确匹配表的地址信息,则将所述外部匹配表的通用匹配表中匹配到的表项保存到所述内部匹配表的通用匹配表中。
在第一方面的第一种可能实现方式中,所述检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
检测所述内部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述内部匹配表的精确匹配表不存在地址信息与所述目的地址 信息匹配的表项,则检测所述内部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
在第一方面的第二种可能实现方式中,所述检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
同时检测所述内部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发包括:
若所述内部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
结合第一方面或第一方面的第一种或第二种任一种可能的实现方式中,在第三种可能的实现方式中,所述检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
检测所述外部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
结合第一方面或第一方面的第一种或第二种任一种可能的实现方式中,在第四种可能的实现方式中,所述检测外部匹配表是否存在地址信息与所述目的 地址信息匹配的表项包括:
同时检测所述外部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发包括:
若所述外部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
结合第一方面的第三种或第四种任一种可能实现方式,在第五种可能的实现方式中,若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项,所述方法还包括:
将所述外部匹配表的精确匹配表中匹配到的表项保存到所述内部匹配表的精确匹配表中。
结合第一方面或第一方面的第一种至第五种任一种可能实现方式,在第六种可能实现方式中,所述检测所述外部匹配表的精确匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息之前,还包括:
检测所述外部匹配表的精确匹配表中匹配到的表项是否被标记为已检测;
若检测到所述外部匹配表的精确匹配表中匹配到的表项未被标识为已检测,则执行所述检测所述外部匹配表的精确匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息的步骤;
所述方法还包括:若检测到所述外部匹配表的精确匹配表中匹配到的表项 的地址信息包含所述外部匹配表的精确匹配表的地址信息时,则标记所述外部匹配表的精确匹配表中匹配到的表项为已检测。
结合第一方面或第一方面的第一种至第六种任一种可能实现方式,在第七种可能的实现方式,还包括:
接收针对所述外部匹配表的精确匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的精确匹配表中,并删除所述内部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部匹配表的精确匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的精确匹配表和所述内部匹配表的精确匹配表中的所述目标表项;和/或,
接收针对所述外部匹配表的精确匹配表中的目标表项输入的修改指令,修改所述外部匹配表的精确匹配表中的所述目标表项,并删除所述内部匹配表的精确匹配表中的修改前的所述目标表项和所述内部匹配表的通用匹配表中与修改后的所述目标表项匹配的表项。
结合第一方面或第一方面的第一种至第六种中任一种可能实现方式,在第八种可能的实现方式,还包括:
接收针对所述外部匹配表的通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的通用匹配表中,并删除所述内部匹配表的通用匹配表和所述外部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部匹配表的通用匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的通用匹配表和所述内部匹配表的通用匹配表中的所述目标表项;和/或,
接收针对所述外部匹配表的通用匹配表中的目标表项输入的修改指令,修改所述外部匹配表的通用匹配表中的所述目标表项,并删除所述内部匹配表的通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
本发明第二方面提供了一种网络设备,包括:
包接收模块,用于通过输入端口接收数据包,解析所述数据包获得其目的地址信息;
内部查表引擎模块,用于检测内部匹配表是否存在地址信息与所述目的地 址信息匹配的表项,所述内部匹配表包括精确匹配表和通用匹配表;
转发模块,用于若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
外部查表引擎模块,用于若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述外部匹配表包括精确匹配表和通用匹配表;
所述转发模块还用于:
若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
第一检测模块,用于若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
处理模块,用于若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息不包含所述外部匹配表的精确匹配表的地址信息,则将所述外部匹配表的通用匹配表中匹配到的表项保存到所述内部匹配表的通用匹配表中。
在第二方面的第一种可能实现方式中,所述内部查表引擎模块具体用于:
检测所述内部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述内部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
在第二方面的第二种可能实现方式中,所述内部查表引擎模块具体用于:
同时检测所述内部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述转发模块还用于:
若所述内部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表 中匹配到的表项指示的输出端口转发;
若所述内部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
结合第二方面或第二方面的第一种或第二种任一种可能实现方式,在第三种可能的实现方式中,所述外部查表引擎模块具体用于:
检测所述外部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
结合第二方面或第二方面的第一种或第二种任一种可能实现方式,在第四种可能的实现方式中,所述外部查表引擎模块具体用于:
同时检测所述外部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述转发模块具体还用于:
若所述外部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配 的表项且所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
结合第二方面的第三种或第四种可能实现方式,在第五种可能的实现方式中,所述处理模块还用于:
若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述外部匹配表的精确匹配表中匹配到的表项保存到所述内部匹配表的精确匹配表中。
结合第二方面或第二方面的第一种至第五种可能实现方式,在第六种可能实现方式,还包括:
第二检测模块,用于检测所述外部匹配表的精确匹配表中匹配到的表项是否被标记为已检测,若检测到所述外部匹配表的精确匹配表中匹配到的表项未被标识为已检测,则触发所述第一检测模块检测所述外部匹配表的精确匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
标记模块,用于若检测到所述外部匹配表的精确匹配表中匹配到的表项的地址信息包含所述外部匹配表的精确匹配表的地址信息时,则标记所述外部匹配表的精确匹配表中匹配到的表项为已检测。
结合第二方面或第二方面的第一种至第六种中任一种可能实现方式,在第七种可能的实现方式,还包括:
匹配表更新模块,用于接收针对所述外部匹配表的精确匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的精确匹配表中,并删除所述内部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部匹配表的精确匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的精确匹配表和所述内部匹配表的精确匹配表中的所述目标表项;和/或,
接收针对所述外部匹配表的精确匹配表中的目标表项输入的修改指令,修改所述外部匹配表的精确匹配表中的所述目标表项,并删除所述内部匹配表的精确匹配表中的修改前的所述目标表项和所述内部匹配表的通用匹配表中与 修改后的所述目标表项匹配的表项。
结合第二方面或第二方面的第一种至第六种中任一种可能实现方式,在第八种可能的实现方式,还包括:
匹配表更新模块,用于接收针对所述外部匹配表的通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的通用匹配表中,并删除所述内部匹配表的通用匹配表和所述外部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部匹配表的通用匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的通用匹配表和所述内部匹配表的通用匹配表中的所述目标表项;和/或,
接收针对所述外部匹配表的通用匹配表中的目标表项输入的修改指令,修改所述外部匹配表的通用匹配表中的所述目标表项,并删除所述内部匹配表的通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
本发明第三方面还提供一种网络设备,所述网络设备包括网络端口、存储器以及处理器,其中,所述存储器中存储一组程序,且处理器用于调用所述存储器中存储的程序,使得所述网络设备执行第一方面提供的一种路由查询方法的部分或全部步骤。
本发明第四方面提供了一种计算机存储介质,所述计算机存储介质存储有程序,所述程序用于使计算机执行时包括第一方面提供的一种路由查询方法的部分或全部步骤。
实施本发明,具有以下有益效果:
本发明先检测内部匹配表是否存在地址信息与数据包的目的地址信息匹配的表项,该内部匹配表包括精确匹配表和通用匹配表,若内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将该数据包通过该表项指示的输出端口转发,实现了同时对精确匹配表和通用匹配表的查找加速;
若内部匹配表不存在,再检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,若外部匹配表的精确匹配表不存在且通用匹配表存在地址信息与所述目的地址信息匹配的表项,则直接将匹配的表项保存到内部匹配表的通用匹配表中,无需扩展为精确匹配表项,节约了内部存储空间,同时也避 免了表项的误删。
附图说明
为了更清楚地说明本发明实施例,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了一种精确匹配表的示意图;
图2示出了一种通用匹配表的示意图;
图3是现有技术中一种网络设备的结构示意图;
图4是现有技术中另一种网络设备的结构示意图;
图5是现有技术中一种查表路由的方法示意图;
图6是本发明第一实施例提供的一种路由查询方法的示意图;
图7是本发明第二实施例提供的一种外部精确匹配表更新方法的示意图;
图8是本发明第三实施例提供的一种外部通用匹配表更新方法的示意图;
图9是本发明第四实施例提供的一种网络设备的结构示意图;
图10是本发明第五实施例提供的另一种网络设备的结构示意图;
图11是本发明第六实施例提供的又一种网络设备的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
在此部分,首先对本发明中各个实施例均涉及的一些基本概念进行说明。在TCP/IP参考模型和OSI参考模型中,对在模型的不同层的数据包有不同的称呼,比如帧、数据报文、分组等等,但为了方便起见,本发明统称为数据包。
本发明实施例提供的路由查询方法应用于网络设备,如二层交换机、三层交换机或路由器等,所述网络设备包括至少一个输入端口,各个所述输入端口 拥有独立的内部匹配表,各个所述输入端口还拥有独立或共享的外部匹配表,其中,内部匹配表用于缓存在外部匹配表中命中的表项;
内部匹配表包括精确匹配表和通用匹配表,外部匹配表包括精确匹配表和通用匹配表,为例便于描述,下述将内部匹配表的精确匹配表简称为“内部精确匹配表”,将内部匹配表的通用匹配表简称为“内部通用匹配表”,将外部匹配表的精确匹配表简称为“外部精确匹配表”,将外部匹配表的通用匹配表简称为“外部通用匹配表”。
本发明第一实施例提供了一种路由查询方法,如图6所示本实施例的所述方法可以包括:
步骤S601,通过输入端口接收数据包,解析所述数据包获得其目的地址信息;可理解的是,如何解析数据包获得其目的地址信息是本领域技术人员可理解的,在此不再赘述;
该目的地址信息可以是所述数据包的目的IP地址。
步骤S602,检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项;若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则执行步骤S603;若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则执行步骤S604;
其中,输入端口与内部匹配表的对应关系,可以是一个输入端口对应一个内部匹配表;也可以是多个输入端口对应一个内部匹配表,等等;应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。
在一种可选的实施方式中,网络设备可以检测内部精确匹配表是否存在地址信息与所述目的地址信息匹配的表项,若所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项,则执行步骤S603;具体实现中,内部精确匹配表的各个表项至少包括目的IP地址以及输出端口号,网络设备可以获取数据包的目的IP地址,通过哈希查询内部精确匹配表,若查询到IP地址和该目的IP地址相同的表项,则执行步骤S603;内部精确匹配表以表1为例,假设,数据包的目的IP地址为10.10.10.8,网络设备查询内部精确匹配表,可以查询到存在IP地址和目的IP地址相同的表项,即表项3,则执行步骤S603;
可理解的是,如何通过哈希查询内部精确匹配表是本领域技术人可理解的,在此不再赘述;
表1
表项 IP地址 输出端口 ……
1 10.10.125.6 1 ……
2 10.10.136.25 2 ……
3 10.10.10.8 3 ……
4 10.111.10.10 4 ……
…… …… …… ……
进一步的,若检测到所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,网络设备还可以检测所述内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项,若所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则执行步骤S603;具体实现中,内部通用匹配表的各个表项至少包括网络地址、掩码以及输出端口号,网络设备可以获取数据包的目的IP地址,通过TCAM查询内部通用匹配表,基于掩码若匹配出与该目的IP地址匹配的表项,则执行步骤S603;
掩码是用来标识两个IP地址是否同属于一个子网,它是一组32位长的二进制数值,其每一位上的数值代表不同含义:若为“1”则代表该位是网络位;若为“0”则代表该位是主机位;如果,数据包的目的IP地址和掩码进行按位“与”计算后得到的结果与其表项的网络地址相同,则说明基于掩码匹配出与该目的IP地址匹配的表项,则执行步骤S603;内部通用匹配表以表2为例,假设,数据包的目的IP地址为10.10.10.8,网络设备查询内部通用匹配表,可以查询到目的IP地址和表项1的掩码进行按位“与”计算后的结果与表项1的网络地址相同,则执行步骤S603。
表2
表项 网络地址 掩码 输出端口 ……
1 10.10.10.0 255.255.255.0 1 ……
2 10.10.20.0 255.255.255.0 1 ……
3 10.10.30.0 255.255.255.0 2 ……
4 10.10.40.0 255.255.255.0 2 ……
……   …… …… ……
在另一种可选的实施方式中,网络设备可以同时检测内部精确匹配表和内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项,若所述内部精确匹配表和所述内部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过所述内部精确匹配表中匹配到的表项指示的输出端口转发;也就是说,若内部精确匹配表和内部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则以内部精确匹配表匹配出的结果为准,内部精确匹配表以表1为例,内部通用匹配表以表2为例,假设,目的IP地址仍为10.10.10.8,则匹配结果为内部精确匹配表的表项3,即输出端口号为“3”;
若所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部通用匹配表中匹配到的表项指示的输出端口转发。
由于,片内缓存分别存储了精确匹配表和通用匹配表,因此,实现了在对精确匹配表进行查找加速的同时,也对通用匹配表的查找进行了加速。
步骤S603,将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发。
步骤S604,检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项;若检测到所述外部精确匹配表存在地址信息与所述目的地址信息匹配的表项,则执行步骤S605;若检测到所述外部通用匹配表存在地址信息与所 述目的地址信息匹配的表项,则执行步骤S607;
其中,输入端口与外部匹配表的对应关系,可以是一个输入端口对应一个外部匹配表;也可以是多个输入端口对应一个外部匹配表,等等;应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。步骤S605,将该表项保存到内部精确匹配表中;
若外部精确匹配表中存在地址信息与所述目的地址信息匹配的表项,则将该表项保存到内部精确匹配表中,当再次接收到与该数据包具有相同目的IP地址的数据包时,则可以在内部精确匹配表中匹配出结果,提高了查表效率;由于,在包交换网络中,通信数据首先在源主机节点被切分和封装成多个数据包,则网络设备可能连续为所述多个数据包路由,如果,在接收到第一个数据包时,则将在外部精确匹配表中匹配的表项存储到内部精确匹配表中,当接收到所述多个数据包中的后续几个数据包时,可以在内部精确匹配表中匹配出结果,提高了查表效率;
进一步的,若外部精确匹配表存在地址信息与所述目的地址信息匹配的表项,网络设备还可以检测在预设时长内该表项的命中次数,若命中次数达到预设次数阈值,才将该表项保存到内部精确匹配表中;需要说明的是,预设次数阈值可以根据实际情况调整,本发明不作限制。
步骤S606,将所述数据包通过在外部匹配表中匹配到的表项指示的输出端口转发;
可以理解的是,步骤S605-步骤S606之间并没有严格的先后执行顺序,并且可以同时执行。
步骤S607,检测该表项的地址信息是否包含外部精确匹配表的地址信息;若检测到该表项的地址信息不包含外部精确匹配表的地址信息,则执行步骤S608;
若外部通用匹配表中存在地址信息与所述目的地址信息匹配的表项,且外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测该表项的地址信息是否包含所述外部精确匹配表的地址信息;
在一种可选的实施方式中,网络设备可以将在外部通用匹配表中匹配的表 项扩展为精确匹配表项,再检测外部精确匹配表中是否存在地址信息与扩展的所述精确匹配表项的地址信息相同的表项,若存在,则说明该表项的地址信息包含所述外部精确匹配表的地址信息;外部通用匹配表以表2为例,外部精确匹配表以表1为例,假设,网络设备在外部通用匹配表中匹配的表项为表项1,将该表项扩展为精确匹配表项时,其各个表项的地址信息为10.10.10.1~10.10.10.254,而外部精确匹配表的表项3的地址信息为10.10.10.8,则说明匹配出的该表项的地址信息包含外部精确匹配表的地址信息,若此时将匹配出的该表项保存到内部通用匹配表中,当再次接收到目的地址信息为10.10.10.8的数据包时,通过查询内部通用匹配表,可以确定该数据包的输出端口为1,但外部精确匹配表记录10.10.10.8的输出端口为3,违背了“精确匹配结果优先于通用匹配结果”这一选择逻辑,因此,不将匹配出的该表项保存到内部通用匹配表;
在另一种可选的实施方式中,网络设备可以将外部精确匹配表中的各个IP地址与在外部通用匹配表中匹配的表项的掩码进行按位“与”运算,若存在等于该网络地址的运算结果,则说明该表项的地址信息包含所述外部精确匹配表的地址信息;外部通用匹配表以表2为例,外部精确匹配表以表1为例,假设,网络设备在外部通用匹配表中匹配的表项为表项1,即网络地址为10.10.10.0,将外部精确匹配表的IP地址与掩码255.255.255.0进行按位“与”运算,存在10.10.10.8与255.255.255.0进行按位“与”运算后的结果等于10.10.10.0,则说明该表项的地址信息包含所述外部精确匹配表的地址信息。
进一步的,网络设备可以先检测该表项是否被标记为已检测,若该表项未被标识为已检测,才检测该表项的地址信息是否包含外部精确匹配表的地址信息,并且,若检测到该表项的地址信息包含所述外部精确匹配表的地址信息时,则标记该表项为已检测。具体的,网络设备在外部通用匹配表中匹配出表项时,可以先检测匹配的该表项是否被标记为已检测,若被标记为已检测,说明匹配的该表项的地址信息已经包含所述外部精确匹配表的地址信息,不执行所述检测该表项的地址信息是否包含所述外部精确匹配表的地址信息的步骤,避免了重复查表;若该表项未被标识为已检测,则执行所述检测该表项的地址信息是否包含所述外部精确匹配表的地址信息的步骤,若检测到该表项的地址信息包 含所述外部精确匹配表的地址信息时,则标记该表项为已检测;
其中,网络设备可以先检测外部精确匹配表,若外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则再检测外部通用匹配表;或者,网络设备可以同时检测外部精确匹配表和外部通用匹配表;
再进一步的,若外部通用匹配表中存在地址信息与所述目的地址信息匹配的表项,且外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,网络设备还可以先检测匹配到的该表项在预设时长内的命中次数是否达到预设次数阈值,若是,才检测该表项的地址信息是否包含外部精确匹配表的地址信息;
其中,网络设备对表项的标记方式本发明不作限定。
步骤S608,将该表项保存到所述内部通用匹配表中。
若检测到该表项的地址信息不包含所述外部精确匹配表的地址信息,则直接将该表项保存到所述内部通用匹配表中,无需扩展为精确匹配表项,节约了内部存储空间,同时也避免了误删。
进一步的,若外部通用匹配表中存在地址信息与所述目的地址信息匹配的表项,且该表项的地址信息不包含所述外部精确匹配表的地址信息,网络设备还可以将匹配的该表项扩展为精确匹配表项,并将扩展的精确匹配表项保存到内部精确匹配表中;
步骤S609,将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发。
可以理解的是,步骤S608-步骤S609之间并没有严格的先后执行顺序,并且可以同时执行。
在图6所示的实施例中,网络设备先检测内部匹配表是否存在地址信息与数据包的目的地址信息匹配的表项,该内部匹配表包括精确匹配表和通用匹配表若内部匹配表,实现了同时对精确匹配表和通用匹配表的查找加速;
若内部匹配表不存在,再检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,若外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项且外部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则直接将匹配的表项保存到内部通用匹配表中,无需扩展为精确匹配表项,节约 了内部存储空间,同时也避免了误删。
当网络状态或路由策略发生变化时,需要对外部精确匹配表和/或外部通用匹配表进行变更。针对上述双缓存的网络设备,本发明实施例提供了一种外部精确匹配表更新方法和一种外部通用匹配表更新方法。所述方法一方面保证变更能正确地被实施,另一方面也保证变更后不会产生违背“精确匹配结果优先于通用匹配结果”这一选择逻辑的查表路由结果。
本发明第二实施例提供了一种外部精确匹配表更新方法,如图7所示所述方法可以包括:
步骤S701,接收针对外部精确匹配表输入的更新指令;
步骤S702,若所述更新指令为针对所述外部精确匹配表的添加指令,则将添加的表项保存到所述外部精确匹配表中,并删除内部通用匹配表中与添加的所述表项匹配的表项;
网络设备可以将添加的表项的地址信息分别与内部通用匹配表中的各个表项的掩码进行按位“与”运算,若运算结果与其表项的网络地址相同,则将该表项从内部通用匹配表中删除;
步骤S703,若所述更新指令为针对所述外部精确匹配表中的目标表项的删除指令,则删除所述外部精确匹配表和内部精确匹配表中的所述目标表项;
步骤S704,若所述更新指令为针对所述外部精确匹配表中的目标表项的修改指令,则修改所述外部精确匹配表中的所述目标表项,并删除所述内部精确匹配表中的修改前的所述目标表项和内部通用匹配表中与修改后的所述目标表项匹配的表项。
可理解的是,网络设备每次可以删除、添加或修改多个表项,本发明不限定。
本发明第三实施例提供了一种外部通用匹配表更新方法,如图8所示所述方法可以包括:
步骤S801,接收针对外部通用匹配表输入的更新指令;
步骤S802,若所述更新指令为针对所述外部通用匹配表的添加指令,则 将添加的表项保存到所述外部通用匹配表中,并删除内部通用匹配表和所述外部通用匹配表中与添加的所述表项匹配的表项;
网络设备可以将针对外部通用匹配表添加的表项的网络地址与内部通用匹配表中的各个表项的网络地址进行比较,若添加的表项的网络地址集合是内部通用匹配表中的表项的网络地址集合的子集,则将其表项从内部通用匹配表中删除;假设,外部通用匹配表添加的表项的网络地址为10.10.10.0,内部通用匹配表存在网络地址为10.10.0.0的表项,由于,10.10.10.0表示的网络地址集合是10.10.0.0表示的网络地址集合的子集,则将10.10.0.0从内部通用匹配表中删除;假设,添加的表项的网络地址为10.10.10.0且输出端口为3,内部通用匹配表中10.10.0.0对应的输出端口为2,若没有将10.10.0.0从内部通用匹配表中删除,当接收到一个目的IP地址为10.10.10.8的数据包,查询内部通用匹配表,确定该数据包的输出端口为2,但实际上该数据包的输出端口为3,造成了输出端口确定失误的问题,若将10.10.0.0从内部通用匹配表中删除,则可以避免此问题;
步骤S803,若所述更新指令为针对所述外部通用匹配表中的目标表项的删除指令,则删除所述外部通用匹配表和内部通用匹配表中的所述目标表项;
步骤S804,若所述更新指令为针对所述外部通用匹配表中的目标表项的修改指令,则修改所述外部通用匹配表中的所述目标表项,并删除内部通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
图9是本发明第四实施例提供的一种网络设备的结构示意图,如图9所示本发明实施例中的网络设备至少可以包括:包接收模块91、内部查表引擎模块92、转发模块93、外部查表引擎模块94、第一检测模块95以及处理模块96,其中:
包接收模块91,用于通过输入端口接收数据包,解析所述数据包获得其目的地址信息;
内部查表引擎模块92,用于检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项;
转发模块93,用于若检测到所述内部匹配表存在地址信息与所述目的地 址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
外部查表引擎模块94,用于若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述转发模块93还用于:
若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
第一检测模块95,用于若检测到所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的外部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部通用匹配表中匹配到的表项的地址信息是否包含所述外部精确匹配表的地址信息;
处理模块96,用于若所述外部通用匹配表中匹配到的表项的地址信息不包含所述外部精确匹配表的地址信息,则将所述外部通用匹配表中匹配到的表项保存到所述内部通用匹配表中。
在一种可选的实施方式中,所述内部查表引擎模块92具体可以用于:
检测所述内部精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述内部精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测对应的内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述内部通用匹配表中匹配到的表项指示的输出端口转发;
若所述内部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则触发所述外部查表引擎模块94检测外部匹配表是否存在地址信息与所述目 的地址信息匹配的表项。
在另一种可选的实施方式中,所述内部查表引擎模块具体可以用于:
同时检测所述内部精确匹配表和内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述内部精确匹配表和内部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述内部精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述内部精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述内部通用匹配表中匹配到的表项指示的输出端口转发;
若所述内部精确匹配表和内部通用匹配表都不存在地址信息与所述目的地址信息匹配的表项,则触发所述外部查表引擎模块94检测所述输入端口对应的外部匹配表是否存在地址信息与所述目的地址信息匹配的表项。
进一步的,所述外部查表引擎模块94具体可以用于:
检测所述外部精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测对应的外部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则触发所述转发模块93将所述数据包通过在所述外部通用匹配表中匹配到的表项指示的输出端口转发,同时,还可以触发第一检测模块95检测该表项的地址信息是否包含所述外部精确匹配表的地址信息;
若该表项的地址信息不包含所述外部精确匹配表的地址信息,则触发处理 模块96将该表项保存到所述内部通用匹配表中。
进一步的,所述外部查表引擎模块94具体还可以用于:
同时检测所述外部精确匹配表和外部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
所述转发模块93具体还用于:
若所述外部精确匹配表和外部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部通用匹配表中匹配到的表项指示的输出端口转发。
再进一步的,若所述外部精确匹配表存在地址信息与所述目的地址信息匹配的表项,所述处理模块96还用于:
将该表项保存到所述内部精确匹配表中。
请参阅图10,图10是本发明第五实施例提供的另一种网络设备的结构示意图,如图10所示,所述网络设备9还可以包括第二检测模块97以及标记模块98,其中:
第二检测模块97,用于检测所述外部通用匹配表中匹配到的表项是否被标记为已检测,若检测到所述外部通用匹配表中匹配到的表项未被标识为已检测,则触发所述第一检测模块95检测所述外部通用匹配表中匹配到的表项的地址信息是否包含所述外部精确匹配表的地址信息;
标记模块98,用于若检测到所述外部通用匹配表中匹配到的表项的地址信息包含所述外部精确匹配表的地址信息时,则标记所述外部通用匹配表中匹配到的表项为已检测。
再进一步的,如图10所示所述网络设备9还可以包括:
匹配表更新模块99,用于接收针对所述外部精确匹配表输入的添加指令, 并将添加的表项保存到所述外部精确匹配表中,并删除所述内部通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部精确匹配表中的目标表项输入的删除指令,并删除所述外部精确匹配表和所述内部精确匹配表中的所述目标表项;和/或,
接收针对所述外部精确匹配表中的目标表项输入的修改指令,修改所述外部精确匹配表中的所述目标表项,并删除所述内部精确匹配表中的修改前的所述目标表项和所述内部通用匹配表中与修改后的所述目标表项匹配的表项;和/或,
接收针对所述外部通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部通用匹配表中,并删除所述内部通用匹配表和所述外部通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部通用匹配表中的目标表项输入的删除指令,并删除所述外部通用匹配表和所述内部通用匹配表中的所述目标表项;和/或,
接收针对所述外部通用匹配表中的目标表项输入的修改指令,修改所述外部通用匹配表中的所述目标表项,并删除所述内部通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
可理解的是,本实施例的网络设备9的各功能模块的功能可根据上述方法实施例中的方法具体实现,可以具体对应参考图6或图8方法实施例的相关描述,此处不再赘述。
图11是本发明第六实施例提供的又一种网络设备的结构示意图,如图11所示,该网络设备11可以包括:至少一个处理器111,例如CPU,至少一个网络端口112,至少一个用户接口113,存储器114,至少一个通信总线115。其中,通信总线115用于实现这些组件之间的连接通信。存储器114可以是高速RAM存储器,也可以是非易失的存储器(non-volatile memory),例如至少一个磁盘存储器。可选的,存储器114还可以是至少一个位于远离前述处理器111的存储装置。存储器114中存储一组程序代码,且处理器111用于调用存储器114中存储的程序代码,用于执行以下操作:
通过网络端口112的输入端口接收数据包,解析所述数据包获得其目的地 址信息;
检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
若检测到所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项且外部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部通用匹配表中匹配到的表项的地址信息是否包含所述外部精确匹配表的地址信息;
若所述外部通用匹配表中匹配到的表项的地址信息不包含所述外部精确匹配表的地址信息,则将所述外部通用匹配表中匹配到的表项保存到所述内部通用匹配表中。
在一种可选的实施方式中,处理器111调用存储器114中存储的程序代码检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项具体可以为:
检测所述内部精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项,则执行将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发的步骤;
若检测到所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测对应的内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若检测到所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则执行所述将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发的步骤;
若检测到所述内部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则执行所述检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项的步骤。
在另一种可选的实施方式中,处理器111调用存储器114中存储的程序代码检测所述输入端口对应的内部匹配表是否存在地址信息与所述目的地址信息匹配的表项具体可以为:
同时检测所述内部精确匹配表和内部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述内部精确匹配表和内部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则执行所述将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发的步骤;
若所述内部精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部精确匹配表中匹配到的表项指示的输出端口转发;
若所述内部通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部通用匹配表中匹配到的表项指示的输出端口转发;
若所述内部精确匹配表和内部通用匹配表都不存在地址信息与所述目的地址信息匹配的表项,则执行所述检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项的步骤。
进一步的,处理器111调用存储器114中存储的程序代码检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项具体可以为:
检测所述外部精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测对应的外部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部通用匹配表存在地址信息与所述目的地址信息匹配的表项,则执行所述将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端 口转发,同时,还可以执行所述检测所述外部通用匹配表中匹配到的表项的地址信息是否包含所述外部精确匹配表的地址信息的步骤;
若所述外部通用匹配表中匹配到的表项的地址信息不包含所述外部精确匹配表的地址信息,则执行所述将所述外部通用匹配表中匹配到的表项保存到所述内部通用匹配表中。
进一步的,处理器111调用存储器114中存储的程序代码检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项具体可以为:
同时检测所述外部精确匹配表和外部通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
若所述外部精确匹配表和外部通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则执行所述将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发的步骤;
若所述外部精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部精确匹配表中匹配到的表项指示的输出端口转发;
若所述外部通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部通用匹配表中匹配到的表项指示的输出端口转发。
再进一步的,若所述外部精确匹配表存在地址信息与所述目的地址信息匹配的表项,处理器111还可以执行以下操作:
将所述外部通用匹配表中匹配到的表项保存到所述内部精确匹配表中。
再进一步的,处理器111还可以执行以下操作
检测所述外部通用匹配表中匹配到的表项是否被标记为已检测,若所述外部通用匹配表中匹配到的表项未被标识为已检测,则执行所述检测所述外部通用匹配表中匹配到的表项的地址信息是否包含所述外部精确匹配表的地址信息的步骤;
若检测到所述外部通用匹配表中匹配到的表项的地址信息包含所述外部精确匹配表的地址信息时,则标记所述外部通用匹配表中匹配到的表项为已检测。
再进一步的,处理器111还可以执行以下操作:
通过用户端口113接收针对所述外部精确匹配表输入的添加指令,并将添加的表项保存到所述外部精确匹配表中,并删除所述内部通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部精确匹配表中的目标表项输入的删除指令,并删除所述外部精确匹配表和所述内部精确匹配表中的所述目标表项;和/或,
接收针对所述外部精确匹配表中的目标表项输入的修改指令,修改所述外部精确匹配表中的所述目标表项,并删除所述内部精确匹配表中的修改前的所述目标表项和所述内部通用匹配表中与修改后的所述目标表项匹配的表项;和/或,
接收针对所述外部通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部通用匹配表中,并删除所述内部通用匹配表和所述外部通用匹配表中与添加的所述表项匹配的表项;和/或,
接收针对所述外部通用匹配表中的目标表项输入的删除指令,并删除所述外部通用匹配表和所述内部通用匹配表中的所述目标表项;和/或,
接收针对所述外部通用匹配表中的目标表项输入的修改指令,修改所述外部通用匹配表中的所述目标表项,并删除所述内部通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
可理解的是,本实施例的网络设备9的各功能模块的功能可根据上述方法实施例中的方法具体实现,可以具体对应参考图6或图8方法实施例的相关描述,此处不再赘述。
可理解的是,本实施例的网络设备11的各功能模块的功能可根据上述方法实施例中的方法具体实现,可以具体对应参考图6或图9方法实施例的相关描述,此处不再赘述。
本发明实施例还提出了一种计算机存储介质,所述计算机存储介质存储有程序,所述程序执行时包括本发明实施例结合图6~图8所描述的方法中的部分或全部的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程, 是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。

Claims (20)

  1. 一种路由查询方法,其特征在于,包括:
    通过输入端口接收数据包,解析所述数据包获得其目的地址信息;
    检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述内部匹配表包括精确匹配表和通用匹配表;
    若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
    若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述外部匹配表包括精确匹配表和通用匹配表;
    若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
    若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
    若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息不包含所述外部匹配表的精确匹配表的地址信息,则将所述外部匹配表的通用匹配表中匹配到的表项保存到所述内部匹配表的通用匹配表中。
  2. 如权利要求1所述的方法,其特征在于,所述检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
    检测所述内部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    若检测到所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述内部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
  3. 如权利要求1所述的方法,其特征在于,所述检测内部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
    同时检测所述内部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    所述将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发包括:
    若所述内部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述内部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述内部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
  4. 如权利要求1-3任一项所述的方法,其特征在于,所述检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
    检测所述外部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
  5. 如权利要求1-3任一项所述的方法,其特征在于,所述检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项包括:
    同时检测所述外部匹配表的精确匹配表和通用匹配表是否存在地址信息 与所述目的地址信息匹配的表项;
    所述将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发包括:
    若所述外部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
  6. 如权利要求4或5所述的方法,其特征在于,若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项,所述方法还包括:
    将所述外部匹配表的精确匹配表中匹配到的表项保存到所述内部匹配表的精确匹配表中。
  7. 如权利要求1-6任一项所述的方法,其特征在于,所述检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息之前,还包括:
    检测所述外部匹配表的通用匹配表中匹配到的表项是否被标记为已检测;
    若检测到所述外部匹配表的通用匹配表中匹配到的表项未被标识为已检测,则执行所述检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息的步骤;
    所述方法还包括:若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息包含所述外部匹配表的精确匹配表的地址信息时,则标记所述外部 匹配表的通用匹配表中匹配到的表项为已检测。
  8. 如权利要求1-7任一项所述的方法,其特征在于,还包括:
    接收针对所述外部匹配表的精确匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的精确匹配表中,并删除所述内部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
    接收针对所述外部匹配表的精确匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的精确匹配表和所述内部匹配表的精确匹配表中的所述目标表项;和/或,
    接收针对所述外部匹配表的精确匹配表中的目标表项输入的修改指令,修改所述外部匹配表的精确匹配表中的所述目标表项,并删除所述内部匹配表的精确匹配表中的修改前的所述目标表项和所述内部匹配表的通用匹配表中与修改后的所述目标表项匹配的表项。
  9. 如权利要求1-7任一项所述的方法,其特征在于,还包括:
    接收针对所述外部匹配表的通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的通用匹配表中,并删除所述内部匹配表的通用匹配表和所述外部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
    接收针对所述外部匹配表的通用匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的通用匹配表和所述内部匹配表的通用匹配表中的所述目标表项;和/或,
    接收针对所述外部匹配表的通用匹配表中的目标表项输入的修改指令,修改所述外部匹配表的通用匹配表中的所述目标表项,并删除所述内部匹配表的通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
  10. 一种网络设备,其特征在于,包括:
    包接收模块,用于通过输入端口接收数据包,解析所述数据包获得其目的地址信息;
    内部查表引擎模块,用于检测内部匹配表是否存在地址信息与所述目的地 址信息匹配的表项,所述内部匹配表包括精确匹配表和通用匹配表;
    转发模块,用于若检测到所述内部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表中匹配到的表项指示的输出端口转发;
    外部查表引擎模块,用于若检测到所述内部匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测外部匹配表是否存在地址信息与所述目的地址信息匹配的表项,所述外部匹配表包括精确匹配表和通用匹配表;
    所述转发模块还用于:
    若检测到所述外部匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表中匹配到的表项指示的输出端口转发;
    第一检测模块,用于若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
    处理模块,用于若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息不包含所述外部匹配表的精确匹配表的地址信息,则将所述外部匹配表的通用匹配表中匹配到的表项保存到所述内部匹配表的通用匹配表中。
  11. 如权利要求10所述的网络设备,其特征在于,所述内部查表引擎模块具体用于:
    检测所述内部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    若检测到所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述内部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
  12. 如权利要求10所述的网络设备,其特征在于,所述内部查表引擎模块具体用于:
    同时检测所述内部匹配表的精确匹配表和通用匹配表是否存在地址信息 与所述目的地址信息匹配的表项;
    所述转发模块还用于:
    若所述内部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述内部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述内部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述内部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述内部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
  13. 如权利要求10-12任一项所述的网络设备,其特征在于,所述外部查表引擎模块具体用于:
    检测所述外部匹配表的精确匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    若检测到所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则检测所述外部匹配表的通用匹配表是否存在地址信息与所述目的地址信息匹配的表项。
  14. 如权利要求10-12任一项所述的网络设备,其特征在于,所述外部查表引擎模块具体用于:
    同时检测所述外部匹配表的精确匹配表和通用匹配表是否存在地址信息与所述目的地址信息匹配的表项;
    所述转发模块具体还用于:
    若所述外部匹配表的精确匹配表和通用匹配表都存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表 中匹配到的表项指示的输出端口转发;
    若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的通用匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的精确匹配表中匹配到的表项指示的输出端口转发;
    若所述外部匹配表的通用匹配表存在地址信息与所述目的地址信息匹配的表项且所述外部匹配表的精确匹配表不存在地址信息与所述目的地址信息匹配的表项,则将所述数据包通过在所述外部匹配表的通用匹配表中匹配到的表项指示的输出端口转发。
  15. 如权利要求13或14所述的网络设备,其特征在于,所述处理模块还用于:
    若所述外部匹配表的精确匹配表存在地址信息与所述目的地址信息匹配的表项,则将所述外部匹配表的精确匹配表中匹配到的表项保存到所述内部匹配表的精确匹配表中。
  16. 如权利要求10-15任一项所述的网络设备,其特征在于,还包括:
    第二检测模块,用于检测所述外部匹配表的精确匹配表中匹配到的表项是否被标记为已检测,若检测到所述外部匹配表的精确匹配表中匹配到的表项未被标识为已检测,则触发所述第一检测模块检测所述外部匹配表的通用匹配表中匹配到的表项的地址信息是否包含所述外部匹配表的精确匹配表的地址信息;
    标记模块,用于若检测到所述外部匹配表的通用匹配表中匹配到的表项的地址信息包含所述外部匹配表的精确匹配表的地址信息时,则标记所述外部匹配表的通用匹配表中匹配到的表项为已检测。
  17. 如权利要求10-16任一项所述的网络设备,其特征在于,还包括:
    匹配表更新模块,用于接收针对所述外部匹配表的精确匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的精确匹配表中,并删除所述内 部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
    接收针对所述外部匹配表的精确匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的精确匹配表和所述内部匹配表的精确匹配表中的所述目标表项;和/或,
    接收针对所述外部匹配表的精确匹配表中的目标表项输入的修改指令,修改所述外部匹配表的精确匹配表中的所述目标表项,并删除所述内部匹配表的精确匹配表中的修改前的所述目标表项和所述内部匹配表的通用匹配表中与修改后的所述目标表项匹配的表项。
  18. 如权利要求10-16任一项所述的网络设备,其特征在于,还包括:
    匹配表更新模块,用于接收针对所述外部匹配表的通用查找匹配表输入的添加指令,并将添加的表项保存到所述外部匹配表的通用匹配表中,并删除所述内部匹配表的通用匹配表和所述外部匹配表的通用匹配表中与添加的所述表项匹配的表项;和/或,
    接收针对所述外部匹配表的通用匹配表中的目标表项输入的删除指令,并删除所述外部匹配表的通用匹配表和所述内部匹配表的通用匹配表中的所述目标表项;和/或,
    接收针对所述外部匹配表的通用匹配表中的目标表项输入的修改指令,修改所述外部匹配表的通用匹配表中的所述目标表项,并删除所述内部匹配表的通用匹配表中与修改前和修改后的所述目标表项匹配的表项。
  19. 一种网络设备,其特征在于,所述网络设备包括网络端口、存储器以及处理器,其中,所述存储器中存储一组程序,且处理器用于调用所述存储器中存储的程序,使得所述网络设备执行权利要求1至9任一项所述的方法。
  20. 一种计算机存储介质,其特征在于,所述计算机存储介质存储有程序,所述程序用于使计算机执行时包括权利要求1-9中任一项所述的方法。
PCT/CN2015/078442 2015-05-07 2015-05-07 一种路由查询方法和网络设备 WO2016176853A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201580001178.0A CN106416150B (zh) 2015-05-07 2015-05-07 一种路由查询方法和网络设备
PCT/CN2015/078442 WO2016176853A1 (zh) 2015-05-07 2015-05-07 一种路由查询方法和网络设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/078442 WO2016176853A1 (zh) 2015-05-07 2015-05-07 一种路由查询方法和网络设备

Publications (1)

Publication Number Publication Date
WO2016176853A1 true WO2016176853A1 (zh) 2016-11-10

Family

ID=57217562

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/078442 WO2016176853A1 (zh) 2015-05-07 2015-05-07 一种路由查询方法和网络设备

Country Status (2)

Country Link
CN (1) CN106416150B (zh)
WO (1) WO2016176853A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108259343A (zh) * 2017-06-14 2018-07-06 新华三技术有限公司 路由策略的匹配方法及装置

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110967030A (zh) * 2018-09-30 2020-04-07 上海擎感智能科技有限公司 一种用于车载导航的信息处理方法及其装置
CN113438162B (zh) * 2021-05-21 2022-11-04 翱捷科技股份有限公司 一种二层转发的实现方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1585358A (zh) * 2003-08-19 2005-02-23 华为技术有限公司 路由查找方法及其系统
JP2005117213A (ja) * 2003-10-06 2005-04-28 Nippon Telegr & Teleph Corp <Ntt> 経路表および経路検索方法
CN1710879A (zh) * 2004-06-17 2005-12-21 株式会社日立制作所 数据包传送装置
CN102325077A (zh) * 2011-05-25 2012-01-18 杭州华三通信技术有限公司 分支机构间的通信方法及分支机构的出口路由器

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2838590B1 (fr) * 2002-04-16 2005-12-30 St Microelectronics Sa Procede de routage pour un reseau de telecommunication et routeur pour la mise en oeuvre dudit procede
CN101079817A (zh) * 2007-07-04 2007-11-28 中兴通讯股份有限公司 一种路由查找方法及系统
CN102291472A (zh) * 2011-09-09 2011-12-21 华为数字技术有限公司 一种网络地址查找方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1585358A (zh) * 2003-08-19 2005-02-23 华为技术有限公司 路由查找方法及其系统
JP2005117213A (ja) * 2003-10-06 2005-04-28 Nippon Telegr & Teleph Corp <Ntt> 経路表および経路検索方法
CN1710879A (zh) * 2004-06-17 2005-12-21 株式会社日立制作所 数据包传送装置
CN102325077A (zh) * 2011-05-25 2012-01-18 杭州华三通信技术有限公司 分支机构间的通信方法及分支机构的出口路由器

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108259343A (zh) * 2017-06-14 2018-07-06 新华三技术有限公司 路由策略的匹配方法及装置

Also Published As

Publication number Publication date
CN106416150A (zh) 2017-02-15
CN106416150B (zh) 2020-01-10

Similar Documents

Publication Publication Date Title
CN109587065B (zh) 转发报文的方法、装置、交换机、设备及存储介质
WO2019128817A1 (zh) 报文处理的方法和装置
US8638793B1 (en) Enhanced parsing and classification in a packet processor
EP2880815B1 (en) Operations, administration, and management (oam) functions in a software defined network
WO2019185051A1 (zh) 一种基于集成流表转发报文的方法及装置
KR102535474B1 (ko) 운영, 관리 및 유지 (ioam) 패킷 송신 방법 및 관련된 장치
US10397116B1 (en) Access control based on range-matching
CN111937360B (zh) 最长前缀匹配
US20200403849A1 (en) Service fault locating method and apparatus
US11522792B2 (en) Method for discovering forwarding path and related device thereof
WO2016176853A1 (zh) 一种路由查询方法和网络设备
US20220263746A1 (en) Method for monitoring running state of peer, apparatus, and storage medium
WO2012075818A1 (zh) 报文包头的解析方法、包头解析预处理装置和网络处理器
JP6678401B2 (ja) 変更のためにパケットを個々のレイヤに分割し、変更後のレイヤを情報処理で継合する方法およびその装置
WO2021027420A1 (zh) 用于数据传输的方法和装置
US11106517B2 (en) Multi-path fault detection
US20150381775A1 (en) Communication system, communication method, control apparatus, control apparatus control method, and program
CN108777654B (zh) 报文转发方法及路由设备
US10541914B2 (en) Data packet forwarding method and network device
WO2015117465A1 (zh) 环形网络中fdb刷新方法、装置、节点及系统
WO2021164546A1 (zh) 报文处理方法、转发设备以及报文处理系统
WO2020001576A9 (zh) 一种网络中获取设备转发信息库的方法、设备和系统
CN116366530A (zh) 一种流表老化方法、装置、计算机设备和存储介质
JP2017163377A (ja) パケット処理装置,及びそのテーブル選択方法
WO2017138936A1 (en) Determining pattern match based on circuit match and hash value match

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15891105

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15891105

Country of ref document: EP

Kind code of ref document: A1