Storing MAC address table entries

CN118947098APending Publication Date: 2024-11-12NEW H3C TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202380008557.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In the existing technology, hash conflicts of MAC address entries frequently lead to storage failures, making it difficult to effectively solve the hash conflict problem and affecting the storage efficiency of MAC address entries.

Method used

Multiple hash tables are used, each hash table is bound to a unique hash algorithm, and conflicting MAC address entries are migrated between storage blocks through the maximum recursion depth and preset recursive traversal algorithm, and free storage locations are found to store the pending Stored MAC address table entries to improve storage success rate.

Benefits of technology

It effectively reduces hash conflicts, improves the storage success rate of MAC address table entries and the storage efficiency of hash tables, and avoids storage failures caused by hash conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118947098A_ABST
    Figure CN118947098A_ABST
Patent Text Reader

Abstract

The invention provides a method and equipment for storing MAC address table entries. The method comprises the following steps: acquiring learned MAC address table entries; calculating a first storage position of the MAC address table entry in each storage block based on a hash algorithm of each hash table and the MAC address table entry; determining that each first storage position stores a first conflict MAC address table item; on the basis of the maximum recursion depth and a preset recursion traversal algorithm, traversing a migratable storage position of each first conflict MAC address table entry in all the storage blocks; finding out more than one migratable storage position of more than one first conflict MAC address table entry in all the storage blocks; selecting one searched transferable storage position, and carrying out table item migration on the first conflict MAC address table item corresponding to the selected transferable storage position; and storing the MAC address table entry to a first storage position of the migrated first conflict MAC address table entry.
Need to check novelty before this filing date? Find Prior Art

Description

Store MAC address entries Background Art

[0001] Network devices learn MAC address entries based on the source MAC (Media Access Control) address of received Ethernet packets. They perform a hash calculation on the MAC address entry's key to obtain a hash value that indicates a storage location in the hash table. If the storage location indicated by the hash value is free, the MAC address entry is stored in the corresponding location using a (key, value) data structure. A hash collision occurs if another MAC address entry is already stored in the location indicated by the hash value. BRIEF DESCRIPTION OF THE DRAWINGS

[0002] FIG1 is a schematic diagram of an example of a method for storing MAC address entries according to the present disclosure;

[0003] FIG2 is a schematic diagram of an example of a hash table configuration of the present disclosure;

[0004] FIG3A is a schematic diagram of an example hash table after storing a MAC address entry 201 according to the present disclosure;

[0005] FIG3B is a schematic diagram of an example hash table after storing the MAC address table entry 202 of the present disclosure;

[0006] FIG4A is a schematic diagram of an example hash table of a MAC address table entry before migration according to the present disclosure;

[0007] FIG4B is a schematic diagram of an example hash table after MAC address table entry migration of the present disclosure;

[0008] FIG4C is a schematic diagram of another example of a hash table after MAC address table entry migration according to the present disclosure;

[0009] FIG5 is a schematic diagram of a device for storing MAC address entries according to the present disclosure. DETAILED DESCRIPTION

[0010] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present disclosure and to make the above-mentioned purposes, features and advantages of the embodiments of the present disclosure more obvious and easy to understand, the technical solutions in the embodiments of the present disclosure are further described in detail below with reference to the accompanying drawings.

[0011] FIG1 is a schematic diagram of a method for storing MAC address entries provided by an embodiment of the present disclosure. As shown in FIG1 , the method for storing MAC addresses may include the following processes 100 to 160:

[0012] Process 100: obtain the learned MAC address table entry.

[0013] In an embodiment of the present disclosure, a network device, such as a switching device, may learn MAC address entries based on received messages.

[0014] In the case of obtaining a learned MAC address entry, the obtained MAC address entry may be used as the current MAC address entry to be stored for subsequent processing.

[0015] Process 110: Calculate the first storage location of the MAC address entry in each storage block based on the hash algorithm of each hash table and the obtained MAC address entry.

[0016] In an embodiment of the present disclosure, a network device provides multiple hash tables to store MAC address entries. Each hash table is stored in a storage block, and each storage block is bound to a unique hash algorithm.

[0017] For the obtained MAC address table entry, the storage location of the MAC address table entry in each storage block can be calculated according to the keyword (key) of the MAC address table entry using the hash algorithm of each hash table. The storage location can be called the first storage location.

[0018] In the embodiments of the present disclosure, the keywords of the MAC address table entries include MAC addresses and virtual local area networks (VLANs), and these keywords are not intended to limit the scope of protection of the present disclosure. The keywords of the MAC address table entries stored by the network device according to the above embodiments may also be MAC addresses, or MAC addresses and virtual forwarding instances (VSIs) of VPN networks, or MAC addresses and other information indicating forwarding domains.

[0019] In step 120 , it is determined that each first storage location stores a first conflicting MAC address entry.

[0020] In the embodiment of the present disclosure, when the MAC address table entry is calculated to be in the first storage position of each storage block, it can be determined whether each first storage position stores a MAC address table entry.

[0021] The MAC address entry stored in the first storage location may be referred to as a first conflicting MAC address entry.

[0022] If it is determined that each first storage location stores a first conflicting MAC address entry, the process 130 may be continued.

[0023] In the embodiment of the present disclosure, when it is determined that at least one first storage location does not store the first conflicting MAC address entry, an idle first storage location may be selected to store the acquired MAC address entry.

[0024] Process 130: Based on the maximum recursion depth and a preset recursive traversal algorithm, traverse the migratable storage location of each first conflicting MAC address entry in all the storage blocks.

[0025] In the embodiment of the present disclosure, considering that a MAC address table entry can correspond to a storage location in each storage block, for a stored MAC address table entry, if there is a hash conflict between the stored MAC address table entry and the MAC address table entry currently to be stored, and there is an idle storage location for the stored MAC address table entry in other storage blocks, the stored MAC address table entry can be migrated to the corresponding idle storage location in other storage blocks so that the MAC address table entry currently to be stored can be successfully stored.

[0026] Therefore, for MAC address entries that cannot be stored due to hash conflicts, the success rate of MAC address entry storage can be improved by attempting to migrate the first conflicting MAC address entry stored in the first storage location, thereby improving the storage rate of the MAC address entry.

[0027] Accordingly, when it is determined that each first storage location stores a first conflicting MAC address entry, the migratable storage location of each first conflicting MAC address entry may be traversed in all the storage blocks.

[0028] In the embodiment of the present disclosure, during the process of traversing and searching for migratable storage locations, multiple levels of migratable storage location searches may be performed.

[0029] For example, taking the storage of MAC address table entry 1 as an example, assuming that the first conflicting MAC address table entry is stored in each first storage location calculated by the hash algorithm of each hash table based on the keyword of MAC address table entry 1, then in the traversal and search process of the migratable storage location, not only can it be determined whether the first conflicting MAC address table entry can be migrated to other storage locations, but it can also be determined whether other MAC address table entries that have hash conflicts with the first conflicting MAC address table entry can be migrated to other storage locations. By recursively traversing the migratable storage locations, the success rate of finding the migratable storage location can be improved.

[0030] In the disclosed embodiment, the maximum recursion depth may be flexibly set based on the number of storage locations in the hash table and the number of hash tables, so that the process of traversing the migratable storage locations in all storage blocks may not occupy too much computing resources.

[0031] Optionally, the maximum recursion depth may include 3 layers, 4 layers, or 5 layers, etc.

[0032] Furthermore, in the embodiment of the present disclosure, during the recursive traversal of the migratable storage locations, different recursive traversal algorithms may be adopted according to the configuration.

[0033] Optionally, the recursive traversal algorithm may include a breadth-first traversal algorithm or a depth-first traversal algorithm.

[0034] Among them, the breadth-first traversal algorithm prioritizes migrating conflicting MAC addresses at the same level; the depth-first traversal algorithm prioritizes migrating multiple levels of the same conflicting MAC address.

[0035] In an embodiment of the present disclosure, the storage location of the MAC address table entry currently to be stored in each storage block can be called a first storage location, and the conflicting MAC address stored in the first storage location can be called a first conflicting MAC address table entry; the storage location of the first conflicting MAC address table entry in each storage block can be called a second storage location, and the conflicting MAC address table entry stored in the second storage location can be called a second conflicting MAC address table entry, and so on.

[0036] For the breadth-first traversal algorithm, when it is determined that each first storage location stores a first conflicting MAC address table entry, each second storage location is traversed to see if a second conflicting MAC address is stored. When each second storage location stores a second conflicting MAC address, each third storage location is traversed to see if a third conflicting MAC address is stored, and so on, until a relocatable storage location is found, or the maximum recursion depth is reached and no relocatable location is found.

[0037] For the depth-first traversal algorithm, when it is determined that each first storage location stores a first conflicting MAC address table entry, the first conflicting MAC addresses can be traversed. For the currently traversed first conflicting MAC address, multiple levels of migration attempts can be made for the first conflicting address until a migratable storage location is found. Alternatively, when the preset maximum recursion depth is reached and a migratable location is still not found, the traversal of the first conflicting MAC address is returned to, and multiple levels of migration attempts are made for the next first conflicting MAC address, and so on, until a migratable storage location is found. Alternatively, all first conflicting MAC addresses are traversed and no migratable location is still found.

[0038] Process 140: Find one or more first conflicting MAC address table entries in one or more removable storage locations in all storage blocks.

[0039] In step 150 , a found migratable storage location is selected, and entry migration is performed for the first conflicting MAC address entry corresponding to the selected migratable storage location.

[0040] Process 160: store the MAC address entry in the first storage location of the migrated first conflicting MAC address entry.

[0041] In an embodiment of the present disclosure, when one or more first conflicting MAC address table entries are found in more than one migratable storage location in all storage blocks in the above manner, that is, it is determined that one or more first conflicting MAC address table entries exist in one or more migratable storage locations in all storage blocks, a found migratable storage location can be selected to perform table entry migration for the first conflicting MAC address table entry corresponding to the selected migratable storage location.

[0042] In the embodiment of the present disclosure, during the process of migrating the first conflicting MAC address table entry corresponding to the selected migratable storage location, it is necessary to adopt a recursive migration method to migrate the MAC address table entry layer by layer.

[0043] For example, assuming that the selected migratable storage location is the third storage location, the corresponding second conflicting MAC address table entry needs to be migrated to the third storage location first to obtain an idle second storage location, and then the corresponding first conflicting MAC address needs to be migrated to the idle second storage location to obtain an idle first storage location. Finally, the current MAC address table entry to be stored is stored in the idle first storage location.

[0044] In the embodiment of the present disclosure, when it is determined that the first conflicting MAC address table entry is not found in the migratable storage location of all storage blocks, the current MAC address table entry to be stored is discarded.

[0045] In the example shown in FIG1 , for the acquired MAC address table entry, a first storage location of the MAC address table entry in each storage block is calculated using a hash algorithm based on each hash table and the MAC address table entry. When it is determined that a first conflicting MAC address table entry is stored in each first storage location, the recursive traversal algorithm is used to traverse the migratable storage locations of each first conflicting MAC address table entry in all storage blocks based on the maximum recursive depth and a preset recursive traversal algorithm. When more than one first conflicting MAC address table entry is found in more than one migratable storage location in all storage blocks, one of the found migratable storage locations is selected, and entry migration is performed for the first conflicting MAC address table entry corresponding to the selected migratable storage location. The acquired MAC address table entry is stored in the first storage location of the migrated first conflicting MAC address table entry. That is, the MAC address table entry storage locations are no longer based on a first-come, first-served basis. Instead, when a hash conflict exists for a MAC address table entry currently to be stored, a MAC address table entry that has already been stored but has other free storage locations is migrated to replace the free storage location of the MAC address table entry currently to be stored, and the MAC address table entry currently to be stored is stored, thereby improving the storage efficiency of the MAC address table entries.

[0046] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present disclosure, the technical solutions provided by the embodiments of the present disclosure are described below with reference to specific examples.

[0047] To reduce hash conflicts in the MAC address hash table, the network device provides multiple hash tables to store MAC address table entries. Each hash table is stored in a storage block, and each storage block is bound to a unique hash algorithm. When the network device adds a MAC address table entry, it first calculates the hash value of the MAC address table entry based on the hash algorithm of the first storage block. When a hash conflict occurs in the first storage block, a new hash value is calculated based on the hash algorithm of the second storage block. If the storage location of the second storage block indicated by the new hash value is also occupied, the hash calculation is continued based on the hash algorithm of the next storage block, and the free storage locations are recursively searched in sequence. Alternatively, the network device calculates multiple hash values ​​based on the bound hash algorithm of each hash table, and searches for free storage locations starting from the hash table of the first storage block.

[0048] Taking the hash table configuration shown in Figure 2 as an example, it is assumed that the network device provides four hash tables to store MAC address table entries, namely hash table 1 to hash table 4. Hash tables 1 to hash tables 4 are stored in storage blocks 21 to storage blocks 24, respectively, and are respectively bound to a unique hash algorithm, assuming hash algorithms 1 to 4, each hash table includes 8 storage locations, corresponding to different hash values ​​Hash0 to Hash7.

[0049] In the embodiments of the present disclosure, the number of storage blocks in the network device and the number of entries recorded in the hash table of the storage blocks are intended to describe that the present disclosure evenly stores MAC address entries in multiple hash tables, and are not used to limit the scope of protection of the present disclosure.

[0050] For example, when a network device adds a MAC address table entry, it calculates multiple hash values ​​based on the binding hash algorithm of each hash table and searches for an idle storage location starting from the hash table of the first storage block.

[0051] Based on the above hash table configuration, when storing the MAC address table entry 201, hash calculations can be performed using hash algorithms 1 to 4 based on the keyword of the MAC address table entry 201 to obtain hash values ​​indicating storage locations in hash tables 1 to 4. Assuming that the hash value indicating the storage location in hash table 1 is Hash3, since the storage location in hash table 1 is idle, the MAC address table entry 201 can be stored in the storage location. A schematic diagram thereof can be shown in Figure 3A.

[0052] When storing MAC address table entry 202, hash calculations can be performed using hash algorithms 1 to 4 based on the keyword of MAC address table entry 202 to obtain hash values ​​indicating storage locations in hash tables 1 to 4. Assuming that the hash value indicating the storage location in hash table 1 is Hash3, since the storage location in hash table 1 is occupied, a hash conflict occurs. Therefore, a free storage value is searched from hash table 2. Assuming that the hash value indicating the storage location in hash table 2 is Hash0, since the storage location in hash table 2 is free, MAC address table entry 202 can be stored in the storage location. A schematic diagram thereof can be shown in FIG3B. The following describes the implementation of the method for storing MAC address table entries provided in an embodiment of the present disclosure based on the hash table configuration shown in FIG2.

[0053] Position ij is the position indicated by Hash j in hash table i. For example, position 12 is the position indicated by Hash 2 in hash table 1.

[0054] The following example takes a maximum recursion depth of 3 layers as an example.

[0055] Assuming that the MAC address table entry 400 is learned, hash calculations can be performed using hash algorithms 1 to 4 based on the keyword of the MAC address table entry 400 to obtain hash values ​​indicating storage locations in hash tables 1 to 4.

[0056] Assume that based on the keyword of MAC address table entry 400, the hash values ​​obtained by hash calculation using hash algorithms 1 to 4 are Hash2 to Hash5 respectively, and the storage positions indicated by each hash value in the corresponding hash table are all occupied, that is, position 12, position 23, position 34 and position 45 are all occupied.

[0057] In this case, it is necessary to determine whether the MAC address storage entries stored in location 12, location 23, location 34, and location 45 can be migrated to other storage locations.

[0058] Based on the configuration, you can use breadth-first or depth-first traversal to attempt MAC address table migration.

[0059] The following describes how to implement a MAC address table entry migration attempt using a breadth-first traversal method.

[0060] Position 12, position 23, position 34, and position 45 may be traversed.

[0061] Assume that the MAC address entry stored at position 12 is MAC address entry 301. Based on the keyword of MAC address entry 301, hash calculations can be performed using hash algorithms 1 to 4 to obtain hash values ​​indicating storage locations in hash tables 1 to 4.

[0062] Assume that based on the keyword of MAC address table entry 301, the hash values ​​obtained by hash calculation using hash algorithms 1 to 4 are Hash2, Hash4 to 6 respectively, and positions 12, 24, 35 and 46 are all occupied, that is, MAC address table entry 301 cannot find a migratable storage location in the current level of recursion.

[0063] Continue traversing position 23, position 34 and position 45.

[0064] Assuming that the MAC address entry stored at location 23 is MAC address entry 302 , hash values ​​indicating storage locations in hash tables 1 to 4 can be obtained by performing hash calculations based on the keyword of MAC address entry 302 using hash algorithms 1 to 4 .

[0065] Assume that the MAC address table entry 302 does not find a migratable storage location in the current level of recursion.

[0066] Continue traversing position 34 and position 45.

[0067] Assuming that the MAC address entry stored at location 34 is MAC address entry 303 , hash values ​​indicating storage locations in hash tables 1 to 4 can be obtained by performing hash calculations based on the keyword of MAC address entry 303 using hash algorithms 1 to 4 .

[0068] Assume that the MAC address table entry 303 does not find a migratable storage location in the current level of recursion.

[0069] Continue traversing to position 45.

[0070] Assuming that the MAC address table entry stored at location 45 is MAC address table entry 304, hash calculations can be performed using hash algorithms 1 to 4 based on the keyword of MAC address table entry 304 to obtain hash values ​​indicating storage locations in hash tables 1 to 4.

[0071] Assume that no migratable storage location is found in the current level of recursion based on the MAC address table entry 304 .

[0072] At this point, the second-level recursive traversal is completed and no migratable storage location is found.

[0073] During the layer 3 recursive traversal, positions 24, 35, and 46 may be traversed to determine whether the MAC address entries stored in these positions are transferable.

[0074] Taking position 46 as an example, assuming that the MAC address table entry stored in position 46 is MAC address table entry 305, hash calculations can be performed based on the keyword of MAC address table entry 305 using hash algorithms 1 to 4 to obtain hash values ​​indicating the storage positions in hash tables 1 to 4.

[0075] Assume that based on the keyword of the MAC address table entry 305, hash values ​​obtained by hashing using hash algorithms 1 to 4 are Hash0, Hash2, Hash3 and Hash6, respectively, and the indicated storage locations are location 10, location 22, location 33 and location 46, respectively.

[0076] Assuming that position 10 is an idle storage position, the MAC address table entry 305 can be migrated from position 46 to position 10, and the MAC address table entry 301 can be migrated from position 12 to position 46, and the MAC address table entry 400 can be stored in position 12. The hash table diagrams before and after the MAC address migration can be shown in Figures 4A and 4B respectively.

[0077] Assuming that no migratable storage location is found after the layer 3 recursive traversal is completed, it is determined that the storage of the MAC address entry 400 has failed.

[0078] The following describes how to implement a MAC address table entry migration attempt using a depth-first traversal method.

[0079] First, based on the keyword of the MAC address table entry 301, hash calculations can be performed using hash algorithms 1 to 4 to obtain hash values ​​indicating storage locations in hash tables 1 to 4, and locations 12, 24, 35, and 46 can be found.

[0080] Assume that positions 12, 24, 35, and 46 are all occupied, that is, no relocatable storage location is found during the Layer 2 recursive traversal of MAC address table entry 301. In this case, a Layer 3 recursive traversal of MAC address table entry 301 can be started, traversing positions 24, 35, and 46.

[0081] The MAC address entry stored at position 24 is MAC address entry 306. Based on the key of MAC address entry 306, hash calculations can be performed using hash algorithms 1 to 4 to obtain hash values ​​indicating storage locations in hash tables 1 to 4.

[0082] Assume that based on the keyword of MAC address table entry 306, the hash values ​​obtained by hash calculation using hash algorithms 1 to 4 are Hash1, Hash4, Hash0, and Hash2 respectively, and positions 11, 24, 30, and 42 are all occupied, that is, MAC address table entry 306 does not find a migratable storage location in the current level of recursion.

[0083] Continue traversing position 35 and position 46.

[0084] Assume that no migratable storage location is found after traversing positions 35 and 46, that is, no migratable storage location is found after the layer 3 recursive traversal of the MAC address table entry 301.

[0085] In this case, the traversal can be returned to the second-level positions, and the traversal can be continued to positions 35 and 46.

[0086] Assuming that the MAC address table entry stored at position 35 is MAC address table entry 307, hash calculations can be performed using hash algorithms 1 to 4 based on the keyword of MAC address 307 to obtain hash values ​​indicating storage locations in hash tables 1 to 4.

[0087] Assume that hash algorithms 1 through 4, based on the key of MAC address table entry 307, generate hash values ​​of Hash7, Hash6, Hash5, and Hash0, respectively, and that positions 17, 26, 35, and 40 are all occupied. This means that no relocatable storage location is found during the Layer 2 recursive traversal of MAC address table entry 307. In this case, a Layer 3 recursive traversal of MAC address table entry 307 can be initiated, traversing positions 17, 26, and 40.

[0088] Assume that the MAC address table entry stored at position 17 is MAC address table entry 308. Based on the keyword of MAC address table entry 308, hash values ​​obtained by hashing using hash algorithms 1 to 4 are Hash7, Hash5, Hash6, and Hash1, respectively.

[0089] Assuming that position 41 is an idle storage location, the MAC address table entry 308 can be migrated from position 17 to position 41, and the MAC address table entry 307 can be migrated from position 35 to position 17, and the MAC address table entry 400 can be stored in position 35. The hash table diagrams before and after the MAC address migration can be shown in Figures 4A and 4C respectively.

[0090] In an embodiment of the present disclosure, the network device can count the storage rate of the hash table of each storage block and the total storage rate of the hash table of all storage blocks. In this way, when the total storage rate of all storage blocks of the network device exceeds a preset storage rate value, the network device executes the above embodiment to store MAC address table entries.

[0091] The network device executing the above embodiment will not discard the learned MAC address table entries just because a hash conflict occurs in each hash table, thereby improving the storage efficiency of the MAC address table entries and the storage rate of each hash table.

[0092] FIG5 is a schematic diagram of a device for storing MAC address table entries according to an embodiment of the present disclosure. Device 50 includes multiple network interfaces 51, a switch device 52 having multiple storage blocks, a processor 53, and a non-transitory computer-readable medium 54 storing processor-executable instructions. Each storage block of the switch device stores a hash table and is assigned a unique hash algorithm.

[0093] The switching device 52 may be implemented by hardware (eg, a processor of an application specific integrated circuit (ASIC)), or by a combination of software and hardware, which is not specifically limited in the embodiment of the present disclosure.

[0094] For example, the switching device 52 may be a switching chip, and the switching chip may include a table entry storage medium 521 . The table entry storage medium 521 may store multiple storage blocks 522 . Each storage block 522 stores a hash table and is set with a unique hash algorithm.

[0095] The switching device 52 learns the MAC address table entries based on the Ethernet packets received by any one of the network interfaces 51 .

[0096] The processor 53 executes the processor executable instructions recorded in the non-transitory machine-readable storage medium 54 to perform the following processing: obtaining the learned MAC address table entries; calculating the first storage location of the MAC address table entries in each storage block based on the hash algorithm of each hash table and the MAC address table entries; determining that each first storage location stores a first conflicting MAC address table entry; traversing the migratable storage location of each first conflicting MAC address table entry in all storage blocks based on the maximum recursive depth and a preset recursive traversal algorithm; finding one or more first conflicting MAC address table entries in one or more migratable storage locations in all storage blocks; selecting one of the found migratable storage locations and performing table entry migration for the first conflicting MAC address table entry corresponding to the selected migratable storage location; and storing the MAC address table entry in the first storage location of the migrated first conflicting MAC address table entry.

[0097] In one example, the processor 53 executes the processor-executable instructions recorded on the non-transitory machine-readable storage medium 54 and further performs the following processing: determining that the first conflicting MAC address table entry is not found in the migratable storage location of all storage blocks, and discarding the MAC address table entry.

[0098] In one example, the preset recursive traversal algorithm is a breadth-first traversal algorithm; the processor 53 executes the following processing of the processor executable instructions recorded in the non-transitory machine-readable storage medium 54: based on the hash algorithm of each hash table and the first conflicting MAC address table entry, calculate the second storage position of the first conflicting MAC address table entry in each storage block; traverse the second storage positions; determine whether there is an idle storage position in the second storage position, and determine the idle storage position as the migratable storage position of the first conflicting MAC address table entry; determine that each second storage position stores the second conflicting MAC address table entry and the number of recursive layers does not reach the maximum recursive depth, traverse the migratable position of each second conflicting MAC address table entry in all storage blocks; find one or more second conflicting MAC address table entries in one or more migratable storage positions in all storage blocks, and select one of the found migratable positions of the second conflicting MAC address as the corresponding migratable storage position of the first conflicting MAC address.

[0099] In one example, the preset recursive traversal algorithm is a depth-first traversal algorithm; the processor 53 executes the following processing of the processor executable instructions recorded in the non-transitory machine-readable storage medium 54: traverse the first conflicting MAC address table entry; calculate the second storage position of the currently traversed first conflicting MAC address table entry in each storage block; determine that there is an idle storage position in the second storage position, and determine the idle storage position as the migratable storage position of the first conflicting MAC address table entry; determine that each second storage position stores the second conflicting MAC address table entry and the number of recursive layers does not reach the maximum recursive depth, traverse the second conflicting MAC address table entry, and traverse the migratable position of the currently traversed second conflicting MAC address table entry in all storage blocks; find one or more second conflicting MAC addresses in one or more migratable storage positions in all storage blocks, and select one of the found migratable positions of the second conflicting MAC address as the corresponding migratable storage position of the first conflicting MAC address.

[0100] In one example, the processor 53 executes the processor executable instructions recorded in the non-transitory machine-readable storage medium 54 and also performs the following processing: if the migratable storage location of the second conflicting MAC address table entry currently traversed is not found and the number of recursive layers reaches the maximum recursive depth, continue to traverse the second conflicting MAC address table entry; if the second conflicting MAC address table entry is traversed and the migratable storage location is not found, continue to traverse the first conflicting MAC address table entry; if the migratable storage location of the second conflicting MAC address table entry currently traversed is not found and the number of recursive layers does not reach the maximum recursive depth, perform a search for the migratable storage location of the next level for the second conflicting MAC address table entry currently traversed.

[0101] The present disclosure also provides a non-transitory machine-readable storage medium for recording processor-executable instructions, such as the non-transitory machine-readable storage medium 54 in Figure 5. The processor-executable instructions can be executed by the processor 53 in the device for storing MAC address table entries shown in Figure 5 to implement the method for storing MAC address table entries described above.

[0102] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.

Claims

1. A method for storing a media access control MAC address table entry, characterized in that: The method comprises: Get the learned MAC address table entries; Based on the hash algorithm of each hash table and the MAC address table entry, calculate the first storage location of the MAC address table entry in each storage block; Determining that each of the first storage locations stores a first conflicting MAC address entry; Based on the maximum recursive depth and a preset recursive traversal algorithm, traverse the migratable storage location of each first conflicting MAC address entry in all the storage blocks; Finding one or more of the first conflicting MAC address table entries in one or more relocatable storage locations of all the storage blocks; Selecting a found migration storage location, and performing entry migration for a first conflicting MAC address entry corresponding to the selected migration storage location; The MAC address entry is stored in the first storage location of the migrated first conflicting MAC address entry.

2. The method according to claim 1, characterized in that The method further comprises: It is determined that the first conflicting MAC address entry is not found in the migratable storage location of all the storage blocks, and the MAC address entry is discarded.

3. The method according to claim 1, characterized in that The preset recursive traversal algorithm is a breadth-first traversal algorithm; The traversing the migratable storage location of each first conflicting MAC address entry in all the storage blocks based on the maximum recursive depth and the preset recursive traversal algorithm includes: Based on the hash algorithm of each hash table and the first conflicting MAC address table entry, calculate the second storage location of the first conflicting MAC address table entry in each storage block; traversing the second storage location; Determine that there is an idle storage location in the second storage location, and determine the idle storage location as a migratable storage location of the first conflicting MAC address table entry; Determine that each of the second storage locations stores a second conflicting MAC address table entry, and the number of recursive layers does not reach the maximum recursive depth, and traverse the migratable position of each of the second conflicting MAC address table entries in all the storage blocks; find one or more of the second conflicting MAC address table entries in more than one migratable storage position in all the storage blocks, and select one of the found migratable positions of the second conflicting MAC address as the migratable storage position of the corresponding first conflicting MAC address.

4. The method according to claim 1, characterized in that: The preset recursive traversal algorithm is a depth-first traversal algorithm; The traversing the migratable storage location of each first conflicting MAC address entry in all the storage blocks based on the maximum recursive depth and the preset recursive traversal algorithm includes: Traversing the first conflicting MAC address table entry; Calculate the first conflicting MAC address entry currently traversed at the second storage location of each storage block; Determine that there is an idle storage location in the second storage location, and determine the idle storage location as a migratable storage location of the first conflicting MAC address table entry; Determine that each of the second storage locations stores a second conflicting MAC address table entry, and the number of recursive layers does not reach the maximum recursive depth, traverse the second conflicting MAC address table entries, and traverse the migratable positions of the currently traversed second conflicting MAC address table entries in all the storage blocks; find one or more second conflicting MAC addresses in more than one migratable storage positions in all the storage blocks, and select one of the found migratable positions of the second conflicting MAC address as the migratable storage position of the corresponding first conflicting MAC address.

5. The method according to claim 4, characterized in that The method further comprises: If the migratable storage location of the second conflicting MAC address table entry currently traversed is not found and the number of recursive layers reaches the maximum recursive depth, continue to traverse the second conflicting MAC address table entry; after traversing the second conflicting MAC address table entry and no migratable storage location is found, continue to traverse the first conflicting MAC address table entry; if the migratable storage location of the second conflicting MAC address table entry currently traversed is not found and the number of recursive layers does not reach the maximum recursive depth, perform a search for the migratable storage location of the next level for the second conflicting MAC address table entry currently traversed.

6. A device for storing MAC addresses, characterized in that: The device includes a plurality of network interfaces, a switching device having a plurality of storage blocks, a processor, and a non-transitory machine-readable medium recording processor-executable instructions; each storage block of the switching device stores a hash table and is set with a unique hash algorithm; The switching device learns MAC address table entries based on Ethernet messages received by any network interface; The processor executes the processor-executable instructions recorded on the non-transitory machine-readable storage medium to perform the following processing: obtaining a learned MAC address table entry; Based on the hash algorithm of each hash table and the MAC address table entry, calculate the first storage location of the MAC address table entry in each storage block; Determining that each of the first storage locations stores a first conflicting MAC address entry; Based on the maximum recursive depth and a preset recursive traversal algorithm, traverse the migratable storage location of each first conflicting MAC address entry in all the storage blocks; Finding one or more of the first conflicting MAC address table entries in one or more relocatable storage locations of all the storage blocks; Selecting a found migration storage location, and performing entry migration for a first conflicting MAC address entry corresponding to the selected migration storage location; The MAC address entry is stored in the first storage location of the migrated first conflicting MAC address entry.

7. The device according to claim 6, characterized in that The processor executes the processor-executable instructions recorded on the non-transitory machine-readable storage medium and further performs the following processing: It is determined that the first conflicting MAC address entry is not found in the migratable storage location of all the storage blocks, and the MAC address entry is discarded.

8. The device according to claim 6, characterized in that The preset recursive traversal algorithm is a breadth-first traversal algorithm; The processor executes the following processing by executing the processor executable instructions recorded on the non-transitory machine-readable storage medium: Based on the hash algorithm of each hash table and the first conflicting MAC address table entry, calculate the second storage location of the first conflicting MAC address table entry in each storage block; traversing the second storage location; Determine that there is an idle storage location in the second storage location, and determine the idle storage location as a migratable storage location of the first conflicting MAC address table entry; Determine that each of the second storage locations stores a second conflicting MAC address entry, and the number of recursive layers does not reach the maximum recursive depth, and traverse the relocatable position of each of the second conflicting MAC address entries in all the storage blocks; One or more second conflicting MAC address entries are found in one or more relocatable storage locations of all the storage blocks, and one of the found relocatable storage locations of the second conflicting MAC address is selected as the relocatable storage location of the corresponding first conflicting MAC address.

9. The device according to claim 6, characterized in that The preset recursive traversal algorithm is a depth-first traversal algorithm; The processor executes the following processing by executing the processor executable instructions recorded on the non-transitory machine-readable storage medium: Traversing the first conflicting MAC address table entry; Calculate the first conflicting MAC address entry currently traversed at the second storage location of each storage block; Determine that there is an idle storage location in the second storage location, and determine the idle storage location as a migratable storage location of the first conflicting MAC address table entry; Determine that each of the second storage locations stores a second conflicting MAC address entry, and the number of recursive layers does not reach the maximum recursive depth, traverse the second conflicting MAC address entry, and traverse the current traversal in all the storage blocks. The relocatable position of the second conflicting MAC address entry in the past; One or more second conflicting MAC addresses are found in one or more relocatable storage locations of all the storage blocks, and one of the found relocatable storage locations of the second conflicting MAC addresses is selected as the relocatable storage location of the corresponding first conflicting MAC address.

10. The device according to claim 9, characterized in that The processor executes the processor-executable instructions recorded on the non-transitory machine-readable storage medium and further performs the following processing: If the migratable storage location of the second conflicting MAC address table entry currently traversed is not found and the number of recursive layers reaches the maximum recursive depth, the second conflicting MAC address table entry continues to be traversed; if the second conflicting MAC address table entry is traversed and the migratable storage location is not found, the first conflicting MAC address table entry continues to be traversed; If the migratable storage location of the second conflicting MAC address entry currently traversed is not found and the number of recursive layers does not reach the maximum recursive depth, a next-level migratable storage location search is performed for the second conflicting MAC address entry currently traversed.

11. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores instructions, which prompt the processor to implement the method for storing MAC address table entries according to claim 1.

Citation Information

Patent Citations

  • Apparatus and method for hash table storage, searching

    CN101604337A

  • Hash data storage method and device

    CN102880628A

  • MAC address processing method and device

    CN112491725A

  • Control method of medium access control address and related medium access control chip thereof

    TW200519618A

  • Hash table management method and device, and computer storage medium

    WO2018099107A1