static int route_classify(struct sk_buff *skb, struct tcf_proto *tp,
struct tcf_result *res)
{
struct dst_entry *dst = skb->dst;
if (dst) {
u32 clid = dst->tclassid;
if (clid && (TC_H_MAJ(clid) == 0 ||
!(TC_H_MAJ(clid^tp->q->handle)))) {
res->classid = clid;
res->class = 0;
return 0;
}
}
return -1;
}
The route classifier classifies packets based on the destination IP address. In the route_classify function, the destination is associated with a dst_entry structure (in include/net/dst.h). The class ID of the class is stored in the tclassid field of the dst_entry structure. If the destination to which the packet needs to be sent is determined, the corresponding class ID is returned in the tcf_result structure. In general, the filters are also associated with policers, to determine if a flow is in profile. Having discussed the classify function, let us now discuss the init function of a filter.