]> git.pld-linux.org Git - packages/kernel.git/blame - pom-ng-IPMARK-20060504.patch
- use CUBIC by default:
[packages/kernel.git] / pom-ng-IPMARK-20060504.patch
CommitLineData
41365f37 1 include/linux/netfilter_ipv4/ipt_IPMARK.h | 13 ++++
2 net/ipv4/netfilter/Kconfig | 18 ++++++
3 net/ipv4/netfilter/Makefile | 1
4 net/ipv4/netfilter/ipt_IPMARK.c | 79 ++++++++++++++++++++++++++++++
5 4 files changed, 111 insertions(+)
6
7diff -Nur --exclude '*.orig' linux.org/include/linux/netfilter_ipv4/ipt_IPMARK.h linux/include/linux/netfilter_ipv4/ipt_IPMARK.h
8--- linux.org/include/linux/netfilter_ipv4/ipt_IPMARK.h 1970-01-01 01:00:00.000000000 +0100
9+++ linux/include/linux/netfilter_ipv4/ipt_IPMARK.h 2006-05-04 11:19:22.000000000 +0200
10@@ -0,0 +1,13 @@
11+#ifndef _IPT_IPMARK_H_target
12+#define _IPT_IPMARK_H_target
13+
14+struct ipt_ipmark_target_info {
15+ unsigned long andmask;
16+ unsigned long ormask;
17+ unsigned char addr;
18+};
19+
20+#define IPT_IPMARK_SRC 0
21+#define IPT_IPMARK_DST 1
22+
23+#endif /*_IPT_IPMARK_H_target*/
24diff -Nur --exclude '*.orig' linux.org/net/ipv4/netfilter/Kconfig linux/net/ipv4/netfilter/Kconfig
25--- linux.org/net/ipv4/netfilter/Kconfig 2006-05-02 23:38:44.000000000 +0200
26+++ linux/net/ipv4/netfilter/Kconfig 2006-05-04 11:19:22.000000000 +0200
27@@ -606,5 +606,23 @@
28 Allows altering the ARP packet payload: source and destination
29 hardware and network addresses.
30
31+config IP_NF_TARGET_IPMARK
32+ tristate 'IPMARK target support'
33+ depends on IP_NF_MANGLE
34+ help
35+ This option adds a `IPMARK' target, which allows you to create rules
36+ in the `mangle' table which alter the netfilter mark field basing
37+ on the source or destination ip address of the packet.
38+ This is very useful for very fast massive shaping - using only one
39+ rule you can direct packets to houndreds different queues.
40+ You will probably find it helpful only if your linux machine acts as
41+ a shaper for many others computers.
42+
43+ If you want to compile it as a module, say M here and read
44+ <file:Documentation/modules.txt>. The module will be called
45+ ipt_IPMARK.o. If unsure, say `N'.
46+
47+
48+
49 endmenu
50
51diff -Nur --exclude '*.orig' linux.org/net/ipv4/netfilter/Makefile linux/net/ipv4/netfilter/Makefile
52--- linux.org/net/ipv4/netfilter/Makefile 2006-05-02 23:38:44.000000000 +0200
53+++ linux/net/ipv4/netfilter/Makefile 2006-05-04 11:19:22.000000000 +0200
54@@ -0,0 +0,1 @@
55+obj-$(CONFIG_IP_NF_TARGET_IPMARK) += ipt_IPMARK.o
56diff -Nur --exclude '*.orig' linux.org/net/ipv4/netfilter/ipt_IPMARK.c linux/net/ipv4/netfilter/ipt_IPMARK.c
57--- linux.org/net/ipv4/netfilter/ipt_IPMARK.c 1970-01-01 01:00:00.000000000 +0100
58+++ linux/net/ipv4/netfilter/ipt_IPMARK.c 2006-05-04 11:19:22.000000000 +0200
59@@ -0,0 +1,79 @@
60+#include <linux/module.h>
61+#include <linux/skbuff.h>
62+#include <linux/ip.h>
63+#include <net/checksum.h>
64+
65+#include <linux/netfilter_ipv4/ip_tables.h>
66+#include <linux/netfilter_ipv4/ipt_IPMARK.h>
67+
68+MODULE_AUTHOR("Grzegorz Janoszka <Grzegorz@Janoszka.pl>");
69+MODULE_DESCRIPTION("IP tables IPMARK: mark based on ip address");
70+MODULE_LICENSE("GPL");
71+
72+static unsigned int
73+target(struct sk_buff **pskb,
74+ const struct net_device *in,
75+ const struct net_device *out,
76+ unsigned int hooknum,
77+ const void *targinfo,
78+ void *userinfo)
79+{
80+ const struct ipt_ipmark_target_info *ipmarkinfo = targinfo;
81+ struct iphdr *iph = (*pskb)->nh.iph;
82+ unsigned long mark;
83+
84+ if (ipmarkinfo->addr == IPT_IPMARK_SRC)
85+ mark = (unsigned long) ntohl(iph->saddr);
86+ else
87+ mark = (unsigned long) ntohl(iph->daddr);
88+
89+ mark &= ipmarkinfo->andmask;
90+ mark |= ipmarkinfo->ormask;
91+
92+ if ((*pskb)->nfmark != mark)
93+ (*pskb)->nfmark = mark;
94+
95+ return IPT_CONTINUE;
96+}
97+
98+static int
99+checkentry(const char *tablename,
100+ const struct ipt_entry *e,
101+ void *targinfo,
102+ unsigned int targinfosize,
103+ unsigned int hook_mask)
104+{
105+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_ipmark_target_info))) {
106+ printk(KERN_WARNING "IPMARK: targinfosize %u != %Zu\n",
107+ targinfosize,
108+ IPT_ALIGN(sizeof(struct ipt_ipmark_target_info)));
109+ return 0;
110+ }
111+
112+ if (strcmp(tablename, "mangle") != 0) {
113+ printk(KERN_WARNING "IPMARK: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
114+ return 0;
115+ }
116+
117+ return 1;
118+}
119+
120+static struct ipt_target ipt_ipmark_reg = {
121+ .name = "IPMARK",
122+ .target = target,
123+ .checkentry = checkentry,
124+ .me = THIS_MODULE
125+};
126+
127+static int __init init(void)
128+{
129+ return ipt_register_target(&ipt_ipmark_reg);
130+}
131+
132+static void __exit fini(void)
133+{
134+ ipt_unregister_target(&ipt_ipmark_reg);
135+}
136+
137+module_init(init);
138+module_exit(fini);
This page took 0.095511 seconds and 4 git commands to generate.