Updating from the mainline PL kernel
[linux-2.6.git] / linux-2.6-522-iptables-connection-tagging.patch
1 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter/xt_MARK.h linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter/xt_MARK.h
2 --- linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter/xt_MARK.h 2008-07-13 23:51:29.000000000 +0200
3 +++ linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter/xt_MARK.h      2009-01-12 01:18:23.000000000 +0100
4 @@ -11,6 +11,7 @@ enum {
5         XT_MARK_SET=0,
6         XT_MARK_AND,
7         XT_MARK_OR,
8 +       XT_MARK_COPYXID,
9  };
10  
11  struct xt_mark_target_info_v1 {
12 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter/xt_SETXID.h linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter/xt_SETXID.h
13 --- linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter/xt_SETXID.h       1970-01-01 01:00:00.000000000 +0100
14 +++ linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter/xt_SETXID.h    2009-01-12 01:18:23.000000000 +0100
15 @@ -0,0 +1,14 @@
16 +#ifndef _XT_SETXID_H_target
17 +#define _XT_SETXID_H_target
18 +
19 +/* Version 1 */
20 +enum {
21 +       XT_SET_PACKET_XID=0
22 +};
23 +
24 +struct xt_setxid_target_info_v1 {
25 +       unsigned long mark;
26 +       u_int8_t mode;
27 +};
28 +
29 +#endif /*_XT_SETXID_H_target*/
30 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter_ipv4/ipt_MARK.h linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter_ipv4/ipt_MARK.h
31 --- linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter_ipv4/ipt_MARK.h   2008-07-13 23:51:29.000000000 +0200
32 +++ linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter_ipv4/ipt_MARK.h        2009-01-12 01:18:23.000000000 +0100
33 @@ -12,6 +12,7 @@
34  #define IPT_MARK_SET   XT_MARK_SET
35  #define IPT_MARK_AND   XT_MARK_AND
36  #define        IPT_MARK_OR     XT_MARK_OR
37 +#define IPT_MARK_COPYXID       XT_MARK_COPYXID
38  
39  #define ipt_mark_target_info_v1 xt_mark_target_info_v1
40  
41 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter_ipv4/ipt_SETXID.h linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter_ipv4/ipt_SETXID.h
42 --- linux-2.6.27.10-vs2.3.x-P/include/linux/netfilter_ipv4/ipt_SETXID.h 1970-01-01 01:00:00.000000000 +0100
43 +++ linux-2.6.27.10-vs2.3.x-P522/include/linux/netfilter_ipv4/ipt_SETXID.h      2009-01-12 01:18:23.000000000 +0100
44 @@ -0,0 +1,13 @@
45 +#ifndef _IPT_SETXID_H_target
46 +#define _IPT_SETXID_H_target
47 +
48 +/* Backwards compatibility for old userspace */
49 +
50 +#include <linux/netfilter/xt_SETXID.h>
51 +
52 +/* Version 1 */
53 +#define IPT_SET_PACKET_XID     XT_SET_PACKET_XID
54 +
55 +#define ipt_setxid_target_info_v1 xt_setxid_target_info_v1
56 +
57 +#endif /*_IPT_SETXID_H_target*/
58 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/include/net/netfilter/nf_conntrack.h linux-2.6.27.10-vs2.3.x-P522/include/net/netfilter/nf_conntrack.h
59 --- linux-2.6.27.10-vs2.3.x-P/include/net/netfilter/nf_conntrack.h      2008-10-13 14:52:09.000000000 +0200
60 +++ linux-2.6.27.10-vs2.3.x-P522/include/net/netfilter/nf_conntrack.h   2009-01-12 01:59:20.000000000 +0100
61 @@ -121,6 +121,9 @@ struct nf_conn
62         /* Storage reserved for other modules: */
63         union nf_conntrack_proto proto;
64  
65 +       /* PLANETLAB. VNET-specific */
66 +       int xid[IP_CT_DIR_MAX];
67 +
68         /* Extensions */
69         struct nf_ct_ext *ext;
70  
71 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/net/netfilter/Kconfig linux-2.6.27.10-vs2.3.x-P522/net/netfilter/Kconfig
72 --- linux-2.6.27.10-vs2.3.x-P/net/netfilter/Kconfig     2008-10-13 14:52:09.000000000 +0200
73 +++ linux-2.6.27.10-vs2.3.x-P522/net/netfilter/Kconfig  2009-01-12 01:18:23.000000000 +0100
74 @@ -477,6 +477,13 @@ config NETFILTER_XT_TARGET_TCPOPTSTRIP
75           This option adds a "TCPOPTSTRIP" target, which allows you to strip
76           TCP options from TCP packets.
77  
78 +config NETFILTER_XT_TARGET_SETXID
79 +       tristate '"SETXID" target support'
80 +       depends on NETFILTER_XTABLES
81 +       help
82 +         This option adds a `SETXID' target, which allows you to alter the
83 +         xid of a socket.
84 +
85  config NETFILTER_XT_MATCH_COMMENT
86         tristate  '"comment" match support'
87         depends on NETFILTER_XTABLES
88 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/net/netfilter/Makefile linux-2.6.27.10-vs2.3.x-P522/net/netfilter/Makefile
89 --- linux-2.6.27.10-vs2.3.x-P/net/netfilter/Makefile    2008-10-13 14:52:09.000000000 +0200
90 +++ linux-2.6.27.10-vs2.3.x-P522/net/netfilter/Makefile 2009-01-12 01:18:23.000000000 +0100
91 @@ -38,6 +38,7 @@ obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_co
92  obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
93  
94  # targets
95 +obj-$(CONFIG_NETFILTER_XT_TARGET_SETXID) += xt_SETXID.o
96  obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
97  obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
98  obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
99 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/net/netfilter/nf_conntrack_core.c linux-2.6.27.10-vs2.3.x-P522/net/netfilter/nf_conntrack_core.c
100 --- linux-2.6.27.10-vs2.3.x-P/net/netfilter/nf_conntrack_core.c 2008-10-13 14:52:09.000000000 +0200
101 +++ linux-2.6.27.10-vs2.3.x-P522/net/netfilter/nf_conntrack_core.c      2009-01-12 02:01:55.000000000 +0100
102 @@ -595,6 +595,9 @@ init_conntrack(const struct nf_conntrack
103         /* Overload tuple linked list to put us in unconfirmed list. */
104         hlist_add_head(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnode, &unconfirmed);
105  
106 +       conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
107 +       conntrack->xid[IP_CT_DIR_REPLY] = -1;
108 +
109         spin_unlock_bh(&nf_conntrack_lock);
110  
111         if (exp) {
112 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/net/netfilter/xt_MARK.c linux-2.6.27.10-vs2.3.x-P522/net/netfilter/xt_MARK.c
113 --- linux-2.6.27.10-vs2.3.x-P/net/netfilter/xt_MARK.c   2008-07-13 23:51:29.000000000 +0200
114 +++ linux-2.6.27.10-vs2.3.x-P522/net/netfilter/xt_MARK.c        2009-01-12 02:20:38.000000000 +0100
115 @@ -8,13 +8,19 @@
116   *     This program is free software; you can redistribute it and/or modify
117   *     it under the terms of the GNU General Public License version 2 as
118   *     published by the Free Software Foundation.
119 + *
120   */
121  
122  #include <linux/module.h>
123 +#include <linux/version.h>
124  #include <linux/skbuff.h>
125  #include <linux/ip.h>
126 +#include <net/udp.h>
127  #include <net/checksum.h>
128 +#include <net/route.h>
129 +#include <net/inet_hashtables.h>
130  
131 +#include <net/netfilter/nf_conntrack.h>
132  #include <linux/netfilter/x_tables.h>
133  #include <linux/netfilter/xt_MARK.h>
134  
135 @@ -24,6 +30,50 @@ MODULE_DESCRIPTION("Xtables: packet mark
136  MODULE_ALIAS("ipt_MARK");
137  MODULE_ALIAS("ip6t_MARK");
138  
139 +#define PEERCRED_SET(x) ((x!=0) && (x!=(unsigned int)-1)) 
140 +
141 +static inline u_int16_t
142 +get_dst_port(struct nf_conntrack_tuple *tuple)
143 +{
144 +       switch (tuple->dst.protonum) {
145 +       case IPPROTO_GRE:
146 +               /* XXX Truncate 32-bit GRE key to 16 bits */
147 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
148 +               return tuple->dst.u.gre.key;
149 +#else
150 +               return htons(ntohl(tuple->dst.u.gre.key));
151 +#endif  
152 +       case IPPROTO_ICMP:
153 +               /* Bind on ICMP echo ID */
154 +               return tuple->src.u.icmp.id;
155 +       case IPPROTO_TCP:
156 +               return tuple->dst.u.tcp.port;
157 +       case IPPROTO_UDP:
158 +               return tuple->dst.u.udp.port;
159 +       default:
160 +               return tuple->dst.u.all;
161 +       }
162 +}
163 +
164 +static inline u_int16_t
165 +get_src_port(struct nf_conntrack_tuple *tuple)
166 +{
167 +       switch (tuple->dst.protonum) {
168 +       case IPPROTO_GRE:
169 +               /* XXX Truncate 32-bit GRE key to 16 bits */
170 +               return htons(ntohl(tuple->src.u.gre.key));
171 +       case IPPROTO_ICMP:
172 +               /* Bind on ICMP echo ID */
173 +               return tuple->src.u.icmp.id;
174 +       case IPPROTO_TCP:
175 +               return tuple->src.u.tcp.port;
176 +       case IPPROTO_UDP:
177 +               return tuple->src.u.udp.port;
178 +       default:
179 +               return tuple->src.u.all;
180 +       }
181 +}
182 +
183  static unsigned int
184  mark_tg_v0(struct sk_buff *skb, const struct net_device *in,
185             const struct net_device *out, unsigned int hooknum,
186 @@ -35,13 +85,88 @@ mark_tg_v0(struct sk_buff *skb, const st
187         return XT_CONTINUE;
188  }
189  
190 +extern DEFINE_PER_CPU(int, sknid_elevator);
191 +
192 +static struct sock *__udp4_lib_lookup(__be32 saddr, __be16 sport,
193 +                      __be32 daddr, __be16 dport,
194 +                      int dif, struct hlist_head udptable[])
195 +{
196 +    struct sock *sk, *result = NULL;
197 +    struct hlist_node *node;
198 +    unsigned short hnum = ntohs(dport);
199 +    int badness = -1;
200 +
201 +    read_lock(&udp_hash_lock);
202 +
203 +    sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
204 +        struct inet_sock *inet = inet_sk(sk);
205 +
206 +        if (sk->sk_hash == hnum && !ipv6_only_sock(sk)) {
207 +            int score = (sk->sk_family == PF_INET ? 1 : 0);
208 +
209 +            if (inet->rcv_saddr) {
210 +                if (inet->rcv_saddr != daddr)
211 +                    continue;
212 +                score+=2;
213 +            } else {
214 +                /* block non nx_info ips */
215 +                if (!v4_addr_in_nx_info(sk->sk_nx_info,
216 +                    daddr, NXA_MASK_BIND))
217 +                    continue;
218 +            }
219 +            if (inet->daddr) {
220 +                if (inet->daddr != saddr)
221 +                    continue;
222 +                score+=2;
223 +            }
224 +            if (inet->dport) {
225 +                if (inet->dport != sport)
226 +                    continue;
227 +                score+=2;
228 +            }
229 +            if (sk->sk_bound_dev_if) {
230 +                if (sk->sk_bound_dev_if != dif)
231 +                    continue;
232 +                score+=2;
233 +            }
234 +            if (score == 9) {
235 +                result = sk;
236 +                break;
237 +            } else if (score > badness) {
238 +                result = sk;
239 +                badness = score;
240 +            }
241 +        }
242 +    }
243 +
244 +    if (result)
245 +        sock_hold(result);
246 +    read_unlock(&udp_hash_lock);
247 +    return result;
248 +}
249 +
250 +#define related(ct) (ct==(IP_CT_IS_REPLY + IP_CT_RELATED))
251 +
252  static unsigned int
253  mark_tg_v1(struct sk_buff *skb, const struct net_device *in,
254             const struct net_device *out, unsigned int hooknum,
255             const struct xt_target *target, const void *targinfo)
256  {
257         const struct xt_mark_target_info_v1 *markinfo = targinfo;
258 -       int mark = 0;
259 +               enum ip_conntrack_info ctinfo;
260 +               struct sock *connection_sk;
261 +               int dif;
262 +               struct nf_conn *ct;
263 +               extern struct inet_hashinfo tcp_hashinfo;
264 +               enum ip_conntrack_dir dir;
265 +               int *curtag;
266 +               u_int32_t src_ip;
267 +               u_int32_t dst_ip;
268 +               u_int16_t proto, src_port;
269 +               u_int32_t ip;
270 +               u_int16_t port;
271 +
272 +               int mark = -1;
273  
274         switch (markinfo->mode) {
275         case XT_MARK_SET:
276 @@ -55,9 +180,119 @@ mark_tg_v1(struct sk_buff *skb, const st
277         case XT_MARK_OR:
278                 mark = skb->mark | markinfo->mark;
279                 break;
280 +
281 +       case XT_MARK_COPYXID: 
282 +               dif = ((struct rtable *)(*pskb)->dst)->rt_iif;
283 +
284 +               ct = nf_ct_get((*pskb), &ctinfo);
285 +               if (!ct) 
286 +                       break;
287 +
288 +               dir = CTINFO2DIR(ctinfo);
289 +               src_ip = ct->tuplehash[dir].tuple.src.u3.ip;
290 +               dst_ip = ct->tuplehash[dir].tuple.dst.u3.ip;
291 +               src_port = get_src_port(&ct->tuplehash[dir].tuple);
292 +               proto = ct->tuplehash[dir].tuple.dst.protonum;
293 +
294 +               ip = ct->tuplehash[dir].tuple.dst.u3.ip;
295 +               port = get_dst_port(&ct->tuplehash[dir].tuple);
296 +
297 +               if (proto == 1) {
298 +                       if ((*pskb)->mark > 0)
299 +                               /* The packet is marked, it's going out */
300 +                               ct->xid[0] = (*pskb)->mark;
301 +
302 +                       if (ct->xid[0] > 0)
303 +                               mark = ct->xid[0];
304 +               }
305 +               else if (proto == 17) {
306 +                       struct sock *sk;
307 +                       if (!(*pskb)->mark) {
308 +                               sk = __udp4_lib_lookup(src_ip, src_port,
309 +                                       ip, port, dif, udp_hash);
310 +
311 +                               if (sk && hooknum == NF_IP_LOCAL_IN)
312 +                                       mark = sk->sk_nid;
313 +
314 +                               if (sk)
315 +                                       sock_put(sk);
316 +                       }
317 +                       else if ((*pskb)->mark > 0)
318 +                               /* The packet is marked, it's going out */
319 +                               ct->xid[0] = (*pskb)->mark;
320 +               }
321 +               else if (proto == 6) /* TCP */{
322 +                       int sockettype = 0; /* Established socket */
323 +
324 +                       /* Looks for an established socket or a listening 
325 +                          socket corresponding to the 4-tuple, in that order.
326 +                          The order is important for Codemux connections
327 +                          to be handled properly */
328 +
329 +                       connection_sk = inet_lookup_established(&tcp_hashinfo,
330 +                               src_ip, src_port, ip, port, dif);
331 +
332 +                       if (!connection_sk) {
333 +                               connection_sk = inet_lookup_listener(&tcp_hashinfo,
334 +                                       ip, port, dif);
335 +                               sockettype = 1; /* Listening socket */
336 +                       }
337 +
338 +                       if (connection_sk) {
339 +                               /* The peercred is not set. We set it if the other side has an xid. */
340 +                               if (!PEERCRED_SET(connection_sk->sk_peercred.uid)
341 +                                       && ct->xid[!dir] > 0 && (sockettype == 0)) {
342 +                                       connection_sk->sk_peercred.gid = 
343 +                                               connection_sk->sk_peercred.uid = ct->xid[!dir];
344 +                               }
345 +
346 +                               /* The peercred is set, and is not equal to the XID of 'the other side' */
347 +                               else if (PEERCRED_SET(connection_sk->sk_peercred.uid) &&
348 +                                       (connection_sk->sk_peercred.uid != ct->xid[!dir]) &&
349 +                                       (sockettype == 0)) {
350 +                                       mark = connection_sk->sk_peercred.uid;
351 +                               }
352 +
353 +                               /* Has this connection already been tagged? */
354 +                               if (ct->xid[dir] < 1) {
355 +                                       /* No - let's tag it */ 
356 +                                       ct->xid[dir]=connection_sk->sk_nid;
357 +                               }
358 +
359 +                               if (mark == -1 && (ct->xid[dir] != 0))
360 +                                       mark = ct->xid[dir];
361 +
362 +                               if (connection_sk->sk_state == TCP_TIME_WAIT) {
363 +                                       inet_twsk_put(inet_twsk(connection_sk));
364 +                                       break;
365 +                               } else
366 +                                       sock_put(connection_sk);
367 +                       }
368
369 +                       /* All else failed. Is this a connection over raw sockets?
370 +                          That explains why we couldn't get anything out of skb->sk,
371 +                          or look up a "real" connection. */
372 +                       if (ct->xid[dir] < 1) {
373 +                               if ((*pskb)->skb_tag)
374 +                                       ct->xid[dir] = (*pskb)->skb_tag;
375 +                       }
376 +
377 +                       /* Covers CoDemux case */
378 +                       if (mark < 1 && (ct->xid[dir] > 0))
379 +                               mark = ct->xid[dir];
380 +
381 +                       if (mark < 1 && (ct->xid[!dir] > 0))
382 +                               mark = ct->xid[!dir];
383 +                       break;
384 +               }
385         }
386 +       if (mark != -1)
387 +               skb->mark = mark;
388 +
389 +       curtag = &__get_cpu_var(sknid_elevator);
390 +       if (mark > 0 && *curtag == -2 && hooknum == NF_IP_LOCAL_IN) 
391 +               *curtag = mark;
392  
393 -       skb->mark = mark;
394         return XT_CONTINUE;
395  }
396  
397 @@ -95,7 +330,8 @@ mark_tg_check_v1(const char *tablename, 
398  
399         if (markinfo->mode != XT_MARK_SET
400             && markinfo->mode != XT_MARK_AND
401 -           && markinfo->mode != XT_MARK_OR) {
402 +           && markinfo->mode != XT_MARK_OR
403 +           && markinfo->mode != XT_MARK_COPYXID) {
404                 printk(KERN_WARNING "MARK: unknown mode %u\n",
405                        markinfo->mode);
406                 return false;
407 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-P/net/netfilter/xt_SETXID.c linux-2.6.27.10-vs2.3.x-P522/net/netfilter/xt_SETXID.c
408 --- linux-2.6.27.10-vs2.3.x-P/net/netfilter/xt_SETXID.c 1970-01-01 01:00:00.000000000 +0100
409 +++ linux-2.6.27.10-vs2.3.x-P522/net/netfilter/xt_SETXID.c      2009-01-12 01:18:23.000000000 +0100
410 @@ -0,0 +1,79 @@
411 +#include <linux/module.h>
412 +#include <linux/skbuff.h>
413 +#include <linux/ip.h>
414 +#include <net/checksum.h>
415 +#include <linux/vs_network.h>
416 +
417 +#include <linux/netfilter/x_tables.h>
418 +#include <linux/netfilter/xt_SETXID.h>
419 +
420 +MODULE_LICENSE("GPL");
421 +MODULE_AUTHOR("");
422 +MODULE_DESCRIPTION("");
423 +MODULE_ALIAS("ipt_SETXID");
424 +
425 +static unsigned int
426 +target_v1(struct sk_buff **pskb,
427 +         const struct net_device *in,
428 +         const struct net_device *out,
429 +         unsigned int hooknum,
430 +         const struct xt_target *target,
431 +         const void *targinfo)
432 +{
433 +       const struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
434 +
435 +       switch (setxidinfo->mode) {
436 +       case XT_SET_PACKET_XID:
437 +                (*pskb)->skb_tag = setxidinfo->mark;
438 +               break;
439 +       }
440 +       return XT_CONTINUE;
441 +}
442 +
443 +
444 +static int
445 +checkentry_v1(const char *tablename,
446 +             const void *entry,
447 +             const struct xt_target *target,
448 +             void *targinfo,
449 +             unsigned int hook_mask)
450 +{
451 +       struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
452 +
453 +       if (setxidinfo->mode != XT_SET_PACKET_XID) {
454 +               printk(KERN_WARNING "SETXID: unknown mode %u\n",
455 +                      setxidinfo->mode);
456 +               return 0;
457 +       }
458 +
459 +       return 1;
460 +}
461 +
462 +static struct xt_target xt_setxid_target[] = {
463 +       {
464 +               .name           = "SETXID",
465 +               .family         = AF_INET,
466 +               .revision       = 1,
467 +               .checkentry     = checkentry_v1,
468 +               .target         = target_v1,
469 +               .targetsize     = sizeof(struct xt_setxid_target_info_v1),
470 +               .table          = "mangle",
471 +               .me             = THIS_MODULE,
472 +       }
473 +};
474 +
475 +static int __init init(void)
476 +{
477 +       int err;
478 +
479 +       err = xt_register_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
480 +       return err;
481 +}
482 +
483 +static void __exit fini(void)
484 +{
485 +       xt_unregister_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
486 +}
487 +
488 +module_init(init);
489 +module_exit(fini);
490
491 ; fixup
492 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-02.0/net/netfilter/nf_conntrack_core.c linux-2.6.27.10-vs2.3.x-PS-02.1/net/netfilter/nf_conntrack_core.c
493 --- linux-2.6.27.10-vs2.3.x-PS-02.0/net/netfilter/nf_conntrack_core.c   2009-01-25 02:29:31.000000000 +0100
494 +++ linux-2.6.27.10-vs2.3.x-PS-02.1/net/netfilter/nf_conntrack_core.c   2009-01-24 23:22:04.000000000 +0100
495 @@ -595,8 +595,8 @@ init_conntrack(const struct nf_conntrack
496         /* Overload tuple linked list to put us in unconfirmed list. */
497         hlist_add_head(&ct->tuplehash[IP_CT_DIR_ORIGINAL].hnode, &unconfirmed);
498  
499 -       conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
500 -       conntrack->xid[IP_CT_DIR_REPLY] = -1;
501 +       ct->xid[IP_CT_DIR_ORIGINAL] = -1;
502 +       ct->xid[IP_CT_DIR_REPLY] = -1;
503  
504         spin_unlock_bh(&nf_conntrack_lock);
505  
506 diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-02.0/net/netfilter/xt_MARK.c linux-2.6.27.10-vs2.3.x-PS-02.1/net/netfilter/xt_MARK.c
507 --- linux-2.6.27.10-vs2.3.x-PS-02.0/net/netfilter/xt_MARK.c     2009-01-25 02:29:31.000000000 +0100
508 +++ linux-2.6.27.10-vs2.3.x-PS-02.1/net/netfilter/xt_MARK.c     2009-01-25 00:06:34.000000000 +0100
509 @@ -19,6 +19,7 @@
510  #include <net/checksum.h>
511  #include <net/route.h>
512  #include <net/inet_hashtables.h>
513 +#include <net/net_namespace.h>
514  
515  #include <net/netfilter/nf_conntrack.h>
516  #include <linux/netfilter/x_tables.h>
517 @@ -182,9 +183,9 @@ mark_tg_v1(struct sk_buff *skb, const st
518                 break;
519  
520         case XT_MARK_COPYXID: 
521 -               dif = ((struct rtable *)(*pskb)->dst)->rt_iif;
522 +               dif = ((struct rtable *)(skb->dst))->rt_iif;
523  
524 -               ct = nf_ct_get((*pskb), &ctinfo);
525 +               ct = nf_ct_get(skb, &ctinfo);
526                 if (!ct) 
527                         break;
528  
529 @@ -198,43 +199,44 @@ mark_tg_v1(struct sk_buff *skb, const st
530                 port = get_dst_port(&ct->tuplehash[dir].tuple);
531  
532                 if (proto == 1) {
533 -                       if ((*pskb)->mark > 0)
534 +                       if (skb->mark > 0)
535                                 /* The packet is marked, it's going out */
536 -                               ct->xid[0] = (*pskb)->mark;
537 +                               ct->xid[0] = skb->mark;
538  
539                         if (ct->xid[0] > 0)
540                                 mark = ct->xid[0];
541                 }
542                 else if (proto == 17) {
543                         struct sock *sk;
544 -                       if (!(*pskb)->mark) {
545 +                       if (!skb->mark) {
546                                 sk = __udp4_lib_lookup(src_ip, src_port,
547                                         ip, port, dif, udp_hash);
548  
549 -                               if (sk && hooknum == NF_IP_LOCAL_IN)
550 +                               if (sk && hooknum == NF_INET_LOCAL_IN)
551                                         mark = sk->sk_nid;
552  
553                                 if (sk)
554                                         sock_put(sk);
555                         }
556 -                       else if ((*pskb)->mark > 0)
557 +                       else if (skb->mark > 0)
558                                 /* The packet is marked, it's going out */
559 -                               ct->xid[0] = (*pskb)->mark;
560 +                               ct->xid[0] = skb->mark;
561                 }
562                 else if (proto == 6) /* TCP */{
563                         int sockettype = 0; /* Established socket */
564 +                       struct net *net = &init_net;
565  
566                         /* Looks for an established socket or a listening 
567                            socket corresponding to the 4-tuple, in that order.
568                            The order is important for Codemux connections
569                            to be handled properly */
570  
571 -                       connection_sk = inet_lookup_established(&tcp_hashinfo,
572 -                               src_ip, src_port, ip, port, dif);
573 +                       connection_sk = inet_lookup_established(net,
574 +                               &tcp_hashinfo, src_ip, src_port, ip, port, dif);
575  
576                         if (!connection_sk) {
577 -                               connection_sk = inet_lookup_listener(&tcp_hashinfo,
578 -                                       ip, port, dif);
579 +                               connection_sk = inet_lookup_listener(net,
580 +                                       &tcp_hashinfo, ip, port, dif);
581                                 sockettype = 1; /* Listening socket */
582                         }
583  
584 @@ -273,8 +275,8 @@ mark_tg_v1(struct sk_buff *skb, const st
585                            That explains why we couldn't get anything out of skb->sk,
586                            or look up a "real" connection. */
587                         if (ct->xid[dir] < 1) {
588 -                               if ((*pskb)->skb_tag)
589 -                                       ct->xid[dir] = (*pskb)->skb_tag;
590 +                               if (skb->skb_tag)
591 +                                       ct->xid[dir] = skb->skb_tag;
592                         }
593  
594                         /* Covers CoDemux case */
595 @@ -290,7 +292,7 @@ mark_tg_v1(struct sk_buff *skb, const st
596                 skb->mark = mark;
597  
598         curtag = &__get_cpu_var(sknid_elevator);
599 -       if (mark > 0 && *curtag == -2 && hooknum == NF_IP_LOCAL_IN) 
600 +       if (mark > 0 && *curtag == -2 && hooknum == NF_INET_LOCAL_IN) 
601                 *curtag = mark;
602  
603         return XT_CONTINUE;