Longest best match search
First Claim
1. A method of locating an entry in a forwarding database corresponding to a longest match of an address, the method comprising:
- (a) applying a mask to the address to determine a masked address that is to be used for purposes of locating a matching entry in the forwarding database;
(b) searching the forwarding database for an entry that matches the masked address; and
(c) performing an address-sensitive decimation of the mask to produce a new mask.
6 Assignments
0 Petitions
Accused Products
Abstract
A method and apparatus for efficiently performing a longest match search are provided. According to one aspect of the present invention, an entry in a forwarding database, a routing table, or the like is located using an improved longest match search. A mask is applied to an address, such as a destination Internet Protocol (IP) address, to determine a masked address that is to be used for purposes of locating a matching entry in the forwarding database. The forwarding database is searched for an entry that matches the masked address. Subsequent masks are produced by performing an address-sensitive decimation of the former mask. For example, the former mask may be shortened based upon the location of the least significant bit containing a one in the masked address. According to another aspect of the present invention, data forwarding employs the improved longest match search. Data is received at a port. An address is extracted from the data. A forwarding database is searched for a longest match for the address by comparing a portion of the address indicated by a mask to entries in the forwarding database and using progressively shorter masks, determined based upon the masked address, for each subsequent search until a matching entry is located. If a matching entry is found, the data is forwarded to a destination associated with the matching entry.
29 Citations
23 Claims
-
1. A method of locating an entry in a forwarding database corresponding to a longest match of an address, the method comprising:
-
(a) applying a mask to the address to determine a masked address that is to be used for purposes of locating a matching entry in the forwarding database;
(b) searching the forwarding database for an entry that matches the masked address; and
(c) performing an address-sensitive decimation of the mask to produce a new mask. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A method of locating an entry in a forwarding database corresponding to a longest match of a search key, the method comprising:
-
a) searching the forwarding database for an entry that matches the search key; and
b) if no entry matches the search key, then 1) scanning the search key to locate the least significant bit containing a one, 2) shortening the search key to exclude the least significant bit containing a one and any lesser significant bits containing a zero than the least significant bit containing the one, 3) searching the forwarding database for an entry that matches the search key, and 4) repeating steps 1-3 until the search key is equal to a predetermined length or until the longest match is located. - View Dependent Claims (10, 11, 12)
-
-
13. A method or forwarding data comprising:
-
(A) receiving a search key;
(B) producing a masked search key by applying a mask to a portion of the search key starting at a least significant bit of the search key until a least significant bit of the masked search key containing a logic one value;
(C) performing a hash function on the masked search key to produce an index;
(D) comparing information stored within a bin of a forwarding mechanism, the bin being addressed by the index;
(E) determining whether a length of the mask is greater than a predetermined threshold concurrently with (C) and (D); and
(F) repeating (B-E) for another search iteration if the information does not match the masked search key and the length of the mask is greater than the predetermined threshold. - View Dependent Claims (14, 15, 16)
-
-
17. An address relocation unit for improving a longest match search, comprising:
-
a hash table including a plurality of bins;
a hash generator to produce an index from an input address and a mask, the index being used to recover data stored in a first bin of the plurality of bins;
circuitry to determine whether the data recovered from the first bin compares with the address; and
a mask decimation logic coupled to the hash generator, the mask decimation logic to shorten the mask supplied to the hash generator so that the hash generator produces a new index that differs from the index if the data recovered fails to compare with a portion of the address identified by the mask.
-
-
18. A method of locating an entry in a forwarding database corresponding to a longest match of a search key, the method comprising:
-
performing a function on the search key to produce a current index;
searching a first location in a table identified by the current index for an entry that matches the search key; and
if no entry is found that matches the search key, each subsequent search iteration performing the following;
shortening the search key to exclude data to cause the function to produce a result that differs from the current index, updating the current index with the result, and searching a second location in the table that is identified by the current index. - View Dependent Claims (19, 20, 21, 23)
-
-
22. A method of locating an entry in a forwarding database corresponding to a longest match of a search key, the method comprising:
-
generating indices for a hash table performing a hash function on the search key to produce a current index into a hash table;
searching a first bin in the hash table identified by the current index for an entry that matches the search key; and
if no entry has been found that matches the search key, for each subsequent search iteration;
shortening the search key to exclude data to cause the hash function to produce a result that is different than the current index, updating the current index with the result, and searching a different bin in the hash table that is identified by the current index.
-
Specification