Ticket #157: 619-netfilter_classify.patch

File 619-netfilter_classify.patch, 5.0 kB (added by greve@fsfeurope.org, 2 years ago)

Patch to add CLASSIFY support to 2.4 kernel

  • linux-2.4.32/Documentation/Configure.help

    old new  
    32513251  If you want to compile it as a module, say M here and read 
    32523252  <file:Documentation/modules.txt>.  If unsure, say `N'. 
    32533253 
     3254CLASSIFY target support 
     3255CONFIG_IP_NF_TARGET_CLASSIFY 
     3256  This option adds a `CLASSIFY' target, which enables the user to set 
     3257  the priority of a packet. Some qdiscs can use this value for classification, 
     3258  among these are: 
     3259 
     3260  atm, cbq, dsmark, pfifo_fast, htb, prio 
     3261 
     3262  If you want to compile it as a module, say M here and read 
     3263  Documentation/modules.txt.  If unsure, say `N'. 
     3264 
    32543265IP set support 
    32553266CONFIG_IP_NF_SET 
    32563267  This option adds IP set support to the kernel. 
  • linux-2.4.32/include/linux/netfilter_ipv4/ipt_CLASSIFY.h

    old new  
     1#ifndef _IPT_CLASSIFY_H 
     2#define _IPT_CLASSIFY_H 
     3 
     4struct ipt_classify_target_info { 
     5        u_int32_t priority; 
     6}; 
     7 
     8#endif /*_IPT_CLASSIFY_H */ 
  • linux-2.4.32/net/ipv4/netfilter/Config.in

    old new  
    172172    dep_tristate '    DSCP target support' CONFIG_IP_NF_TARGET_DSCP $CONFIG_IP_NF_MANGLE 
    173173  
    174174    dep_tristate '    MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE 
     175    dep_tristate '    CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE 
    175176    dep_tristate '    IMQ target support' CONFIG_IP_NF_TARGET_IMQ $CONFIG_IP_NF_MANGLE 
    176177  fi 
    177178  if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then 
  • linux-2.4.32/net/ipv4/netfilter/ipt_CLASSIFY.c

    old new  
     1/* 
     2 * This is a module which is used for setting the skb->priority field 
     3 * of an skb for qdisc classification. 
     4 */ 
     5 
     6#include <linux/module.h> 
     7#include <linux/skbuff.h> 
     8#include <linux/ip.h> 
     9#include <net/checksum.h> 
     10 
     11#include <linux/netfilter_ipv4/ip_tables.h> 
     12#include <linux/netfilter_ipv4/ipt_CLASSIFY.h> 
     13 
     14MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); 
     15MODULE_LICENSE("GPL"); 
     16MODULE_DESCRIPTION("iptables qdisc classification target module"); 
     17 
     18static unsigned int 
     19target(struct sk_buff **pskb, 
     20       unsigned int hooknum, 
     21       const struct net_device *in, 
     22       const struct net_device *out, 
     23       const void *targinfo, 
     24       void *userinfo) 
     25{ 
     26        const struct ipt_classify_target_info *clinfo = targinfo; 
     27 
     28        if((*pskb)->priority != clinfo->priority) { 
     29                (*pskb)->priority = clinfo->priority; 
     30                (*pskb)->nfcache |= NFC_ALTERED; 
     31        } 
     32 
     33        return IPT_CONTINUE; 
     34} 
     35 
     36static int 
     37checkentry(const char *tablename, 
     38           const struct ipt_entry *e, 
     39           void *targinfo, 
     40           unsigned int targinfosize, 
     41           unsigned int hook_mask) 
     42{ 
     43        if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){ 
     44                printk(KERN_ERR "CLASSIFY: invalid size (%u != %u).\n", 
     45                       targinfosize, 
     46                       IPT_ALIGN(sizeof(struct ipt_classify_target_info))); 
     47                return 0; 
     48        } 
     49         
     50        if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) { 
     51                printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n"); 
     52                return 0; 
     53        } 
     54 
     55        if (strcmp(tablename, "mangle") != 0) { 
     56                printk(KERN_WARNING "CLASSIFY: can only be called from " 
     57                                    "\"mangle\" table, not \"%s\".\n", 
     58                                    tablename); 
     59                return 0; 
     60        } 
     61 
     62        return 1; 
     63} 
     64 
     65static struct ipt_target ipt_classify_reg 
     66= { { NULL, NULL }, "CLASSIFY", target, checkentry, NULL, THIS_MODULE }; 
     67 
     68static int __init init(void) 
     69{ 
     70        if (ipt_register_target(&ipt_classify_reg)) 
     71                return -EINVAL; 
     72 
     73        return 0; 
     74} 
     75 
     76static void __exit fini(void) 
     77{ 
     78        ipt_unregister_target(&ipt_classify_reg); 
     79} 
     80 
     81module_init(init); 
     82module_exit(fini); 
  • linux-2.4.32/net/ipv4/netfilter/Makefile

    old new  
    134134 
    135135# targets 
    136136obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o 
     137obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o 
    137138obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o 
    138139obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o 
    139140obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o