]> git.pld-linux.org Git - packages/kernel.git/blame - 2.6.5-rc1-patch-o-matic-ng-base-20040316.patch
- obsolete
[packages/kernel.git] / 2.6.5-rc1-patch-o-matic-ng-base-20040316.patch
CommitLineData
4e23f685 1diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter.h linux-2.6.5-rc1/include/linux/netfilter.h
2--- linux-2.6.5-rc1.org/include/linux/netfilter.h 2004-03-16 05:46:35.000000000 +0000
3+++ linux-2.6.5-rc1/include/linux/netfilter.h 2004-03-16 11:53:42.000000000 +0000
4@@ -99,6 +99,24 @@
5
6 extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
7
8+typedef void nf_logfn(unsigned int hooknum,
9+ const struct sk_buff *skb,
10+ const struct net_device *in,
11+ const struct net_device *out,
12+ const char *prefix);
13+
14+/* Function to register/unregister log function. */
15+int nf_log_register(int pf, nf_logfn *logfn);
16+void nf_log_unregister(int pf, nf_logfn *logfn);
17+
18+/* Calls the registered backend logging function */
19+void nf_log_packet(int pf,
20+ unsigned int hooknum,
21+ const struct sk_buff *skb,
22+ const struct net_device *in,
23+ const struct net_device *out,
24+ const char *fmt, ...);
25+
26 /* Activate hook; either okfn or kfree_skb called, unless a hook
27 returns NF_STOLEN (in which case, it's up to the hook to deal with
28 the consequences).
29diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ip_conntrack.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ip_conntrack.h
30--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ip_conntrack.h 2004-03-16 05:47:19.000000000 +0000
31+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ip_conntrack.h 2004-03-16 11:53:55.000000000 +0000
32@@ -251,6 +251,9 @@
33 /* Call me when a conntrack is destroyed. */
34 extern void (*ip_conntrack_destroyed)(struct ip_conntrack *conntrack);
35
36+/* Fake conntrack entry for untracked connections */
37+extern struct ip_conntrack ip_conntrack_untracked;
38+
39 /* Returns new sk_buff, or NULL */
40 struct sk_buff *
41 ip_ct_gather_frags(struct sk_buff *skb);
42diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_TTL.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_TTL.h
43--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_TTL.h 1970-01-01 00:00:00.000000000 +0000
44+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_TTL.h 2004-03-16 11:53:46.000000000 +0000
45@@ -0,0 +1,21 @@
46+/* TTL modification module for IP tables
47+ * (C) 2000 by Harald Welte <laforge@gnumonks.org> */
48+
49+#ifndef _IPT_TTL_H
50+#define _IPT_TTL_H
51+
52+enum {
53+ IPT_TTL_SET = 0,
54+ IPT_TTL_INC,
55+ IPT_TTL_DEC
56+};
57+
58+#define IPT_TTL_MAXMODE IPT_TTL_DEC
59+
60+struct ipt_TTL_info {
61+ u_int8_t mode;
62+ u_int8_t ttl;
63+};
64+
65+
66+#endif
67diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_ULOG.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_ULOG.h
68--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_ULOG.h 2004-03-16 05:46:09.000000000 +0000
69+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_ULOG.h 2004-03-16 11:53:42.000000000 +0000
70@@ -11,6 +11,9 @@
71 #define NETLINK_NFLOG 5
72 #endif
73
74+#define ULOG_DEFAULT_NLGROUP 1
75+#define ULOG_DEFAULT_QTHRESHOLD 1
76+
77 #define ULOG_MAC_LEN 80
78 #define ULOG_PREFIX_LEN 32
79
80diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_connlimit.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_connlimit.h
81--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_connlimit.h 1970-01-01 00:00:00.000000000 +0000
82+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_connlimit.h 2004-03-16 11:53:47.000000000 +0000
83@@ -0,0 +1,12 @@
84+#ifndef _IPT_CONNLIMIT_H
85+#define _IPT_CONNLIMIT_H
86+
87+struct ipt_connlimit_data;
88+
89+struct ipt_connlimit_info {
90+ int limit;
91+ int inverse;
92+ u_int32_t mask;
93+ struct ipt_connlimit_data *data;
94+};
95+#endif /* _IPT_CONNLIMIT_H */
96diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_conntrack.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_conntrack.h
97--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_conntrack.h 2004-03-16 05:47:04.000000000 +0000
98+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_conntrack.h 2004-03-16 11:53:55.000000000 +0000
99@@ -10,6 +10,7 @@
100
101 #define IPT_CONNTRACK_STATE_SNAT (1 << (IP_CT_NUMBER + 1))
102 #define IPT_CONNTRACK_STATE_DNAT (1 << (IP_CT_NUMBER + 2))
103+#define IPT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3))
104
105 /* flags, invflags: */
106 #define IPT_CONNTRACK_STATE 0x01
107diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_dstlimit.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_dstlimit.h
108--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_dstlimit.h 1970-01-01 00:00:00.000000000 +0000
109+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_dstlimit.h 2004-03-16 11:53:48.000000000 +0000
110@@ -0,0 +1,39 @@
111+#ifndef _IPT_DSTLIMIT_H
112+#define _IPT_DSTLIMIT_H
113+
114+/* timings are in milliseconds. */
115+#define IPT_DSTLIMIT_SCALE 10000
116+/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
117+ seconds, or one every 59 hours. */
118+
119+/* details of this structure hidden by the implementation */
120+struct ipt_dstlimit_htable;
121+
122+#define IPT_DSTLIMIT_HASH_DIP 0x0001
123+#define IPT_DSTLIMIT_HASH_DPT 0x0002
124+#define IPT_DSTLIMIT_HASH_SIP 0x0004
125+
126+struct dstlimit_cfg {
127+ u_int32_t mode; /* bitmask of IPT_DSTLIMIT_HASH_* */
128+ u_int32_t avg; /* Average secs between packets * scale */
129+ u_int32_t burst; /* Period multiplier for upper limit. */
130+
131+ /* user specified */
132+ u_int32_t size; /* how many buckets */
133+ u_int32_t max; /* max number of entries */
134+ u_int32_t gc_interval; /* gc interval */
135+ u_int32_t expire; /* when do entries expire? */
136+};
137+
138+struct ipt_dstlimit_info {
139+ char name [IFNAMSIZ]; /* name */
140+ struct dstlimit_cfg cfg;
141+ struct ipt_dstlimit_htable *hinfo;
142+
143+ /* Used internally by the kernel */
144+ union {
145+ void *ptr;
146+ struct ipt_dstlimit_info *master;
147+ } u;
148+};
149+#endif /*_IPT_DSTLIMIT_H*/
150diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_fuzzy.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_fuzzy.h
151--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_fuzzy.h 1970-01-01 00:00:00.000000000 +0000
152+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_fuzzy.h 2004-03-16 11:53:50.000000000 +0000
153@@ -0,0 +1,21 @@
154+#ifndef _IPT_FUZZY_H
155+#define _IPT_FUZZY_H
156+
157+#include <linux/param.h>
158+#include <linux/types.h>
159+
160+#define MAXFUZZYRATE 10000000
161+#define MINFUZZYRATE 3
162+
163+struct ipt_fuzzy_info {
164+ u_int32_t minimum_rate;
165+ u_int32_t maximum_rate;
166+ u_int32_t packets_total;
167+ u_int32_t bytes_total;
168+ u_int32_t previous_time;
169+ u_int32_t present_time;
170+ u_int32_t mean_rate;
171+ u_int8_t acceptance_rate;
172+};
173+
174+#endif /*_IPT_FUZZY_H*/
175diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_ipv4options.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_ipv4options.h
176--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_ipv4options.h 1970-01-01 00:00:00.000000000 +0000
177+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_ipv4options.h 2004-03-16 11:53:51.000000000 +0000
178@@ -0,0 +1,21 @@
179+#ifndef __ipt_ipv4options_h_included__
180+#define __ipt_ipv4options_h_included__
181+
182+#define IPT_IPV4OPTION_MATCH_SSRR 0x01 /* For strict source routing */
183+#define IPT_IPV4OPTION_MATCH_LSRR 0x02 /* For loose source routing */
184+#define IPT_IPV4OPTION_DONT_MATCH_SRR 0x04 /* any source routing */
185+#define IPT_IPV4OPTION_MATCH_RR 0x08 /* For Record route */
186+#define IPT_IPV4OPTION_DONT_MATCH_RR 0x10
187+#define IPT_IPV4OPTION_MATCH_TIMESTAMP 0x20 /* For timestamp request */
188+#define IPT_IPV4OPTION_DONT_MATCH_TIMESTAMP 0x40
189+#define IPT_IPV4OPTION_MATCH_ROUTER_ALERT 0x80 /* For router-alert */
190+#define IPT_IPV4OPTION_DONT_MATCH_ROUTER_ALERT 0x100
191+#define IPT_IPV4OPTION_MATCH_ANY_OPT 0x200 /* match packet with any option */
192+#define IPT_IPV4OPTION_DONT_MATCH_ANY_OPT 0x400 /* match packet with no option */
193+
194+struct ipt_ipv4options_info {
195+ u_int16_t options;
196+};
197+
198+
199+#endif /* __ipt_ipv4options_h_included__ */
200diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_mport.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_mport.h
201--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_mport.h 1970-01-01 00:00:00.000000000 +0000
202+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_mport.h 2004-03-16 11:53:52.000000000 +0000
203@@ -0,0 +1,24 @@
204+#ifndef _IPT_MPORT_H
205+#define _IPT_MPORT_H
206+#include <linux/netfilter_ipv4/ip_tables.h>
207+
208+#define IPT_MPORT_SOURCE (1<<0)
209+#define IPT_MPORT_DESTINATION (1<<1)
210+#define IPT_MPORT_EITHER (IPT_MPORT_SOURCE|IPT_MPORT_DESTINATION)
211+
212+#define IPT_MULTI_PORTS 15
213+
214+/* Must fit inside union ipt_matchinfo: 32 bytes */
215+/* every entry in ports[] except for the last one has one bit in pflags
216+ * associated with it. If this bit is set, the port is the first port of
217+ * a portrange, with the next entry being the last.
218+ * End of list is marked with pflags bit set and port=65535.
219+ * If 14 ports are used (last one does not have a pflag), the last port
220+ * is repeated to fill the last entry in ports[] */
221+struct ipt_mport
222+{
223+ u_int8_t flags:2; /* Type of comparison */
224+ u_int16_t pflags:14; /* Port flags */
225+ u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */
226+};
227+#endif /*_IPT_MPORT_H*/
228diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_nth.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_nth.h
229--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_nth.h 1970-01-01 00:00:00.000000000 +0000
230+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_nth.h 2004-03-16 11:53:53.000000000 +0000
231@@ -0,0 +1,19 @@
232+#ifndef _IPT_NTH_H
233+#define _IPT_NTH_H
234+
235+#include <linux/param.h>
236+#include <linux/types.h>
237+
238+#ifndef IPT_NTH_NUM_COUNTERS
239+#define IPT_NTH_NUM_COUNTERS 16
240+#endif
241+
242+struct ipt_nth_info {
243+ u_int8_t every;
244+ u_int8_t not;
245+ u_int8_t startat;
246+ u_int8_t counter;
247+ u_int8_t packet;
248+};
249+
250+#endif /*_IPT_NTH_H*/
251diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_quota.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_quota.h
252--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_quota.h 1970-01-01 00:00:00.000000000 +0000
253+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_quota.h 2004-03-16 11:53:54.000000000 +0000
254@@ -0,0 +1,11 @@
255+#ifndef _IPT_QUOTA_H
256+#define _IPT_QUOTA_H
257+
258+/* print debug info in both kernel/netfilter module & iptable library */
259+//#define DEBUG_IPT_QUOTA
260+
261+struct ipt_quota_info {
262+ u_int64_t quota;
263+};
264+
265+#endif /*_IPT_QUOTA_H*/
266diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_realm.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_realm.h
267--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_realm.h 1970-01-01 00:00:00.000000000 +0000
268+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_realm.h 2004-03-16 11:53:56.000000000 +0000
269@@ -0,0 +1,9 @@
270+#ifndef _IPT_REALM_H
271+#define _IPT_REALM_H
272+
273+struct ipt_realm_info {
274+ u_int32_t id;
275+ u_int32_t mask;
276+ u_int8_t invert;
277+};
278+#endif /*_IPT_REALM_H*/
279diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_sctp.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_sctp.h
280--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_sctp.h 1970-01-01 00:00:00.000000000 +0000
281+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_sctp.h 2004-03-16 11:53:57.000000000 +0000
282@@ -0,0 +1,107 @@
283+#ifndef _IPT_SCTP_H_
284+#define _IPT_SCTP_H_
285+
286+#define IPT_SCTP_SRC_PORTS 0x01
287+#define IPT_SCTP_DEST_PORTS 0x02
288+#define IPT_SCTP_CHUNK_TYPES 0x04
289+
290+#define IPT_SCTP_VALID_FLAGS 0x07
291+
292+#define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))
293+
294+
295+struct ipt_sctp_flag_info {
296+ u_int8_t chunktype;
297+ u_int8_t flag;
298+ u_int8_t flag_mask;
299+};
300+
301+#define IPT_NUM_SCTP_FLAGS 4
302+
303+struct ipt_sctp_info {
304+ u_int16_t dpts[2]; /* Min, Max */
305+ u_int16_t spts[2]; /* Min, Max */
306+
307+ u_int32_t chunkmap[256 / sizeof (u_int32_t)]; /* Bit mask of chunks to be matched according to RFC 2960 */
308+
309+#define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */
310+#define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */
311+#define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */
312+
313+ u_int32_t chunk_match_type;
314+ struct ipt_sctp_flag_info flag_info[IPT_NUM_SCTP_FLAGS];
315+ int flag_count;
316+
317+ u_int32_t flags;
318+ u_int32_t invflags;
319+};
320+
321+#define bytes(type) (sizeof(type) * 8)
322+
323+#define SCTP_CHUNKMAP_SET(chunkmap, type) \
324+ do { \
325+ chunkmap[type / bytes(u_int32_t)] |= \
326+ 1 << (type % bytes(u_int32_t)); \
327+ } while (0)
328+
329+#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
330+ do { \
331+ chunkmap[type / bytes(u_int32_t)] &= \
332+ ~(1 << (type % bytes(u_int32_t))); \
333+ } while (0)
334+
335+#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
336+({ \
337+ (chunkmap[type / bytes (u_int32_t)] & \
338+ (1 << (type % bytes (u_int32_t)))) ? 1: 0; \
339+})
340+
341+#define SCTP_CHUNKMAP_RESET(chunkmap) \
342+ do { \
343+ int i; \
344+ for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
345+ chunkmap[i] = 0; \
346+ } while (0)
347+
348+#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
349+ do { \
350+ int i; \
351+ for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
352+ chunkmap[i] = ~0; \
353+ } while (0)
354+
355+#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
356+ do { \
357+ int i; \
358+ for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
359+ destmap[i] = srcmap[i]; \
360+ } while (0)
361+
362+#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
363+({ \
364+ int i; \
365+ int flag = 1; \
366+ for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
367+ if (chunkmap[i]) { \
368+ flag = 0; \
369+ break; \
370+ } \
371+ } \
372+ flag; \
373+})
374+
375+#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
376+({ \
377+ int i; \
378+ int flag = 1; \
379+ for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
380+ if (chunkmap[i] != ~0) { \
381+ flag = 0; \
382+ break; \
383+ } \
384+ } \
385+ flag; \
386+})
387+
388+#endif /* _IPT_SCTP_H_ */
389+
390diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_state.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_state.h
391--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_state.h 2004-03-16 05:47:18.000000000 +0000
392+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_state.h 2004-03-16 11:53:55.000000000 +0000
393@@ -4,6 +4,8 @@
394 #define IPT_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1))
395 #define IPT_STATE_INVALID (1 << 0)
396
397+#define IPT_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 1))
398+
399 struct ipt_state_info
400 {
401 unsigned int statemask;
402diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_u32.h linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_u32.h
403--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4/ipt_u32.h 1970-01-01 00:00:00.000000000 +0000
404+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4/ipt_u32.h 2004-03-16 11:53:58.000000000 +0000
405@@ -0,0 +1,40 @@
406+#ifndef _IPT_U32_H
407+#define _IPT_U32_H
408+#include <linux/netfilter_ipv4/ip_tables.h>
409+
410+enum ipt_u32_ops
411+{
412+ IPT_U32_AND,
413+ IPT_U32_LEFTSH,
414+ IPT_U32_RIGHTSH,
415+ IPT_U32_AT
416+};
417+
418+struct ipt_u32_location_element
419+{
420+ u_int32_t number;
421+ u_int8_t nextop;
422+};
423+struct ipt_u32_value_element
424+{
425+ u_int32_t min;
426+ u_int32_t max;
427+};
428+/* *** any way to allow for an arbitrary number of elements?
429+ for now I settle for a limit of 10 of each */
430+#define U32MAXSIZE 10
431+struct ipt_u32_test
432+{
433+ u_int8_t nnums;
434+ struct ipt_u32_location_element location[U32MAXSIZE+1];
435+ u_int8_t nvalues;
436+ struct ipt_u32_value_element value[U32MAXSIZE+1];
437+};
438+
439+struct ipt_u32
440+{
441+ u_int8_t ntests;
442+ struct ipt_u32_test tests[U32MAXSIZE+1];
443+};
444+
445+#endif /*_IPT_U32_H*/
446diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv4.h linux-2.6.5-rc1/include/linux/netfilter_ipv4.h
447--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv4.h 2004-03-16 05:47:18.000000000 +0000
448+++ linux-2.6.5-rc1/include/linux/netfilter_ipv4.h 2004-03-16 11:53:55.000000000 +0000
449@@ -51,6 +51,8 @@
450
451 enum nf_ip_hook_priorities {
452 NF_IP_PRI_FIRST = INT_MIN,
453+ NF_IP_PRI_CONNTRACK_DEFRAG = -400,
454+ NF_IP_PRI_RAW = -300,
455 NF_IP_PRI_SELINUX_FIRST = -225,
456 NF_IP_PRI_CONNTRACK = -200,
457 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175,
458diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_HL.h linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_HL.h
459--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_HL.h 1970-01-01 00:00:00.000000000 +0000
460+++ linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_HL.h 2004-03-16 11:53:43.000000000 +0000
461@@ -0,0 +1,22 @@
462+/* Hop Limit modification module for ip6tables
463+ * Maciej Soltysiak <solt@dns.toxicfilms.tv>
464+ * Based on HW's TTL module */
465+
466+#ifndef _IP6T_HL_H
467+#define _IP6T_HL_H
468+
469+enum {
470+ IP6T_HL_SET = 0,
471+ IP6T_HL_INC,
472+ IP6T_HL_DEC
473+};
474+
475+#define IP6T_HL_MAXMODE IP6T_HL_DEC
476+
477+struct ip6t_HL_info {
478+ u_int8_t mode;
479+ u_int8_t hop_limit;
480+};
481+
482+
483+#endif
484diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_REJECT.h linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_REJECT.h
485--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_REJECT.h 2004-03-16 05:45:18.000000000 +0000
486+++ linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_REJECT.h 2004-03-16 11:53:45.000000000 +0000
487@@ -2,15 +2,17 @@
488 #define _IP6T_REJECT_H
489
490 enum ip6t_reject_with {
491- IP6T_ICMP_NET_UNREACHABLE,
492- IP6T_ICMP_HOST_UNREACHABLE,
493- IP6T_ICMP_PROT_UNREACHABLE,
494- IP6T_ICMP_PORT_UNREACHABLE,
495- IP6T_ICMP_ECHOREPLY
496+ IP6T_ICMP6_NO_ROUTE,
497+ IP6T_ICMP6_ADM_PROHIBITED,
498+ IP6T_ICMP6_NOT_NEIGHBOUR,
499+ IP6T_ICMP6_ADDR_UNREACH,
500+ IP6T_ICMP6_PORT_UNREACH,
501+ IP6T_ICMP6_ECHOREPLY,
502+ IP6T_TCP_RESET
503 };
504
505 struct ip6t_reject_info {
506 enum ip6t_reject_with with; /* reject type */
507 };
508
509-#endif /*_IPT_REJECT_H*/
510+#endif /*_IP6T_REJECT_H*/
511diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_fuzzy.h linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_fuzzy.h
512--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_fuzzy.h 1970-01-01 00:00:00.000000000 +0000
513+++ linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_fuzzy.h 2004-03-16 11:53:50.000000000 +0000
514@@ -0,0 +1,21 @@
515+#ifndef _IP6T_FUZZY_H
516+#define _IP6T_FUZZY_H
517+
518+#include <linux/param.h>
519+#include <linux/types.h>
520+
521+#define MAXFUZZYRATE 10000000
522+#define MINFUZZYRATE 3
523+
524+struct ip6t_fuzzy_info {
525+ u_int32_t minimum_rate;
526+ u_int32_t maximum_rate;
527+ u_int32_t packets_total;
528+ u_int32_t bytes_total;
529+ u_int32_t previous_time;
530+ u_int32_t present_time;
531+ u_int32_t mean_rate;
532+ u_int8_t acceptance_rate;
533+};
534+
535+#endif /*_IP6T_FUZZY_H*/
536diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_nth.h linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_nth.h
537--- linux-2.6.5-rc1.org/include/linux/netfilter_ipv6/ip6t_nth.h 1970-01-01 00:00:00.000000000 +0000
538+++ linux-2.6.5-rc1/include/linux/netfilter_ipv6/ip6t_nth.h 2004-03-16 11:53:53.000000000 +0000
539@@ -0,0 +1,19 @@
540+#ifndef _IP6T_NTH_H
541+#define _IP6T_NTH_H
542+
543+#include <linux/param.h>
544+#include <linux/types.h>
545+
546+#ifndef IP6T_NTH_NUM_COUNTERS
547+#define IP6T_NTH_NUM_COUNTERS 16
548+#endif
549+
550+struct ip6t_nth_info {
551+ u_int8_t every;
552+ u_int8_t not;
553+ u_int8_t startat;
554+ u_int8_t counter;
555+ u_int8_t packet;
556+};
557+
558+#endif /*_IP6T_NTH_H*/
559diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/core/netfilter.c linux-2.6.5-rc1/net/core/netfilter.c
560--- linux-2.6.5-rc1.org/net/core/netfilter.c 2004-03-16 05:46:34.000000000 +0000
561+++ linux-2.6.5-rc1/net/core/netfilter.c 2004-03-16 11:53:42.000000000 +0000
562@@ -8,8 +8,10 @@
563 *
564 * February 2000: Modified by James Morris to have 1 queue per protocol.
565 * 15-Mar-2000: Added NF_REPEAT --RR.
566+ * 08-May-2003: Internal logging interface added by Jozsef Kadlecsik.
567 */
568 #include <linux/config.h>
569+#include <linux/kernel.h>
570 #include <linux/netfilter.h>
571 #include <net/protocol.h>
572 #include <linux/init.h>
573@@ -741,6 +743,72 @@
574 EXPORT_SYMBOL(skb_ip_make_writable);
575 #endif /*CONFIG_INET*/
576
577+/* Internal logging interface, which relies on the real
578+ LOG target modules */
579+
580+#define NF_LOG_PREFIXLEN 128
581+
582+static nf_logfn *nf_logging[NPROTO]; /* = NULL */
583+static int reported = 0;
584+static spinlock_t nf_log_lock = SPIN_LOCK_UNLOCKED;
585+
586+int nf_log_register(int pf, nf_logfn *logfn)
587+{
588+ int ret = -EBUSY;
589+
590+ /* Any setup of logging members must be done before
591+ * substituting pointer. */
592+ smp_wmb();
593+ spin_lock(&nf_log_lock);
594+ if (!nf_logging[pf]) {
595+ nf_logging[pf] = logfn;
596+ ret = 0;
597+ }
598+ spin_unlock(&nf_log_lock);
599+ return ret;
600+}
601+
602+void nf_log_unregister(int pf, nf_logfn *logfn)
603+{
604+ spin_lock(&nf_log_lock);
605+ if (nf_logging[pf] == logfn)
606+ nf_logging[pf] = NULL;
607+ spin_unlock(&nf_log_lock);
608+
609+ /* Give time to concurrent readers. */
610+ synchronize_net();
611+}
612+
613+void nf_log_packet(int pf,
614+ unsigned int hooknum,
615+ const struct sk_buff *skb,
616+ const struct net_device *in,
617+ const struct net_device *out,
618+ const char *fmt, ...)
619+{
620+ va_list args;
621+ char prefix[NF_LOG_PREFIXLEN];
622+ nf_logfn *logfn;
623+
624+ rcu_read_lock();
625+ logfn = nf_logging[pf];
626+ if (logfn) {
627+ va_start(args, fmt);
628+ vsnprintf(prefix, sizeof(prefix), fmt, args);
629+ va_end(args);
630+ /* We must read logging before nf_logfn[pf] */
631+ smp_read_barrier_depends();
632+ logfn(hooknum, skb, in, out, prefix);
633+ } else if (!reported) {
634+ printk(KERN_WARNING "nf_log_packet: can\'t log yet, "
635+ "no backend logging module loaded in!\n");
636+ reported++;
637+ }
638+ rcu_read_unlock();
639+}
640+EXPORT_SYMBOL(nf_log_register);
641+EXPORT_SYMBOL(nf_log_unregister);
642+EXPORT_SYMBOL(nf_log_packet);
643
644 /* This does not belong here, but ipt_REJECT needs it if connection
645 tracking in use: without this, connection may not be in hash table,
646diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/Kconfig linux-2.6.5-rc1/net/ipv4/netfilter/Kconfig
647--- linux-2.6.5-rc1.org/net/ipv4/netfilter/Kconfig 2004-03-16 05:47:17.000000000 +0000
648+++ linux-2.6.5-rc1/net/ipv4/netfilter/Kconfig 2004-03-16 11:53:58.000000000 +0000
649@@ -579,5 +579,89 @@
650
651 To compile it as a module, choose M here. If unsure, say N.
652
653+config IP_NF_TARGET_IPV4OPTSSTRIP
654+ tristate 'IPV4OPTSSTRIP target support'
655+ depends on IP_NF_MANGLE
656+ help
657+
658+config IP_NF_TARGET_TTL
659+ tristate 'TTL target support'
660+ depends on IP_NF_MANGLE
661+ help
662+
663+config IP_NF_MATCH_CONNLIMIT
664+ tristate 'Connections/IP limit match support'
665+ depends on IP_NF_IPTABLES
666+ help
667+
668+config IP_NF_MATCH_DSTLIMIT
669+ tristate 'dstlimit match support'
670+ depends on IP_NF_IPTABLES
671+ help
672+
673+config IP_NF_MATCH_FUZZY
674+ tristate 'fuzzy match support'
675+ depends on IP_NF_IPTABLES
676+ help
677+
678+config IP_NF_MATCH_IPV4OPTIONS
679+ tristate 'IPV4OPTIONS match support'
680+ depends on IP_NF_IPTABLES
681+ help
682+
683+config IP_NF_MATCH_MPORT
684+ tristate 'Multiple port with ranges match support'
685+ depends on IP_NF_IPTABLES
686+ help
687+
688+config IP_NF_MATCH_NTH
689+ tristate 'Nth match support'
690+ depends on IP_NF_IPTABLES
691+ help
692+
693+config IP_NF_MATCH_QUOTA
694+ tristate 'quota match support'
695+ depends on IP_NF_IPTABLES
696+ help
697+
698+config IP_NF_TARGET_NOTRACK
699+ tristate 'NOTRACK target support'
700+ depends on IP_NF_RAW
701+ help
702+ The NOTRACK target allows a select rule to specify
703+ which packets *not* to enter the conntrack/NAT
704+ subsystem with all the consequences (no ICMP error tracking,
705+ no protocol helpers for the selected packets).
706+
707+ If you want to compile it as a module, say M here and read
708+ <file:Documentation/modules.txt>. If unsure, say `N'.
709+
710+config IP_NF_RAW
711+ tristate 'raw table support (required for NOTRACK/TRACE)'
712+ depends on IP_NF_IPTABLES
713+ help
714+ This option adds a `raw' table to iptables. This table is the very
715+ first in the netfilter framework and hooks in at the PREROUTING
716+ and OUTPUT chains.
717+
718+ If you want to compile it as a module, say M here and read
719+ <file:Documentation/modules.txt>. If unsure, say `N'.
720+ help
721+
722+config IP_NF_MATCH_REALM
723+ tristate 'realm match support'
724+ depends on IP_NF_IPTABLES && NET_CLS_ROUTE
725+ help
726+
727+config IP_NF_MATCH_SCTP
728+ tristate 'SCTP protocol match support'
729+ depends on IP_NF_IPTABLES
730+ help
731+
732+config IP_NF_MATCH_U32
733+ tristate 'U32 match support'
734+ depends on IP_NF_IPTABLES
735+ help
736+
737 endmenu
738
739diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/Makefile linux-2.6.5-rc1/net/ipv4/netfilter/Makefile
740--- linux-2.6.5-rc1.org/net/ipv4/netfilter/Makefile 2004-03-16 05:45:49.000000000 +0000
741+++ linux-2.6.5-rc1/net/ipv4/netfilter/Makefile 2004-03-16 11:53:58.000000000 +0000
742@@ -38,19 +38,33 @@
743 obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o
744 obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o
745 obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o
746+obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o
747
748 # matches
749 obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o
750 obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o
751+obj-$(CONFIG_IP_NF_MATCH_SCTP) += ipt_sctp.o
752+obj-$(CONFIG_IP_NF_MATCH_QUOTA) += ipt_quota.o
753+obj-$(CONFIG_IP_NF_MATCH_DSTLIMIT) += ipt_dstlimit.o
754 obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o
755 obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o
756 obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
757
758 obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o
759 obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o
760+
761+obj-$(CONFIG_IP_NF_MATCH_MPORT) += ipt_mport.o
762+
763 obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o
764 obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o
765
766+obj-$(CONFIG_IP_NF_MATCH_NTH) += ipt_nth.o
767+
768+obj-$(CONFIG_IP_NF_MATCH_IPV4OPTIONS) += ipt_ipv4options.o
769+
770+
771+obj-$(CONFIG_IP_NF_MATCH_FUZZY) += ipt_fuzzy.o
772+
773 obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o
774
775 obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o
776@@ -59,10 +73,15 @@
777
778 obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_length.o
779
780+obj-$(CONFIG_IP_NF_MATCH_U32) += ipt_u32.o
781+
782+
783 obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
784 obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o
785+obj-$(CONFIG_IP_NF_MATCH_CONNLIMIT) += ipt_connlimit.o
786 obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o
787 obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o
788+obj-$(CONFIG_IP_NF_MATCH_REALM) += ipt_realm.o
789
790 obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o
791
792@@ -79,8 +98,11 @@
793 obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
794 obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o
795 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
796+obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o
797+obj-$(CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP) += ipt_IPV4OPTSSTRIP.o
798 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
799 obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o
800+obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o
801
802 # generic ARP tables
803 obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
804diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_conntrack_core.c linux-2.6.5-rc1/net/ipv4/netfilter/ip_conntrack_core.c
805--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_conntrack_core.c 2004-03-16 05:45:17.000000000 +0000
806+++ linux-2.6.5-rc1/net/ipv4/netfilter/ip_conntrack_core.c 2004-03-16 11:53:55.000000000 +0000
807@@ -67,6 +67,7 @@
808 static atomic_t ip_conntrack_count = ATOMIC_INIT(0);
809 struct list_head *ip_conntrack_hash;
810 static kmem_cache_t *ip_conntrack_cachep;
811+struct ip_conntrack ip_conntrack_untracked;
812
813 extern struct ip_conntrack_protocol ip_conntrack_generic_protocol;
814
815@@ -691,42 +692,50 @@
816 struct ip_conntrack_expect *, tuple);
817 READ_UNLOCK(&ip_conntrack_expect_tuple_lock);
818
819- /* If master is not in hash table yet (ie. packet hasn't left
820- this machine yet), how can other end know about expected?
821- Hence these are not the droids you are looking for (if
822- master ct never got confirmed, we'd hold a reference to it
823- and weird things would happen to future packets). */
824- if (expected && !is_confirmed(expected->expectant))
825- expected = NULL;
826-
827- /* Look up the conntrack helper for master connections only */
828- if (!expected)
829- conntrack->helper = ip_ct_find_helper(&repl_tuple);
830-
831- /* If the expectation is dying, then this is a loser. */
832- if (expected
833- && expected->expectant->helper->timeout
834- && ! del_timer(&expected->timeout))
835- expected = NULL;
836-
837 if (expected) {
838- DEBUGP("conntrack: expectation arrives ct=%p exp=%p\n",
839- conntrack, expected);
840- /* Welcome, Mr. Bond. We've been expecting you... */
841- IP_NF_ASSERT(master_ct(conntrack));
842- __set_bit(IPS_EXPECTED_BIT, &conntrack->status);
843- conntrack->master = expected;
844- expected->sibling = conntrack;
845- LIST_DELETE(&ip_conntrack_expect_list, expected);
846- expected->expectant->expecting--;
847- nf_conntrack_get(&master_ct(conntrack)->infos[0]);
848- }
849- atomic_inc(&ip_conntrack_count);
850+ /* If master is not in hash table yet (ie. packet hasn't left
851+ this machine yet), how can other end know about expected?
852+ Hence these are not the droids you are looking for (if
853+ master ct never got confirmed, we'd hold a reference to it
854+ and weird things would happen to future packets). */
855+ if (!is_confirmed(expected->expectant)) {
856+
857+ conntrack->helper = ip_ct_find_helper(&repl_tuple);
858+ goto end;
859+ }
860+
861+ /* Expectation is dying... */
862+ if (expected->expectant->helper->timeout
863+ && ! del_timer(&expected->timeout)) {
864+ goto end;
865+ }
866+
867+ DEBUGP("conntrack: expectation arrives ct=%p exp=%p\n",
868+ conntrack, expected);
869+ /* Welcome, Mr. Bond. We've been expecting you... */
870+ IP_NF_ASSERT(master_ct(conntrack));
871+ __set_bit(IPS_EXPECTED_BIT, &conntrack->status);
872+ conntrack->master = expected;
873+ expected->sibling = conntrack;
874+ LIST_DELETE(&ip_conntrack_expect_list, expected);
875+ expected->expectant->expecting--;
876+ nf_conntrack_get(&master_ct(conntrack)->infos[0]);
877+
878+ /* this is a braindead... --pablo */
879+ atomic_inc(&ip_conntrack_count);
880+ WRITE_UNLOCK(&ip_conntrack_lock);
881+
882+ if (expected->expectfn)
883+ expected->expectfn(conntrack);
884+
885+ goto ret;
886+ } else
887+ conntrack->helper = ip_ct_find_helper(&repl_tuple);
888+
889+end: atomic_inc(&ip_conntrack_count);
890 WRITE_UNLOCK(&ip_conntrack_lock);
891
892- if (expected && expected->expectfn)
893- expected->expectfn(conntrack);
894- return &conntrack->tuplehash[IP_CT_DIR_ORIGINAL];
895+ret: return &conntrack->tuplehash[IP_CT_DIR_ORIGINAL];
896 }
897
898 /* On success, returns conntrack ptr, sets skb->nfct and ctinfo */
899@@ -794,6 +803,15 @@
900 int set_reply;
901 int ret;
902
903+ /* Never happen */
904+ if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) {
905+ if (net_ratelimit()) {
906+ printk(KERN_ERR "ip_conntrack_in: Frag of proto %u (hook=%u)\n",
907+ (*pskb)->nh.iph->protocol, hooknum);
908+ }
909+ return NF_DROP;
910+ }
911+
912 /* FIXME: Do this right please. --RR */
913 (*pskb)->nfcache |= NFC_UNKNOWN;
914
915@@ -812,18 +830,10 @@
916 }
917 #endif
918
919- /* Previously seen (loopback)? Ignore. Do this before
920- fragment check. */
921+ /* Previously seen (loopback or untracked)? Ignore. */
922 if ((*pskb)->nfct)
923 return NF_ACCEPT;
924
925- /* Gather fragments. */
926- if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
927- *pskb = ip_ct_gather_frags(*pskb);
928- if (!*pskb)
929- return NF_STOLEN;
930- }
931-
932 proto = ip_ct_find_proto((*pskb)->nh.iph->protocol);
933
934 /* It may be an icmp error... */
935@@ -1422,6 +1432,18 @@
936
937 /* For use by ipt_REJECT */
938 ip_ct_attach = ip_conntrack_attach;
939+
940+ /* Set up fake conntrack:
941+ - to never be deleted, not in any hashes */
942+ atomic_set(&ip_conntrack_untracked.ct_general.use, 1);
943+ /* - and look it like as a confirmed connection */
944+ set_bit(IPS_CONFIRMED_BIT, &ip_conntrack_untracked.status);
945+ /* - and prepare the ctinfo field for REJECT & NAT. */
946+ ip_conntrack_untracked.infos[IP_CT_NEW].master =
947+ ip_conntrack_untracked.infos[IP_CT_RELATED].master =
948+ ip_conntrack_untracked.infos[IP_CT_RELATED + IP_CT_IS_REPLY].master =
949+ &ip_conntrack_untracked.ct_general;
950+
951 return ret;
952
953 err_free_hash:
954diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_conntrack_standalone.c linux-2.6.5-rc1/net/ipv4/netfilter/ip_conntrack_standalone.c
955--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_conntrack_standalone.c 2004-03-16 05:46:27.000000000 +0000
956+++ linux-2.6.5-rc1/net/ipv4/netfilter/ip_conntrack_standalone.c 2004-03-16 11:53:55.000000000 +0000
957@@ -194,6 +194,26 @@
958 return ip_conntrack_confirm(*pskb);
959 }
960
961+static unsigned int ip_conntrack_defrag(unsigned int hooknum,
962+ struct sk_buff **pskb,
963+ const struct net_device *in,
964+ const struct net_device *out,
965+ int (*okfn)(struct sk_buff *))
966+{
967+ /* Previously seen (loopback)? Ignore. Do this before
968+ fragment check. */
969+ if ((*pskb)->nfct)
970+ return NF_ACCEPT;
971+
972+ /* Gather fragments. */
973+ if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
974+ *pskb = ip_ct_gather_frags(*pskb);
975+ if (!*pskb)
976+ return NF_STOLEN;
977+ }
978+ return NF_ACCEPT;
979+}
980+
981 static unsigned int ip_refrag(unsigned int hooknum,
982 struct sk_buff **pskb,
983 const struct net_device *in,
984@@ -236,6 +256,14 @@
985
986 /* Connection tracking may drop packets, but never alters them, so
987 make it the first hook. */
988+static struct nf_hook_ops ip_conntrack_defrag_ops = {
989+ .hook = ip_conntrack_defrag,
990+ .owner = THIS_MODULE,
991+ .pf = PF_INET,
992+ .hooknum = NF_IP_PRE_ROUTING,
993+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
994+};
995+
996 static struct nf_hook_ops ip_conntrack_in_ops = {
997 .hook = ip_conntrack_in,
998 .owner = THIS_MODULE,
999@@ -244,6 +272,14 @@
1000 .priority = NF_IP_PRI_CONNTRACK,
1001 };
1002
1003+static struct nf_hook_ops ip_conntrack_defrag_local_out_ops = {
1004+ .hook = ip_conntrack_defrag,
1005+ .owner = THIS_MODULE,
1006+ .pf = PF_INET,
1007+ .hooknum = NF_IP_LOCAL_OUT,
1008+ .priority = NF_IP_PRI_CONNTRACK_DEFRAG,
1009+};
1010+
1011 static struct nf_hook_ops ip_conntrack_local_out_ops = {
1012 .hook = ip_conntrack_local,
1013 .owner = THIS_MODULE,
1014@@ -470,10 +506,20 @@
1015 if (!proc) goto cleanup_init;
1016 proc->owner = THIS_MODULE;
1017
1018+ ret = nf_register_hook(&ip_conntrack_defrag_ops);
1019+ if (ret < 0) {
1020+ printk("ip_conntrack: can't register pre-routing defrag hook.\n");
1021+ goto cleanup_proc;
1022+ }
1023+ ret = nf_register_hook(&ip_conntrack_defrag_local_out_ops);
1024+ if (ret < 0) {
1025+ printk("ip_conntrack: can't register local_out defrag hook.\n");
1026+ goto cleanup_defragops;
1027+ }
1028 ret = nf_register_hook(&ip_conntrack_in_ops);
1029 if (ret < 0) {
1030 printk("ip_conntrack: can't register pre-routing hook.\n");
1031- goto cleanup_proc;
1032+ goto cleanup_defraglocalops;
1033 }
1034 ret = nf_register_hook(&ip_conntrack_local_out_ops);
1035 if (ret < 0) {
1036@@ -511,6 +557,10 @@
1037 nf_unregister_hook(&ip_conntrack_local_out_ops);
1038 cleanup_inops:
1039 nf_unregister_hook(&ip_conntrack_in_ops);
1040+ cleanup_defraglocalops:
1041+ nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
1042+ cleanup_defragops:
1043+ nf_unregister_hook(&ip_conntrack_defrag_ops);
1044 cleanup_proc:
1045 proc_net_remove("ip_conntrack");
1046 cleanup_init:
1047@@ -602,5 +652,6 @@
1048 EXPORT_SYMBOL(ip_conntrack_expect_list);
1049 EXPORT_SYMBOL(ip_conntrack_lock);
1050 EXPORT_SYMBOL(ip_conntrack_hash);
1051+EXPORT_SYMBOL(ip_conntrack_untracked);
1052 EXPORT_SYMBOL_GPL(ip_conntrack_find_get);
1053 EXPORT_SYMBOL_GPL(ip_conntrack_put);
1054diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_nat_core.c linux-2.6.5-rc1/net/ipv4/netfilter/ip_nat_core.c
1055--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ip_nat_core.c 2004-03-16 05:45:35.000000000 +0000
1056+++ linux-2.6.5-rc1/net/ipv4/netfilter/ip_nat_core.c 2004-03-16 11:53:55.000000000 +0000
1057@@ -1016,6 +1016,10 @@
1058 /* FIXME: Man, this is a hack. <SIGH> */
1059 IP_NF_ASSERT(ip_conntrack_destroyed == NULL);
1060 ip_conntrack_destroyed = &ip_nat_cleanup_conntrack;
1061+
1062+ /* Initialize fake conntrack so that NAT will skip it */
1063+ ip_conntrack_untracked.nat.info.initialized |=
1064+ (1 << IP_NAT_MANIP_SRC) | (1 << IP_NAT_MANIP_DST);
1065
1066 return 0;
1067 }
1068diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c
1069--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c 1970-01-01 00:00:00.000000000 +0000
1070+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c 2004-03-16 11:53:44.000000000 +0000
1071@@ -0,0 +1,89 @@
1072+/**
1073+ * Strip all IP options in the IP packet header.
1074+ *
1075+ * (C) 2001 by Fabrice MARIE <fabrice@netfilter.org>
1076+ * This software is distributed under GNU GPL v2, 1991
1077+ */
1078+
1079+#include <linux/module.h>
1080+#include <linux/skbuff.h>
1081+#include <linux/ip.h>
1082+#include <net/checksum.h>
1083+
1084+#include <linux/netfilter_ipv4/ip_tables.h>
1085+
1086+MODULE_AUTHOR("Fabrice MARIE <fabrice@netfilter.org>");
1087+MODULE_DESCRIPTION("Strip all options in IPv4 packets");
1088+MODULE_LICENSE("GPL");
1089+
1090+static unsigned int
1091+target(struct sk_buff **pskb,
1092+ const struct net_device *in,
1093+ const struct net_device *out,
1094+ unsigned int hooknum,
1095+ const void *targinfo,
1096+ void *userinfo)
1097+{
1098+ struct iphdr *iph;
1099+ struct sk_buff *skb;
1100+ struct ip_options *opt;
1101+ unsigned char *optiph;
1102+ int l;
1103+
1104+ if (!skb_ip_make_writable(pskb, (*pskb)->len))
1105+ return NF_DROP;
1106+
1107+ skb = (*pskb);
1108+ iph = (*pskb)->nh.iph;
1109+ optiph = skb->nh.raw;
1110+ l = ((struct ip_options *)(&(IPCB(skb)->opt)))->optlen;
1111+
1112+ /* if no options in packet then nothing to clear. */
1113+ if (iph->ihl * 4 == sizeof(struct iphdr))
1114+ return IPT_CONTINUE;
1115+
1116+ /* else clear all options */
1117+ memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
1118+ memset(optiph+sizeof(struct iphdr), IPOPT_NOOP, l);
1119+ opt = &(IPCB(skb)->opt);
1120+ opt->is_data = 0;
1121+ opt->optlen = l;
1122+
1123+ skb->nfcache |= NFC_ALTERED;
1124+
1125+ return IPT_CONTINUE;
1126+}
1127+
1128+static int
1129+checkentry(const char *tablename,
1130+ const struct ipt_entry *e,
1131+ void *targinfo,
1132+ unsigned int targinfosize,
1133+ unsigned int hook_mask)
1134+{
1135+ if (strcmp(tablename, "mangle")) {
1136+ printk(KERN_WARNING "IPV4OPTSSTRIP: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
1137+ return 0;
1138+ }
1139+ /* nothing else to check because no parameters */
1140+ return 1;
1141+}
1142+
1143+static struct ipt_target ipt_ipv4optsstrip_reg = {
1144+ .name = "IPV4OPTSSTRIP",
1145+ .target = target,
1146+ .checkentry = checkentry,
1147+ .me = THIS_MODULE };
1148+
1149+static int __init init(void)
1150+{
1151+ return ipt_register_target(&ipt_ipv4optsstrip_reg);
1152+}
1153+
1154+static void __exit fini(void)
1155+{
1156+ ipt_unregister_target(&ipt_ipv4optsstrip_reg);
1157+}
1158+
1159+module_init(init);
1160+module_exit(fini);
1161diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_LOG.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_LOG.c
1162--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_LOG.c 2004-03-16 05:47:18.000000000 +0000
1163+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_LOG.c 2004-03-16 11:53:42.000000000 +0000
1164@@ -19,6 +19,7 @@
1165 #include <net/tcp.h>
1166 #include <net/route.h>
1167
1168+#include <linux/netfilter.h>
1169 #include <linux/netfilter_ipv4/ip_tables.h>
1170 #include <linux/netfilter_ipv4/ipt_LOG.h>
1171
1172@@ -26,6 +27,10 @@
1173 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
1174 MODULE_DESCRIPTION("iptables syslog logging module");
1175
1176+static unsigned int nflog = 1;
1177+MODULE_PARM(nflog, "i");
1178+MODULE_PARM_DESC(nflog, "register as internal netfilter logging module");
1179+
1180 #if 0
1181 #define DEBUGP printk
1182 #else
1183@@ -324,28 +329,25 @@
1184 /* maxlen = 230+ 91 + 230 + 252 = 803 */
1185 }
1186
1187-static unsigned int
1188-ipt_log_target(struct sk_buff **pskb,
1189+static void
1190+ipt_log_packet(unsigned int hooknum,
1191+ const struct sk_buff *skb,
1192 const struct net_device *in,
1193 const struct net_device *out,
1194- unsigned int hooknum,
1195- const void *targinfo,
1196- void *userinfo)
1197+ const struct ipt_log_info *loginfo,
1198+ const char *level_string,
1199+ const char *prefix)
1200 {
1201- const struct ipt_log_info *loginfo = targinfo;
1202- char level_string[4] = "< >";
1203-
1204- level_string[1] = '0' + (loginfo->level % 8);
1205 spin_lock_bh(&log_lock);
1206 printk(level_string);
1207 printk("%sIN=%s OUT=%s ",
1208- loginfo->prefix,
1209+ prefix == NULL ? loginfo->prefix : prefix,
1210 in ? in->name : "",
1211 out ? out->name : "");
1212 #ifdef CONFIG_BRIDGE_NETFILTER
1213- if ((*pskb)->nf_bridge) {
1214- struct net_device *physindev = (*pskb)->nf_bridge->physindev;
1215- struct net_device *physoutdev = (*pskb)->nf_bridge->physoutdev;
1216+ if (skb->nf_bridge) {
1217+ struct net_device *physindev = skb->nf_bridge->physindev;
1218+ struct net_device *physoutdev = skb->nf_bridge->physoutdev;
1219
1220 if (physindev && in != physindev)
1221 printk("PHYSIN=%s ", physindev->name);
1222@@ -357,25 +359,56 @@
1223 if (in && !out) {
1224 /* MAC logging for input chain only. */
1225 printk("MAC=");
1226- if ((*pskb)->dev && (*pskb)->dev->hard_header_len
1227- && (*pskb)->mac.raw != (void*)(*pskb)->nh.iph) {
1228+ if (skb->dev && skb->dev->hard_header_len
1229+ && skb->mac.raw != (void*)skb->nh.iph) {
1230 int i;
1231- unsigned char *p = (*pskb)->mac.raw;
1232- for (i = 0; i < (*pskb)->dev->hard_header_len; i++,p++)
1233+ unsigned char *p = skb->mac.raw;
1234+ for (i = 0; i < skb->dev->hard_header_len; i++,p++)
1235 printk("%02x%c", *p,
1236- i==(*pskb)->dev->hard_header_len - 1
1237+ i==skb->dev->hard_header_len - 1
1238 ? ' ':':');
1239 } else
1240 printk(" ");
1241 }
1242
1243- dump_packet(loginfo, *pskb, 0);
1244+ dump_packet(loginfo, skb, 0);
1245 printk("\n");
1246 spin_unlock_bh(&log_lock);
1247+}
1248+
1249+static unsigned int
1250+ipt_log_target(struct sk_buff **pskb,
1251+ const struct net_device *in,
1252+ const struct net_device *out,
1253+ unsigned int hooknum,
1254+ const void *targinfo,
1255+ void *userinfo)
1256+{
1257+ const struct ipt_log_info *loginfo = targinfo;
1258+ char level_string[4] = "< >";
1259+
1260+ level_string[1] = '0' + (loginfo->level % 8);
1261+ ipt_log_packet(hooknum, *pskb, in, out, loginfo, level_string, NULL);
1262
1263 return IPT_CONTINUE;
1264 }
1265
1266+static void
1267+ipt_logfn(unsigned int hooknum,
1268+ const struct sk_buff *skb,
1269+ const struct net_device *in,
1270+ const struct net_device *out,
1271+ const char *prefix)
1272+{
1273+ struct ipt_log_info loginfo = {
1274+ .level = 0,
1275+ .logflags = IPT_LOG_MASK,
1276+ .prefix = ""
1277+ };
1278+
1279+ ipt_log_packet(hooknum, skb, in, out, &loginfo, KERN_WARNING, prefix);
1280+}
1281+
1282 static int ipt_log_checkentry(const char *tablename,
1283 const struct ipt_entry *e,
1284 void *targinfo,
1285@@ -413,11 +446,18 @@
1286
1287 static int __init init(void)
1288 {
1289- return ipt_register_target(&ipt_log_reg);
1290+ if (ipt_register_target(&ipt_log_reg))
1291+ return -EINVAL;
1292+ if (nflog)
1293+ nf_log_register(PF_INET, &ipt_logfn);
1294+
1295+ return 0;
1296 }
1297
1298 static void __exit fini(void)
1299 {
1300+ if (nflog)
1301+ nf_log_unregister(PF_INET, &ipt_logfn);
1302 ipt_unregister_target(&ipt_log_reg);
1303 }
1304
1305diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_NOTRACK.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_NOTRACK.c
1306--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_NOTRACK.c 1970-01-01 00:00:00.000000000 +0000
1307+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_NOTRACK.c 2004-03-16 11:53:55.000000000 +0000
1308@@ -0,0 +1,75 @@
1309+/* This is a module which is used for setting up fake conntracks
1310+ * on packets so that they are not seen by the conntrack/NAT code.
1311+ */
1312+#include <linux/module.h>
1313+#include <linux/skbuff.h>
1314+
1315+#include <linux/netfilter_ipv4/ip_tables.h>
1316+#include <linux/netfilter_ipv4/ip_conntrack.h>
1317+
1318+static unsigned int
1319+target(struct sk_buff **pskb,
1320+ const struct net_device *in,
1321+ const struct net_device *out,
1322+ unsigned int hooknum,
1323+ const void *targinfo,
1324+ void *userinfo)
1325+{
1326+ /* Previously seen (loopback)? Ignore. */
1327+ if ((*pskb)->nfct != NULL)
1328+ return IPT_CONTINUE;
1329+
1330+ /* Attach fake conntrack entry.
1331+ If there is a real ct entry correspondig to this packet,
1332+ it'll hang aroun till timing out. We don't deal with it
1333+ for performance reasons. JK */
1334+ (*pskb)->nfct = &ip_conntrack_untracked.infos[IP_CT_NEW];
1335+ nf_conntrack_get((*pskb)->nfct);
1336+
1337+ return IPT_CONTINUE;
1338+}
1339+
1340+static int
1341+checkentry(const char *tablename,
1342+ const struct ipt_entry *e,
1343+ void *targinfo,
1344+ unsigned int targinfosize,
1345+ unsigned int hook_mask)
1346+{
1347+ if (targinfosize != 0) {
1348+ printk(KERN_WARNING "NOTRACK: targinfosize %u != 0\n",
1349+ targinfosize);
1350+ return 0;
1351+ }
1352+
1353+ if (strcmp(tablename, "raw") != 0) {
1354+ printk(KERN_WARNING "NOTRACK: can only be called from \"raw\" table, not \"%s\"\n", tablename);
1355+ return 0;
1356+ }
1357+
1358+ return 1;
1359+}
1360+
1361+static struct ipt_target ipt_notrack_reg = {
1362+ .name = "NOTRACK",
1363+ .target = target,
1364+ .checkentry = checkentry,
1365+ .me = THIS_MODULE
1366+};
1367+
1368+static int __init init(void)
1369+{
1370+ if (ipt_register_target(&ipt_notrack_reg))
1371+ return -EINVAL;
1372+
1373+ return 0;
1374+}
1375+
1376+static void __exit fini(void)
1377+{
1378+ ipt_unregister_target(&ipt_notrack_reg);
1379+}
1380+
1381+module_init(init);
1382+module_exit(fini);
1383+MODULE_LICENSE("GPL");
1384diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_TTL.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_TTL.c
1385--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_TTL.c 1970-01-01 00:00:00.000000000 +0000
1386+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_TTL.c 2004-03-16 11:53:46.000000000 +0000
1387@@ -0,0 +1,120 @@
1388+/* TTL modification target for IP tables
1389+ * (C) 2000 by Harald Welte <laforge@gnumonks.org>
1390+ *
1391+ * Version: $Revision$
1392+ *
1393+ * This software is distributed under the terms of GNU GPL
1394+ */
1395+
1396+#include <linux/module.h>
1397+#include <linux/skbuff.h>
1398+#include <linux/ip.h>
1399+#include <net/checksum.h>
1400+
1401+#include <linux/netfilter_ipv4/ip_tables.h>
1402+#include <linux/netfilter_ipv4/ipt_TTL.h>
1403+
1404+MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
1405+MODULE_DESCRIPTION("IP tables TTL modification module");
1406+MODULE_LICENSE("GPL");
1407+
1408+static unsigned int
1409+ipt_ttl_target(struct sk_buff **pskb, const struct net_device *in,
1410+ const struct net_device *out, unsigned int hooknum,
1411+ const void *targinfo, void *userinfo)
1412+{
1413+ struct iphdr *iph;
1414+ const struct ipt_TTL_info *info = targinfo;
1415+ u_int16_t diffs[2];
1416+ int new_ttl;
1417+
1418+ if (!skb_ip_make_writable(pskb, (*pskb)->len))
1419+ return NF_DROP;
1420+
1421+ iph = (*pskb)->nh.iph;
1422+
1423+ switch (info->mode) {
1424+ case IPT_TTL_SET:
1425+ new_ttl = info->ttl;
1426+ break;
1427+ case IPT_TTL_INC:
1428+ new_ttl = iph->ttl + info->ttl;
1429+ if (new_ttl > 255)
1430+ new_ttl = 255;
1431+ break;
1432+ case IPT_TTL_DEC:
1433+ new_ttl = iph->ttl + info->ttl;
1434+ if (new_ttl < 0)
1435+ new_ttl = 0;
1436+ break;
1437+ default:
1438+ new_ttl = iph->ttl;
1439+ break;
1440+ }
1441+
1442+ if (new_ttl != iph->ttl) {
1443+ diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ 0xFFFF;
1444+ iph->ttl = new_ttl;
1445+ diffs[1] = htons(((unsigned)iph->ttl) << 8);
1446+ iph->check = csum_fold(csum_partial((char *)diffs,
1447+ sizeof(diffs),
1448+ iph->check^0xFFFF));
1449+ (*pskb)->nfcache |= NFC_ALTERED;
1450+ }
1451+
1452+ return IPT_CONTINUE;
1453+}
1454+
1455+static int ipt_ttl_checkentry(const char *tablename,
1456+ const struct ipt_entry *e,
1457+ void *targinfo,
1458+ unsigned int targinfosize,
1459+ unsigned int hook_mask)
1460+{
1461+ struct ipt_TTL_info *info = targinfo;
1462+
1463+ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_TTL_info))) {
1464+ printk(KERN_WARNING "TTL: targinfosize %u != %Zu\n",
1465+ targinfosize,
1466+ IPT_ALIGN(sizeof(struct ipt_TTL_info)));
1467+ return 0;
1468+ }
1469+
1470+ if (strcmp(tablename, "mangle")) {
1471+ printk(KERN_WARNING "TTL: can only be called from \"mangle\" table, not \"%s\"\n", tablename);
1472+ return 0;
1473+ }
1474+
1475+ if (info->mode > IPT_TTL_MAXMODE) {
1476+ printk(KERN_WARNING "TTL: invalid or unknown Mode %u\n",
1477+ info->mode);
1478+ return 0;
1479+ }
1480+
1481+ if ((info->mode != IPT_TTL_SET) && (info->ttl == 0)) {
1482+ printk(KERN_WARNING "TTL: increment/decrement doesn't make sense with value 0\n");
1483+ return 0;
1484+ }
1485+
1486+ return 1;
1487+}
1488+
1489+static struct ipt_target ipt_TTL = {
1490+ .name = "TTL",
1491+ .target = ipt_ttl_target,
1492+ .checkentry = ipt_ttl_checkentry,
1493+ .me = THIS_MODULE
1494+};
1495+
1496+static int __init init(void)
1497+{
1498+ return ipt_register_target(&ipt_TTL);
1499+}
1500+
1501+static void __exit fini(void)
1502+{
1503+ ipt_unregister_target(&ipt_TTL);
1504+}
1505+
1506+module_init(init);
1507+module_exit(fini);
1508diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_ULOG.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_ULOG.c
1509--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_ULOG.c 2004-03-16 05:46:08.000000000 +0000
1510+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_ULOG.c 2004-03-16 11:53:42.000000000 +0000
1511@@ -50,6 +50,7 @@
1512 #include <linux/netlink.h>
1513 #include <linux/netdevice.h>
1514 #include <linux/mm.h>
1515+#include <linux/netfilter.h>
1516 #include <linux/netfilter_ipv4/ip_tables.h>
1517 #include <linux/netfilter_ipv4/ipt_ULOG.h>
1518 #include <linux/netfilter_ipv4/lockhelp.h>
1519@@ -80,6 +81,10 @@
1520 MODULE_PARM(flushtimeout, "i");
1521 MODULE_PARM_DESC(flushtimeout, "buffer flush timeout");
1522
1523+static unsigned int nflog = 1;
1524+MODULE_PARM(nflog, "i");
1525+MODULE_PARM_DESC(nflog, "register as internal netfilter logging module");
1526+
1527 /* global data structures */
1528
1529 typedef struct {
1530@@ -157,17 +162,17 @@
1531 return skb;
1532 }
1533
1534-static unsigned int ipt_ulog_target(struct sk_buff **pskb,
1535- const struct net_device *in,
1536- const struct net_device *out,
1537- unsigned int hooknum,
1538- const void *targinfo, void *userinfo)
1539+static void ipt_ulog_packet(unsigned int hooknum,
1540+ const struct sk_buff *skb,
1541+ const struct net_device *in,
1542+ const struct net_device *out,
1543+ const struct ipt_ulog_info *loginfo,
1544+ const char *prefix)
1545 {
1546 ulog_buff_t *ub;
1547 ulog_packet_msg_t *pm;
1548 size_t size, copy_len;
1549 struct nlmsghdr *nlh;
1550- struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;
1551
1552 /* ffs == find first bit set, necessary because userspace
1553 * is already shifting groupnumber, but we need unshifted.
1554@@ -176,8 +181,8 @@
1555
1556 /* calculate the size of the skb needed */
1557 if ((loginfo->copy_range == 0) ||
1558- (loginfo->copy_range > (*pskb)->len)) {
1559- copy_len = (*pskb)->len;
1560+ (loginfo->copy_range > skb->len)) {
1561+ copy_len = skb->len;
1562 } else {
1563 copy_len = loginfo->copy_range;
1564 }
1565@@ -214,19 +219,21 @@
1566
1567 /* copy hook, prefix, timestamp, payload, etc. */
1568 pm->data_len = copy_len;
1569- pm->timestamp_sec = (*pskb)->stamp.tv_sec;
1570- pm->timestamp_usec = (*pskb)->stamp.tv_usec;
1571- pm->mark = (*pskb)->nfmark;
1572+ pm->timestamp_sec = skb->stamp.tv_sec;
1573+ pm->timestamp_usec = skb->stamp.tv_usec;
1574+ pm->mark = skb->nfmark;
1575 pm->hook = hooknum;
1576- if (loginfo->prefix[0] != '\0')
1577+ if (prefix != NULL)
1578+ strncpy(pm->prefix, prefix, sizeof(pm->prefix));
1579+ else if (loginfo->prefix[0] != '\0')
1580 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
1581 else
1582 *(pm->prefix) = '\0';
1583
1584 if (in && in->hard_header_len > 0
1585- && (*pskb)->mac.raw != (void *) (*pskb)->nh.iph
1586+ && skb->mac.raw != (void *) skb->nh.iph
1587 && in->hard_header_len <= ULOG_MAC_LEN) {
1588- memcpy(pm->mac, (*pskb)->mac.raw, in->hard_header_len);
1589+ memcpy(pm->mac, skb->mac.raw, in->hard_header_len);
1590 pm->mac_len = in->hard_header_len;
1591 } else
1592 pm->mac_len = 0;
1593@@ -241,8 +248,8 @@
1594 else
1595 pm->outdev_name[0] = '\0';
1596
1597- /* copy_len <= (*pskb)->len, so can't fail. */
1598- if (skb_copy_bits(*pskb, 0, pm->payload, copy_len) < 0)
1599+ /* copy_len <= skb->len, so can't fail. */
1600+ if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
1601 BUG();
1602
1603 /* check if we are building multi-part messages */
1604@@ -266,8 +273,7 @@
1605
1606 UNLOCK_BH(&ulog_lock);
1607
1608- return IPT_CONTINUE;
1609-
1610+ return;
1611
1612 nlmsg_failure:
1613 PRINTR("ipt_ULOG: error during NLMSG_PUT\n");
1614@@ -276,8 +282,35 @@
1615 PRINTR("ipt_ULOG: Error building netlink message\n");
1616
1617 UNLOCK_BH(&ulog_lock);
1618+}
1619+
1620+static unsigned int ipt_ulog_target(struct sk_buff **pskb,
1621+ const struct net_device *in,
1622+ const struct net_device *out,
1623+ unsigned int hooknum,
1624+ const void *targinfo, void *userinfo)
1625+{
1626+ struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;
1627
1628- return IPT_CONTINUE;
1629+ ipt_ulog_packet(hooknum, *pskb, in, out, loginfo, NULL);
1630+
1631+ return IPT_CONTINUE;
1632+}
1633+
1634+static void ipt_logfn(unsigned int hooknum,
1635+ const struct sk_buff *skb,
1636+ const struct net_device *in,
1637+ const struct net_device *out,
1638+ const char *prefix)
1639+{
1640+ struct ipt_ulog_info loginfo = {
1641+ .nl_group = ULOG_DEFAULT_NLGROUP,
1642+ .copy_range = 0,
1643+ .qthreshold = ULOG_DEFAULT_QTHRESHOLD,
1644+ .prefix = ""
1645+ };
1646+
1647+ ipt_ulog_packet(hooknum, skb, in, out, &loginfo, prefix);
1648 }
1649
1650 static int ipt_ulog_checkentry(const char *tablename,
1651@@ -341,7 +374,9 @@
1652 sock_release(nflognl->sk_socket);
1653 return -EINVAL;
1654 }
1655-
1656+ if (nflog)
1657+ nf_log_register(PF_INET, &ipt_logfn);
1658+
1659 return 0;
1660 }
1661
1662@@ -352,6 +387,8 @@
1663
1664 DEBUGP("ipt_ULOG: cleanup_module\n");
1665
1666+ if (nflog)
1667+ nf_log_unregister(PF_INET, &ipt_logfn);
1668 ipt_unregister_target(&ipt_ulog_reg);
1669 sock_release(nflognl->sk_socket);
1670
1671diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_connlimit.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_connlimit.c
1672--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_connlimit.c 1970-01-01 00:00:00.000000000 +0000
1673+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_connlimit.c 2004-03-16 11:53:47.000000000 +0000
1674@@ -0,0 +1,230 @@
1675+/*
1676+ * netfilter module to limit the number of parallel tcp
1677+ * connections per IP address.
1678+ * (c) 2000 Gerd Knorr <kraxel@bytesex.org>
1679+ * Nov 2002: Martin Bene <martin.bene@icomedias.com>:
1680+ * only ignore TIME_WAIT or gone connections
1681+ *
1682+ * based on ...
1683+ *
1684+ * Kernel module to match connection tracking information.
1685+ * GPL (C) 1999 Rusty Russell (rusty@rustcorp.com.au).
1686+ */
1687+#include <linux/module.h>
1688+#include <linux/skbuff.h>
1689+#include <linux/list.h>
1690+#include <linux/netfilter_ipv4/ip_conntrack.h>
1691+#include <linux/netfilter_ipv4/ip_conntrack_core.h>
1692+#include <linux/netfilter_ipv4/ip_conntrack_tcp.h>
1693+#include <linux/netfilter_ipv4/ip_tables.h>
1694+#include <linux/netfilter_ipv4/ipt_connlimit.h>
1695+
1696+#define DEBUG 0
1697+
1698+MODULE_LICENSE("GPL");
1699+
1700+/* we'll save the tuples of all connections we care about */
1701+struct ipt_connlimit_conn
1702+{
1703+ struct list_head list;
1704+ struct ip_conntrack_tuple tuple;
1705+};
1706+
1707+struct ipt_connlimit_data {
1708+ spinlock_t lock;
1709+ struct list_head iphash[256];
1710+};
1711+
1712+static int ipt_iphash(u_int32_t addr)
1713+{
1714+ int hash;
1715+
1716+ hash = addr & 0xff;
1717+ hash ^= (addr >> 8) & 0xff;
1718+ hash ^= (addr >> 16) & 0xff;
1719+ hash ^= (addr >> 24) & 0xff;
1720+ return hash;
1721+}
1722+
1723+static int count_them(struct ipt_connlimit_data *data,
1724+ u_int32_t addr, u_int32_t mask,
1725+ struct ip_conntrack *ct)
1726+{
1727+#if DEBUG
1728+ const static char *tcp[] = { "none", "established", "syn_sent", "syn_recv",
1729+ "fin_wait", "time_wait", "close", "close_wait",
1730+ "last_ack", "listen" };
1731+#endif
1732+ int addit = 1, matches = 0;
1733+ struct ip_conntrack_tuple tuple;
1734+ struct ip_conntrack_tuple_hash *found;
1735+ struct ipt_connlimit_conn *conn;
1736+ struct list_head *hash,*lh;
1737+
1738+ spin_lock(&data->lock);
1739+ tuple = ct->tuplehash[0].tuple;
1740+ hash = &data->iphash[ipt_iphash(addr & mask)];
1741+
1742+ /* check the saved connections */
1743+ for (lh = hash->next; lh != hash; lh = lh->next) {
1744+ conn = list_entry(lh,struct ipt_connlimit_conn,list);
1745+ found = ip_conntrack_find_get(&conn->tuple,ct);
1746+ if (0 == memcmp(&conn->tuple,&tuple,sizeof(tuple)) &&
1747+ found != NULL &&
1748+ found->ctrack->proto.tcp.state != TCP_CONNTRACK_TIME_WAIT) {
1749+ /* Just to be sure we have it only once in the list.
1750+ We should'nt see tuples twice unless someone hooks this
1751+ into a table without "-p tcp --syn" */
1752+ addit = 0;
1753+ }
1754+#if DEBUG
1755+ printk("ipt_connlimit [%d]: src=%u.%u.%u.%u:%d dst=%u.%u.%u.%u:%d %s\n",
1756+ ipt_iphash(addr & mask),
1757+ NIPQUAD(conn->tuple.src.ip), ntohs(conn->tuple.src.u.tcp.port),
1758+ NIPQUAD(conn->tuple.dst.ip), ntohs(conn->tuple.dst.u.tcp.port),
1759+ (NULL != found) ? tcp[found->ctrack->proto.tcp.state] : "gone");
1760+#endif
1761+ if (NULL == found) {
1762+ /* this one is gone */
1763+ lh = lh->prev;
1764+ list_del(lh->next);
1765+ kfree(conn);
1766+ continue;
1767+ }
1768+ if (found->ctrack->proto.tcp.state == TCP_CONNTRACK_TIME_WAIT) {
1769+ /* we don't care about connections which are
1770+ closed already -> ditch it */
1771+ lh = lh->prev;
1772+ list_del(lh->next);
1773+ kfree(conn);
1774+ nf_conntrack_put(&found->ctrack->infos[0]);
1775+ continue;
1776+ }
1777+ if ((addr & mask) == (conn->tuple.src.ip & mask)) {
1778+ /* same source IP address -> be counted! */
1779+ matches++;
1780+ }
1781+ nf_conntrack_put(&found->ctrack->infos[0]);
1782+ }
1783+ if (addit) {
1784+ /* save the new connection in our list */
1785+#if DEBUG
1786+ printk("ipt_connlimit [%d]: src=%u.%u.%u.%u:%d dst=%u.%u.%u.%u:%d new\n",
1787+ ipt_iphash(addr & mask),
1788+ NIPQUAD(tuple.src.ip), ntohs(tuple.src.u.tcp.port),
1789+ NIPQUAD(tuple.dst.ip), ntohs(tuple.dst.u.tcp.port));
1790+#endif
1791+ conn = kmalloc(sizeof(*conn),GFP_ATOMIC);
1792+ if (NULL == conn)
1793+ return -1;
1794+ memset(conn,0,sizeof(*conn));
1795+ INIT_LIST_HEAD(&conn->list);
1796+ conn->tuple = tuple;
1797+ list_add(&conn->list,hash);
1798+ matches++;
1799+ }
1800+ spin_unlock(&data->lock);
1801+ return matches;
1802+}
1803+
1804+static int
1805+match(const struct sk_buff *skb,
1806+ const struct net_device *in,
1807+ const struct net_device *out,
1808+ const void *matchinfo,
1809+ int offset,
1810+ int *hotdrop)
1811+{
1812+ const struct ipt_connlimit_info *info = matchinfo;
1813+ int connections, match;
1814+ struct ip_conntrack *ct;
1815+ enum ip_conntrack_info ctinfo;
1816+
1817+ ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo);
1818+ if (NULL == ct) {
1819+ printk("ipt_connlimit: Oops: invalid ct state ?\n");
1820+ *hotdrop = 1;
1821+ return 0;
1822+ }
1823+ connections = count_them(info->data,skb->nh.iph->saddr,info->mask,ct);
1824+ if (-1 == connections) {
1825+ printk("ipt_connlimit: Hmm, kmalloc failed :-(\n");
1826+ *hotdrop = 1; /* let's free some memory :-) */
1827+ return 0;
1828+ }
1829+ match = (info->inverse) ? (connections <= info->limit) : (connections > info->limit);
1830+#if DEBUG
1831+ printk("ipt_connlimit: src=%u.%u.%u.%u mask=%u.%u.%u.%u "
1832+ "connections=%d limit=%d match=%s\n",
1833+ NIPQUAD(skb->nh.iph->saddr), NIPQUAD(info->mask),
1834+ connections, info->limit, match ? "yes" : "no");
1835+#endif
1836+
1837+ return match;
1838+}
1839+
1840+static int check(const char *tablename,
1841+ const struct ipt_ip *ip,
1842+ void *matchinfo,
1843+ unsigned int matchsize,
1844+ unsigned int hook_mask)
1845+{
1846+ struct ipt_connlimit_info *info = matchinfo;
1847+ int i;
1848+
1849+ /* verify size */
1850+ if (matchsize != IPT_ALIGN(sizeof(struct ipt_connlimit_info)))
1851+ return 0;
1852+
1853+ /* refuse anything but tcp */
1854+ if (ip->proto != IPPROTO_TCP)
1855+ return 0;
1856+
1857+ /* init private data */
1858+ info->data = kmalloc(sizeof(struct ipt_connlimit_data),GFP_KERNEL);
1859+ spin_lock_init(&(info->data->lock));
1860+ for (i = 0; i < 256; i++)
1861+ INIT_LIST_HEAD(&(info->data->iphash[i]));
1862+
1863+ return 1;
1864+}
1865+
1866+static void destroy(void *matchinfo, unsigned int matchinfosize)
1867+{
1868+ struct ipt_connlimit_info *info = matchinfo;
1869+ struct ipt_connlimit_conn *conn;
1870+ struct list_head *hash;
1871+ int i;
1872+
1873+ /* cleanup */
1874+ for (i = 0; i < 256; i++) {
1875+ hash = &(info->data->iphash[i]);
1876+ while (hash != hash->next) {
1877+ conn = list_entry(hash->next,struct ipt_connlimit_conn,list);
1878+ list_del(hash->next);
1879+ kfree(conn);
1880+ }
1881+ }
1882+ kfree(info->data);
1883+}
1884+
1885+static struct ipt_match connlimit_match = {
1886+ .name = "connlimit",
1887+ .match = &match,
1888+ .checkentry = &check,
1889+ .destroy = &destroy,
1890+ .me = THIS_MODULE
1891+};
1892+
1893+static int __init init(void)
1894+{
1895+ return ipt_register_match(&connlimit_match);
1896+}
1897+
1898+static void __exit fini(void)
1899+{
1900+ ipt_unregister_match(&connlimit_match);
1901+}
1902+
1903+module_init(init);
1904+module_exit(fini);
1905diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_conntrack.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_conntrack.c
1906--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_conntrack.c 2004-03-16 05:47:18.000000000 +0000
1907+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_conntrack.c 2004-03-16 11:53:55.000000000 +0000
1908@@ -35,11 +35,13 @@
1909
1910 #define FWINV(bool,invflg) ((bool) ^ !!(sinfo->invflags & invflg))
1911
1912- if (ct)
1913- statebit = IPT_CONNTRACK_STATE_BIT(ctinfo);
1914- else
1915- statebit = IPT_CONNTRACK_STATE_INVALID;
1916-
1917+ if (skb->nfct == &ip_conntrack_untracked.infos[IP_CT_NEW])
1918+ statebit = IPT_CONNTRACK_STATE_UNTRACKED;
1919+ else if (ct)
1920+ statebit = IPT_CONNTRACK_STATE_BIT(ctinfo);
1921+ else
1922+ statebit = IPT_CONNTRACK_STATE_INVALID;
1923+
1924 if(sinfo->flags & IPT_CONNTRACK_STATE) {
1925 if (ct) {
1926 if(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip !=
1927diff -Nur --exclude '*.orig' linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_dstlimit.c linux-2.6.5-rc1/net/ipv4/netfilter/ipt_dstlimit.c
1928--- linux-2.6.5-rc1.org/net/ipv4/netfilter/ipt_dstlimit.c 1970-01-01 00:00:00.000000000 +0000
1929+++ linux-2.6.5-rc1/net/ipv4/netfilter/ipt_dstlimit.c 2004-03-16 11:53:48.000000000 +0000
1930@@ -0,0 +1,690 @@
1931+/* iptables match extension to limit the number of packets per second
1932+ * seperately for each destination.
1933+ *
1934+ * (C) 2003 by Harald Welte <laforge@netfilter.org>
1935+ *
1936+ * $Id$
1937+ *
1938+ * Development of this code was funded by Astaro AG, http://www.astaro.com/
1939+ *
1940+ * based on ipt_limit.c by:
1941