1. Field of Invention
The present invention relates to a packet processing method, and more particularly to a processing method for accelerating filtering of packet content.
2. Related Art
All of the current firewall static packet filtering technologies are implemented by using a series of rule chains. The maintenance and management of the rule chains are completed by a system administrator. Each node (that is, filtering policy) in a rule chain is consisted of packet data filtering policies set by the system administrator.
After the above rule chains are determined, a system device filters the received packet data one by one according to every filtering rule in the rule chain. In this process, a packet may match a piece of particular rule, or may not match any rules at all.
The packet data being filtered is processed during the packet filtering in the following manners. In the first case, that is, if a packet matches a piece of corresponding policy during the filtering, the system stops the performance of other filtering policies in the rule chains on the packet data. In the second case, that is, if the packet does not match any pieces of corresponding filtering policies during the filtering, the arbitration for the packet is determined by the system.
For the administrator, this manner can add filtering policies rapidly, but it results in the reduction in flexibility for maintenance and integration of the filtering policies.
In the light of the above problems, the present invention is directed to a processing method for accelerating packet filtering, which is used to accelerate the process of filtering packet data in a computer.
For the above-mentioned purpose, the present invention provides a processing method for accelerating packet filtering, which includes the following steps. A rule chain including a plurality of packet filtering policies is loaded. A plurality of batches of packet data is received. If a policy group is found to match the packet, the packet is filtered by using all the filtering policies in the policy group one by one. When it is found that a packet has no policy group to match with it, a new policy group is established according to protocol information of this packet. Then, it is verified whether the filtering policy should be added to the newly established policy group or not according to the matching relationship between feature values of each packet filtering policy and feature values of this newly established policy group. The packet information is filtered by using the policy group respectively. If there is a packet which does not match any policy groups, a corresponding policy group is added dynamically according to the protocol information of the packet. The filtering operation is repeated until the filtering of all packet data is completed.
In the present invention, a grouping process is performed on a plurality of packet filtering policies sequentially performed in a rule chain, such that interrelated filtering policies are integrated into the same policy group, and then the filtering policies in the policy group are performed sequentially. This can reduce the complexities of the dispatch and comparison of resources, thereby accelerating the speed of filtering the packet data.
The features and practices of the present invention will be illustrated from the detailed description of the best embodiments when read in conjunction with accompanying drawings.
The present invention will become more fully understood from the detailed description given herein below for illustration only, and thus are not limitative of the present invention, and wherein:
Referring to
A rule chain including a plurality of packet filtering policies is loaded (step S110). A plurality of packet data is received (step S120). A grouping procedure is performed on the packet filtering policies according to feature values of the packet filtering policies, so that the packet filtering policies meeting threshold values are set as a policy group (step S130). All of the packet filtering policies that match a policy group are added to this policy group. The packet data is filtered by using the policy group respectively (step S140).
It is determined whether the packet data matches the policy group or not (step S150). If the packet data matches the policy group, a packet filtering process is performed by using each packet filtering policy in the policy group (step S151). If the packet data does not match the policy group, a new policy group is added dynamically (step S152). The step of adding a new policy group is determined based on the protocol of the packet data. If the packet data does not match any packet filtering policy in the policy group, the packet data is processed according to a preset processing policy (step S153). The preset processing policy can be set as passing, discarding, or retaining the packet data, and the like.
To facilitate illustrating the spirit of the present invention, nodes of different forms are taken as examples of different filtering policies and are not limited to the number as described. Referring to
In the present invention, the feature values can take the network protocol or the type of network services in the received packet data as the condition of feature values. For example, in all the link layer packages, Ethernet, token ring and the like are in the first layer, ARP, RARP, IPV4, IPV6 are in the second layer, and TCP, UDP, ICMP, IGMP, SCTP are in the third layer. A corresponding set value is assigned to them, and then the feature values of the packet filtering are resolved according the set values for the above-mentioned packet filtering policies. Accordingly, the following set values can be assigned to the various protocols and services described above.
//layer 2 mask define
#define IPV4_MASK 1 //00000001
#define IPV6_MASK 2 //00000010
#define ARP_MASK 4 //00000100
#define RARP_MASK 8 //00001000
//layer3 mask define
#define TCP_MASK 1 //00000001
#define UDP_MASK 2 //00000010
#define ICMP_MASK 4 //00000100
#define SCTP_MASK 8 //00001000
Therefore, the system is adapted to resolve the feature values of each packet filtering policy, thereby producing corresponding policy groups. Referring to
After the above policy groups have established, the performing sequence of the rule chain 200 in
In Rule 1, the performing sequences of filtering policies in each policy group are connected in series. For example, the filtering policies in the policy group 210 are the first and the fifth filtering policy in the
In Rule 2, the producing sequence of policy groups is taken as a new sequence of rule chain 200, as referred to
In addition, whenever a policy group processes a packet, as long as the packet does not match any filtering policies in the policy group, the system performs corresponding filtering process on the packet data according to a preset processing policy. The preset processing policy performs the following steps according to the protocol information of the packet: adding policy groups, passing the packet, or discarding the packet. This can not only guarantee the transparence of the dynamic generation of the policy groups to the administrator, but also guarantee that all necessary policy groups are always generated in particular application environment.
In the present invention, a regular grouping process is performed on a rule chain 200 performed sequentially, such that the filtering policies with the same feature values are integrated into one policy group, and then the filtering policies in the policy group are performed sequentially. In this manner, the complexities of the dispatch and comparison of resources is reduced, thereby accelerating the speed of filtering the packet data.