CN102289453A - TCAM (ternary content addressable memory) rule storing method, device and network equipment - Google Patents

TCAM (ternary content addressable memory) rule storing method, device and network equipment Download PDF

Info

Publication number
CN102289453A
CN102289453A CN201110166640A CN201110166640A CN102289453A CN 102289453 A CN102289453 A CN 102289453A CN 201110166640 A CN201110166640 A CN 201110166640A CN 201110166640 A CN201110166640 A CN 201110166640A CN 102289453 A CN102289453 A CN 102289453A
Authority
CN
China
Prior art keywords
tcam
unit
idle
stored
long
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201110166640A
Other languages
Chinese (zh)
Other versions
CN102289453B (en
Inventor
潘坚平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Star Net Ruijie Networks Co Ltd
Original Assignee
Beijing Star Net Ruijie Networks Co Ltd
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 Beijing Star Net Ruijie Networks Co Ltd filed Critical Beijing Star Net Ruijie Networks Co Ltd
Priority to CN 201110166640 priority Critical patent/CN102289453B/en
Publication of CN102289453A publication Critical patent/CN102289453A/en
Application granted granted Critical
Publication of CN102289453B publication Critical patent/CN102289453B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a TCAM (ternary content addressable memory) rule storing method, device and network equipment. The method comprises the following steps: when the rule to be stored is a long rule, judging whether the TCAM storage space has a long TCAM unit, wherein the TCAM storage space is formed by splicing at least two TCAMs in parallel, and the long TCAM unit is composed of multiple TCAM units adjacent in the same row; if the judgment result indicates that the long TCAM unit does not exist, performing defragmentation on the TCAM storage space to obtain a long TCAM unit; and storing the rule to be stored in the TCAM storage space according to the obtained idle long TCAM unit. By adopting the technical scheme of the invention, the waste of TCAM resources can be reduced, and the utilization rate of TCAM resources can be improved.

Description

Three-state content addressing memory rale store method, device and the network equipment
Technical field
The present invention relates to data communication technology, relate in particular to a kind of three-state content addressing memory rale store method, device and the network equipment.
Background technology
Three-state content addressing memory (Ternary Content Addressable Memory; Abbreviate as: TCAM) different with storage medium in the past, TCAM allows all clauses and subclauses of concurrent access, and supports preferential matched rule.For example: store 1000 among the TCAM and search the TCAM rule, TCAM once just can be to the operation of comparing of these 1000 TCAM rules, finds the most forward with its coupling, and carries out corresponding actions, and efficient height and complexity are lower.Based on this, TCAM is widely used in the network equipment, for example is used to deposit routing table, Access Control List (ACL) (Access Control List; Abbreviate as: ACL) etc.But it is its price comparison costliness that TCAM has a significant disadvantages, therefore, need make full use of TCAM.
For the internet, the most frequently used TCAM rule just is based on Internet protocol (Internet Protocol; Abbreviate as: IP) address, medium access control (Media Access Control; Abbreviate as: MAC) the various filtering rules that form such as address, and TCAM normally forms a plurality of TCAM unit of corresponding size according to the length of TCAM rule and be arranged in order by a plurality of TCAM unit and form, a TCAM rule is put in each TCAM unit.At present, the size of TCAM unit is generally 24 bytes.But, along with the development of IP technology, Internet protocol the 6th version (Internet Protocol Version 6 has appearred; Abbreviate as: IPv6), and the length of IPv6 address is 128 bits, is 4 times of IPv4 address, and the original like this TCAM unit that is used to deposit the short rule that realizes based on IPv4 can't hold based on the calipers of IPv6 then.Wherein, calipers then is not limited only to the rule that realizes based on IPv6, also comprises the rule that related more message field (MFLD) forms, for example the rule that forms of related source IP address, purpose IP address, source MAC and target MAC (Media Access Control) address etc. simultaneously.
For calipers then, need longer TCAM unit to store.A kind of way of the prior art is then to create the TCAM with longer TCAM unit separately for calipers, such network equipment just has two independently TCAM, cost is than higher, if two TCAM are not all used the waste that also can cause the TCAM resource, so another kind of solution occurred.As shown in Figure 1, another kind of solution is that two TCAM will having shorter TCAM unit are stitched together and form the TCAM storage space with longer TCAM unit.In this solution, if deposit short rule, just with a TCAM unit among the TCAM, for example label is the TCAM unit of (1); If deposit calipers then, just with the TCAM unit among two TCAM of the delegation that coexists, promptly constitute a longer TCAM unit by two TCAM unit and deposit calipers then, for example label can be used for depositing a calipers then for the TCAM unit of (3) and label for the TCAM unit of (4).But this solution still exists whole TCAM storage space to also have enough spaces to deposit calipers then and can't deposit calipers situation then, at this moment will cause the waste of TCAM resource.
Summary of the invention
The invention provides a kind of three-state content addressing memory rale store method, device and the network equipment,, improve the TCAM operating factor of memory space in order to reduce the waste of TCAM resource.
The invention provides a kind of three-state content addressing memory TCAM rale store method, comprising:
When rule to be stored is a calipers then the time, judge whether there is long TCAM unit in the TCAM storage space, described TCAM storage space is spliced side by side by at least two TCAM, and described long TCAM unit is by constituting with a plurality of TCAM unit adjacent in the delegation;
If judged result is carried out defragmentation for not existing to described TCAM storage space, obtain described long TCAM unit;
Described long TCAM unit according to obtaining is stored in described rule to be stored in the described TCAM storage space.
The invention provides a kind of three-state content addressing memory TCAM rale store device, comprising:
First judge module, being used in rule to be stored is calipers then the time, judges whether there is idle long TCAM unit in the TCAM storage space; Described TCAM storage space is spliced side by side by at least two TCAM, and described long TCAM unit is by constituting with a plurality of TCAM unit adjacent in the delegation;
The defragmentation module is used in the judged result of described first judge module described TCAM storage space being carried out defragmentation for not the time, obtains the long TCAM unit of described free time;
Memory module is used for the long TCAM unit according to the described free time of obtaining, and described rule to be stored is stored in the described TCAM storage space.
The invention provides a kind of network equipment, comprise arbitrary three-state content addressing memory TCAM rale store device provided by the invention.
Three-state content addressing memory rale store method of the present invention, device and the network equipment, definite rule to be stored be calipers then, and when in judging the TCAM storage space that is spliced by polylith TCAM, not having long TCAM unit, the TCAM storage space is carried out defragmentation, obtain the long TCAM unit that to deposit rule to be stored, reduce the waste of TCAM resource, improved the utilization factor of TCAM resource.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, to do one to the accompanying drawing of required use in embodiment or the description of the Prior Art below introduces simply, apparently, accompanying drawing in describing below is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the structural representation of the TCAM storage space that is spliced to form by two TCAM in the prior art;
The process flow diagram of the TCAM rale store method that Fig. 2 provides for one embodiment of the invention;
The process flow diagram of the TCAM rale store method that Fig. 3 provides for another embodiment of the present invention;
Fig. 4 carries out defragmentation for what one embodiment of the invention provided to the TCAM storage space, obtains the method flow diagram of idle long TCAM unit;
Fig. 5 carries out defragmentation for what another embodiment of the present invention provided to the TCAM storage space, obtains the method flow diagram of idle long TCAM unit;
The process flow diagram of the TCAM rale store method that Fig. 6 provides for further embodiment of this invention;
The structural representation of the TCAM rale store device that Fig. 7 provides for one embodiment of the invention;
The structural representation of the TCAM rale store device that Fig. 8 provides for another embodiment of the present invention.
Embodiment
For the purpose, technical scheme and the advantage that make the embodiment of the invention clearer, below in conjunction with the accompanying drawing in the embodiment of the invention, technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
The process flow diagram of the TCAM rale store method that Fig. 2 provides for one embodiment of the invention.As shown in Figure 2, the method for present embodiment comprises:
Step 201, when rule to be stored is a calipers then the time, judge whether there is idle long TCAM unit in the TCAM storage space; If promptly there is not idle long TACM unit in judged result for not in the TCAM storage space, then execution in step 202; If judged result is for being, promptly there are idle long TCAM unit, execution in step 204 in the TCAM storage space.
Wherein, the TCAM storage space is spliced side by side by at least two TCAM.Every TCAM is made of a plurality of TCAM unit.Long TCAM unit is meant by constituting with a plurality of TCAM unit adjacent in the delegation.The length of TCAM unit can be length value commonly used in the prior art, for example 24 bytes (K) among every TCAM.So-called long TCAM unit is the length of current relatively common rule, for example is short rule for the rule that realizes based on the IPv4 address, based on the rule of IPv6 address realization be calipers then.Again for example: the rule of related more message field (MFLD) also belongs to calipers then, for example: the rule of while associated source IP, purpose IP, source MAC, purpose MAC.The then shared storage space of calipers is normally lacked 2 times of rule at present, but is not limited to this.Wherein, long TCAM unit and calipers then adapt, short rule of a TCAM unit storage, and calipers of a long TCAM unit storage is then.If a calipers then be made of the short rule of n bar, then a long TCAM unit also just has to be in n of delegation adjacent TCAM unit and constitutes, and that is to say that the TCAM storage space is spliced side by side by n piece TCAM at least.Wherein, be in the piece number that is less than or equal to the TCAM that constitutes the TCAM storage space with the number of the TCAM unit of a long TCAM of the formation in delegation unit, equate to be preferred implementation and get both.
Step 202, the TCAM storage space is carried out defragmentation, obtain idle long TCAM unit, and execution in step 203.
When not having idle long TCAM unit in the TCAM storage space, illustrate enough scattered short rale store space (being the TCAM unit) is arranged in the TCAM storage space, but these TCAM unit are discontinuous, therefore, can't directly calipers then be stored in the TCAM storage space, so the TCAM storage space is carried out defragmentation, obtains idle long TCAM unit.Wherein, described " fragment " is meant not to be in delegation or to be in does not have adjacent a plurality of TCAM unit with delegation.For calipers then for, these are not in delegation or are in delegation does not have adjacent a plurality of TCAM unit to belong to fragment, but for short rule, these are not in delegation or are in that not have adjacent a plurality of TCAM unit with delegation be not to belong to fragment, and a short rule all can be stored in each TCAM unit.
" defragmentation " of present embodiment is meant does not have adjacent a plurality of TCAM unit to move to not being in delegation or being in delegation, makes these not be in delegation or be in delegation and do not have a plurality of TCAM unit in the adjacent TCAM unit to be in delegation and a long TCAM of adjacent formation unit.Wherein, these are not in delegation or are in does not have mode that adjacent TCAM unit moves still to keep original priority level between the rule that guarantees to have stored with delegation, concrete move which TCAM unit, which direction to move, to move what TCAM unit to and all do not do qualification, every mode of an available long TCAM unit that can move out is all within the scope of present embodiment.
The long TCAM unit of the free time that step 203, basis are obtained is stored in rule to be stored in the TCAM storage space, and finishes this deposit operation.
After the long TCAM unit of putting out a free time in order, just can rule to be stored be stored in the TCAM storage space according to the long TCAM unit of the free time of putting in order out, then this time regular deposit operation finishes.
Wherein, the search operation based on TCAM is to realize by the engine that is solidificated in the TCAM storage space.Once complete TCAM search procedure is in engine.Search engine and have following feature: 1, a TCAM rale store device may exist a plurality of engines of searching.2, one search engine can only mate calipers then or short rule wherein a kind of; That is to say an engine or coupling calipers then, or the short rule of coupling, same engine can not only not hit calipers then but also hit short rule.3, to search the rule that engine mates be not have priority relationship to difference.In the TCAM of present embodiment storage space, there are two kinds of engines simultaneously, a kind of engine and calipers then adapt, and are used to mate calipers then, and another kind of engine adapts with short rule, is used to mate short rule, and does not have priority relationship between two kinds of engines; When the engine of selecting then to adapt to calipers mates, only can then mate with calipers, when the engine of selecting to adapt to short rule mates, only can mate with short rule, that is to say, when having calipers then with short rule simultaneously in the TCAM of present embodiment storage space, calipers then and between the short rule does not have priority relationship.Therefore, when carrying out defragmentation, moving short rule is to cross over storage calipers long TCAM unit then.
But there is priority relationship in calipers between then.Therefore, after getting access to idle long TCAM unit, not directly rule to be stored to be stored among the long TCAM unit of the free time of obtaining, but to rule to be stored be stored in the TCAM storage space according to the long TCAM unit of the free time of obtaining, make rule to be stored be stored in the requirement that can then satisfy priority relationship after the TCAM storage space with other calipers, promptly the calipers that priority is high then leave in the low calipers of priority then before.
At this moment, if also have next rule to be stored, then continue to go to store next rule according to above-mentioned steps; If there is not next rule to be stored, then whole storage operation finishes.
Step 204, direct long TCAM unit according to the free time in the TCAM storage space are stored in rule to be stored in the TCAM storage space, and finish this deposit operation.
When having idle long TCAM unit in the TCAM storage space, do not need the TCAM storage space is carried out defragmentation, can rule to be stored be stored in the TCAM storage space, and finish this deposit operation directly according to the long TCAM unit of the free time in the TCAM storage space.In this step, deposit rule to be stored and the time also will guarantee priority relationship between already present calipers is then in rule to be stored and the TCAM storage space, promptly to guarantee the high calipers of priority then leave in the low calipers of priority then before.
At this moment, if also have next rule to be stored, then continue to go to store next rule according to above-mentioned steps; If there is not next rule to be stored, then whole storage operation finishes.
The TCAM rale store method of present embodiment, when rule to be stored is that calipers is then the time, judge earlier whether the TCAM space also exists idle long TCAM unit, and when not having idle long TCAM unit, defragmentation is carried out in the TCAM space, obtain the available long TCAM unit that to deposit rule to be stored, and rule to be stored is stored in the TCAM storage space based on the available long TCAM unit that obtains, both solved calipers storage problem then, reduce the waste in TCAM space again, improved the TCAM operating factor of memory space.
The process flow diagram of the TCAM rale store method that Fig. 3 provides for another embodiment of the present invention.Present embodiment is based on realization embodiment illustrated in fig. 2, the method of present embodiment comprised before step 201 judges whether the TCAM storage space has the storage resources of enough storages rule to be stored, and judge whether rule to be stored is calipers operation then, as shown in Figure 3, the method for present embodiment specifically may further comprise the steps:
Step 20a, receive rule to be stored.
Concrete, the network equipment or upper-layer user send to TCAM rale store device with rule to be stored.For example: the user at the network equipment (for example: switch) go up ACL of configuration and be used to filter some message, so at first the relative program in the network equipment can resolve to user configured ACL one rule TCAM rule, and tells TCAM rale store device that these TCAM rules will be installed.Wherein, the length of every rule to be stored itself is equivalent to the size of rule to be stored, that is to say that rule to be stored itself carries its size information.
Step 20b, judge whether the TCAM storage space has the storage resources of enough storages rule to be stored; If judged result is for being that promptly the TCAM storage space has the storage resources of enough storages rule to be stored, execution in step 20c; If judged result is not, promptly the TCAM storage space does not have enough storage resources of storage rule to be stored, execution in step 206.
Concrete, TCAM rale store device is when receiving rule to be stored, at first obtain the size of the needed storage space of storage rule to be stored according to the length of rule to be stored, whether judge then has enough storage resources to deposit (perhaps installing) these TCAM rules in the TCAM storage space, if there are enough storage resources to deposit (or installation) these rules to be stored, TCAM rale store device is installed rule to be stored with regard to finding suitable position.Concrete, TCAM rale store device is provided with a counter, and the initial value of this counter is 0, and maximal value is the max cap. of TCAM storage space.Whenever deposit a short rule, the value of counter just adds 1, whenever deposit a calipers then the value of counter just add n, n represents that a calipers then is made of the short rule of n bar.For ease of describing, it is that example describes that various embodiments of the present invention all equal 2 with n, calipers of then every installation then, the value of counter just adds 2.Along with the installation of TCAM rule, the value of counter constantly increases, and on the contrary, if delete a short rule, then the value of counter reduces 1 accordingly, if delete a calipers then, the value of counter reduces 2 accordingly.Therefore, TCAM rale store device can judge whether to also have enough storage resources to deposit rule to be stored by its counter.For example: if a calipers is installed then, then deduct behind the currency of counter still greater than 2 (being n), represent that then the TCAM storage space has the ability this calipers to be installed then with the TCAM max cap.; If a short rule is installed, then deduct behind the currency of counter still greater than 1 with the TCAM max cap., represent that then the TCAM storage space has the ability to install that this is short regular.In addition, TCAM rale store device also can be known by query statistic TCAM storage space and deposits the needed storage resources of rule to be stored whether in addition.Described storage resources is meant the size of all idle TCAM unit in the TCAM storage space.
Step 20c, judge rule to be stored whether be calipers then; If judged result is for being, rule promptly to be stored be calipers then, execution in step 201; If judged result is not, rule promptly to be stored is short rule, execution in step 205.
When having enough storage resources in judging the TCAM storage space, TCAM rale store device is according to the content and the predefined judgement calipers algorithm then of rule to be stored, judge rule to be stored whether be calipers then.For example: if the length of rule to be stored greater than predefined length threshold, is then just then deposited rule to be stored by calipers; For example: suppose that rule to be stored is " source IP address (SIP)=192.168.1.1 and purpose IP address (DIP)=192.168.2.1 and source MAC (SMAC)=0000.0000.0001 and target MAC (Media Access Control) address (DMAC)=0000.0000.0002 ", will then install with calipers so.If the length of rule to be stored is not more than predefined length threshold, then just deposit rule to be stored by short rule; For example: suppose that rule to be stored is " SIP=192.168.1.1 ", so as long as just can install with short rule.
Step 201, judge whether there is idle long TCAM unit in the TCAM storage space; If promptly there is not idle long TCAM unit in judged result for not in the TCAM storage space, then execution in step 202; If judged result is for being, promptly there are idle long TCAM unit, execution in step 204 in the TCAM storage space.
When judge rule to be stored be calipers then, and when in the TCAM storage space enough storage resources being arranged, TCAM rale store device judges further whether idle long TCAM storage unit is arranged in the TCAM storage space, so that store calipers then.
Step 202, the TCAM storage space is carried out defragmentation, obtain idle long TCAM unit, and execution in step 203.
The long TCAM unit of the free time that step 203, basis are obtained is stored in rule to be stored in the TCAM storage space, and finishes this deposit operation.
Step 204, according to the long TCAM unit of the free time that exists in the TCAM storage space, directly rule to be stored is stored in the TCAM storage space, and finishes this deposit operation.
The long TCAM unit of the free time that above-mentioned basis is obtained or according to the long TCAM unit of the free time that exists in the TCAM storage space, rule to be stored is stored in the TCAM storage space, specifically comprises: whether the priority of at first judging rule to be stored is lower than the calipers priority then in the last long TCAM unit of idle long TCAM unit; When priority that judgement draws rule to be stored was lower than then priority of the calipers stored in the last long TCAM unit of idle long TCAM unit, whether the priority that continues to judge rule to be stored was higher than the calipers priority then in the long TCAM of the next one unit of long TCAM unit of free time; When judged result is that the priority of rule to be stored is lower than the calipers priority then of being stored in the last long TCAM unit of idle long TCAM unit, when being higher than then priority of the calipers stored in the long TCAM of the next one unit of idle long TCAM unit, rule to be stored is stored in the long TCAM unit of free time.When the priority of judging rule to be stored is higher than then priority of the calipers stored in the last long TCAM unit of idle long TCAM unit, perhaps when the priority of judging rule to be stored is lower than then priority of the calipers stored in the long TCAM of the next one unit of idle long TCAM unit, according to the rule of having stored in the TCAM storage space, long TCAM unit to the free time moves, be lower than the calipers priority then of being stored in the last long TCAM unit of idle long TCAM unit to the priority that makes rule to be stored up to long TCAM cell moving with the free time, be higher than till the calipers priority then of being stored in the long TCAM of the next one unit of idle long TCAM unit, then rule to be stored be stored in the long TCAM unit of the free time after moving.For example: store long acl rule corresponding and the short acl rule corresponding in the TCAM storage space as shown in table 1 simultaneously with engine 2 with engine 1; Wherein, label is the short acl rule that stores engine 2 correspondences in the TCAM unit of (1), (5), (9), (10), (13) and (14), is respectively ACL2.ace100, ACL2.ace200, ACL2.ace300, ACL2.ace350, ACL2.ace400 and ACL2.ace500; Label is for depositing the long acl rule ACL1.ace20 of engine 1 correspondence in the TCAM unit of (7) and (8); Label is for depositing the long acl rule ACL1.ace30 of engine 1 correspondence in the TCAM unit of (11) and (12); Label is idle TCAM unit for the TCAM unit of (2) and (6).
Table 1
Figure BDA0000069664240000101
Suppose this moment a regular ACL1.ace15 to be installed, this rule is the long acl rule that adapts to engine 1; Through searching the TCAM storage space, find to also have 2 idle TCAM unit, there are enough resources that this regular ACL1.ace15 is installed, but since this rule be calipers then, but do not find idle long TCAM unit, so ACL2.ace200 is moved to label in the TCAM unit, space of (2), obtained by the long TCAM unit of label for (5) and (6) two TCAM unit formations, as shown in table 2.
Table 2
Figure BDA0000069664240000112
As shown in table 2, the last long TCAM unit of the long TCAM unit that is made of for two TCAM unit of (5) and (6) label is to be two TCAM unit formations of (3) and (4) by label, and wherein Cun Chu calipers priority level then is " 10 "; The long TCAM of the next one unit of the long TCAM unit that is made of for two TCAM unit of (5) and (6) label is to be two TCAM unit formations of (7) and (8) by label, wherein the calipers of being stored priority level then is " 20 ", and the priority level of regular ACL1.ace15 to be stored is " 15 ", between above-mentioned two calipers priority then, so regular ACL1.ace15 can be stored in by in the long TCAM unit of label for two TCAM unit formations of (5) and (6).
Again for example, suppose that rule to be stored is ACL1.ace25, be that calipers priority then in the long TCAM unit of two TCAM unit formations of (7) and (8) is low through priority ratio that judge to find regular ACL1.ace25 to be stored by label, so the time will by label for the calipers in the long TCAM unit of two TCAM unit formations of (7) and (8) then ACL1.ace20 move forward, move to by in the long TCAM unit of label for two TCAM unit formations of (5) and (6), and will become the long TCAM unit of free time by the long TCAM unit that label constitutes for two TCAM unit of (7) and (8), and through judge finding that this moment, rule to be stored was that the priority of ACL1.ace25 is lower than by label and is calipers priority then in the long TCAM unit of two TCAM unit formations of (5) and (6), be higher than by label and be calipers priority then in the long TCAM unit of two TCAM unit formations of (11) and (12), so regular ACL1.ace25 to be stored is left in by in the long TCAM unit of label for two TCAM unit formations of (7) and (8), as shown in table 3.
Table 3
Figure BDA0000069664240000121
In this explanation, above-mentioned long TCAM unit to the free time (comprises what the process defragmentation obtained, also comprising in the TCAM storage space what itself existed) mode that moves is not limited to a kind ofly, everyly can make each calipers that stores in the TCAM storage space then satisfy the move mode that priority requires all to be applicable to present embodiment.
Step 205, with in the idle TCAM unit of rale store to be stored in the TCAM storage space, and finish this deposit operation.
Be short rule when judging rule to be stored, and when in the TCAM storage space enough storage resources being arranged, directly rule to be stored be stored in the TCAM unit of suitable free time and get final product.Wherein, the TCAM unit of described suitable free time also is meant and satisfies the TCAM unit that the priority between the short rule requires, if the TCAM unit of current free time does not satisfy the priority requirement between the short rule, then can move the TCAM unit equally, obtain and satisfy the TCAM unit that the priority between the short rule requires.If also have next rule to be stored, then continue execution in step 20a and subsequent step, next one rule to be stored is carried out deposit operation, if there is not next rule to be stored, then can finish storage operation.
Step 206, the storage operation that finishes.
When judging the TCAM storage space and not having enough storage spaces, illustrate that the TCAM storage space is taken basically, owing to can't deposit this rule to be stored, also can't deposit next rule to be stored, so the end storage operation.
The TCAM rale store method of present embodiment, when receiving rule to be stored, by judging one by one whether the TCAM storage space has enough storage resources, the situation that enough storage resources are arranged judge rule to be stored whether be calipers then, in rule to be stored is that calipers judges whether there is idle long TCAM unit in the TCAM storage space then the time, and when not having idle long TCAM unit, the TCAM storage space is carried out defragmentation, put out idle long TCAM unit in order, and then deposit rule to be stored in view of the above, both solved calipers storage problem then, reduce the waste of TCAM resource again, improved the TCAM operating factor of memory space.
Fig. 4 carries out defragmentation for what one embodiment of the invention provided to the TCAM storage space, obtains the method flow diagram of idle long TCAM unit.As shown in Figure 4, the method for present embodiment comprises:
Step 401, inquire about TCAM unit in the TCAM storage space successively, obtain a plurality of idle TCAM unit that inquires at first.
In the present embodiment, TCAM rale store device is inquired about the TCAM unit in the TCAM storage space successively, judges whether the TCAM unit is idle.When inquiring TCAM when idle, the label record of the TCAM unit of free time of inquiring is got off, till the TCAM unit that inquires a plurality of free time.Wherein, the TCAM storage space is spliced side by side by a plurality of TCAM.
In the present embodiment, a long TCAM unit comprises a plurality of TCAM unit, that is to say, a calipers then takies a plurality of TCAM unit, but is not limited to this, and long TCAM unit comprises that specifically several TCAM unit decides on calipers length then.
The a plurality of idle TCAM unit that step 402, basis inquire, to move with the rule in the TCAM unit between a plurality of idle TCAM unit that inquire, obtain and be in delegation and adjacent a plurality of idle TCAM unit, being in delegation and adjacent a plurality of idle TCAM unit of getting access to constitutes idle long TCAM unit.
Wherein, TCAM unit between the TCAM unit of a plurality of free time all is used, according to the position of a plurality of TCAM unit in the TCAM storage space, the rule in the TCAM unit is moved, till moving out a plurality of TCAM unit that are in delegation and adjacent free time.Wherein, move mode can have multiple, and present embodiment is not done qualification to this.
The scrap cleaning method of present embodiment, for the most forward a plurality of idle TCAM unit that inquires (then with respect to calipers, these idle TCAM unit are a kind of fragments) carry out defragmentation, obtain idle long TCAM unit, have the fast advantage of seek rate, be convenient in time put in order out idle long TCAM unit.
Further, when the TCAM space is when being spliced side by side by two TCAM, TCAM rale store device specifically inquires two idle TCAM unit, and correspondingly a kind of embodiment of step 402 comprises:
Whether the label of first idle TCAM unit is odd number in two idle TCAM unit that step 4021, judgement inquire; When judged result for being that promptly the label of first idle TCAM unit is an odd number, execution in step 4022; When judged result for not the time, promptly the label of first idle TCAM unit is an even number, execution in step 4023.
The label whether step 4022, the label of judging second idle TCAM unit in two idle TCAM unit inquiring equal first idle TCAM unit adds 1; If judged result is for being that promptly first idle TCAM unit and second idle TCAM unit are in delegation and adjacent execution in step 4025; If judged result is that promptly first idle TCAM unit and second idle TCAM unit are not non-conterminous, execution in step 4024.
Wherein, when directly forwarding step 4022 to by step 4021, first idle TCAM unit is first TCAM unit in two idle TCAM unit that inquire.If forward step 4022 to by step 4023, the idle TCAM of wherein first unit is meant through the idle TCAM unit after moving.
Step 4023, the rule in the TCAM unit adjacent with first idle TCAM unit before first idle TCAM unit is moved to first idle TCAM unit, and the label of first idle TCAM unit subtracted 1, even first idle TCAM unit becomes adjacent with it TCAM unit before, and changes and go execution in step 4022.
Step 4024, the rule in the TCAM unit adjacent with second idle TCAM unit before second idle TCAM unit is moved in second idle TCAM unit, and the label of second idle TCAM unit is subtracted 1, and change and go execution in step 4022.
Step 4025, finish herein the defragmentation operation.
At this moment, promptly obtained to be in, that is to say and put out a long TCAM unit in order with delegation and two adjacent idle TCAM unit.
In the present embodiment, because the TCAM storage space is spliced to form side by side by two TCAM, so when being odd number (being on the left side) by label in first idle TCAM unit, whether the label of judging second idle TCAM unit is that the label of first idle TCAM unit adds 1, whether the TCAM unit that can judge two free time is in delegation and adjacent, its mode of operation is simple, and is convenient to implement.
Further, when the TCAM space is when being spliced side by side by N (N is greater than 2) piece TCAM, TCAM rale store device specifically inquires N idle TCAM unit, and correspondingly a kind of embodiment of step 402 comprises: whether the label of judging first idle TCAM unit in N the idle TCAM unit that inquires is N*m-(N-1); Wherein, m can be any round values between the TCAM unit number (being the line number that the TCAM storage space is comprised) that comprises of 1 to every TCAM.That is to say, judge whether first idle TCAM unit is the leftmost TCAM unit that is in the TCAM storage space.
If judged result is first idle TCAM unit when being in the Far Left of TCAM storage space, the label whether label of then judging second idle TCAM unit equals first idle TCAM unit adds 1; If the label that judged result is the label of second idle TCAM unit equals first idle TCAM unit adds 1, then continue the idle TCAM of next one unit is judged, till idle TCAM judges the unit to all.If the label that judged result is the label of second idle TCAM unit is not equal to first idle TCAM unit adds 1, then to having moved after idle TCAM cell moving arrives first idle TCAM unit with second with the rule in the TCAM unit before second idle TCAM unit and till adjacent with first idle TCAM unit, and continue the idle TCAM of next one unit is handled, up to make N idle TCAM unit be in delegation and adjacent till.
If judged result is not in the Far Left of TCAM storage space for first idle TCAM unit, at first move with the rule in the TCAM unit, with the Far Left of first idle TCAM cell moving to the TCAM storage space to before first idle TCAM unit; The label whether label of judging second idle TCAM unit then equals first idle TCAM unit adds 1; If the label that judged result is the label of second idle TCAM unit equals first idle TCAM unit adds 1, then continue the idle TCAM of next one unit is judged, till idle TCAM judges the unit to all.If the label that judged result is the label of second idle TCAM unit is not equal to first idle TCAM unit adds 1, then to having moved after idle TCAM cell moving arrives first idle TCAM unit with second with the rule in the TCAM unit before second idle TCAM unit and till adjacent with first idle TCAM unit, and continue the idle TCAM of next one unit is handled, up to make N idle TCAM unit be in delegation and adjacent till.
Above-mentionedly carry out the scheme that defragmentation obtains the long TCAM unit that is made of a plurality of idle TCAM unit, similar with the scheme of obtaining the long TCAM unit that constitutes by two idle TCAM unit, give unnecessary details no longer in detail.This embodiment is simple relatively, and is convenient to implement.
Fig. 5 carries out defragmentation for what another embodiment of the present invention provided to the TCAM storage space, obtains the method flow diagram of idle long TCAM unit.As shown in Figure 5, the method for present embodiment comprises:
Step 501, inquire about TCAM unit in the TCAM storage space successively, obtain at a distance of two nearest idle TCAM unit.
In the present embodiment, the TCAM storage space is spliced side by side by two TCAM.TCAM rale store device is by all TCAM unit of traversal TCAM storage space, and the magnitude relationship between the label of the idle TCAM unit that arrives by comparison query, obtains at a distance of two nearest idle TCAM unit.
Step 502, basis are at a distance of two nearest idle TCAM unit, to between two nearest idle TCAM unit, move with the rule in the TCAM unit, obtain and be in delegation and two adjacent idle TCAM unit, being in delegation and two adjacent idle TCAM unit of getting access to constitutes idle long TCAM unit.
Wherein, may comprise a plurality of TCAM unit of having used at a distance of between two nearest idle TCAM unit, also may not comprise with the TCAM unit but be in different row, based on this, concrete how each TCAM unit is moved and obtains the mode that is in delegation and adjacent two idle TCAM unit, present embodiment is not done qualification, decides according to actual conditions.Wherein, with mobile least number of times, can guarantee that the move mode of the priority level between the storage rule is preferred move mode.
In the present embodiment, when the fragment in the TCAM storage space that is spliced side by side by two TCAM is put in order, based on carrying out defragmentation at a distance of two nearest TCAM unit, can reduce mobile number of times like this, improved the efficient of obtaining idle long TCAM unit.
The operation of top defragmentation is based on that row in the TCAM arrangement mode carries out, also can be undertaken by row, some decision logics in the concrete defragmentation process need be done accommodation, description based on the foregoing description, those skilled in the art can know the embodiment of concrete defragmentation according to the actual requirements by inference, do not do detailed argumentation at this.
The process flow diagram of the TCAM rale store method that Fig. 6 provides for further embodiment of this invention.In the present embodiment, concrete storage ACL among the TCAM, rule promptly to be stored is ACL, and the TCAM storage space is spliced by two TCAM.Wherein, ACL is the instruction list of the interface of the network equipments such as a kind of router or switch, is used for the packet of control port turnover.In the network equipment, general with some field in the message as the standard that judges whether to allow message to pass through, each standard is an ACE rule.Several ACE rules are arranged among each ACL, and each ACE rule is according to the priority relationship series arrangement.For example the user disposes following filter criteria: 10Permit IP 192.168.1.1 and 20Deny any, every filtering rule is stored among the ACL as an ACE rule.Wherein, 10 among the 10Permit IP192.168.1.1 is sequence numbers of ACE rule, and this ACE rule expression permission IP address is that the message of 192.168.1.1 passes through; Among 20Deny any 20 is the sequence number of ACE rule, and this ACE rule expression does not allow all messages to pass through.When these two ACE rule application during in port, be exactly that to have only the IP address be that the message of 192.168.1.1 passes through on this port, other messages all are filtered.In the TCAM storage space, these two ACE rules leave in two TCAM unit according to two TCAM rules of the resolved one-tenth of hardware template (Key), and are as shown in table 4.Wherein, the priority level of being supported according to the TCAM storage space, sequence number is that need to leave sequence number in be before 20 the ACE rule for 10 ACE rule, as shown in table 4, sequence number is that 10 ACE rule is stored at label in the TCAM unit of (1), and sequence number is that 20 ACE rule is stored at label in the TCAM unit of (3).
Above-mentioned ACE rule belongs to short rule, and all short rules leave among the ACL; If the ACE rule is based on the realization of IPv6 address, perhaps simultaneously related a plurality of message field (MFLD)s realize that then belong to calipers then, all calipers then leave among the ACL.For example: this sequence number of 30Permit IP2001:0DB8:0000:0000:0000:0000:1428:57ab be 30 ACE rule be exactly a calipers then, then need to leave in simultaneously in the long TCAM unit that forms by two TCAM unit for calipers, as shown in table 4, sequence number is that to be stored at label be in the TCAM unit of (6) for (5) and label for 30 ACE rule.If have not only new rule to be stored (promptly but also have new ACL) will be stored among the TCAM this moment, then as shown in Figure 6, the method for present embodiment comprises:
Step 601, TCAM rale store device receive rule to be stored.
Wherein, rule to be stored is ACL, and this ACL can comprise an ACE rule, can comprise many ACE rules, all ACE rule otherwise be calipers then, or for short regular.Present embodiment is an example with 3 ACE rules, and supposes that all ACE rules are calipers then.Wherein, article one ACE rule is: 40Permit IP 2001:0DB8:0000:0000:0000:0000:1428:67ab; Second ACE rule is: 50Permit IP 2001:0DB8:0000:0000:0000:0000:1428:71cb; Article three, the ACE rule is: 25Permit IP 2001:0DB8:0000:0000:0000:0000:1428:3342.Explanation in addition, the ACL that will deposit in a storing process can also all comprise short ACE rule, also can not only comprise short ACE rule but also comprise long ACE rule.But, need then install with calipers as long as an ACE rule occurs, all the ACE rules among this ACL all will then be installed with calipers so.
Step 602, TCAM rale store device judge whether the storage resources of enough depositing rule to be stored is arranged in the TCAM storage space.If judged result is for being execution in step 603; If judged result is for denying execution in step 612.
In the present embodiment, the TCAM storage space is spliced by two TCAM.It is 6 TCAM unit that TCAM rale store device obtains the required storage space of rule to be stored, and TCAM rale store device is by query statistic TCAM storage space, find that the TCAM storage space also comprises 6 TCAM unit, promptly current TCAM storage space comprises the storage resources of enough storages rule to be stored.
Step 603, TCAM rale store device judge rule to be stored whether be calipers then; If judged result is for being execution in step 604; If judged result is for denying execution in step 607.
In the present embodiment, TCAM rale store device judge rule to be stored whether calipers then mainly be meant to judge whether there is the ACE rule that need then install with calipers in the rule to be stored; If exist, then expression this rule to be stored be calipers then, otherwise, represent that this rule to be stored is that weak point is regular.Concrete, TCAM rale store device can be judged that calipers algorithm is then judged and the length of every ACE rule whether judges corresponding ACE rule greater than length threshold whether needs are then installed with calipers according to predefined.
In the present embodiment, TCAM rale store device is judged all ACE rules all to be needed then to install with calipers, promptly represent rule to be stored be calipers then, then execution in step 604.
Step 604, TCAM rale store device judge whether there is idle long TCAM unit in the TCAM storage space; If judged result is for being execution in step 606; If judged result is for denying execution in step 605.
Shown in the associative list 4, the TCAM rale store device of present embodiment is judged the long TCAM unit that also has two free time in the TCAM storage space, so direct execution in step 606 promptly directly is stored in an ACE rule in the long TCAM unit.
When carrying out the 3rd ACE rule, TCAM rale store device will be judged does not have idle long TCAM unit in the TCAM storage space, then with execution in step 605.
Step 605, TCAM rale store device carry out defragmentation to the TCAM storage space, obtain the long TCAM unit of a free time, and execution in step 606.
Shown in the associative list 4, the TCAM rale store device of present embodiment moves to label in the TCAM unit of (2) with label for the rule " 20Deny any " in the TCAM unit of (3), is (3) and the label long TCAM unit for the free time of the TCAM unit formation of (4) thereby obtain by label.Perhaps, TCAM rale store device at first moves to label in the TCAM unit of (4) with label for the rule " 20Deny any " in the TCAM unit of (3), then, label is moved to the TCAM unit of label for (2) for the rule " 10Permit IP 192.168.1.1 " in the TCAM unit of (1), again from label for moving to label the TCAM unit of (2) in the TCAM unit of (3), be (1) and label long TCAM unit thereby obtain for the free time of the TCAM unit formation of (2) by label.Present embodiment is an example with first kind of situation, and execution in step 606 again, the 3rd ACE rule is stored in the long TCAM unit of the free time of obtaining, promptly stores into by label to be (3) and the label long TCAM unit for the free time of the TCAM unit formation of (4).
Step 606, TCAM rale store device are stored in a rule to be stored in the idle long TCAM unit, and execution in step 608.
Concrete, when having idle long TCAM unit in the TCAM storage space, get final product in the direct TCAM unit that an ACE rule is stored in a free time.In the present embodiment, suppose that article one ACE rule 40Permit IP 2001:0DB8:0000:0000:0000:0000:1428:67ab is stored in by label in (7) and the long TCAM unit of label for the TCAM unit formation of (8); Second ACE rule 50Permit IP 2001:0DB8:0000:0000:0000:0000:1428:71cb is stored in label in (9) and the long TCAM unit of label for the TCAM unit formation of (10).And the 3rd ACE rule 25Permit IP 2001:0DB8:0000:0000:0000:0000:1428:3342 is stored in by label in (3) and the long TCAM unit of label for the TCAM unit formation of (4).In the present embodiment, the priority relationship between just in time satisfied three the long ACE rules in the long TCAM unit of the free time that defragmentation goes out is not so need the long TCAM unit of free time is moved processing.
Step 607, TCAM rale store device are stored in a rule to be stored in the TCAM unit of a free time, and change and go execution in step 610.
If rule to be stored is short rule, then TCAM rale store device stores a rule to be stored (i.e. ACE rule) in the TCAM unit into according to the priority level of rule to be stored and gets final product.
Step 608, TCAM rale store device judge whether next bar rule to be stored in addition; If judged result is for being execution in step 609; If judged result is for denying execution in step 612.
After being stored in an ACE rule in the TCAM storage space, TCAM rale store device judges whether next bar ACE rule in addition; If also have next bar ACE rule, then execution in step 609, obtain next bar ACE rule, and change and remove execution in step 604 and subsequent step, to finish depositing next bar ACE rule.
Step 609 is obtained next bar rule to be stored, and changes and go execution in step 604.
Step 610, TCAM rale store device judge whether next bar rule to be stored in addition; If judged result is for being execution in step 611; If judged result is for denying execution in step 612.
Step 611, obtain next bar rule to be stored, and the rule to be stored that will obtain is stored in the idle TCAM unit, and changes and go execution in step 610.
Step 612, end rules deposit operation.
After all ACE rules all are stored in the TCAM storage space, the end rules deposit operation.When not having enough storage resources in the TCAM storage space, also the deposit operation of direct end rules to save unnecessary operation, is saved the resource that regular deposit operation consumes.
So far, present embodiment has been finished and has been treated depositing of storage rule, and it is as shown in table 5 that it deposits the result.
Table 4
Figure BDA0000069664240000211
Table 5
Figure BDA0000069664240000222
The TCAM rale store method of present embodiment, in the TCAM storage space, do not deposit calipers long TCAM unit then, but when storage resources is enough again, carry out defragmentation by independent TCAM unit to the TCAM storage space, obtain long TCAM unit and deposit calipers then, both solve calipers storage problem then, reduced the waste of TCAM resource again, improved the utilization ratio of TCAM storage space.
The structural representation of the TCAM rale store device that Fig. 7 provides for one embodiment of the invention.As shown in Figure 7, the device of present embodiment comprises: first judge module 71, defragmentation module 72 and memory module 73.
Wherein, first judge module 71, being used in rule to be stored is calipers then the time, judges whether there is idle long TCAM unit in the TCAM storage space.This TCAM storage space is spliced side by side by at least two TCAM, and long TCAM unit is by constituting with a plurality of TCAM unit adjacent in the delegation.Defragmentation module 72 is connected with first judge module 71, is used in the judged result of first judge module 71 the TCAM storage space being carried out defragmentation for not the time, obtains idle long TCAM unit.Memory module 73 is connected with defragmentation module 72, is used for the long TCAM unit according to the described free time of obtaining, and described rule to be stored is stored in the described TCAM storage space.
The above-mentioned functions module of the TCAM rale store device of present embodiment can be used for carrying out the flow process of method embodiment shown in Figure 2, and its concrete principle of work repeats no more, and please see the description of method embodiment for details.
The TCAM rale store device of present embodiment, in rule to be stored is that calipers is then the time, judge earlier whether the TCAM space also exists idle long TCAM unit, and when not having idle long TCAM unit, defragmentation is carried out in the TCAM space, obtain idle long TCAM unit, and then rule to be stored is stored in the TCAM storage space according to the long TCAM unit of the free time of obtaining, both solved calipers storage problem then, reduce the waste in TCAM space again, improved the TCAM operating factor of memory space.
The structural representation of the TCAM rale store device that Fig. 8 provides for another embodiment of the present invention.Present embodiment is based on realization embodiment illustrated in fig. 7, and as shown in Figure 8, the device of present embodiment also comprises: receiver module 81, second judge module 82, the 3rd judge module 83 and trigger module 84.
Above-mentioned each functional module is used for treating storage rule and carrying out respective handling before first judge module 71 is carried out decision operation.Concrete, receiver module 81 is used to receive rule to be stored.Second judge module 82 is connected with receiver module 81, is used for after receiver module 81 receives rule to be stored, judges according to the size of rule to be stored whether the TCAM storage space has the storage resources of enough storages rule to be stored.The 3rd judge module 83 is connected with second judge module 82, is used in the judged result of second judge module 82 when being, judge rule to be stored whether be calipers then.Trigger module 84 is connected with first judge module 71 with the 3rd judge module 83, is used in the judged result of the 3rd judge module 83 triggering first judge module 71 and carrying out the operation of judging the long TCAM unit that whether has the free time in the TCAM storage space when being.In addition, when the judged result of the 3rd judge module 83 for not the time, TCAM rale store device can be with in the idle TCAM unit of rale store to be stored in the TCAM storage space.Wherein, when the judged result of second judge module 82 for not the time, finish storage operation.
Above-mentioned each functional module can be used for carrying out the flow process of appropriate section among the method embodiment shown in Figure 3, and its concrete principle of work repeats no more, and please see the description of method embodiment for details.
The TCAM rale store device of present embodiment, receive rule to be stored by above-mentioned each functional module, and judge one by one whether the TCAM storage space has enough storage resources, the situation that enough storage resources are arranged judge rule to be stored whether be calipers then, in rule to be stored is that calipers judges whether there is idle long TCAM unit in the TCAM storage space then the time, and when not having idle long TCAM unit, the TCAM storage space is carried out defragmentation, put out idle long TCAM unit in order, and then rule to be stored is stored in the TCAM storage space based on the long TCAM unit of the free time of putting in order out, both solved calipers storage problem then, reduce the waste of TCAM resource again, improved the TCAM operating factor of memory space.
Further, the defragmentation module 72 of present embodiment comprises the first inquiry submodule 721 and the first arrangement submodule 722.
Wherein, the first inquiry submodule 721 is connected with first judge module 71, is used in the judged result of first judge module 71 inquiring about the TCAM unit in the TCAM storage space successively when denying, and obtains a plurality of idle TCAM unit that inquires at first.The first arrangement submodule 722, be connected with the first inquiry submodule 721, be used for inquiring about a plurality of idle TCAM unit that submodule 721 inquires according to first, to move with the rule in the TCAM unit between a plurality of idle TCAM unit that inquire, obtain and be in delegation and adjacent a plurality of idle TCAM unit, being in delegation and adjacent a plurality of idle TCAM unit of getting access to constitutes idle long TCAM unit.
Wherein, when the TCAM storage space was spliced side by side by two TCAM, the first arrangement submodule 722 specifically comprised: first processing unit, second processing unit and the 3rd processing unit.
Concrete, first processing unit, when being used for label and being even number in first the idle TCAM unit, two idle TCAM unit that inquires, rule in the TCAM unit adjacent with first idle TCAM unit before first idle TCAM unit is moved to first idle TCAM unit, and the label of first idle TCAM unit subtracted 1, promptly first processing unit specifically is used for first idle TCAM unit is moved on to the left side by the right side; The label whether label of judging second idle TCAM unit in two idle TCAM unit inquiring then equals current first idle TCAM unit adds 1.
Second processing unit, when being used for label in first the idle TCAM unit, two idle TCAM unit that inquires and being odd number, the label whether label of judging second idle TCAM unit in two idle TCAM unit that inquire equals first idle TCAM unit adds 1.Wherein, first the idle TCAM unit in two idle TCAM unit that inquire also comprises first the idle TCAM unit that obtains after being moved by first processing unit.
The 3rd processing unit, be used in the judged result of first processing unit or second processing unit for not the time, rule in the TCAM unit adjacent with second idle TCAM unit before second idle TCAM unit is moved in second idle TCAM unit, and the label of second idle TCAM unit subtracted 1, the label that the label up to current second idle TCAM unit equals current first idle TCAM unit adds till 1.Promptly the 3rd processing unit is used at two idle TCAM unit when non-conterminous, second idle TCAM unit moved forward so that second idle TCAM unit near first idle TCAM unit.In addition, the 3rd processing unit also is used in the judged result of first processing unit or second processing unit when being end operation.Promptly when the judged result of first processing unit or second processing unit when being, show to have obtained idle long TCAM unit, so need to finish move operation.
Above-mentioned each functional module or functional unit specifically can be used for carrying out method flow embodiment illustrated in fig. 4, and its concrete principle of work repeats no more, and sees the description of method embodiment for details.
Further, when the TCAM storage space was spliced side by side by two TCAM, the defragmentation module 72 of present embodiment can also be made of the second inquiry submodule 723 and the second arrangement submodule 724.
Concrete, the second inquiry submodule 723 is connected with first judge module 71, is used in the judged result of first judge module 71 inquiring about the TCAM unit in the TCAM storage space successively for not the time, obtains two nearest idle TCAM unit apart.The second arrangement submodule 724, be connected with the second inquiry submodule 723, be used for inquiring about two nearest idle TCAM unit apart that submodule 723 inquires according to second, to between two nearest idle TCAM unit, move with the rule in the TCAM unit, obtain and be in delegation and two adjacent idle TCAM unit, being in delegation and two adjacent idle TCAM unit of getting access to constitutes idle long TCAM unit.
Wherein, may comprise a plurality of TCAM unit of having used at a distance of between two nearest idle TCAM unit, also may not comprise with the TCAM unit but be in different row, based on this, concrete how each TCAM unit is moved and obtains the mode that is in delegation and adjacent two idle TCAM unit, present embodiment is not done qualification, decides according to actual conditions.Wherein, with mobile least number of times, can guarantee that the move mode of the priority level between the storage rule is preferred move mode.
Further, the memory module 73 of present embodiment comprises: first sub module stored 731 and second sub module stored 732.
First sub module stored 731, be used for priority in rule to be stored be lower than idle long TCAM unit on the calipers priority then that long TCAM unit is stored, when being higher than then priority of the calipers stored in the long TCAM of the next one unit of idle long TCAM unit, rule to be stored is stored in the long TCAM unit of free time.Second sub module stored 732, be used for priority in rule to be stored be higher than idle long TCAM unit on during then priority of the calipers stored of long TCAM unit, perhaps when the priority of rule to be stored is lower than then priority of the calipers stored in the long TCAM of the next one unit of idle long TCAM unit, according to the rule of having stored in the TCAM storage space, long TCAM unit to the free time moves, be lower than the calipers priority then of being stored in the last long TCAM unit of idle long TCAM unit to the priority that makes rule to be stored up to long TCAM cell moving with the free time, be higher than till the calipers priority then of being stored in the long TCAM of the next one unit of idle long TCAM unit, and rule to be stored be stored in the long TCAM unit of the free time after moving.
The above-mentioned functions submodule can be used for carrying out in the TCAM rale store method flow shown in Figure 3 the flow process that long TCAM unit to the free time of putting in order out moves, and its concrete principle of work repeats no more.
The TCAM rale store device of present embodiment, by above-mentioned each functional module or unit the idle TCAM unit of scattered distribution is moved arrangement, get access to idle long TCAM unit, and move by long TCAM unit and to realize calipers storage then to the free time, and handle by the TCAM storage space being moved arrangement, improve the TCAM operating factor of memory space, reduced the waste of TCAM resource.
In addition, by the description of the various embodiments described above as can be seen, various embodiments of the present invention are to put in order as required to the mobile arrangement of TCAM storage space, fragment problems when having solved calipers then with short regular shared TCAM, made full use of each TCAM unit of TCAM, reduce the cost of the network equipment, kept the original laxity of storage rule simultaneously, the efficient that has kept TCAM to search.
One embodiment of the invention provides a kind of network equipment, comprising: TCAM rale store device is used for required filtering rule of the network equipment etc. and is stored in the TCAM storage space.The network equipment of present embodiment can be switch, router etc.Wherein, the structure of TCAM rale store device and principle of work see the description of said apparatus embodiment and method embodiment respectively for details, do not repeat them here.
The network equipment of present embodiment comprises TCAM rale store device, can be used for carrying out the flow process of TCAM rale store method, fragment problems when having solved calipers equally then with short regular shared TCAM, made full use of each TCAM unit of TCAM, improve the TCAM operating factor of memory space, reduced the waste of TCAM resource, reduced the cost of the network equipment, keep the original laxity of storage rule simultaneously, the efficient that has kept TCAM to search.
One of ordinary skill in the art will appreciate that: all or part of step that realizes said method embodiment can be finished by the relevant hardware of programmed instruction, aforesaid program can be stored in the computer read/write memory medium, this program is carried out the step that comprises said method embodiment when carrying out; And aforesaid storage medium comprises: various media that can be program code stored such as ROM, RAM, magnetic disc or CD.
It should be noted that at last: above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit; Although with reference to previous embodiment the present invention is had been described in detail, those of ordinary skill in the art is to be understood that: it still can be made amendment to the technical scheme that aforementioned each embodiment put down in writing, and perhaps part technical characterictic wherein is equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution break away from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (13)

1. a three-state content addressing memory TCAM rale store method is characterized in that, comprising:
When rule to be stored is a calipers then the time, judge whether there is idle long TCAM unit in the TCAM storage space; Described TCAM storage space is spliced side by side by at least two TCAM, and described long TCAM unit is by constituting with a plurality of TCAM unit adjacent in the delegation;
If judged result is carried out defragmentation for not existing to described TCAM storage space, obtain the long TCAM unit of described free time;
Long TCAM unit according to the described free time of obtaining is stored in described rule to be stored in the described TCAM storage space.
2. TCAM rale store method according to claim 1 is characterized in that, described when rule to be stored be calipers then the time, judge whether exist in the TCAM storage space before the idle long TCAM unit, comprising:
Receive described rule to be stored;
Judge whether described TCAM storage space has the storage resources of the described rule to be stored of enough storages;
If judged result is the storage resources that the described rule to be stored of enough storages is arranged, judge described rule to be stored whether be calipers then;
If judged result is described rule to be stored be calipers then, carry out the operation judge the long TCAM unit that whether has the free time in the TCAM storage space.
3. TCAM rale store method according to claim 1 and 2 is characterized in that, described TCAM storage space is carried out defragmentation, obtains the long TCAM unit of described free time, comprising:
Inquire about the TCAM unit in the described TCAM storage space successively, obtain a plurality of idle TCAM unit that inquires at first;
According to a plurality of idle TCAM unit that inquires, to move with the rule in the TCAM unit between the described a plurality of idle TCAM unit that inquires, obtain and be in delegation and adjacent a plurality of idle TCAM unit, what get access to is in the long TCAM unit that constitutes the described free time with delegation and adjacent a plurality of idle TCAM unit.
4. TCAM rale store method according to claim 3 is characterized in that described TCAM storage space is spliced side by side by two TCAM, and the described a plurality of idle TCAM unit that inquires is two idle TCAM unit;
The a plurality of idle TCAM unit that described basis inquires is in delegation and adjacent a plurality of idle TCAM unit moving with the rule in the TCAM unit between the described a plurality of idle TCAM unit that inquires, obtaining, and comprising:
When the label of first idle TCAM unit in described two idle TCAM unit that inquire is even number, rule in the TCAM unit adjacent with described first idle TCAM unit before described first idle TCAM unit is moved to described first idle TCAM unit, and the label of described first idle TCAM unit subtracted 1, the label whether label of judging second idle TCAM unit in described two idle TCAM unit that inquire then equals current described first idle TCAM unit adds 1;
When the label of first idle TCAM unit in described two idle TCAM unit that inquire was odd number, the label whether label of judging second idle TCAM unit in described two idle TCAM unit that inquire equals described first idle TCAM unit added 1;
If the label that judged result is the label of described second idle TCAM unit is not equal to described first idle TCAM unit adds 1, rule in the TCAM unit adjacent with described second idle TCAM unit before described second idle TCAM unit is moved in described second idle TCAM unit, and the label of described second idle TCAM unit subtracted 1, the label that the label up to current described second idle TCAM unit equals current described first idle TCAM unit adds till 1.
5. according to claim 1 or 2 described TCAM rale store methods, it is characterized in that described TCAM storage space is spliced side by side by two TCAM;
Described described TCAM storage space is carried out defragmentation, obtains the long TCAM unit of described free time, comprising:
Inquire about the TCAM unit in the described TCAM storage space successively, obtain at a distance of two nearest idle TCAM unit;
According to described two nearest idle TCAM unit apart, move with the rule in the TCAM unit at a distance of between two nearest idle TCAM unit described, obtain and be in delegation and two adjacent idle TCAM unit, what get access to is in the long TCAM unit that constitutes the described free time with delegation and two adjacent idle TCAM unit.
6. TCAM rale store method according to claim 1 and 2 is characterized in that, the long TCAM unit of the described free time that described basis is obtained is stored in described rule to be stored in the described TCAM storage space, comprising:
When the priority of described rule to be stored is lower than the calipers priority then of being stored in the last long TCAM unit of long TCAM unit of described free time, when being higher than then priority of the calipers stored in the long TCAM of the next one unit of long TCAM unit of described free time, described rule to be stored is stored in the long TCAM unit of described free time;
When the priority of described rule to be stored is higher than then priority of the calipers stored in the last long TCAM unit of long TCAM unit of described free time, perhaps when the priority of described rule to be stored is lower than then priority of the calipers stored in the long TCAM of the next one unit of long TCAM unit of described free time, according to the rule of having stored in the described TCAM storage space, long TCAM unit to the described free time moves, be lower than the calipers priority then of being stored in the last long TCAM unit of long TCAM unit of described free time to the priority that makes described rule to be stored up to long TCAM cell moving with the described free time, be higher than till the calipers priority then of being stored in the long TCAM of the next one unit of long TCAM unit of described free time, and described rule to be stored be stored in the long TCAM unit of the free time after moving.
7. a three-state content addressing memory TCAM rale store device is characterized in that, comprising:
First judge module, being used in rule to be stored is calipers then the time, judges whether there is idle long TCAM unit in the TCAM storage space; Described TCAM storage space is spliced side by side by at least two TCAM, and described long TCAM unit is by constituting with a plurality of TCAM unit adjacent in the delegation;
The defragmentation module is used in the judged result of described first judge module described TCAM storage space being carried out defragmentation for not the time, obtains the long TCAM unit of described free time;
Memory module is used for the long TCAM unit according to the described free time of obtaining, and described rule to be stored is stored in the described TCAM storage space.
8. TCAM rale store device according to claim 7 is characterized in that, also comprises:
Receiver module is used to receive described rule to be stored;
Second judge module is used to judge whether described TCAM storage space has the storage resources of the described rule to be stored of enough storages;
The 3rd judge module is used in the judged result of described second judge module when being, judge described rule to be stored whether be calipers then;
Trigger module is used in the judged result of described the 3rd judge module triggering described first judge module and carrying out the operation of judging the long TCAM unit that whether has the free time in the TCAM storage space when being.
9. according to claim 7 or 8 described TCAM rale store devices, it is characterized in that described defragmentation module comprises:
First inquires about submodule, is used for inquiring about successively the TCAM unit of described TCAM storage space, obtains a plurality of idle TCAM unit that inquires at first;
The first arrangement submodule, be used for according to a plurality of idle TCAM unit that inquires, to move with the rule in the TCAM unit between the described a plurality of idle TCAM unit that inquires, obtain and be in delegation and adjacent a plurality of idle TCAM unit, what get access to is in the long TCAM unit that constitutes the described free time with delegation and adjacent a plurality of idle TCAM unit.
10. TCAM rale store device according to claim 9 is characterized in that described TCAM storage space is spliced side by side by two TCAM; The described a plurality of idle TCAM unit that inquires is two idle TCAM unit;
The described first arrangement submodule comprises:
First processing unit, when being used for label and being even number in described first the idle TCAM unit, two idle TCAM unit that inquires, rule in the TCAM unit adjacent with described first idle TCAM unit before described first idle TCAM unit is moved to described first idle TCAM unit, and the label of described first idle TCAM unit subtracted 1, the label whether label of judging second idle TCAM unit in described two idle TCAM unit that inquire then equals current described first idle TCAM unit adds 1;
Second processing unit, when being used for label in described first the idle TCAM unit, two idle TCAM unit that inquires and being odd number, the label whether label of judging second idle TCAM unit in described two idle TCAM unit that inquire equals described first idle TCAM unit adds 1;
The 3rd processing unit, be used in the judged result of described first processing unit or described second processing unit for not the time, rule in the TCAM unit adjacent with described second idle TCAM unit before described second idle TCAM unit is moved in described second idle TCAM unit, and the label of described second idle TCAM unit subtracted 1, the label that the label up to current described second idle TCAM unit equals current described first idle TCAM unit adds till 1.
11., it is characterized in that described TCAM storage space is spliced side by side by two TCAM according to claim 7 or 8 described TCAM rale store devices;
Described defragmentation module comprises:
Second inquires about submodule, is used for inquiring about successively the TCAM unit of described TCAM storage space, obtains at a distance of two nearest idle TCAM unit;
The second arrangement submodule, be used for according to described at a distance of two nearest idle TCAM unit, move with the rule in the TCAM unit at a distance of between two nearest idle TCAM unit described, obtain and be in delegation and two adjacent idle TCAM unit, what get access to is in the long TCAM unit that constitutes the described free time with delegation and two adjacent idle TCAM unit.
12., it is characterized in that described memory module comprises according to claim 7 or 8 described TCAM rale store devices:
First sub module stored, be used for priority in described rule to be stored be lower than the described free time long TCAM unit on the calipers priority then that long TCAM unit is stored, when being higher than then priority of the calipers stored in the long TCAM of the next one unit of long TCAM unit of described free time, described rule to be stored is stored in the long TCAM unit of described free time;
Second sub module stored, be used for priority in described rule to be stored be higher than the described free time long TCAM unit on during then priority of the calipers stored of long TCAM unit, perhaps when the priority of described rule to be stored is lower than then priority of the calipers stored in the long TCAM of the next one unit of long TCAM unit of described free time, according to the rule of having stored in the described TCAM storage space, long TCAM unit to the described free time moves, be lower than the calipers priority then of being stored in the last long TCAM unit of long TCAM unit of described free time to the priority that makes described rule to be stored up to long TCAM cell moving with the described free time, be higher than till the calipers priority then of being stored in the long TCAM of the next one unit of long TCAM unit of described free time, and described rule to be stored be stored in the long TCAM unit of the free time after moving.
13. a network equipment is characterized in that, comprises each described three-state content addressing memory TCAM rale store device of claim 7-12.
CN 201110166640 2011-06-20 2011-06-20 TCAM (ternary content addressable memory) rule storing method, device and network equipment Expired - Fee Related CN102289453B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110166640 CN102289453B (en) 2011-06-20 2011-06-20 TCAM (ternary content addressable memory) rule storing method, device and network equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110166640 CN102289453B (en) 2011-06-20 2011-06-20 TCAM (ternary content addressable memory) rule storing method, device and network equipment

Publications (2)

Publication Number Publication Date
CN102289453A true CN102289453A (en) 2011-12-21
CN102289453B CN102289453B (en) 2013-09-18

Family

ID=45335885

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110166640 Expired - Fee Related CN102289453B (en) 2011-06-20 2011-06-20 TCAM (ternary content addressable memory) rule storing method, device and network equipment

Country Status (1)

Country Link
CN (1) CN102289453B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105791455A (en) * 2014-12-26 2016-07-20 中兴通讯股份有限公司 Ternary content addressable memory TCAM space processing method and device
CN106302184A (en) * 2015-06-12 2017-01-04 华为技术有限公司 A kind of stream list item delivery method, stream list item store method, relevant apparatus and system
CN111078587A (en) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN111224879A (en) * 2018-11-23 2020-06-02 恒为科技(上海)股份有限公司 Method for expanding Ternary Content Addressable Memory (TCAM) bit width
CN113328948A (en) * 2021-06-02 2021-08-31 杭州迪普信息技术有限公司 Resource management method, device, network equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101035062A (en) * 2006-03-09 2007-09-12 中兴通讯股份有限公司 Rule update method for three-folded content addressable memory message classification
CN101364947A (en) * 2008-09-08 2009-02-11 中兴通讯股份有限公司 Rule matching method and system for control list access
CN101620623A (en) * 2009-08-12 2010-01-06 杭州华三通信技术有限公司 Method and device for managing list item of content addressable memory CAM

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101035062A (en) * 2006-03-09 2007-09-12 中兴通讯股份有限公司 Rule update method for three-folded content addressable memory message classification
CN101364947A (en) * 2008-09-08 2009-02-11 中兴通讯股份有限公司 Rule matching method and system for control list access
CN101620623A (en) * 2009-08-12 2010-01-06 杭州华三通信技术有限公司 Method and device for managing list item of content addressable memory CAM

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105791455A (en) * 2014-12-26 2016-07-20 中兴通讯股份有限公司 Ternary content addressable memory TCAM space processing method and device
CN105791455B (en) * 2014-12-26 2020-04-07 中兴通讯股份有限公司 Processing method and device for TCAM space
CN106302184A (en) * 2015-06-12 2017-01-04 华为技术有限公司 A kind of stream list item delivery method, stream list item store method, relevant apparatus and system
US10469388B2 (en) 2015-06-12 2019-11-05 Huawei Technologies Co., Ltd. Flow entry delivering method, flow entry storage method, related apparatus, and related system
CN106302184B (en) * 2015-06-12 2020-02-14 华为技术有限公司 Flow entry issuing method, flow entry storing method, related device and system
CN111224879A (en) * 2018-11-23 2020-06-02 恒为科技(上海)股份有限公司 Method for expanding Ternary Content Addressable Memory (TCAM) bit width
CN111078587A (en) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN111078587B (en) * 2019-12-10 2022-05-06 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN113328948A (en) * 2021-06-02 2021-08-31 杭州迪普信息技术有限公司 Resource management method, device, network equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN102289453B (en) 2013-09-18

Similar Documents

Publication Publication Date Title
CN102289453B (en) TCAM (ternary content addressable memory) rule storing method, device and network equipment
US7606236B2 (en) Forwarding information base lookup method
EP2643762B1 (en) Method and apparatus for high performance, updatable, and deterministic hash table for network equipment
US8345688B2 (en) System and method for managing flow of packets
US9219681B2 (en) System and method for storing flow entries in hardware tables
US8750144B1 (en) System and method for reducing required memory updates
US9577932B2 (en) Techniques for managing ternary content-addressable memory (TCAM) resources in heterogeneous systems
US7706375B2 (en) System and method of fast adaptive TCAM sorting for IP longest prefix matching
US20080080539A1 (en) Method for ternary contents address memory table management
CN102882810A (en) Rapid message transmitting method and device
CN101789908B (en) Fragmental message receiving and processing method and device
US9240959B2 (en) Method for packet classification and device therefor
CN102291472A (en) Network address lookup method and device
US20200328914A1 (en) Packet transmission
CN101834788B (en) Storage operation method, device and equipment of media access control address table items
US8990492B1 (en) Increasing capacity in router forwarding tables
CN101620623A (en) Method and device for managing list item of content addressable memory CAM
CN104734955A (en) Network function virtualization implementation method, wide-band network gateway and control device
US11570105B2 (en) Dynamic route profile storage in a hardware trie routing table
CN104836738A (en) Router hardware item resource management method and device, and network equipment
CN101364987B (en) Frame processing method, apparatus and system
CN102970239B (en) Flow processing method, flow processing device, router and flow processing system
CN102164080B (en) Routing address inquiry method and device
CN105335307B (en) A kind of loading method and device of acl rule
CN103812774A (en) TCAM based strategy configuration method, message processing method and corresponding device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130918

Termination date: 20210620

CF01 Termination of patent right due to non-payment of annual fee