Inventors:
Simon Knee - Del Mar CA, US
Ronald Perloff - Poway CA, US
International Classification:
G06F007/00
Abstract:
A method and apparatus for efficiently performing a longest match search are provided. According to one embodiment of the present invention, a longest match search of a routing table is initiated in response to receiving a search key (typically a destination IP address of a received packet). To avoid performing fruitless searches, a set of masks are determined that are known to have a potential for matching an entry in the routing table when applied to the search key. A routing table query is formed based upon the search key and the longest mask of the set of masks. Then, the routing table query is applied to the routing table. If subsequent iterations are required, the longest mask is removed from the set of masks and the next routing table query is formed based upon the search key and the longest mask of the updated set of masks.