1 diff -uNr linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ip_conntrack.h linux-2.6.4-rc1/include/linux/netfilter_ipv4/ip_conntrack.h
2 --- linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ip_conntrack.h 2004-03-03 03:30:33.000000000 +0100
3 +++ linux-2.6.4-rc1/include/linux/netfilter_ipv4/ip_conntrack.h 2004-03-03 03:58:03.401720416 +0100
6 #endif /* CONFIG_IP_NF_NAT_NEEDED */
8 +#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
13 /* get master conntrack via master expectation */
14 diff -uNr linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ipt_connmark.h linux-2.6.4-rc1/include/linux/netfilter_ipv4/ipt_connmark.h
15 --- linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ipt_connmark.h 1970-01-01 01:00:00.000000000 +0100
16 +++ linux-2.6.4-rc1/include/linux/netfilter_ipv4/ipt_connmark.h 2004-03-03 03:58:03.402720264 +0100
18 +#ifndef _IPT_CONNMARK_H
19 +#define _IPT_CONNMARK_H
21 +struct ipt_connmark_info {
22 + unsigned long mark, mask;
26 +#endif /*_IPT_CONNMARK_H*/
27 diff -uNr linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ipt_CONNMARK.h linux-2.6.4-rc1/include/linux/netfilter_ipv4/ipt_CONNMARK.h
28 --- linux-2.6.4-rc1/include/linux.orig/netfilter_ipv4/ipt_CONNMARK.h 1970-01-01 01:00:00.000000000 +0100
29 +++ linux-2.6.4-rc1/include/linux/netfilter_ipv4/ipt_CONNMARK.h 2004-03-03 03:58:03.402720264 +0100
31 +#ifndef _IPT_CONNMARK_H_target
32 +#define _IPT_CONNMARK_H_target
35 + IPT_CONNMARK_SET = 0,
37 + IPT_CONNMARK_RESTORE
40 +struct ipt_connmark_target_info {
41 + unsigned long mark, mask;
45 +#endif /*_IPT_CONNMARK_H_target*/
46 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/ip_conntrack_core.c linux-2.6.4-rc1/net/ipv4/netfilter/ip_conntrack_core.c
47 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/ip_conntrack_core.c 2004-03-03 03:30:33.000000000 +0100
48 +++ linux-2.6.4-rc1/net/ipv4/netfilter/ip_conntrack_core.c 2004-03-03 03:58:03.418717832 +0100
50 __set_bit(IPS_EXPECTED_BIT, &conntrack->status);
51 conntrack->master = expected;
52 expected->sibling = conntrack;
53 +#if CONFIG_IP_NF_CONNTRACK_MARK
54 + conntrack->mark = expected->expectant->mark;
56 LIST_DELETE(&ip_conntrack_expect_list, expected);
57 expected->expectant->expecting--;
58 nf_conntrack_get(&master_ct(conntrack)->infos[0]);
59 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/ip_conntrack_standalone.c linux-2.6.4-rc1/net/ipv4/netfilter/ip_conntrack_standalone.c
60 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/ip_conntrack_standalone.c 2004-03-03 03:30:33.000000000 +0100
61 +++ linux-2.6.4-rc1/net/ipv4/netfilter/ip_conntrack_standalone.c 2004-03-03 03:58:03.420717528 +0100
63 len += sprintf(buffer + len, "[ASSURED] ");
64 len += sprintf(buffer + len, "use=%u ",
65 atomic_read(&conntrack->ct_general.use));
66 +#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
67 + len += sprintf(buffer + len, "mark=%ld ", conntrack->mark);
69 len += sprintf(buffer + len, "\n");
72 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/ipt_connmark.c linux-2.6.4-rc1/net/ipv4/netfilter/ipt_connmark.c
73 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/ipt_connmark.c 1970-01-01 01:00:00.000000000 +0100
74 +++ linux-2.6.4-rc1/net/ipv4/netfilter/ipt_connmark.c 2004-03-03 03:58:03.429716160 +0100
76 +/* Kernel module to match connection mark values. */
77 +#include <linux/module.h>
78 +#include <linux/skbuff.h>
80 +#include <linux/netfilter_ipv4/ip_tables.h>
81 +#include <linux/netfilter_ipv4/ipt_connmark.h>
82 +#include <linux/netfilter_ipv4/ip_conntrack.h>
85 +match(const struct sk_buff *skb,
86 + const struct net_device *in,
87 + const struct net_device *out,
88 + const void *matchinfo,
92 + const struct ipt_connmark_info *info = matchinfo;
93 + enum ip_conntrack_info ctinfo;
94 + struct ip_conntrack *ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo);
98 + return ((ct->mark & info->mask) == info->mark) ^ info->invert;
102 +checkentry(const char *tablename,
103 + const struct ipt_ip *ip,
105 + unsigned int matchsize,
106 + unsigned int hook_mask)
108 + if (matchsize != IPT_ALIGN(sizeof(struct ipt_connmark_info)))
114 +static struct ipt_match connmark_match = {
115 + .name = "connmark",
117 + .checkentry = &checkentry,
121 +static int __init init(void)
123 + return ipt_register_match(&connmark_match);
126 +static void __exit fini(void)
128 + ipt_unregister_match(&connmark_match);
133 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/ipt_CONNMARK.c linux-2.6.4-rc1/net/ipv4/netfilter/ipt_CONNMARK.c
134 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/ipt_CONNMARK.c 1970-01-01 01:00:00.000000000 +0100
135 +++ linux-2.6.4-rc1/net/ipv4/netfilter/ipt_CONNMARK.c 2004-03-03 03:58:03.427716464 +0100
137 +/* This is a module which is used for setting/remembering the mark field of
138 + * an connection, or optionally restore it to the skb
140 +#include <linux/module.h>
141 +#include <linux/skbuff.h>
142 +#include <linux/ip.h>
143 +#include <net/checksum.h>
145 +#include <linux/netfilter_ipv4/ip_tables.h>
146 +#include <linux/netfilter_ipv4/ipt_CONNMARK.h>
147 +#include <linux/netfilter_ipv4/ip_conntrack.h>
150 +target(struct sk_buff **pskb,
151 + const struct net_device *in,
152 + const struct net_device *out,
153 + unsigned int hooknum,
154 + const void *targinfo,
157 + const struct ipt_connmark_target_info *markinfo = targinfo;
159 + enum ip_conntrack_info ctinfo;
160 + struct ip_conntrack *ct = ip_conntrack_get((*pskb), &ctinfo);
162 + switch(markinfo->mode) {
163 + case IPT_CONNMARK_SET:
164 + ct->mark = markinfo->mark;
166 + case IPT_CONNMARK_SAVE:
167 + ct->mark = (*pskb)->nfmark;
169 + case IPT_CONNMARK_RESTORE:
170 + if (ct->mark != (*pskb)->nfmark) {
171 + (*pskb)->nfmark = ct->mark;
172 + (*pskb)->nfcache |= NFC_ALTERED;
178 + return IPT_CONTINUE;
182 +checkentry(const char *tablename,
183 + const struct ipt_entry *e,
185 + unsigned int targinfosize,
186 + unsigned int hook_mask)
188 + struct ipt_connmark_target_info *matchinfo = targinfo;
189 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_connmark_target_info))) {
190 + printk(KERN_WARNING "CONNMARK: targinfosize %u != %Zu\n",
192 + IPT_ALIGN(sizeof(struct ipt_connmark_target_info)));
196 + if (matchinfo->mode == IPT_CONNMARK_RESTORE) {
197 + if (strcmp(tablename, "mangle") != 0) {
198 + printk(KERN_WARNING "CONNMARK: restore can only be called from \"mangle\" table, not \"%s\"\n", tablename);
206 +static struct ipt_target ipt_connmark_reg = {
207 + .name = "CONNMARK",
209 + .checkentry = checkentry,
213 +static int __init init(void)
215 + if (ipt_register_target(&ipt_connmark_reg))
221 +static void __exit fini(void)
223 + ipt_unregister_target(&ipt_connmark_reg);
228 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/Kconfig linux-2.6.4-rc1/net/ipv4/netfilter/Kconfig
229 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/Kconfig 2004-03-03 03:43:30.000000000 +0100
230 +++ linux-2.6.4-rc1/net/ipv4/netfilter/Kconfig 2004-03-03 03:58:03.414718440 +0100
233 To compile it as a module, choose M here. If unsure, say Y.
235 +config IP_NF_CONNTRACK_MARK
236 + bool "Connection mark tracking support"
237 + depends on IP_NF_CONNTRACK
239 + This option enables support for connection marks, used by the
240 + `CONNMARK' target and `connmark' match. Similar to the mark value
241 + of packets, but this mark value is kept in the conntrack session
242 + instead of the individual packets.
245 tristate "IRC protocol support"
246 depends on IP_NF_CONNTRACK
249 To compile it as a module, choose M here. If unsure, say N.
251 +config IP_NF_MATCH_CONNMARK
252 + tristate "Connection mark match support"
253 + depends on IP_NF_CONNTRACK_MARK && IP_NF_CONNTRACK && IP_NF_IPTABLES
255 + This option adds a `connmark' match, which allows you to match the
256 + connection mark value previously set for the session by `CONNMARK'.
258 + To compile it as a module, choose M here. If unsure, say N.
260 config IP_NF_MATCH_CONNTRACK
261 tristate "Connection tracking match support"
262 depends on IP_NF_CONNTRACK && IP_NF_IPTABLES
265 To compile it as a module, choose M here. If unsure, say N.
267 +config IP_NF_TARGET_CONNMARK
268 + tristate "CONNMARK target support"
269 + depends on IP_NF_CONNTRACK_MARK && IP_NF_CONNTRACK && IP_NF_IPTABLES
271 + This option adds a `CONNMARK' target, which allows one to manipulate
272 + the connection mark value. Similar to the MARK target, but
273 + affects the connection mark value rather than the packet mark value.
275 + To compile it as a module, choose M here, the module will be called
276 + ipt_CONNMARK.o. If unsure, say N.
278 config IP_NF_TARGET_ULOG
279 tristate "ULOG target support"
280 depends on IP_NF_IPTABLES
281 diff -uNr linux-2.6.4-rc1/net/ipv4.orig/netfilter/Makefile linux-2.6.4-rc1/net/ipv4/netfilter/Makefile
282 --- linux-2.6.4-rc1/net/ipv4.orig/netfilter/Makefile 2004-03-03 03:43:30.000000000 +0100
283 +++ linux-2.6.4-rc1/net/ipv4/netfilter/Makefile 2004-03-03 04:01:17.565203080 +0100
285 obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
286 obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
287 obj-$(CONFIG_IP_NF_MATCH_CONNLIMIT) += ipt_connlimit.o
288 +obj-$(CONFIG_IP_NF_MATCH_CONNMARK) += ipt_connmark.o
289 obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
290 obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
291 obj-$(CONFIG_IP_NF_MATCH_REALM) += ipt_realm.o
293 obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
294 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
295 obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
296 +obj-$(CONFIG_IP_NF_TARGET_CONNMARK) += ipt_CONNMARK.o
297 obj-$(CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP) += ipt_IPV4OPTSSTRIP.o
298 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
299 obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o