Longest prefix match lookup using hash function
First Claim
1. A method for determining a longest prefix match for a variable length search key by a computer processing device, comprising the acts of:
- reading an internet protocol (IP) destination address;
reading a virtual private network (VPN) number;
performing a hash on the N most significant bits of the IP destination address and the VPN number, and concatenating the remaining least significant bits of the IP destination address to the result of the hash operation to form an input key;
using the hashed portion of the input key as an index into a table representing a plurality of root nodes of search trees wherein each non-empty entry in the table contains a pointer to a next branch in the search free or a leaf;
determining if the pointer in a non-empty table entry points to a leaf or a next branch of the corresponding search tree;
use a next-bit-to-test field in the entry to find a distinguishing bit position in the search key, and determine if that bit is a one or a zero;
responsive to the state of the identified distinguishing bit, reading either the first half or second half of the next branch contents if the pointer points to a next brunch of the corresponding search free;
storing intermediate leaf pointers and corresponding prefix length as determined by distinguishing bit position;
reading a leaf pattern when the leaf of a corresponding search tree is reached and comparing the leaf pattern with the input key to determine if the leaf pattern matches the input key;
if leaf pattern matches, identifying the leaf as the longest prefix match;
if leaf pattern does not match, identifying previously stored leaf pointer with distinguishing bit greater than least significant bit of mismatch as the longest prefix match; and
returning the Longest prefix match found for the input key to a requesting application.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and apparatus are used for finding the longest prefix match in a variable length prefix search when searching a direct table within a routing table structure of a network processor. The search through the routing table structure is expedited by hashing a first segment of an internet protocol address with a virtual private network number followed by concatenating the unhashed bits of the IP address to the result of the hash operation to form an input key. Patterns are compared a bit at a time until an exact match or the best match is found. The search is conducted in a search tree that provides that the matching results will be the best possible match.
-
Citations
9 Claims
-
1. A method for determining a longest prefix match for a variable length search key by a computer processing device, comprising the acts of:
-
reading an internet protocol (IP) destination address; reading a virtual private network (VPN) number; performing a hash on the N most significant bits of the IP destination address and the VPN number, and concatenating the remaining least significant bits of the IP destination address to the result of the hash operation to form an input key; using the hashed portion of the input key as an index into a table representing a plurality of root nodes of search trees wherein each non-empty entry in the table contains a pointer to a next branch in the search free or a leaf; determining if the pointer in a non-empty table entry points to a leaf or a next branch of the corresponding search tree; use a next-bit-to-test field in the entry to find a distinguishing bit position in the search key, and determine if that bit is a one or a zero; responsive to the state of the identified distinguishing bit, reading either the first half or second half of the next branch contents if the pointer points to a next brunch of the corresponding search free; storing intermediate leaf pointers and corresponding prefix length as determined by distinguishing bit position; reading a leaf pattern when the leaf of a corresponding search tree is reached and comparing the leaf pattern with the input key to determine if the leaf pattern matches the input key; if leaf pattern matches, identifying the leaf as the longest prefix match; if leaf pattern does not match, identifying previously stored leaf pointer with distinguishing bit greater than least significant bit of mismatch as the longest prefix match; and returning the Longest prefix match found for the input key to a requesting application. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A method of conducting a search through a virtual private network routing table structure for at least one search tree, comprising:
-
performing a hash operation on a first segment of an internet protocol destination address with a virtual private network number to provide an output, and concatenating the remainder of the internet protocol destination address to the output of the hash operation to form a search key; inputting the first segment of the search key into a direct table within the routing table structure wherein said direct table represents a plurality of root nodes of search frees; and determining a longest prefix match for a variable length search key; further including inserting a new route into the direct table structure comprises the steps of; determining the direct table entry correlating to the new route; if the direct table entry is empty, adding the entry directly to the direct table; if the distinguishing bit position is greater than bit 28, insert the entry normally; if the distinguishing bit position is bit 28 or less; if the first pattern search control block (PSCB) in place is greater than bit 28, add another pattern search control block to resolve new virtual private network from existing virtual private network; and use bit 28 if distinguishing; otherwise, use first distinguishing bit, then add a new pattern search control block at bit 28 for each virtual private network; if the first pattern search control block in place is less than bit 28 thus indicating that multiple virtual private networks are already in place use bit 28 if distinguishing; and otherwise, use first distinguishing bit and then add pattern search control block at bit 28 for new virtual private network.
-
-
9. A method of conducting a search through a virtual private network routing table structure for at least one search tree, comprising:
-
performing a hash operation on a first segment of an internet protocol destination address with a virtual private network number to provide an output and concatenating the remainder of the internet protocol destination address to the output of the bash operation to form a search key; inputting the first segment of the search key into a direct table within the routing table structure wherein said direct table represents a plurality of root nodes of search trees; and determining a longest prefix match for a variable length search key; further including deleting a route from the direct table comprises the steps of; determining the direct table entry correlating to the route to be deleted; if the route to be deleted is at the direct table entry, delete the route from the direct table normally; if the distinguishing bit position is greater than bit 28, delete the route normally; if the distinguishing bit position is bit 28, or if next pattern search control block is with only one choice at bit 28; if no previous pattern search control blocks are in place, remove the pattern search control blocks, and use the direct table entry to point directly; if at least one previous pattern search control block is in place, remove the pattern search control block normally; and if the distinguishing bit position has one or more subsequent pattern search control blocks prior to the pattern search control block at bit 28, remove the pattern search control block normally.
-
Specification