摘要 |
The present invention discloses a method and an apparatus for setting a TCAM entry and relates to the field of communications, which are used to achieve an objective of improving utilization of a TCAM. The method for setting a TCAM entry includes: acquiring a number set formed by values of same fields in preset packets, where the packets are packets on which a same action needs to be performed, and the number set includes at least two numbers; acquiring a longest continuous mask of the number set; obtaining an acquisition result according to the longest continuous mask of the number set; and storing the acquisition result in a ternary content-addressable memory TCAM entry corresponding to the action. The solutions disclosed in the present invention are applicable to a scenario of setting a TCAM entry. |