The Open Systems Interconnection (OSI) Reference Model defines seven network protocol layers (L1-L7) used to communicate over a transmission medium. The upper layers (L4-L7) represent end-to-end communications and the lower layers (L1-L3) represent local communications.
Networking application aware systems need to process, filter and switch a range of L3 to L7 network protocol layers, for example, L7 network protocol layers such as, HyperText Transfer Protocol (HTTP) and Simple Mail Transfer Protocol (SMTP), and L4 network protocol layers such as Transmission Control Protocol (TCP). In addition to processing the network protocol layers, the networking application aware systems need to simultaneously secure these protocols with access and content based security through L4-L7 network protocol layers including Firewall, Virtual Private Network (VPN), Secure Sockets Layer (SSL), Intrusion Detection System (IDS), Internet Protocol Security (IPSec), Anti-Virus (AV) and Anti-Spam functionality at “wire-speed” (i.e., a rate of data transfer over a physical medium of the network over which data is transmitted and received).
Network processors are available for high-throughput L2 and L3 network protocol processing, that is, performing packet processing to forward packets at wire-speed. Typically, a general purpose processor is used to process L4-L7 network protocols that require more intelligent processing. Although a general purpose processor may perform such compute intensive tasks, it may not provide sufficient performance to process the data so that the data may be forwarded at wire-speed.
An Intrusion Detection System (IDS) application may inspect content of individual packets flowing through a network, and may identify suspicious patterns that may indicate an attempt to break into or compromise a system. One example of a suspicious pattern may be a particular text string in a packet followed by 100 characters later by another particular text string. Such content aware networking may require inspection of the contents of packets at wire speed. The content may be analyzed to determine whether there has been a security breach or an intrusion.
A large number of patterns and rules in the form of regular expressions (also referred to herein as regular expression patterns) may be applied to ensure that all security breaches or intrusions are detected. A regular expression is a compact method for describing a pattern in a string of characters. The simplest pattern matched by a regular expression is a single character or string of characters, for example, /c/ or /cat/. The regular expression may also include operators and meta-characters that have a special meaning. Through the use of meta-characters, the regular expression may be used for more complicated searches such as, “abc.*xyz.” That is, find the string “abc” followed by the string “xyz,” with an unlimited number of characters in-between “abc” and “xyz.” Another example is the regular expression “abc..abc.*xyz;” that is, find the string “abc,” followed two characters later by the string “abc,” and an unlimited number of characters later by the string “xyz.”
Content searching is typically performed using a search method such as, Deterministic Finite Automata (DFA) or Non-Deterministic Finite Automata (NFA) to process the regular expression.
Embodiments of the present invention provide a method, apparatus, computer program product, and corresponding system that may search an input stream for at least one regular expression pattern using at least one finite automaton.
According to one embodiment, a method may comprise operatively coupling a first memory and a second memory. The method may comprise operatively coupling at least one processor to the first memory and the second memory. The at least one processor may be configured to store a context for walking a given node, of a plurality of nodes of a given finite automaton of at least one finite automaton. The store may include a determination, based on context state information associated with the first memory, for accessing (i) the first memory and not the second memory or (ii) the first memory and the second memory.
The context may identify the given node and an offset, of a segment in a payload of an input stream received from the network, to enable the at least one processor to walk the given node with the segment, based on retrieving the context stored.
The context state information associated with the first memory may include a validity state, the validity state may indicate a valid or invalid state of the first memory.
The valid state may indicate that the first memory has a pending context stored and the invalid state may indicate that the first memory has no pending context stored.
The determination for accessing (i) the first memory and not the second memory, may be based on the validity state indicating the invalid state, and the determination for accessing (ii) the first memory and the second memory, may be based on the validity state indicating the valid state.
Based on the determination to (i) access the first memory and not the second memory, the at least one processor may be further configured to access the first memory to store the context in the first memory and update the context state information associated with the first memory.
To update the context state information associated with the first memory, the at least one processor may be further configured to change a validity state included in the context state information from an invalid state to a valid state to indicate that the first memory has a pending context stored.
Based on the determination to (ii) access the first memory and the second memory, the at least one processor may be further configured to access the first memory to retrieve a pending context stored in the first memory. The at least one processor may be further configured to access the second memory to store the pending context retrieved. The at least one processor may be further configured to access the first memory to store the context in the first memory and preserve the context state information associated with the first memory.
The first memory may be a register and a first field of the register may be configured to store the context state information and a second field of the register may be configured to store the context.
First read and write access times of the first memory may be faster relative to second read and write access times of the second memory.
The first read and write access times may be at least three times faster than the second read and write access times.
The first memory may be configured with a single entry for storing a single context, the second memory may be configured with multiple entries for storing multiple contexts, and the second memory may be maintained as a circular buffer.
The second memory may be configured to store a head pointer for the circular buffer and based on the determination to (ii) access the first memory and the second memory, the at least one processor may be further configured to access the first memory to retrieve a pending context stored in the first memory, access the second memory to store the pending context retrieved based on the head pointer, access the first memory to store the context in the first memory, and preserve the context state information associated with the first memory.
To store the pending context retrieved based on the head pointer, the at least one processor may be further configured to update the head pointer and store the pending context retrieved in an empty context entry of the second memory, the empty context entry being addressed by the head pointer updated.
The determination may be a store determination, and the at least one processor may be further configured to retrieve a pending context. The retrieval may include a retrieve determination, based on the context state information associated with the first memory, for accessing (iii) the first memory and not the second memory or (iv) the second memory and not the first memory.
The context state information associated with the first memory may include a validity state, the validity state indicating a valid or invalid state of the first memory.
The valid state may indicate that the first memory has the pending context stored and the invalid state may indicate that the first memory has no pending context stored.
The retrieve determination for accessing (iii) the first memory and not the second memory may be based on the validity state indicating the valid state, and the retrieve determination for accessing (iv) the second memory and not the first memory, may be based on the validity state indicating the invalid state.
Based on the retrieve determination to (iii) access the first memory and not the second memory, the at least one processor may be further configured to access the first memory to retrieve the pending context from the first memory and update the context state information associated with the first memory.
To update the context state information associated with the first memory, the at least one processor may be further configured to change a validity state included in the context state information from a valid state to an invalid state to indicate that the first memory has no pending context stored.
Based on the retrieve determination to (iv) access the second memory and not the first memory, the at least one processor may be further configured to access the second memory to retrieve the pending context and preserve the context state information associated with the first memory.
The second memory may be maintained as a circular buffer and may be configured to store a head pointer. To access the second memory to retrieve the pending context the at least one processor may be further configured to retrieve the pending context based on the head pointer.
To retrieve the pending context based on the head pointer, the at least one processor may be further configured to retrieve the pending context from a current entry location of the second memory addressed via the head pointer and update the head pointer to address a next entry location of the second memory immediately subsequent to the current entry location.
The context may include a plurality of fields and the plurality of fields may include a context entry type field that is based on a node type, of a plurality of node types, of the given node, the context entry type field signifying which fields, of the plurality of fields, are relevant for the node type.
The context entry may further include a match type field that is relevant based on the context entry type field, the match type field being based on the node type and used to determine whether the given node is configured to match a single instance or multiple consecutive instances of a given element in an input stream received from the network.
The context entry may further include an element field that is relevant regardless of the context entry type field and identifies the given element for matching at the given node.
The context entry may further include a next node address field that is relevant regardless of the context entry type field and identifies a next node.
The context entry may further include a count field that is relevant based on the context entry type field and identifies a count value, indicating a number of consecutive instances remaining for positively matching to the given element or having been positively matched to the given element, at the given node, based on the context entry type field.
The context entry may further include a discard unexplored context (DUP) field that is relevant regardless of the context entry type field and identifies whether to discard the context or walk the next node based on the context, in an event a complete match of at least one regular expression is detected in the input stream.
The context entry may further include a reverse walk direction field that is relevant regardless of the context entry type field and identifies a reverse or forward direction of walking.
The context entry may further include an offset field that is relevant regardless of the context entry type field and identifies an offset of a segment of a payload in the input stream for matching to the given element at the given node or to a next element at the next node, based on the context entry type field, the next element identified via metadata associated with the next node.
The at least one finite automaton may include a deterministic finite automaton (DFA) and at least one non-deterministic finite automaton (NFA), the given finite automaton may be a given NFA of the at least one NFA.
Another example embodiment disclosed herein includes an apparatus corresponding to operations consistent with the apparatus embodiments disclosed herein.
Further, yet another example embodiment may include a non-transitory computer-readable medium having stored thereon a sequence of instructions which, when loaded and executed by a processor, causes a processor to perform methods disclosed herein.
The foregoing will be apparent from the following more particular description of example embodiments of the invention, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating embodiments of the present invention.
Before describing example embodiments of the present invention in detail, an example security application in which the embodiments may be implemented and typical processing using deterministic finite automata (DFA) and non-deterministic finite automata (NFA) are described immediately below to help the reader understand inventive features disclosed herein.
The network services processor 100 may be configured to process Open System Interconnection (OSI) network L2-L7 layer protocols encapsulated in received packets. As is well-known to those skilled in the art, the OSI reference model defines seven network protocol layers (L1-L7). The physical layer (L1) represents the actual interface, electrical and physical that connects a device to a transmission medium. The data link layer (L2) performs data framing. The network layer (L3) formats the data into packets. The transport layer (L4) handles end to end transport. The session layer (L5) manages communications between devices, for example, whether communication is half-duplex or full-duplex. The presentation layer (L6) manages data formatting and presentation, for example, syntax, control codes, special graphics and character sets. The application layer (L7) permits communications between users, for example, file transfer and electronic mail.
The network services processor 100 may schedule and queue work (e.g., packet processing operations) for upper level network protocols, for example L4-L7, and enable processing of upper level network protocols in received packets to be performed to forward packets at wire-speed. By processing the protocols to forward the packets at wire-speed, the network services processor 100 does not slow down the network data transfer rate. The network services processor 100 may receive packets from the network interfaces 103a or 103b that may be physical hardware interfaces, and may perform L2-L7 network protocol processing on the received packets. The network services processor 100 may subsequently forward processed packets 101b through the network interfaces 103a or 103b to another hop in the network, a final destination, or through another bus (not shown) for further processing by a host processor (not shown). The network protocol processing may include processing of network security protocols such as Firewall, Application Firewall, Virtual Private Network (VPN) including IP Security (IPSec) and/or Secure Sockets Layer (SSL), Intrusion Detection System (IDS) and Anti-virus (AV).
The network services processor 100 may deliver high application performance using a plurality of processors (i.e., cores). Each of the cores (not shown) may be dedicated to performing data plane or control plane operations. A data plane operation may include packet operations for forwarding packets. A control plane operation may include processing of portions of complex higher level protocols such as Internet Protocol Security (IPSec), Transmission Control Protocol (TCP) and Secure Sockets Layer (SSL). The data plane operation may include processing of other portions of these complex higher level protocols.
The network services processor 100 may also include application specific co-processors that may offload the cores so that the network services processor 100 achieves high-throughput. For example, the network services processor 100 may include an acceleration unit 106 that may include a hyper non-deterministic automata (HNA) co-processor 108 for hardware acceleration of NFA processing and a hyper finite automata (HFA) co-processor 110 for hardware acceleration of DFA processing. The HNA 108 and HFA 110 co-processors may be configured to offload the network services processor 100 general purpose cores (not shown) from the heavy burden of performing compute and memory intensive pattern matching methods.
The network services processor 100 may perform pattern searching, regular expression processing, content validation, transformation, and security accelerate packet processing. The regular expression processing and the pattern searching may be used to perform string matching for AV and IDS applications and other applications that may require string matching. A memory controller (not shown) in the network services processor 100 may control access to a memory 104 that is operatively coupled to the network services processor 100. The memory may be internal (i.e., on-chip) or external (i.e., off chip), or a combination thereof, and may be configured to store data packets received, such as packets 101a for processing by the network services processor 100. The memory may be configured to store compiled rules data utilized for lookup and pattern matching in DFA and NFA graph expression searches. The compiled rules data may be stored as a binary image 112 that may include compiled rules data for both DFA and NFA, or multiple binary images separating DFA compiled rules data from NFA compiled rules data.
Typical content aware application processing may use either a DFA or an NFA to recognize patterns in content of received packets. DFA and NFA are both finite state machines, that is, models of computation each including a set of states, a start-state, an input alphabet (set of all possible symbols) and a transition function. Computation begins in the start-state and changes to new states dependent on the transition function.
The pattern is commonly expressed using a regular expression that includes atomic elements, for example, normal text characters such as, A-Z and 0-9, and meta-characters, such as, *, ^ and |. The atomic elements of a regular expression are the symbols (single characters) to be matched. Atomic elements may be combined with meta-characters that allow concatenation (+) alternation (|), and Kleene-star (*). The meta-character for concatenation may be used to create multiple character matching patterns from a single character (or sub-strings) while the meta-character for alternation (|) may be used to create a regular expression that can match any of two or more sub-strings. The meta-character Kleene-star (*) allows a pattern to match any number of times, including no occurrences of the preceding character or string of characters.
Combining different operators and single characters allows complex subpatterns of expressions to be constructed. For example, a subpattern such as (th(is|at)*) may match multiple character strings, such as: th, this, that, thisis, thisat, thatis, or thatat. Another example of a complex subpattern of an expression may be one that incorporates a character class construct [ . . . ] that allows listing of a list of characters for which to search. For example, gr[ea]y looks for both grey and gray. Other complex subpattern examples are those that may use a dash to indicate a range of characters, for example, [A-Z], or a meta-character “.” that matches any one character. An element of the pattern may be an atomic element or a combination of one or more atomic elements in combination with one or more meta-characters.
The input to the DFA or NFA state machine is typically a segment, such as a string of (8-bit) bytes, that is, the alphabet may be a single byte (one character or symbol), from an input stream (i.e., received packets). Each segment (e.g., byte) in the input stream may result in a transition from one state to another state. The states and the transition functions of the DFA or NFA state machine may be represented by a graph. Each node in the graph may represent a state and arcs (also referred to herein as transition arcs) in the graph may represent state transitions. A current state of the state machine may be represented by a node identifier that selects a particular node in the graph.
Using DFA to process a regular expression and to find a pattern or patterns described by a regular expression in an input stream of characters may be characterized as having deterministic run time performance. A next state of a DFA may be determined from an input character (or symbol), and a current state of the DFA, because there is only one state transition per DFA state. As such, run time performance of the DFA is said to be deterministic and the behavior can be completely predicted from the input. However, a tradeoff for determinism is a graph in which the number of nodes (or graph size) may grow exponentially with the size of a pattern.
In contrast, the number of nodes (or graph size) of an NFA graph may be characterized as growing linearly with the size of the pattern. However, using NFA to process the regular expression, and to find a pattern or patterns described by the regular expression in the input stream of characters, may be characterized as having non-deterministic run time performance. For example, given an input character (or symbol) and a current state of the NFA, it is possible that there is more than one next state of the NFA to which to transition. As such, a next state of the NFA cannot be uniquely determined from the input and the current state of the NFA. Thus, run time performance of the NFA is said to be non-deterministic as the behavior cannot be completely predicted from the input.
According to embodiments disclosed herein, content searching may be performed using DFA, NFA, or a combination thereof. According to one embodiment, a run time processor, co-processor, or a combination thereof, may be implemented in hardware and may be configured to implement a compiler and a walker.
The compiler may compile a pattern or an input list of patterns (also known as signatures or rules) into the DFA, NFA, or combination thereof. The DFA and NFA may be binary data structures, such as DFA and NFA graphs and tables.
The walker may perform run time processing, for example, actions that may identify an existence of a pattern in an input stream, or matching the pattern to content in the input stream. Content may be a payload portion of an Internet Protocol (IP) datagram, or any other suitable payload in an input stream. Run time processing of DFA or NFA graphs may be referred to herein as walking or traversing the DFA or NFA graphs, with the payload, to determine a pattern match. A processor configured to generate DFA, NFA, or a combination thereof, may be referred to herein as a compiler. A processor configured to implement run time processing of a payload using the generated DFA, NFA, or combination thereof, may be referred to as a walker herein. According to embodiments disclosed herein, the network services processor 100 may be configured to implement a compiler and a walker in the security appliance 102.
According to embodiments disclosed herein, the compiler 306 may generate the binary image 112 by processing a rule set 310 that may include a set of one or more regular expression patterns 304 and optional qualifiers 308. From the rule set 310, the compiler 306 may generate a unified DFA 312 using subpatterns selected from all of the one or more regular expression patterns and at least one NFA 314 for at least one pattern in the set of one or more regular expression patterns 304 for use by the walker 320 during run time processing, and metadata (not shown) including mapping information for transitioning the walker 320 between states (not shown) of the unified DFA 312 and states of the at least one NFA 314. According to embodiments disclosed herein, each NFA that is generated may be for a particular pattern in the set, whereas a unified DFA may be generated based on all subpatterns from all patterns in the set.
The unified DFA 312 and the at least one NFA 314 may be represented data structure-wise as graphs, or in any other suitable form, and the mapping in the metadata may be represented data structure-wise as one or more tables, or in any other suitable form. According to embodiments disclosed herein, if a subpattern selected from a given pattern is the entire given pattern, then no NFA is generated for the given pattern.
The walker 320 may be configured to walk the unified DFA 312 and the at least one NFA 314 with a payload by transitioning states of the unified DFA 312 and the at least one NFA based on processing (also referred to herein as consuming) segments from the payload in the received packets 101a. Processing may including updating a current offset within the payload from a current segment to another segment. Updating the current offset may be based on a direction of walking, for example, the walker 320 may walk the unified DFA 312 or the at least one NFA 314 in a forward or reverse direction, incrementing the current offset based on the forward direction of the walk and decrementing the current offset based on the reverse direction of the walk. As such, the walker 320 walks the payload through the unified DFA 312 and the at least one NFA 314.
The rule set 310 may include a set of one or more regular expression patterns 304 and may be in a form of a Perl Compatible Regular Expression (PCRE) script file or any other suitable form currently known or hereinafter developed. PCRE has become a de facto standard for regular expression syntax in security and networking applications. As more applications requiring deep packet inspections have emerged or more threats have become prevalent in the Internet, corresponding signatures/patterns to identify virus/attacks or applications have also become more complex. For example, signature databases have evolved from having simple string patterns to regular expression (regex) patterns with wild card characters, ranges, character classes, and advanced PCRE signatures.
As shown in
A subpattern is a set of one or more consecutive elements from a pattern, wherein each element from the pattern may be represented by a node in a DFA or NFA graph, for purposes of matching segments from the payload. An element, as described above, may be a single text character represented by a node or a character class represented by a node. The compiler 306 may determine which subpatterns in the pattern are better suited for NFA based on whether or not a subpattern is likely to cause excessive DFA graph explosion, as described above in reference to
Determining the match of the entire pattern may be found by utilizing match results from the unified DFA, the at least one NFA, or a combination thereof. According to embodiments disclosed herein, if a payload in the received packets 101 includes content that matches a subpattern selected 318 from a pattern 316, the walker may transition to walk at least one NFA for the pattern 318. The walker 320 may report a match of the subpattern selected 318 and an offset that identifies a location in the received packets of the last character of the matching subpattern as an end offset for the subpattern in the payload.
A subpattern match may be a partial match for the pattern if the subpattern is a subset of the pattern. As such, the walker 320 may continue the search for the remainder of the pattern in the payload by walking at least one NFA for the pattern, in order to determine a final match for the pattern. It should be understood that the pattern may traverse one or more payloads in the received packets 101a.
According to embodiments disclosed herein, the HNA 108 may be configured to read at least one instruction 453 from an instruction queue 454. The instruction queue 454 may be configured to store the at least one instruction 453 that may be sent by a host (not shown) to be processed by the HNA 108. The at least one instruction 453 may include at least one job, such as S1459a, S2459b, or S3459c. Each at least one job may be determined based on partial match results identified by the HFA co-processor 110 of
A given job of the at least one job may indicate a given NFA of the at least one NFA 314, at least one given node of the given NFA, at least one given offset in a given payload, as well as at least one walk direction, each at least one walk direction corresponding to one node of the at least one given node. Each at least one job may include results of processing by the HFA, enabling the HNA to advance a match in the given NFA for a given pattern of the at least one pattern 304 that corresponds to the given subpattern. As such, each job represents partial match results determined by the HFA co-processor 110 in order to advancing the match of the given pattern by the HNA co-processor 108.
The HNA 108 may process the at least one instruction 453 by reading at least one pointer (not shown), or other suitable instruction information, stored therein. The at least one pointer may include an input buffer pointer (not shown) to an input buffer 458. The at least one instruction 453 may also include a payload pointer (not shown) to a payload 462, a result buffer pointer (not shown) to a match result buffer 466, a save buffer pointer (not shown) to a save buffer 464, and a run stack pointer (not shown) to a run stack 460.
The input buffer 458, run stack 460, and the save buffer 464 may be referred to herein as an input stack, run stack, and save stack, respectively, although the input buffer 458, run stack 460, and save buffer 464 may or may not exhibit the Last In First Out (LIFO) properties of a stack. The input buffer 458, run stack 460, and save buffer 464 may be located within a same or different physical buffer. If located within the same physical buffer, entries of the input stack 458, run stack 460, and save stack 464 may be differentiated based on a field setting of the entries, or differentiated in any other suitable manner. The input stack 458 and the run stack 460 may be located in the same physical buffer that may be on-chip and the save buffer 464 may be located in another physical buffer that may be off-chip.
The at least one job, such as S1459a, S2459b, or S3459c, of the at least one instruction 453, may be stored in the input stack 458 for processing by the HNA 108. The at least one job of the at least one instruction may each belong to a same given payload, such as the payload 462, that was processed by the HFA 110.
The HNA 108 may be configured to load (i.e., fetch or retrieve) at least one job from the input buffer 458, such as jobs S1459a, S2459b, or S3459c, based on the input buffer pointer. The HNA 108 may push (i.e., store) the at least one job to the run stack 460. The HNA 108 may pop (i.e., read, fetch, load, etc.) a given job from the run stack, such as entry S1459a, S2459b, or S3459c, and process the given job. Each at least one job (e.g., S1459a, S2459b, or S3459c) may include a payload offset (not shown) to a segment (not shown) of the payload 462, and a pointer to a graph 457, that may be a given finite automata of at least one finite automata, such as the at least one NFA 314 of
The HNA 108 may load (i.e., fetch) the graph 457 from the graph memory 456 that may be included in the binary image 112 of
As the HNA 108 may process the graph 457 using payload segments from the payload 462, pushing and popping entries to/from the run stack 460 to save and resume its place in the graph 457. For example, the HNA 108 may need to save its place in the graph if a walked node presents multiple options for a next node to walk. For example, the HNA 108 may walk a node that presents multiple processing path options, such as a fork represented in the graph. According to embodiments disclosed herein, nodes of a DFA or NFA may be associated with a node type. Nodes associated with a split or variable count node type may present multiple processing path options. The split and variable count node types are further disclosed below in reference to
According to embodiments disclosed herein, the HNA 108 may be configured to select a given path, of the multiple processing paths, and push an entry to the run stack 460 that may enable the HNA 108 to return and proceed along the unselected path, of the multiple processing paths, based on determining a mismatch (i.e., negative) result at walked node along the selected path. As such, pushing the entry on the run stack 460 may save a place in the graph 457 that represents unexplored context. The unexplored context may indicate a given node of the graph 457 and a corresponding payload offset to enable the HNA 108 to return to the given node and walk the given node with the given segment of the payload 462, as the given segment may be located at the corresponding payload offset in the payload 462. As such, the run stack 460 may be used to enable the engine to remember and later walk an unexplored path of the graph 457. Pushing or storing an entry that indicates a given node and a corresponding offset in a given payload may be referred to herein as storing unexplored context, thread or inactive thread. Popping, fetching, or loading an entry that indicates the given node and the corresponding offset in the given payload in order to walk the given node with a segment located at the corresponding offset in the given payload may be referred to herein as activating a thread. Discarding an entry that indicates the given node and the corresponding offset in the given payload may be referred to herein as flushing an entry or retiring a thread.
The run stack 460 may enable the HNA 108 to save its place in the graph 457 in an event that an end of the payload 462 is reached while walking segments of the payload 462 with the graph 457. For example, the HNA 108 may determine that the payload or a portion of the payload 462 is partially matching a given pattern and that a current payload offset of the payload 462 is an end offset of the payload 462. As such, the HNA 108 may determine that only a partial match of the given pattern was found and that the entire payload 462 was processed. As such, the HNA 108 may save the run stack 460 content to the save buffer 464 to continue a walk with a next payload corresponding to a same flow as the payload 462 that was processed. The save buffer 464 may be configured to store at least one run stack entry of the run stack 460, mirroring a running state of the run stack 460 in an event the entire payload 462 is processed.
Based on finding a final (i.e., entire or complete) match of the pattern, the HNA may pop and discard entries in the run stack 460 that are associated with the current job, for example the job loaded from the input buffer, such as S1459a, and save match results (not shown) to the match results buffer 466. Alternatively, the HNA 108 may continue processing entries of the run stack 460 that are associated with the current job as all possible matching paths may be of interest.
The match results may include a node address associated with a node at which the final match of the pattern was determined. The node at which the final match of the pattern was determined may be referred to herein as a marked node. The node address, or other identifier of a final match location in the graph 457, identifier of the matching pattern, length of the matching pattern, or any other suitable match results or a combination thereof, may be included in the match results.
Based on processing all of the run stack entries associated with the current job, the HNA 108 may load a next job from the run stack that has been previously loaded from the input buffer 458 (e.g., S2459b), as the HNA 108 may be configured to process jobs of the instruction 453 sequentially. As such, the HNA 108 may fetch a next graph (not shown) from the graph memory 456 walk the next graph with one or more payload segments from the payload 462 identified by the next job, and continue to process additional jobs until the run stack 460 is empty.
Based on finding a mismatch of the payload 462 while walking the graph 457 with the payload 462, the HNA 108 may pop an entry from the run stack 460 that is associated with the current job (e.g., S1459a) and walk a next node with a next segment of the payload 462 based on content of the entry popped. If the run stack 460 does not include an entry associated with the current job, the HNA 108 may be done with the current job and may load a next job from the run stack 460 that has been previously loaded from the input buffer 458 (e.g., S2459c). As such, the HNA 108 may be configured to walk a next graph based on the next job loaded, and continue to process additional jobs until the run stack 460 is empty.
According to embodiments disclosed herein, the walker 320 functionality of the HNA 108 may include optimizing matching at least one regular expression pattern to an input stream by walking a given NFA in a speculative manner. The speculative manner may include walking at least two nodes of the given NFA, in parallel, with a segment, at a given offset within a payload of a packet in the input stream. The walking may include determining a match result for the segment, at the given offset within the payload, at each node of the at least two nodes. The walking may further include determining at least one subsequent action for walking the given finite automaton, based on an aggregation of each match result determined. Such optimized matching of the at least one regular expression pattern to the input stream by walking the given NFA in the speculative manner is further disclosed below.
In the example embodiment, the input stream may include a packet (not shown) with a payload 542. The regular expression pattern 502 is a pattern “h[^\n]*ab” that specifies the character “h” followed by an unlimited number of consecutive characters not matching a newline character (i.e., [^\n]*). The unlimited number may be zero or more. The pattern 502 further includes the characters “a” and “b” consecutively following the unlimited number of characters not matching the newline character. In the example embodiment, the payload 542 includes segments 522a-d (i.e., h, x, a, and, b), with respective offsets 520a-d (i.e., 0, 1, 2, and 3) in the payload 542.
It should be understood that the regular expression pattern 502, NFA graph 504, payload 542, segments 522a-d, and offsets 520a-d represent examples used for illustrative purposes and that the system, methods, and corresponding apparatus disclosed herein may apply to any suitable regular expression pattern, NFA graph, payload, segments, and offsets. Further, it should be understood that the NFA graph 504 may be a sub-section of a larger NFA graph (not shown). In addition, the payload 542 may a portion of a larger payload (not shown) and the portion may be at the beginning, end, or any location of the larger payload, resulting in offsets different from those in the example embodiment.
In the example embodiment, the NFA graph 504 is configured to match the regular expression pattern 502 to the input stream. For example, the NFA graph 504 may be a graph including a plurality of nodes generated by the compiler 306, such as nodes N0506, N1508, N2510, N3512, N4514, and N5515. The node N0506 may represent a starting node for the pattern 502, and the node N5515 may represent a marked node for the pattern 502. The marked node N5515 may be associated with an indicator that reflects a final (i.e., entire or complete) match of the pattern 502 matched to the input stream. As such, the walker 320 may determine that the pattern 502 is matching in the input stream based on traversing the marked node N5515.
According to embodiments disclosed herein, the walker 320 may walk the segments 522a-d of the payload 542 one segment at a time through the NFA graph 504 to match the regular expression pattern 502 to the input stream. A given segment of the segments 516 for walking a given node may be determined based on its respective offset of the offsets 518 being a current offset within the payload 542. According to embodiments disclosed herein, the walker 320 may update the current offset by incrementing or decrement the current offset. For example, the walker 320 may walk the NFA graph 504 in a forward or reverse direction, and, thus, may walk segments from the payload 542 in a forward 543 or a reverse 546 direction, by respectively incrementing or decrementing the current offset.
The nodes N0506, N2510, N3512, and N4514, may be configured to match a respective element to a given segment of the payload 542, whereas nodes N1508 and N5515 may be nodes of a node type indicating no matching functionality, and, thus, would not process from the payload 542. In the example embodiment, node N1508 is split node presenting multiple transition path options to the walker 320. For example, walking the split node N1508 presents epsilon paths 530a and 530b. According to embodiments disclosed herein, the walker 320 may select a given path of the multiple paths 530a and 530b based on an implicit setting that is in mutual agreement with the walker 306. For example, the compiler 306 may generate the NFA graph 504 based on an implicit understanding that the walker 320 follows a deterministic path, for example, with the implicit understand that the walker 320 selects an upper epsilon path 530a based on walking the split node 508. According to embodiment disclosed herein, the upper epsilon path 530a may be selected as the upper epsilon path 530a represents a lazy path. The lazy path may be the path representing the shortest possible match of elements.
According to embodiments disclosed herein, the split node 508 may be associated with split node metadata (not shown) to present the multiple path options. For example, the split node metadata may indicate, either directly or indirectly, multiple next nodes, such as the nodes N2510 and N3512, in the example embodiment. If the multiple next nodes are indicated directly, the metadata may include absolute addresses or pointers to the next nodes N2510 and N3512. If the multiple next nodes are indicated indirectly, the metadata may include indices or offsets that may be used to resolve absolute addresses for or pointers to the next nodes N2510 and N3512. Alternatively, other suitable forms for directly or indirectly indicating the multiple next nodes may be used.
The implicit understanding may include configuring the walker 320 to select a given next node of multiple next nodes based on node metadata included in a particular entry location within the split node metadata. The compiler 306 may be configured to generate the split node metadata including an indication of the given next node at the designated entry location. As such, the implicit understanding that a given path, such as the upper epsilon path 530a, will be selected by the walker 320 at the split node N1508 may be used by the compiler 306 generating the NFA graph 504.
As shown in the table 538, the processing cycles 540a-h may include walking a current node 530 with a segment from the payload 542 at a current offset 532 to determine a match result 534 and walker action 536 based on the match result 534. In the example embodiment, the node N0506 may have a character node type. For example, the node N0506 may be a character node that is configured to match the character “h” in the input stream. In the example embodiment, the walker 320 may walk the starting node N0506 with the segment 522a (i.e., “h”) at the current offset 520a in the processing cycle 540a.
The walker 320 may determine that the match result 534 is a positive match result as the segment 522a matches character “h” at the node N0506. As specified by the compiler 306 via metadata (not shown) associated with the starting node N0506, the walker 320 may walk in a forward direction and fetch the next node indicated by the metadata associated with the node N0506 and may increment the current offset from 520a (i.e., “0”) to 520b (i.e., “1”). The next node indicated by the node N0506 is the split node N1508 in the example embodiment. As such, the walker 320 takes the action 536 for the processing cycle 540a that includes updating the current offset to “1” in the payload 542 and transitioning to the split node N1508. Transitioning may include fetching (also referred to herein as loading) the split node N1508.
As the split node N1508 presents multiple transition path options, such as the epsilon paths 530a and 530b, the action 536 for the processing cycle 540b may include selecting the upper epsilon path 530a and fetching the node N2510 independent of the payload 542 and without consuming (i.e., processing) from the payload 542. Since no matching function is performed by the split node N1508, the current offset/segment 532 are unchanged, and, thus, payload is not processed for the processing cycle 540b.
Since the split node N1508 presents multiple path options, the action 536 may include storing unexplored context, such as by storing an indirect or direct identifier of the node N3512 and the current offset 520b (i.e., “1”). The selected transition path may be referred to herein as the current or active thread and each untraversed transition path that is stored may be referred to herein as a stored thread. Each thread may be identified by a corresponding node identifier and offset in a payload. As such, the unexplored context may identify an unexplored thread (i.e., path).
Storing the unexplored context may enable the walker 320 to remember to return to the node N3512 to walk the node N3512 with the segment “1” at the offset 520b in the payload 542 in an event a negative match result occurs along the selected partially matching path, for example, if the negative match result is determined at the node N2510 or nodes along a path extending from the node N2510. According to embodiments disclosed herein, the unexplored context may be marked with a Discard Unexplored Processing (DUP) indicator that indicates to the walker 320 whether to discard or process the unexplored context in an event a final match for the pattern 502 is identified along the selected transition path.
For example, based on reaching the marked node N5515 that indicates the final (i.e., complete or entire) match for the pattern 502 in the input stream, the walker 320 may utilize the DUP indicator to determine whether to process the unexplored context by walking the node N3512 with the segment “x” at the offset 520b in an effort to determine another path of the NFA graph 504 that matches the pattern 502, or whether to discard the unexplored context. Marking the unexplored context with the DUP indicator may include marking the unexplored context in any suitable manner, such as by setting a bit or field associated with the unexplored context to true, to signify desired processing of the stack entry, or false to signify a desired discard of the stack entry.
Whether or not a stored thread is traversed may be determined by the compiler 306. For example, the compiler 306 may control whether or not the DUP indicator is set by configuring a setting in corresponding metadata for each node. Alternatively, the compiler 306 may configure a global setting included in global metadata associated with the finite automata, specifying that all stored threads are to be traversed, enabling all possible matches to be identified
In the example embodiment, the selection of the epsilon transition path 530a may result in detecting a match failure at the node N2510 or at a subsequent node, such as N4514, of the current thread. As such, if a match failure is detected, the stored thread for the epsilon transition path 530b may then be traversed. Alternatively, if specified by the compiler 306, the epsilon transition path 530b may be traversed regardless of whether or not traversing the epsilon transition path 530b results detection of a match failure.
Storing the untraversed transition path may include pushing an entry on a stack, such as the run stack 460 of
According to the example embodiment, based on selecting the upper path (i.e., the epsilon transition path 530a) the walker 320 may fetch node the N2510 and try to match the segment 522b (i.e., “x”) at the current offset 520b (i.e., “1’) to the element “a” of the node N2510 in the processing cycle 540c. Since “x” does not match element “a” at the node N2510, the action 536 for the processing cycle 540c may include popping an entry from the run stack 460. The entry popped 544b may be a most recently popped entry, such as a stored entry 544a indicating the node N3512 and offset 520b (i.e., “1”) in the example embodiment.
The walker 320 may transition and walk the node N3512 and with the segment “x” located at the offset 520b in the payload 542. As such, the processing cycle 540d shows the match result 534 is positive for processing cycle 540d. The action 536 for the processing cycle 540d may include updating the current offset to the offset 520c and transitioning back to the split node N1508 that may be a next node indicated by the node N3512.
Since all arcs transitioning from the split node 508 are epsilon transitions, the walker 320 may again select a path of the multiple path options and does not consume (i.e., process) from the payload 542 as the current offset is not updated for the processing cycle 540e. In the example embodiment, the walker 320 again selects the epsilon transition path 530a. As such, the walker 320 again stores a thread by pushing node N3512 and the current offset, now 520c (i.e., “2”), on the run stack 460. As shown for processing cycle 540f, the walker 320 fetches node N2510 and matches the segment 522c (i.e., “a”) at offset 520c (i.e., “2”) to the element “a” of the node N2510. Since “a” matches at the node N2510, the walker 320 updates the current offset to 520d (i.e., “3”) and transitions to the node N4514 that is specified by the node N2510 metadata as configured by the compiler 306.
As such, for the processing cycle 540g, the walker 320 may fetch the next node N4514 and the next segment 522d (i.e., “b”) at the offset 520d. Since “b” matches at the node N4514, the walker 320 may transition to the next node N5515. The node N5515 is a marked node associated with an indicator signifying a final (i.e., complete or entire) match of the regular expression pattern 502 in the input stream. Thus, for the processing cycle 540h the walker 320 may discontinue the walk along the current path and report the final match by storing an entry in the match result buffer 466. The walker 320 may then check the run stack 460 for stored threads and either discard the stored threads or activate them as indicated by the corresponding DUP indicator. As such, the walker 320 pops the entry that identifies the node N3512 and the offset 520 (i.e., “2”), and determines whether to activate the stored thread by walking the node N3512 with the segment 522c at the offset 520c or discard the stored thread according to the DUP indicator associated with the popped entry.
As shown in the table 538 of
Performance optimization gained from embodiments disclosed herein may be based on an observation that a given segment at a given offset may be processed by at least two nodes in an NFA and that for a majority (e.g., 99%) of the time that the given segment at the given offset is processed by the at least two nodes, the given segment fails to match at a first node of the at least two nodes and matches at a second node of the at least two nodes. For example, in the example embodiment of
According to embodiments disclosed herein, match performance may be optimized by processing the segment at the given offset at each node of the at least two nodes in parallel. Processing the at least two nodes in parallel may be referred to herein as speculative processing. Embodiments disclosed herein may be based on the assumption that a matching operation at a selected node of at least two nodes will result in a mismatch. The selected node of the at least two nodes may be referred to herein an element node. A non-selected node of the at least two nodes, that would be traversed based on a mismatch at the selected node, may be referred to herein as a parallel node, and may be processed, speculatively, in a same processing cycle with the same segment being processed by the selected node, to improve match performance. As described in reference to
The speculative processing rule 578b may be of particular interest as it optimizes match performance by matching at the element node and the parallel node, in parallel, as the action 576 indicates updating the offset and no transition. As such, the speculative processing rule 578b enables the element node and the parallel node to process a next segment, in parallel, obviating memory access for node fetching.
The subsequent action 576 is directed to providing the subsequent action for the element node if the match result for the element node is positive, as the parallel node was processed speculatively. For example, if the match result at the element node is positive, the subsequent action 576 includes updating the current offset in the payload and transitioning to a next node, the next node being specified by metadata associated with the element node. If the match result for the element node is positive then the match result for the parallel node is used to determine whether or not the subsequent action 576 includes a push of the parallel node and the current offset in order to store unexplored context.
For example, speculative processing entry 578a pushes an entry to the run stack 460 to enable the walker 320 to return to the parallel node with a segment at the current offset because returning may yield another partially matching thread in the NFA graph. However, if the match result at the parallel node is a negative match result, as is the case for the lazy speculative processing rule 578c, then unexplored context is not pushed on the stack as returning to the parallel node with the segment at the current offset would not advance a partial match of the pattern. As such, performance of matching may be optimized by the lazy speculative processing rule 578c as well, since the lazy speculative processing rule 578c obviates at least one set of push and pop operations for the matching.
As shown by the lazy speculative processing rule 578d, based on the aggregation of the match result of the parallel node 572 and the match result of the element node 574 including a negative match result at each node, the at least one subsequent action may include discontinuing the walk of a given path. A next segment, at a next given offset within the payload, may walked based on sensing unexplored context, such as by checking the run stack 460 for a stored thread and popping the stored thread if stored. The method may terminate the walk based on not sensing the unexplored context.
As shown by lazy speculative processing rules 578a and 578c, based on the aggregation of the match result of the element node 574 including a positive match result for the segment at the element node and the match result of the parallel node 572 including a positive match result or a negative match result for the segment at the parallel node, the at least one subsequent action includes updating the given offset to produce a next offset and transitioning to a next node. The next node may be identified based on metadata associated with the element node. As such the next node may be walked with a next segment, at the next offset within the payload. As shown by the lazy speculative processing rule 578a, based on the positive match result for the segment at the parallel node, the least one subsequent action may further include storing an unexplored context in a stack entry and pushing the stack entry onto a stack. The unexplored context identifying, either directly or indirectly, the parallel node and the given offset.
Similar to the embodiment of
According to the example embodiment of
According to the example embodiment of
As shown for processing cycle 554c, the walker 320 may determine a negative match result for the segment 522b (i.e., “x”) at the element node N2510 and a positive match result at the parallel node N3512. An aggregation of such match results maps to the lazy speculative processing rule entry 578b of
As shown for processing cycle 554d, the walker 320 walks the element node N2510 and the parallel node N3512 with the segment 522c (i.e., “a”) at the updated offset which is the offset 520c (i.e., “2”). The match result 534′ is positive at both the element node N2510 and the parallel node N3512 as the segment “a” matches the element “a” at node N2510 and also matches the “^\n” element at node N3512, as “a” is not a newline character. As such, an aggregation of the positive match results 534′ for the processing cycle 554d map to the lazy speculative processing rule entry 578a of
According to the example embodiment, the current offset may be updated to 520d (i.e., “3”) and the node N4514 may be fetched transitioning the walker 320. A positive match result for the segment 522d (i.e., “b”) may be determined for the processing cycle 554e at the node N4514 and the walker 320 may fetch the marked node N5515, transitioning to the marked node N5515 that may be specified as a next node for the node N4514 in metadata associated with the node N4514. Since the node N5515 is a marked node, the walker may store the final match result to the match result buffer 466 and discontinue walking the active thread (e.g., the current path) and activating a stored thread if the run stack 460 is non-empty.
For example, walker 320 may check the run stack 460 for an empty status. In the example embodiment the run stack 460 is non-empty as unexplored context was pushed to the run stack 460 in the processing cycle 554d. As such, the walker 320 may pop the unexplored context that indicates advancing the walk to the parallel node N3512 with the segment 522d (i.e., “b”) at the offset 520d (i.e., “3”) and may determine whether to discard the unexplored context or process the unexplored context based on the DUP indicator associated with the stack entry, as disclosed above. As shown in the table 550 of the example embodiment, the number of processing cycles for matching the payload 542 to the pattern 502 is six, which is a reduced number as compared with the eight processing cycles used in the example embodiment of
According to embodiments disclosed herein, the variable count node N1N3′ 607 may be configured to identify a given element, such as the character class 611 (i.e., [^\n]), a variable number of instances 613, such as infinite, as indicated by the variable count node. The variable number of instances 613 may be at least zero times or any other suitable number of instances. It should be understood that the given element character class 611 is for illustrative purposes of the example embodiment and that the given element may be any suitable element being matched by the variable count node N1N3′.
A variable count node is a node that may match an element a variable number of times, the number of times may be defined by a range (e.g., zero to five times). A variable count node may be one of four types of variable count nodes: a lazy, greedy, possessive, or all match node. The variable count lazy node may be configured to find a shortest possible match of elements within the range. A variable count greedy or possessive node may be configured to find the longest possible match of elements within the range. A variable count all match node may be configured to return all matches in the payload.
The variable count lazy node may be configured to process (i.e., consume) a single instance of a segment from the payload based on a mismatch of a segment at a next node identified by metadata associated with the variable count lazy node. The variable count greedy node may be configured to process consecutive segments from the payload until a mismatch of one of the consecutive segments is determined at the variable count greedy node or until the variable count greedy node has processed (i.e., consumed) the total number of the variable number of consecutive segments.
In the example embodiment of
According to embodiments disclosed herein, each node of the NFA may be associated with metadata that includes at least four fields, such as a node type, element, count, and next node, although one or more of the at least four fields may not be applicable based on the node type.
The metadata 609 associated with the variable count lazy node N1N3′ 607 may include a count (not shown) for tracking a total number (not shown) of consecutive instances of the element 611 positively matching in the payload to enable a comparison of the total number to the variable number 613. Alternatively, the count may be initially configured to indicate the variable number 613 and may be decremented for each consecutive positive match such that the count reflects a number of positively matching instances remaining.
According to embodiments disclosed herein, the walker 320 may be configured to walk the NFA graph 604 in a speculative manner to optimize performance of a match of the regular expression pattern 502 in the input stream.
Since variable count lazy node N1N3′ 607 is lazy, the action 626 for the processing cycle 628b may include storing the unexplored context, such as by storing an indirect or direct identifier of the node N1N3′ 607 and the current offset 520b (i.e., “1”) and advancing to the next node 617 identified by the variable count lazy node N1N3′ 607 without updating the current offset. As such, no payload is processed by the variable count lazy node N1N3′ 607 for the processing cycle 628a.
Storing the unexplored context may enable the walker 320 to remember to return to the variable count lazy node N1N3′ 607 to walk the variable count lazy node N1N3′ 607 with the segment “x” at the offset 520b in the payload 542 in an event a negative match result occurs along the selected partially matching path, for example, if the negative match result is determined at the node N2610 or nodes along a path extending from node N2610. To store the unexplored context, the walker 320 may push 630a an entry on the run stack 460 that includes an identifier for the variable count lazy node N1N3′ 607 and the offset 520b.
According to embodiments disclosed herein, the unexplored context may be marked with the DUP indicator that indicates to the walker 320 whether to discard or process the pushed unexplored context in an event a final match for the pattern 502 is identified along the selected transition path. For example, based on reaching the marked node N5615 that indicates the final (i.e., complete or entire) match for the pattern 502 in the input stream, the walker 320 may utilize the DUP indicator of the pushed stack entry to determine whether to process the unexplored context by walking the variable count lazy node N1N3′ 607 with the segment “x” at the offset 520b in an effort to determine another path of the NFA graph 604 that matches the pattern 502, or whether to discard the unexplored context as only a single matching path of the pattern 502 in the input stream is of interest.
According to the example embodiment of
The walker 320 may transition and walk the variable count lazy node N1N3′ 607 with the segment “x” located at offset 520b in the payload 542. Since “x” is not a newline character, “x” is a positive match at the variable count lazy node N1N3′ 607 and the processing cycle 628d shows the match result 624 is positive for the processing cycle 528d. The action 618 for the processing cycle 528d may include updating the current offset to offset 520c and transitioning back to the element node N2610 that may be the next node indicated by the metadata 609 associated with the variable count lazy node N1N3′ 607.
As shown for processing cycle 628e, the walker 320 fetches the node N2610 and compares the segment 522c (i.e., “a”) at the offset 520c (i.e., “2”). Since “a” is a positive match at the element node N2610, the walker 320 updates the current offset to 520d (i.e., “3”) and transitions to the node N4614.
As such, for the processing cycle 628f, the walker 320 may fetch the node N4614 and the segment 522d (i.e., “b”) at offset 520d. Since “b” is a positive match at the node N4614, the walker 320 may transition to the node N5615. The node N5615 is a marked node associated with an indicator signifying a final (i.e., complete or entire) match of the regular expression pattern 502 in the input stream. Thus, for the processing cycle 628g, the walker 320 may discontinue the walk and report the final match by storing an entry in the match result buffer 466. The walker may then check the run stack 460 for stored threads and either discard the stored threads or activate them as indicated by the corresponding DUP indicator of the entries in the run stack 460.
As shown in the table 618 of
According to embodiments disclosed herein, such match performance may be improved by reducing a number or processing cycles needed for the matching, by reducing a number of processing cycles on which a given segment is processed and reducing a number of times memory is accessed by reducing a number of push and pop operations for storing and retrieving unexplored context. Similar to the walk disclosed above for
For example, the walker 320 may be configured to walk at least two nodes of the NFA 604, in parallel, with a given segment, at a given offset within the payload 542. The walker 320 may determine a match result for the segment, at the given offset within the payload, at each node of the at least two nodes. The walker 320 may determine at least one subsequent action for walking the NFA graph 604, based on an aggregation of each match result determined.
According to the example embodiment of
Including the speculative processing indicator may be performed in any suitable manner that enables the walker 320 to walk at least two nodes of the NFA graph 604 that are to be processed in a speculative manner. The at least two nodes processed in parallel may include an element node and a parallel node. In the example embodiment, the node N2610 may be referred to as the element node and the variable count lazy node N1N3′ 607 may be referred to as the parallel node.
According to the example embodiment of
As shown for the processing cycle 658c, the walker 320 walks the element node N2610 and the parallel node N1N3′ 607 with the segment 522c (i.e., “a”) at the updated offset which is offset 520c (i.e., “2”) in the payload 542. The match result 654 is positive at both the element node N2610 and the parallel node N1N3′ 607 as the segment “a” matches the element “a” at the element node N2610 and also matches the “^\n” element at the parallel node N1N3′ 607, as “a” is not a newline character.
An aggregate of the positive match results of the match results 654 for the processing cycle 658c map to the lazy speculative processing rule entry 578a. Thus, unexplored context indicating the parallel node N1N3′ 607 and the current offset 520c (i.e., “2”) may be pushed on the run stack 460, and a next node specified by the metadata of the element node 610 may be fetched. According to the example embodiment, the current offset may be updated to 520d (i.e., “3”) and the node N4614 may be fetched, as the node N4614 is the next node indicated by the metadata of the element node N2610.
A positive match result for the segment 522d (i.e. “b”) may be determined for the processing cycle 658d at the node N4614 and the walker 320 may transition to the marked node N5615 that may be specified as a next node for the node N4614 in metadata associated with the node N4614. Since the node N5615 is a marked node, the walker may store the final match result to the match result buffer 466 and discontinue walking the active thread (e.g., the current path).
The walker 320 may check the run stack 460 for an empty status. In the example embodiment the run stack 460 is not empty as unexplored context was pushed to the run stack 460 in the processing cycle 658c. As such, the walker 320 may pop the unexplored context that indicates advancing the walk to the parallel node N1N3607 with the segment 522d (i.e., “a”) at the offset 520c (i.e., “2”) and determine whether to discard the unexplored context or process the unexplored context based on the DUP indicator associated with the stack entry.
As shown in the table 648 of the example embodiment, the number of processing cycles using speculative processing for matching the payload 542 to the pattern 502 is five, which is a reduced number as compared with the seven processing cycles needed for the non-speculative processing example embodiment of
As disclosed above, the variable count node is a node that may match an element a variable number of times, the number of times may be defined by a range (e.g., zero to five times) and may be associated with a node type, such as lazy or greedy. In contrast to the variable count node with the lazy node type (i.e., a variable count lazy node), that may be configured to find a shortest possible match of elements within the range, the variable count node with the greedy node type (i.e., a variable count greedy node) may be configured to find the longest possible match of elements within the range. For example, as disclosed above, the walker 320 may be configured to select the upper epsilon path 530a to find the shortest possible match of elements within the range. However, to find the longest possible match within the range, the walker 320 may be configured to select the lower epsilon path 530b as the lower epsilon path 530b represents a greedy path.
The compiler 306 may be configured to generate split node metadata that may enable the walker 320 to select the lower epsilon path 530b to effect selection of the greedy path. As such, the walker 320 may iteratively transition between the split node 508 and the speculative node N3512 to process consecutive segments from the input stream provided each of the consecutive segments positively matches at the speculative node N3512. Based on negatively matching a given segment of the consecutive segments, the walker 320 may transition to the element node N2510 via the upper epsilon path 530a, as the greedy path may be configured to process consecutive segments from the payload until a segment mismatch is determined.
The variable count greedy node N1N3′ 707 may be configured to process consecutive segments at the variable count greedy node N1N3′ 707 until a segment mismatch (i.e., negative match) is determined or until the variable count greedy node has processed a threshold number of positively matching consecutive segments. The threshold number may be the upper value for a range of values associated with the variable count greedy node N1N3′ 707.
According to embodiments disclosed herein, the variable count greedy node N1N3′ 707 may be configured to identify a given element, such as the character class element 711 (i.e., [^\n], a variable number of instances 713 as indicated by the metadata 709 associated with the variable count greedy node N1N3′ 707. The variable number of instances 713 may be at least zero times or any other suitable number of instances, such as infinite in the example embodiment. It should be understood that the given character class element 711 and variable number of instances 713 are for illustrative purposes of the example embodiment and that the given element may be any suitable element being matched by the variable count greedy node N1N3′ 707 the variable number of times 713.
In the example embodiment of
Since the variable count greedy node N1N3′ 707 is a greedy type node, the action 812 for the processing cycles 828b-h may include incrementing a count value included in the metadata 709 associated with the variable count greedy node N1N3′ 707 in each of the processing cycles 828b-h to track a total number of consecutive segments that have been positively matched at the variable count greedy node N1N3′ 707. The action 812 for the processing cycles 828b-h may further include updating the current offset to a next segment offset of the segment offsets 818 to process a next segment of the segments 816 as shown by the processing cycles 828b-h. Such incrementing of the count value and updating of the current offset may be repeated until a mismatch of the payload segment at the current offset 808 is determined, as is the case shown for processing cycle 828i.
As shown in the table 818, the segment 822i at the current offset 820i negatively matches at the variable count greedy node N1N3′ 707 for the processing cycle 828i. According to embodiments disclosed herein, unexplored context such as an identifier of the next node N2710 of the variable count greedy node N1N3′ 707 may be stored in conjunction with the count value of the variable count greedy node N1N3′ 707 and a DUP indicator that may be set to one.
Based on the negative match result 810 for the processing cycle 828i, the walker may fetch the next node indicated, either directly or indirectly, by the metadata 709 associated with the variable count greedy node N1N3′ 707 and transition to the node N2710 to walk the node N2710 with the segment 820i having negatively matched at the variable count greedy node N1N3′ 707, in an effort to find the longest possible match.
As shown for processing cycle 828j, the segment 820i has a match result 810 that is negative at the node N2710 as the segment “\n” does not match the element “a” of the element node N2710. As such, the walker 320 may proceed to incrementally unroll the consecutive segments having previously positively matched at the variable count greedy node N1N3′ 707. For example, the walker 320 may unroll segments 820h . . . 820b, in an effort to determine a most recently walked segment having positively matched at the variable count greedy node N1N3′ 707 that also matches at the next node N2710, in an effort to find the longest possible match. An unrolling action may include popping context stored that identifies the element node and a count of the number of positively matching consecutive segments matched at the variable count node prior to a segment mismatch. The unrolling action may include decrementing the count and pushing stored context identifying the element node and including the count decremented. The unrolling action may further include updating the current offset and fetching the element node.
As shown for processing cycle 828k, the segment 820h negatively matches at the element node N2710 and the walker 320 takes the actions 812 shown, similar to the unrolling actions 830 of the processing cycle 828j, and, thus, proceeds to unroll by determining if the segment 820g matches at the element node N2710 as shown for the processing cycle 828l. Since the segment 820g (i.e., “a”) positively matches at the element node N2710, the walker 320 may update the current offset and fetch the next node N4714 that may be identified via metadata associated with the element node N2710. The segment 820h may be positively matched at the node N4714 as shown for processing cycle 828m and the walker 320 may update the current offset and fetch the next node N5715 that may be identified via metadata associated with the element node N4714.
The node N5715 is a marked node associated with an indicator signifying a final (i.e., complete or entire) match of the regular expression pattern 842 in the input stream. Thus, for the processing cycle 828n, the walker 320 may discontinue the walk and report the final match by storing an entry in the match result buffer 466. The walker may then check the run stack 460 for stored threads and either discard the stored threads or activate them as indicated by the corresponding DUP indicator of the entries in the run stack 460.
Based on the payload 842 segment content, a number of processing cycles for the unrolling may increase. As shown, the action 812 for each of the unrolling cycles 828j and 828k includes popping and pushing of context that may be costly operations as disclosed above. According to embodiments disclosed herein, match performance may be improved by reducing a number or processing cycles needed for the matching and by reducing a number of times memory is accessed by reducing a number of push and pop operations for storing and retrieving context. According to embodiments disclosed herein, match performance may be improved by walking in a speculative manner. For example, the walker 320 may walk the NFA graph 704 in a speculative manner. As disclosed above, processing at least two nodes in parallel may be referred to herein as speculative processing. According to embodiments disclosed herein, match performance based on greedy path processing may be optimized by speculative processing as disclosed below.
The greedy speculative processing rules 978a and 978b enable the variable count greedy node and the element node to iteratively process a segment, at a current offset within a payload, in parallel, based on a positive match at the variable count greedy node, obviating memory access for node fetching. Further, the greedy speculative processing rule 978a includes storing context as shown by the corresponding action 976. The greedy speculative processing rule 978a includes storing a context identifying the next offset and a next node of the given finite automaton based on positively matching the segment, at the current offset in the payload, at the given node and the element node. The element node is associated with metadata identifying the element and the next node.
The storing of context based on positively matching a segment at both the variable count greedy node and the element node enables the walker 320 to record segment offset and node information to obviate unrolling, such as the unrolling action 830 as disclosed in reference to
As shown by the greedy speculative processing rule 978c, iteratively walking the element and variable count greedy nodes, in parallel, is discontinued, and the current offset is updated. The next node may be fetched and the walker may walk the next node with a next segment at the current offset updated. As such, the greedy speculative processing rule 978c may include discontinuing iteratively walking, updating the current offset to the next offset, and walking the next node with a next segment at the next offset in the payload.
As shown by the greedy speculative processing rule 978d, based on the match results of the variable count greedy node 972 and element node 974 being both negative, the action 976 may include discontinuing the walk of a given path. As such, a next segment, at a next given offset within the payload, may be walked based on sensing unexplored context, such as by checking the run stack 460 for a stored thread and popping the stored thread if stored. Alternatively the walk may be terminated based on not sensing the unexplored context or if all stored threads are marked for discard based on a corresponding Discard Unexplored Processing (DUP) indicator. As such, the greedy speculative processing rule 978d may specify at least one subsequent action that includes discontinuing iteratively walking, and popping a stack entry from the run stack 460. Based on a non-empty status of the run stack 460, a stack entry that was most recently pushed entry onto the stack may be popped, and the walk may be advanced to a next node with a next segment based on the stack entry popped. Otherwise, based on an empty status of the run stack 460, the walk may be terminated.
If the VCG node is speculative, the method may fetch an element node (1008). The element node fetched may be a next node identified via the metadata associated with the VCG node. The method may process a segment at a current offset at both the VCG node and the element node (1010). The VCG node may be configured to match a variable number of consecutive instances of a first element in the payload and the element node may be configured to match a single instance of a second element in the payload.
The method may check if the segment at the current offset positively matches at the VCG node (1012). Checking if the segment at the current offset positively matches at the VCG node may include determining that the segment positively matches the first element identified via the metadata associated with the VCG node and determining that the count value of consecutive segments having been positively matched at the VCG node has not exceeded a given threshold. If the segment at the current offset positively matches the VCG node, a count value included in the metadata associated with the VCG node may be incremented (1014).
The method may check if the segment at the current offset positively matches at the element node (1016). Checking if the segment at the current offset positively matches at the element node may include determining that the segment positively matches the second element identified via metadata associated with the element node. It should be understood that such determination of the positive match at the VCG node and element node occur in parallel as the segment at the current offset is processed at both nodes in parallel. The VCG node and the element node may be walked, in parallel, with the segment, at the current offset within the payload, within a same processing cycle of the at least one processor.
If the segment at the current offset positively matches at the element node, the current offset may be updated to a next offset (1018) and context may be stored (1020). Storing the context may include pushing an address or other identifier of a next node, identified via metadata of the element node, in conjunction with the next offset. The method may proceed to process the segment at the next offset at both the VCG and element node in a next iteration by returning to process the segment at the current offset at both the VCG node and the element node (1010).
However, if a positive match of the segment at the current offset at the element node (1016) is not determined, the method may update the current offset to the next offset (1034) and the method may proceed to process the segment at the next offset at both the VCG and element node in a next iteration by returning to process the segment at the current offset at both the VCG and elements nodes (1010). As such, the walk may include iteratively walking the VCG node and the element node, in parallel, with a segment, at a current offset within a payload, based on positively matching the segment at the VCG node. The current offset may be updated to a next offset per iteration as shown by (1018) and (1034).
However, if a positive match of the segment at the current offset at the VCG node (1012) is not determined, the method may discontinue iteratively walking, and the method may determine if the segment at the current offset positively matches at the element node (1022). If no, the method may transition based on stored context (1030) and the method ends (1032) in the example embodiment.
However, if a positive match of the segment at the current offset at the element node (1022) is determined, the method may update the current offset to the next offset (1024). The method may process the segment at the next offset at the next node (1028) and the method thereafter ends (1032) in the example embodiment.
According to embodiments disclosed herein, the metadata associated with the variable count greedy node may include a speculative processing indicator. According to embodiments disclosed herein, if the speculative processing indicator is not included in the metadata 709 associated with the variable count greedy node N1N3′ 707, the walker 320 may continue as in the example embodiment of
According to the example embodiment of
According to the example embodiment of
As shown for processing cycle 1158b, the walker 320 may determine a negative match result for the segment 822b (i.e., “x”) at the element node N2710 and a positive match result at the variable count greedy node N1N3′ 707. Such match results map to the greedy speculative processing rule entry 978b. As such, the action 976 specifies that the current offset be updated and that the element and variable count greedy nodes, such as nodes N2710 and N1N3′ 707, respectively, be processed (i.e., walked) again, based on the positive match result at the variable count greedy node N1N3′ 707. As the nodes N2710 and N1N3′ 707 were already fetched for the processing cycle 1158b, no node fetch is needed for the processing cycle 1158c. The count value (not shown) included in the metadata 709 may be incremented to 1 based on the positive match result 1154 at the variable count greedy node N1N3′ 707 and the current offset may be updated to 2.
As shown for the processing cycle 1158c, the walker 320 walks the element node N2710 and the variable count greedy node N1N3′ 707 with the segment 822c (i.e., “x”) at the updated offset which is offset 820c (i.e., “2”) in the payload 842. The match result 1154 is again negative at the element node N2710 and positive at the variable count greedy node N1N3707 as the segment “x” does not match the element “a” at the element node N2710 but matches the “^\n” element at the variable count greedy node N1N3′ 707, as “x” is not a newline character. The match results 1154 again map to the greedy speculative processing rule entry 978b. As such, the action 976 specifies that the current offset be updated and that the element and variable count greedy nodes, such as nodes N2710 and N1N3′ 707, respectively, be processed (i.e., walked) again, based on the positive match result at the variable count greedy node N1N3′ 707. The count value may be incremented to 2 based on the positive match result 1154 at the variable count greedy node N1N3′ 707 and the current offset may be increment to 3.
As shown for the processing cycle 1158d the walker 320 walks the element node N2710 and the variable count greedy node N1N3′ 707 with the segment 822c (i.e., “x”) at the current offset which is offset 820d (i.e., “3”) in the payload 842. The match result 1154 is again negative at the element node N2710 and positive at the variable count greedy node N1N3′ 707 and, thus, the action 1156 is similar to processing cycles 1158b and 1158c disclosed above.
As shown for the processing cycle 1158e the walker 320 walks the element node N2710 and the variable count greedy node N1N3′ 707 with the segment 822e (i.e., “a”) at the current offset which is offset 820d (i.e., “4”) in the payload 842. The match result 1154 is positive at both the element node N2710 and the variable count greedy node N1N3′ 707. The match results 1154 map to the greedy speculative processing rule entry 978a. Thus, in addition to incrementing the count value and updating the current offset, the action 1156 further includes storing unexplored context that includes pushing a stack entry identifying the node N4714 that is the next node identified via metadata associated with element node N2710 and the current offset that is now 5. As such, if a subsequent cycle determines a segment mismatch at the variable count greedy node N1N3′ 707, the walker 320 may walk the node N4714 with the segment 822f at the current offset 5, obviating unrolling to find the offset at which both the element node N2710 and the variable count greedy node N1N3′ 707 positively matched a same segment.
As shown for processing cycles 1158f, 1158g, and 1158h, the walker 320 continues the iterative walk of the element node N2710 and the variable count greedy node N1N3′ 707 based on the positive match result 1154 at the variable count greedy node N1N3′ 707. However, as shown for the processing cycle 1158g, similar to the processing cycle 1158e, disclosed above, unexplored context may be stored to enable the walker to return to the node N4714 that is the next node identified via metadata associated with element node N2710 with a segment corresponding to the offset 822h corresponding to offset 7 which is the updated current offset for use in the consecutive processing cycle 1158h.
As shown for the processing cycle 1158i, the walker 320 may determine a negative match result for the segment 822i (i.e., “\n”) at the element node N2710 and a negative match result at the variable count greedy node N1N3′ 707. Such match results map to the greedy speculative processing rule entry 978d. As such, iteratively walking of the element node N2710 and the variable count greedy node N1N3′ 707 is discontinued as the match result 1154 at the variable count greedy node N1N3′ 707 is negative. The walker 320 may check the stack for stored entries and if the stack is non-empty the most recently pushed entry may be popped. As such, the entry pushed for processing cycle 1158g may be popped to enable the walker to fetch the node N4714 and transition to the node N4714 with the segment 822h at the offset 820h.
As shown for the processing cycle 1158j, the segment 822h (i.e., “b”) at the offset 820h identified via the stack entry popped for processing cycle 1158h positively matches at the node N4714. Thus, the walker 320 updates the current offset to 820i and fetches the node N5715 that is the next node identified via the metadata associated with the node N4714.
Since the node N5715 is a marked node, the walker may store the final match result to the match result buffer 466 and discontinue walking the active thread (e.g., the current path). The walker 320 may check the run stack 460 for an empty status. In the example embodiment the run stack 460 is not empty as unexplored context was pushed to the run stack 460 in the processing cycle 1158e. As such, the walker 320 may pop the unexplored context that indicates advancing the walk to the node N4714 with the segment 822f (i.e., “b”) at the offset 820f (i.e., “5”) and determine whether to discard the unexplored context or process the unexplored context based on the DUP indicator associated with the stack entry.
According to embodiments disclosed herein, updating the current offset may include incrementing or decrementing the current offset based on a forward or reverse direction of the walk, respectively. As such, incrementing or decrementing of the current offset is for illustrative purpose in accordance with a direction of the walk of the examples.
As shown in the table 1148 of the example embodiment, the number of processing cycles using greedy speculative processing for matching the payload 842 to the pattern 502 is eleven, which is a reduced number as compared with the fourteen processing cycles needed for the greedy non-speculative processing example embodiment of
According to embodiments disclosed herein, walking the given NFA in a speculative manner may reduce a number of push or pop operations to the run stack 460, thus, optimizing match performance. As disclosed above, such push or pop operations may be expensive memory accesses, for example, the run stack 460 may be an ECC protected type memory. Accessing the ECC protected memory for a push or pop operation may take four clock periods or more. In addition to reducing the number of push or pop operations, as disclosed above, embodiments disclosed herein may further optimize match performance by employing a supplemental memory, as disclosed below.
Referring back to
According to embodiments disclosed herein, the supplemental memory 470 may be associated with context state information 472 that may include a validity state (also referred to interchangeably herein as a validity indicator). The validity state may indicate a valid or invalid state for the supplemental memory 470. The valid state may indicate that the supplemental memory 470 has a pending context stored. The pending context may be stored context that has not yet been processed by the HNA 108.
The invalid state may indicate that the supplemental memory 470 has no pending context stored, for example, any entry stored to the supplemental memory 460 has already been popped by the HNA 108 to walk a given node with a segment or otherwise discarded by the HNA 108. As such, the context state information 472 may be used by the HNA 108 to discern whether the supplemental memory 470 has a pending context.
According to embodiments disclosed herein, the validity state may be implemented as a bit of the supplemental memory 470, as a multi-bit field of the supplemental memory 470, as an indicator stored separate from the supplemental memory 470, or implemented in any other suitable manner that conveys status regarding whether the supplemental memory 470 register has pending context stored.
The supplemental memory 470 may be referred to interchangeably herein as a Top of Stack (TOS) memory 470, TOS register 470 or the TOS 470. As disclosed above, the HNA 108 may employ the run stack 460 to save context such as states of nodes of an NFA graph during a walk of the nodes of the NFA graph. According to embodiments disclosed herein, the TOS 470 register has faster access (i.e., read/write) times than the run stack 460. In contrast to an ECC protect memory for which a push or pop operation may take three, four, or more clock periods, the push or pop operation may take one clock period if performed on the TOS register 470.
As disclosed above, processing of finite automata may include lazy or greedy type processing that may readily include consecutive push/pop operations. According to embodiments disclosed herein, the TOS register 470 may maintain a most recently pushed stack entry separate from earlier pushed entries that may be pushed to the run stack 460 via the TOS register 470. Maintaining the most recently pushed entry in the TOS register 470 may improve walk performance as the most recently pushed entry may be a most frequently accessed entry, that is, the most recently pushed entry is likely to be popped before another entry is pushed.
The most recently pushed entry may be manipulated frequently, for example, during greedy processing, as disclosed above, whereby a given context may be pushed, popped, modified, and pushed again. According to embodiments disclosed herein, such consecutive push/pop operations may be performed via the TOS register 470, instead of the run stack 460, thus, optimizing match performance. According to embodiments disclosed herein, the TOS register 470 may be a first memory and the run stack 460 may be a second memory operatively coupled to the first memory.
Referring back to
However, in an event the HNA 108 pushes 474 the first context and the context state information 472 reflects the valid state, a pending context such as a second context is understood to be stored in the TOS 470 register. The second context stored by the TOS 470 register may be pushed 476 to the run stack 460 based on the push of the first context and the valid state of the TOS 470 register indicated by the context state information 472. The first context may be pushed to the TOS 470 register subsequent to the second context being pushed to the run stack 460. As the TOS 470 register continues to store pending context, the context state information 472 may be preserved by the HNA 108 to continue to reflect the valid state of the TOS 470 register.
As such, storing context, such as by pushing the first context, may include a store determination, based on the context state information 472 associated with the TOS 470 register, to access the TOS 470 register and not the run stack 460 or to access the TOS 470 register and the run stack 460. The store determination to access the TOS register 470 and not the run stack 460 may be based on the context state information 472 indicating the invalid state of the TOS register 470. The store determination to access the TOS register 470 and the run stack 460 may be based on the context state information 472 indicating the valid state of the TOS register 470.
However, if the check for the validity state (1304) indicates the valid state, the determination may be to access the first memory and the second memory (1306). The method may access the first memory to retrieve a pending context stored in the first memory (1308) and access the second memory to store the pending context retrieved (1310). The method may access the first memory to store the context in the first memory (1312) and may preserve the context state information associated with the first memory (1314), since the first memory continues to store a pending context. The method thereafter ends (1322) in the example embodiment.
According to embodiments disclosed herein, the TOS stack 470 may be configured with a single entry for storing a single context and the run stack 460 may be configured with multiple entries for storing multiple contexts. The run stack 460 may be maintained as a circular buffer, such as the circular buffer 481 of
For example, to store the context or push the context, the HNA 108 may be configured to update the head pointer 482 and store the stack entry in an empty context entry of the run stack 460 as the empty context entry may be addressed by the head pointer updated. To retrieve or pop a stack entry (i.e., context), the HNA 108 may be configured to retrieve the stack entry from a current entry location that is addressed by the head pointer 482. For example, the HNA 108 may update the head pointer 482 by incrementing the head pointer to address a next entry location of the second memory immediately subsequent to the current entry location. Alternatively, the HNA 108 may update the head pointer 482 by decrementing the head pointer to address a next entry location of the second memory immediately preceding the current entry location.
As such, addressing of the run stack 460 may increase from a previous pointer to a next pointer, i.e., to pop a stack entry the HNA 108 may read the stack entry at the head pointer and increment the head pointer to point to the next stack entry, whereas to push a stack entry the HNA 108 may decrement the head pointer and add the stack entry at the location pointed to by the decremented head pointer. Alternatively, addressing of the run stack 460 may decrease from a current pointer to a previous pointer, i.e., to pop a stack entry the HNA 108 may read the stack entry at the head pointer and decrement the head pointer to point to a previous stack entry, whereas to push a stack entry the HNA 108 may increment the head pointer and add the stack entry at the location pointed to by the incremented head pointer.
In an event the HNA 108 pops context (i.e., a stack entry), for example, to retrieve a stored context, a check may be made as to whether the context state information 472 indicates the valid or invalid state of the TOS 470 register. If the context state information 472 indicates the valid state, a most recently pushed context may be popped 478 from the TOS register 470 and the context state information 472 may be updated to indicate the now invalid state of the TOS register 470 as TOS register 470 no longer stores a pending context.
If however, the check determines that the context state information 472 indicates the invalid state, the pending context may instead be popped 480 (i.e., retrieved) from the run stack 460. According to embodiments disclosed herein, pending context is retrieved from the run stack 460 based on an invalid state of the context state information 472 associated with the TOS register 470, and pending context stored by the run stack 460 is not written to the TOS register 470.
If the validity state indicates the valid state, a retrieve determination may be to access the first memory and not the second memory (1506). The first memory may be accessed to retrieve the pending context from the first memory (1508). The context state information associated with the first memory may be updated (1510), for example, to change the validity state included in the context state information from a valid state to an invalid state to indicate that the first memory has no pending context stored. The method thereafter ends (1518) in the example embodiment.
If however, the check for the validity state (1504) indicates the invalid state, the retrieve determination may be to access the second memory and not the first memory (1512). The second memory may be accessed to retrieve the pending context (1514) and the context state information associated with the first memory may be preserved (1516) as the first memory continues to have no pending context stored. The method thereafter ends (1518) in the example embodiment.
The context 1601 may further include a match type field 1604 that that may be relevant based on the context entry type field 1602. The match type field 1604 may be based on the node type and may be used to determine whether a given node is configured to match a single instance or multiple consecutive instances of a given element in an input stream received from the network. For example the match type field 1604 may indicate a lazy or greedy match type.
The context 1601 may further include an element field 1608 that may be relevant regardless of the context entry type field 1602 and may identify the given element for matching at the given node.
The context 1601 may further include a next node address field 1610 that may be relevant regardless of the context entry type field and may identify a next node associated with the given node. For example, based on a positive match at the given node, the next node for walking a next segment may be identified via the next node address field 1610.
The context 1601 may further include a count field 1612 that may be relevant based on the context entry type field 1602. For example, if the context entry type field 1602 indicates that the given node is a fixed count node then the count value may not be relevant whereas if the context entry type field indicates that the given node is a variable count lazy node or a variable count greedy (VCG) node then the count value may be relevant. The count field 1612 may identify a count value for a number of consecutive instances remaining for positively matching the given element identified by the element field 1608 at the given node, based on the context entry type field indicating the variable count lazy node type. Based on the context entry type field 1602 indicating that the given node is a variable count greedy node (VCG) node, the count field may indicate a number of consecutive instances positively matched to the given element at the given node. For example, the count value such as the count value shown for the processing cycles 828b-h of
The context 1601 may further include a discard unexplored context (DUP) field 1614 that may be relevant regardless of the context entry type field 1602 and may identify whether to discard the context 1601 or walk the next node identified by the next node address field 1610, in an event a complete match of at least one regular expression is detected in the input stream.
The context 1601 may further include a reverse walk direction field 1616 that may be relevant regardless of the context entry type field 1602 and may identify a reverse or forward direction of walking.
The context 1601 may further include an offset field 1618 that may be relevant regardless of the context entry type field 1602 and may identify an offset of a segment of a payload in the input stream for matching to a particular element. The particular element may be identified based on the context entry type field 1602. For example, based on the context entry type field 1602 indicating a variable count lazy node, the offset field 1618 may identify a segment of the payload for matching the given element identified by the element field 1608 of the context 1601. However, based on the context entry type field 1602 indicating a variable count greedy node, the offset field 1618 may identify a segment of the payload for matching with a next element, the next element identified via next metadata associated with the next node identified via the next node address field 1610 of the context 1601. The next metadata may be obtained based on fetching the next node via the next node address field 1610.
As such, according to embodiments disclosed herein, pushing context may include configuring a stack entry that includes the context 1601 and the stack entry may be stored on a stack such as the run stack 460 of
According to embodiments disclosed herein, the context 1601 may be interpreted by the HNA 108 based on a context status setting (not shown) included in the context entry type field 1602. The context status setting may indicate whether or not the context 1601 is complete or incomplete. Based on the context status setting of the context entry type field 1602 of the context 1601 of a popped stack entry indicating that the context 1401 is incomplete, the HNA 108 may be configured to fetch the next node identified via the next node address field 1610 and proceed with the walk based on metadata stored by the next node and current run time configuration, such as a direction of the walk, rather than proceeding with the walk based on field configuration of the context 1601 of the popped stack entry.
Further example embodiments of the present invention may be configured using a computer program product; for example, controls may be programmed in software for implementing example embodiments of the present invention. Further example embodiments of the present invention may include a non-transitory computer-readable medium containing instructions that may be executed by a processor, and, when executed, cause the processor to complete methods described herein. It should be understood that elements of the block and flow diagrams described herein may be implemented in software, hardware, firmware, or other similar implementation determined in the future. In addition, the elements of the block and flow diagrams described herein may be combined or divided in any manner in software, hardware, or firmware.
It should be understood that the term “herein” is transferable to an application or patent incorporating the teachings presented herein such that the subject matter, definitions, or data carries forward into the application or patent making the incorporation.
If implemented in software, the software may be written in any language that can support the example embodiments disclosed herein. The software may be stored in any form of computer readable medium, such as random access memory (RAM), read only memory (ROM), compact disk read-only memory (CD-ROM), and so forth. In operation, a general purpose or application-specific processor loads and executes software in a manner well understood in the art. It should be understood further that the block and flow diagrams may include more or fewer elements, be arranged or oriented differently, or be represented differently. It should be understood that implementation may dictate the block, flow, and/or network diagrams and the number of block and flow diagrams illustrating the execution of embodiments of the invention.
While this invention has been particularly shown and described with references to example embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the invention encompassed by the appended claims.
Number | Name | Date | Kind |
---|---|---|---|
5428554 | Laskoski | Jun 1995 | A |
5608662 | Large | Mar 1997 | A |
5893142 | Moyer et al. | Apr 1999 | A |
6314513 | Ross | Nov 2001 | B1 |
6954424 | Barrack et al. | Oct 2005 | B2 |
7046848 | Olcott | May 2006 | B1 |
7225188 | Gai et al. | May 2007 | B1 |
7260558 | Cheng et al. | Aug 2007 | B1 |
7308446 | Panagrahy et al. | Dec 2007 | B1 |
7460473 | Kodama | Dec 2008 | B1 |
7594081 | Bouchard et al. | Sep 2009 | B2 |
7702629 | Cytron et al. | Apr 2010 | B2 |
7710988 | Tripathi et al. | May 2010 | B1 |
7805393 | Steele et al. | Sep 2010 | B1 |
7870161 | Wang | Jan 2011 | B2 |
7944920 | Pandya | May 2011 | B2 |
7949683 | Goyal | May 2011 | B2 |
7962434 | Estan et al. | Jun 2011 | B2 |
8024802 | Preston | Sep 2011 | B1 |
8051085 | Srinivasan et al. | Nov 2011 | B1 |
8180803 | Goyal | May 2012 | B2 |
8301788 | Bouchard et al. | Oct 2012 | B2 |
8473523 | Goyal | Jan 2013 | B2 |
8392590 | Bouchard et al. | Mar 2013 | B2 |
8407794 | Kim et al. | Mar 2013 | B2 |
8516456 | Starovoitov et al. | Aug 2013 | B1 |
8554698 | Bando et al. | Oct 2013 | B2 |
8566344 | Bando et al. | Oct 2013 | B2 |
8683590 | Namjoshi et al. | Mar 2014 | B2 |
8862585 | Chao et al. | Oct 2014 | B2 |
9083731 | Namjoshi et al. | Jul 2015 | B2 |
9203805 | Goyal et al. | Dec 2015 | B2 |
9280600 | Hay et al. | Mar 2016 | B2 |
9398033 | Goyal et al. | Jul 2016 | B2 |
9419943 | Goyal et al. | Aug 2016 | B2 |
9426165 | Billa et al. | Aug 2016 | B2 |
9426166 | Billa et al. | Aug 2016 | B2 |
9432284 | Goyal et al. | Aug 2016 | B2 |
9438561 | Goyal et al. | Sep 2016 | B2 |
9495479 | Goyal | Nov 2016 | B2 |
9507563 | Billa et al. | Nov 2016 | B2 |
9514246 | Billa et al. | Dec 2016 | B2 |
9563399 | Goyal et al. | Feb 2017 | B2 |
9602532 | Goyal et al. | Mar 2017 | B2 |
9762544 | Goyal et al. | Sep 2017 | B2 |
9785403 | Goyal et al. | Oct 2017 | B2 |
20010033552 | Barrack et al. | Oct 2001 | A1 |
20030195874 | Akaboshi | Oct 2003 | A1 |
20040059443 | Sharangpani | Mar 2004 | A1 |
20040162826 | Wyschogrod et al. | Aug 2004 | A1 |
20040172234 | Dapp et al. | Sep 2004 | A1 |
20040225999 | Nuss | Nov 2004 | A1 |
20050108518 | Pandya | May 2005 | A1 |
20050278781 | Zhao et al. | Dec 2005 | A1 |
20060069872 | Bouchard | Mar 2006 | A1 |
20060075206 | Bouchard et al. | Apr 2006 | A1 |
20060085533 | Hussain et al. | Apr 2006 | A1 |
20060101195 | Jain | May 2006 | A1 |
20060136570 | Pandya | Jun 2006 | A1 |
20060235811 | Fairweather | Oct 2006 | A1 |
20070192863 | Kapoor et al. | Aug 2007 | A1 |
20070282833 | McMillen | Dec 2007 | A1 |
20080034427 | Cadambi et al. | Feb 2008 | A1 |
20080047012 | Rubin et al. | Feb 2008 | A1 |
20080059464 | Law et al. | Mar 2008 | A1 |
20080071783 | Langmead et al. | Mar 2008 | A1 |
20080077793 | Tan et al. | Mar 2008 | A1 |
20080082946 | Zilic et al. | Apr 2008 | A1 |
20080097959 | Chen et al. | Apr 2008 | A1 |
20080101371 | Law et al. | May 2008 | A1 |
20080189784 | Mangione-Smith | Aug 2008 | A1 |
20080228991 | Ferroussat et al. | Sep 2008 | A1 |
20080229415 | Kapoor et al. | Sep 2008 | A1 |
20080262991 | Kapoor et al. | Oct 2008 | A1 |
20080270833 | McMillen | Oct 2008 | A1 |
20080271141 | Goldman et al. | Oct 2008 | A1 |
20090106183 | Estan et al. | Apr 2009 | A1 |
20090119279 | Goyal et al. | May 2009 | A1 |
20090119399 | Hussain et al. | May 2009 | A1 |
20090138440 | Goyal | May 2009 | A1 |
20090138494 | Goyal | May 2009 | A1 |
20100050177 | Goyal et al. | Feb 2010 | A1 |
20100095162 | Inakoshi | Apr 2010 | A1 |
20100114973 | Goyal | May 2010 | A1 |
20100138367 | Yamagaki | Jun 2010 | A1 |
20100146623 | Namjoshi | Jun 2010 | A1 |
20100153420 | Yang et al. | Jun 2010 | A1 |
20100158394 | Chang et al. | Jun 2010 | A1 |
20100174770 | Pandya | Jul 2010 | A1 |
20100192225 | Ma et al. | Jul 2010 | A1 |
20100198850 | Cytron et al. | Aug 2010 | A1 |
20110016154 | Goyal et al. | Jan 2011 | A1 |
20110066637 | Wang | Mar 2011 | A1 |
20110072199 | Reiter et al. | Mar 2011 | A1 |
20110093484 | Bando et al. | Apr 2011 | A1 |
20110093496 | Bando et al. | Apr 2011 | A1 |
20110113191 | Pandya | May 2011 | A1 |
20110119440 | Pandya | May 2011 | A1 |
20110173490 | Narayanaswamy et al. | Jul 2011 | A1 |
20110185077 | Bremler-Barr et al. | Jul 2011 | A1 |
20110238855 | Korsunsky et al. | Sep 2011 | A1 |
20110320393 | Pandya | Dec 2011 | A1 |
20110320397 | Podkolzin et al. | Dec 2011 | A1 |
20120017262 | Kapoor et al. | Jan 2012 | A1 |
20120143854 | Goyal et al. | Jun 2012 | A1 |
20120221494 | Pasetto et al. | Aug 2012 | A1 |
20120221497 | Goyal et al. | Aug 2012 | A1 |
20120275642 | Aller | Nov 2012 | A1 |
20120284222 | Atasu et al. | Nov 2012 | A1 |
20120311529 | Beveridge et al. | Dec 2012 | A1 |
20130074081 | Cassetti et al. | Mar 2013 | A1 |
20130097608 | Kessler et al. | Apr 2013 | A1 |
20130103909 | Pangborn et al. | Apr 2013 | A1 |
20130133064 | Goyal et al. | May 2013 | A1 |
20130191916 | Yao et al. | Jul 2013 | A1 |
20130254197 | Hay et al. | Sep 2013 | A1 |
20130290356 | Yang et al. | Oct 2013 | A1 |
20140025923 | Klein | Jan 2014 | A1 |
20140101176 | Ruehle | Apr 2014 | A1 |
20140129775 | Ruehle | May 2014 | A1 |
20140143874 | Namjoshi et al. | May 2014 | A1 |
20140173254 | Ruehle | Jun 2014 | A1 |
20140214749 | Ruehle | Jul 2014 | A1 |
20150066927 | Goyal et al. | Mar 2015 | A1 |
20150067123 | Goyal et al. | Mar 2015 | A1 |
20150067200 | Goyal et al. | Mar 2015 | A1 |
20150067776 | Goyal et al. | Mar 2015 | A1 |
20150067836 | Billa et al. | Mar 2015 | A1 |
20150067863 | Billa et al. | Mar 2015 | A1 |
20150186786 | Goyal et al. | Jul 2015 | A1 |
20150220845 | Goyal et al. | Aug 2015 | A1 |
20150262009 | Szabo | Sep 2015 | A1 |
20150293846 | Goyal et al. | Oct 2015 | A1 |
20150295889 | Goyal et al. | Oct 2015 | A1 |
20150295891 | Goyal et al. | Oct 2015 | A1 |
20160021060 | Goyal et al. | Jan 2016 | A1 |
20160021123 | Goyal et al. | Jan 2016 | A1 |
Number | Date | Country |
---|---|---|
1716958 | Jan 2006 | CN |
101201836 | Jun 2008 | CN |
101296116 | Oct 2008 | CN |
101351784 | Jan 2009 | CN |
101360088 | Feb 2009 | CN |
102148805 | Aug 2011 | CN |
102420750 | Apr 2012 | CN |
102902713 | Jan 2013 | CN |
103166802 | Jun 2013 | CN |
2276217 | Jan 2011 | EP |
WO 2004013777 | Feb 2004 | WO |
WO 2007109445 | Sep 2007 | WO |
WO 2008005772 | Jan 2008 | WO |
WO 2009017131 | Feb 2009 | WO |
WO 2013078053 | May 2013 | WO |
Entry |
---|
Branch, J.W. et al., “Denial of Service Intrusion Detection Using Time Dependent Deterministic Finite Automata,” Proc. Research Conference, Troy, NY, Oct. 2002. |
Faro, S., et al., “Efficient Variants of the Backward-Oracle-Matching Algorithm,” Proceedings of Prague Stringology Conference, 2008, pp. 146-160. |
Navarro, G., “NR-grep: A Fast and Flexible Pattern Matching Tool,” pp. 1-49, published 2000. |
Navarro, G., “Pattern Matching,” pp. 1-24, published 2002. |
Hayes, C.L., et al., “DPICO: A High Speed Deep Packet Inspection Engine Using Compact Finite Automata,” ANCS'07 pp. 195-203 (2007). |
Nitrox DPI CN17XX L7 Content Processor Family Preliminary Product Brief. Cavium Networks 2009. http://cavium.com/pdfFiles/Nitrox_DPI_PB_v1.pdf. Retrieved Apr. 6, 2017. |
Ko{hacek over (s)}a{hacek over (r)}, V., et al., “Towards Efficient Field Programmable Pattern Matching Array,” 2015 Euromicro Conference on Digital System Design, IEEE, pp. 1-8 (2015). |
Peng, K., et al., “Chain-Based DFA Deflation for Fast and Scalable Regular Expression Matching Using TCAM,” ACM/IEEE Seventh Symposium on Architectures for Networking and Communications Systems Year 2011, pp. 24-35 (2011). |
Lin, C-H., et al., “Optimization of Pattern Matching Circuits for Regular Expression of FPGA,” IEEE Transactions on Very Large Scale Integration (VLSI) Systems, 15(12): 1303-1310 (2007). |
Clark, C.R., et al., “Scalable Pattern Matching for High Speed Networks,” 12th Annual IEEE Symposium on Field Programmable Custom Computing Machines, pp. 249-257 (2004). |
Becchi, M., “Data Structures, Algorithms and Architectures for Efficient Regular Expression Evaluation,” Washington University in St. Louis School of Engineering & Applied Science, published May 2009. |
Becchi, M., et al., “A Hybrid Finite Automation for Practical Deep Packet Inspection,” published 2007. |
Becchi, M., et al., “Extending Finite Automata to Efficiently Match Perl-compatible Regular Expressions”, Proceedings of the 2008 CoNext Conference, Dec. 9-12, 2008. |
Chodnicki, S., “An Introduction to Regular Expressions/Adventures with Open Source B1”, available at http://type-exit.org/adventures-with-open-source-bi/2011/05/an-introduction-to-regular-expressions May 7, 2013 (29 pgs). |
Hoperoft, J.E. and Ullman, J.D., “Introduction to Automata Theory, Languages, and Computation,” Addison-Wesley Publishing, Reading, Massachusetts (1979). ISBN 0-201-02988-X. (See chapter 2.). |
Rabin, M.O. and Scott, D., “Finite Automata and their Decision Problems,” IBM Journal of Research and Development, 3(2): 114-125 (1959). |
Singh, H., Regular Expressions, http://www.seeingwithe.org/topic7html.html (2002) downloaded May 7, 2013 (10 pgs). |
Sipser, M., “Introduction to the Theory of Computation,” PWS, Boston (1997). ISBN 0-534-94728-X. (See section 1.2: Nondeterminism, pp. 47-63.). |
Sun, W., et al., “HFilter: Hybrid Finite Automation Based Stream Filtering for Deep and Recursive XML Data,” School of Computer Science and Tech., published 2008. |
Number | Date | Country | |
---|---|---|---|
20150220454 A1 | Aug 2015 | US |