]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-pom-ng-IPMARK.patch
- try to fix ppc builds for external modules (untested yet)
[packages/kernel.git] / kernel-pom-ng-IPMARK.patch
1 diff -NurpP --minimal linux-2.6.21.a/include/linux/netfilter_ipv4/ipt_IPMARK.h linux-2.6.21.b/include/linux/netfilter_ipv4/ipt_IPMARK.h
2 --- linux-2.6.21.a/include/linux/netfilter_ipv4/ipt_IPMARK.h    1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.21.b/include/linux/netfilter_ipv4/ipt_IPMARK.h    2007-05-30 12:01:20.000000000 +0200
4 @@ -0,0 +1,13 @@
5 +#ifndef _IPT_IPMARK_H_target
6 +#define _IPT_IPMARK_H_target
7 +
8 +struct ipt_ipmark_target_info {
9 +       unsigned long andmask;
10 +       unsigned long ormask;
11 +       unsigned char addr;
12 +};
13 +
14 +#define IPT_IPMARK_SRC    0
15 +#define IPT_IPMARK_DST    1
16 +
17 +#endif /*_IPT_IPMARK_H_target*/
18 diff -NurpP --minimal linux-2.6.21.a/net/ipv4/netfilter/Kconfig linux-2.6.21.b/net/ipv4/netfilter/Kconfig
19 --- linux-2.6.21.a/net/ipv4/netfilter/Kconfig   2007-05-30 12:01:03.000000000 +0200
20 +++ linux-2.6.21.b/net/ipv4/netfilter/Kconfig   2007-05-30 12:01:20.000000000 +0200
21 @@ -893,5 +893,23 @@ config IP_NF_RSH
22           If you want to compile it as a module, say M here and read
23           <file:Documentation/modules.txt>.  If unsure, say `N'.
24  
25 +config IP_NF_TARGET_IPMARK
26 +       tristate  'IPMARK target support'
27 +       depends on IP_NF_MANGLE
28 +       help
29 +         This option adds a `IPMARK' target, which allows you to create rules
30 +         in the `mangle' table which alter the netfilter mark field basing
31 +         on the source or destination ip address of the packet.
32 +         This is very useful for very fast massive shaping - using only one
33 +         rule you can direct packets to houndreds different queues.
34 +         You will probably find it helpful only if your linux machine acts as
35 +         a shaper for many others computers.
36 +
37 +         If you want to compile it as a module, say M here and read
38 +         <file:Documentation/modules.txt>. The module will be called
39 +         ipt_IPMARK.o.  If unsure, say `N'.
40 +
41 +
42 +
43  endmenu
44  
45 diff -NurpP --minimal linux-2.6.21.a/net/ipv4/netfilter/Makefile linux-2.6.21.b/net/ipv4/netfilter/Makefile
46 --- linux-2.6.21.a/net/ipv4/netfilter/Makefile  2007-05-30 12:01:03.000000000 +0200
47 +++ linux-2.6.21.b/net/ipv4/netfilter/Makefile  2007-05-30 12:01:21.000000000 +0200
48 @@ -82,6 +82,7 @@
49  obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
50  obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
51  obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
52 +obj-$(CONFIG_IP_NF_TARGET_IPMARK) += ipt_IPMARK.o
53  
54  obj-$(CONFIG_IP_NF_MATCH_IPV4OPTIONS) += ipt_ipv4options.o
55  
56 diff -NurpP --minimal linux-2.6.21.a/net/ipv4/netfilter/ipt_IPMARK.c linux-2.6.21.b/net/ipv4/netfilter/ipt_IPMARK.c
57 --- linux-2.6.21.a/net/ipv4/netfilter/ipt_IPMARK.c      1970-01-01 01:00:00.000000000 +0100
58 +++ linux-2.6.21.b/net/ipv4/netfilter/ipt_IPMARK.c      2007-05-30 12:01:21.000000000 +0200
59 @@ -0,0 +1,99 @@
60 +#include <linux/module.h>
61 +#include <linux/skbuff.h>
62 +#include <linux/version.h>
63 +#include <linux/ip.h>
64 +#include <net/checksum.h>
65 +
66 +#include <linux/netfilter_ipv4/ip_tables.h>
67 +#include <linux/netfilter_ipv4/ipt_IPMARK.h>
68 +
69 +MODULE_AUTHOR("Grzegorz Janoszka <Grzegorz@Janoszka.pl>");
70 +MODULE_DESCRIPTION("IP tables IPMARK: mark based on ip address");
71 +MODULE_LICENSE("GPL");
72 +
73 +static unsigned int
74 +target(struct sk_buff *skb,
75 +       const struct net_device *in,
76 +       const struct net_device *out,
77 +       unsigned int hooknum,
78 +       const struct xt_target *target,
79 +       const void *targinfo)
80 +{
81 +       const struct ipt_ipmark_target_info *ipmarkinfo = targinfo;
82 +       struct iphdr *iph = ip_hdr(skb);
83 +       unsigned long mark;
84 +
85 +       if (ipmarkinfo->addr == IPT_IPMARK_SRC)
86 +               mark = (unsigned long) ntohl(iph->saddr);
87 +       else
88 +               mark = (unsigned long) ntohl(iph->daddr);
89 +
90 +       mark &= ipmarkinfo->andmask;
91 +       mark |= ipmarkinfo->ormask;
92 +
93 +       if (skb->mark != mark)
94 +               skb->mark = mark;
95 +       return IPT_CONTINUE;
96 +}
97 +
98 +static bool
99 +checkentry(const char *tablename,
100 +          const void *e,
101 +          const struct xt_target *target,
102 +           void *targinfo,
103 +           unsigned int hook_mask)
104 +{
105 +
106 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
107 +       if (targinfosize != IPT_ALIGN(sizeof(struct ipt_ipmark_target_info))) {
108 +               printk(KERN_WARNING "IPMARK: targinfosize %u != %Zu\n",
109 +                      targinfosize,
110 +                      IPT_ALIGN(sizeof(struct ipt_ipmark_target_info)));
111 +               return 0;
112 +       }
113 +#endif
114 +
115 +       if (strcmp(tablename, "mangle") != 0) {
116 +               printk(KERN_WARNING "IPMARK: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
117 +               return 0;
118 +       }
119 +
120 +       return 1;
121 +}
122 +
123 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
124 +static struct xt_target ipt_ipmark_reg = {
125 +#else
126 +static struct ipt_target ipt_ipmark_reg = { 
127 +#endif
128 +       .name           = "IPMARK",
129 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
130 +       .family         = AF_INET,
131 +#endif
132 +       .target         = target,
133 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17)
134 +       .targetsize     = sizeof(struct ipt_ipmark_target_info),
135 +#endif
136 +       .checkentry     = checkentry,
137 +       .me             = THIS_MODULE
138 +};
139 +
140 +static int __init init(void)
141 +{
142 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
143 +       return xt_register_target(&ipt_ipmark_reg);
144 +#else
145 +       return ipt_register_target(&ipt_ipmark_reg);
146 +#endif
147 +}
148 +
149 +static void __exit fini(void)
150 +{
151 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
152 +       xt_unregister_target(&ipt_ipmark_reg);
153 +#else
154 +       ipt_unregister_target(&ipt_ipmark_reg);
155 +#endif
156 +}
157 +
158 +module_init(init);
159 +module_exit(fini);
This page took 0.049012 seconds and 3 git commands to generate.