Always enabled device mapper.
[linux-2.6.git] / linux-2.6-520-vnet+.patch
1 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter/xt_MARK.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter/xt_MARK.h
2 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter/xt_MARK.h   2006-06-17 21:49:35.000000000 -0400
3 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter/xt_MARK.h   2007-11-14 16:04:04.000000000 -0500
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 -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter/xt_SETXID.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter/xt_SETXID.h
13 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter/xt_SETXID.h 1969-12-31 19:00:00.000000000 -0500
14 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter/xt_SETXID.h 2007-11-14 16:05:44.000000000 -0500
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 -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter_ipv4/ipt_MARK.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter_ipv4/ipt_MARK.h
31 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter_ipv4/ipt_MARK.h     2006-06-17 21:49:35.000000000 -0400
32 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter_ipv4/ipt_MARK.h     2007-11-14 16:03:44.000000000 -0500
33 @@ -9,9 +9,10 @@
34  #define ipt_mark_target_info xt_mark_target_info
35  
36  /* Version 1 */
37 -#define IPT_MARK_SET   XT_MARK_SET
38 -#define IPT_MARK_AND   XT_MARK_AND
39 -#define        IPT_MARK_OR     XT_MARK_OR
40 +#define IPT_MARK_SET           XT_MARK_SET
41 +#define IPT_MARK_AND           XT_MARK_AND
42 +#define        IPT_MARK_OR             XT_MARK_OR
43 +#define IPT_MARK_COPYXID       XT_MARK_COPYXID
44  
45  #define ipt_mark_target_info_v1 xt_mark_target_info_v1
46  
47 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter_ipv4/ipt_SETXID.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter_ipv4/ipt_SETXID.h
48 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/netfilter_ipv4/ipt_SETXID.h   1969-12-31 19:00:00.000000000 -0500
49 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/netfilter_ipv4/ipt_SETXID.h   2007-11-14 16:05:44.000000000 -0500
50 @@ -0,0 +1,13 @@
51 +#ifndef _IPT_SETXID_H_target
52 +#define _IPT_SETXID_H_target
53 +
54 +/* Backwards compatibility for old userspace */
55 +
56 +#include <linux/netfilter/xt_SETXID.h>
57 +
58 +/* Version 1 */
59 +#define IPT_SET_PACKET_XID     XT_SET_PACKET_XID
60 +
61 +#define ipt_setxid_target_info_v1 xt_setxid_target_info_v1
62 +
63 +#endif /*_IPT_SETXID_H_target*/
64 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/skbuff.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/skbuff.h
65 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/skbuff.h      2007-07-21 18:00:24.000000000 -0400
66 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/skbuff.h      2007-11-15 13:57:04.000000000 -0500
67 @@ -299,6 +299,9 @@ struct sk_buff {
68  #endif
69  #ifdef CONFIG_NETWORK_SECMARK
70         __u32                   secmark;
71 +#  define skb_tag              secmark
72 +#else
73 +#  define skb_tag              mark
74  #endif
75  
76         __u32                   mark;
77 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/socket.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/socket.h
78 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/socket.h      2007-07-21 18:00:24.000000000 -0400
79 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/socket.h      2007-11-14 14:24:36.000000000 -0500
80 @@ -288,6 +288,8 @@ struct ucred {
81  #define SOL_TIPC       271
82  #define SOL_RXRPC      272
83  
84 +#define SO_SETXID      SO_PEERCRED
85 +
86  /* IPX options */
87  #define IPX_TYPE       1
88  
89 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/vserver/network.h linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/vserver/network.h
90 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/linux/vserver/network.h     2007-10-29 21:23:59.000000000 -0400
91 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/linux/vserver/network.h     2007-11-14 14:23:54.000000000 -0500
92 @@ -44,6 +44,8 @@ static inline uint64_t __nxf_init_set(vo
93  /* network caps */
94  
95  #define NXC_RAW_ICMP           0x00000100
96 +#define NXC_RAW_SOCKET         0x00000200
97 +#define NXC_RAW_SEND           0x00000400
98  
99  
100  /* address types */
101 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/net/netfilter/nf_conntrack.h linux-2.6.22.10-vs2.3.0.29-pl04/include/net/netfilter/nf_conntrack.h
102 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/net/netfilter/nf_conntrack.h        2007-07-21 18:00:24.000000000 -0400
103 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/net/netfilter/nf_conntrack.h        2007-11-14 16:35:42.000000000 -0500
104 @@ -131,6 +131,9 @@ struct nf_conn
105         /* Storage reserved for other modules: */
106         union nf_conntrack_proto proto;
107  
108 +       /* PLANETLAB. VNET-specific */
109 +       xid_t xid[IP_CT_DIR_MAX];
110 +
111         /* features dynamically at the end: helper, nat (both optional) */
112         char data[0];
113  };
114 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/include/net/raw.h linux-2.6.22.10-vs2.3.0.29-pl04/include/net/raw.h
115 --- linux-2.6.22.10-vs2.3.0.29-pl03/include/net/raw.h   2007-05-04 09:55:46.000000000 -0400
116 +++ linux-2.6.22.10-vs2.3.0.29-pl04/include/net/raw.h   2007-11-14 14:22:49.000000000 -0500
117 @@ -36,7 +36,7 @@ extern rwlock_t raw_v4_lock;
118  
119  extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
120                                     __be32 raddr, __be32 laddr,
121 -                                   int dif);
122 +                                   int dif, int tag);
123  
124  extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash);
125  
126 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/core/skbuff.c linux-2.6.22.10-vs2.3.0.29-pl04/net/core/skbuff.c
127 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/core/skbuff.c   2007-07-21 18:00:25.000000000 -0400
128 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/core/skbuff.c   2007-11-14 15:12:52.000000000 -0500
129 @@ -56,6 +56,7 @@
130  #include <linux/rtnetlink.h>
131  #include <linux/init.h>
132  #include <linux/scatterlist.h>
133 +#include <linux/vs_network.h>
134  
135  #include <net/protocol.h>
136  #include <net/dst.h>
137 @@ -174,6 +175,7 @@ struct sk_buff *__alloc_skb(unsigned int
138         skb->data = data;
139         skb_reset_tail_pointer(skb);
140         skb->end = skb->tail + size;
141 +       skb->skb_tag = nx_current_nid();
142         /* make sure we initialize shinfo sequentially */
143         shinfo = skb_shinfo(skb);
144         atomic_set(&shinfo->dataref, 1);
145 @@ -443,6 +445,8 @@ struct sk_buff *skb_clone(struct sk_buff
146         C(tail);
147         C(end);
148  
149 +       /* Sapan: Cloned skbs aren't owned by anyone. Let the cloner decide who it belongs to. */
150 +
151         atomic_inc(&(skb_shinfo(skb)->dataref));
152         skb->cloned = 1;
153  
154 @@ -492,6 +496,7 @@ static void copy_skb_header(struct sk_bu
155         new->tc_index   = old->tc_index;
156  #endif
157         skb_copy_secmark(new, old);
158 +       new->skb_tag = old->skb_tag;
159         atomic_set(&new->users, 1);
160         skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
161         skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
162 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/core/sock.c linux-2.6.22.10-vs2.3.0.29-pl04/net/core/sock.c
163 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/core/sock.c     2007-10-29 21:23:59.000000000 -0400
164 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/core/sock.c     2007-11-14 14:36:36.000000000 -0500
165 @@ -444,6 +444,19 @@ set_sndbuf:
166                 }
167                 goto set_sndbuf;
168  
169 +       case SO_SETXID:
170 +               if (current_vx_info()) {
171 +                       ret = -EPERM;
172 +                       break;
173 +               }
174 +               if (val < 0 || val > MAX_S_CONTEXT) {
175 +                       ret = -EINVAL;
176 +                       break;
177 +               }
178 +               sk->sk_xid = val;
179 +               sk->sk_nid = val;
180 +               break;
181 +
182         case SO_RCVBUF:
183                 /* Don't error on this BSD doesn't and if you think
184                    about it this is right. Otherwise apps have to
185 @@ -573,7 +586,7 @@ set_rcvbuf:
186                 char devname[IFNAMSIZ];
187  
188                 /* Sorry... */
189 -               if (!capable(CAP_NET_RAW)) {
190 +               if (!nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
191                         ret = -EPERM;
192                         break;
193                 }
194 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/af_inet.c linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/af_inet.c
195 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/af_inet.c  2007-10-29 21:23:59.000000000 -0400
196 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/af_inet.c  2007-11-14 16:40:54.000000000 -0500
197 @@ -178,6 +178,8 @@ static int inet_autobind(struct sock *sk
198                         return -EAGAIN;
199                 }
200                 inet->sport = htons(inet->num);
201 +               sk->sk_xid = vx_current_xid();
202 +               sk->sk_nid = nx_current_nid();
203         }
204         release_sock(sk);
205         return 0;
206 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/icmp.c linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/icmp.c
207 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/icmp.c     2007-11-14 14:00:56.000000000 -0500
208 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/icmp.c     2007-11-15 13:57:04.000000000 -0500
209 @@ -709,7 +709,7 @@ static void icmp_unreach(struct sk_buff 
210         if ((raw_sk = sk_head(&raw_v4_htable[hash])) != NULL) {
211                 while ((raw_sk = __raw_v4_lookup(raw_sk, protocol, iph->daddr,
212                                                  iph->saddr,
213 -                                                skb->dev->ifindex)) != NULL) {
214 +                                                skb->dev->ifindex, skb->skb_tag)) != NULL) {
215                         raw_err(raw_sk, skb, info);
216                         raw_sk = sk_next(raw_sk);
217                         iph = (struct iphdr *)skb->data;
218 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/ip_options.c linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/ip_options.c
219 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/ip_options.c       2007-07-21 18:00:25.000000000 -0400
220 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/ip_options.c       2007-11-14 17:03:19.000000000 -0500
221 @@ -409,7 +409,7 @@ int ip_options_compile(struct ip_options
222                                         optptr[2] += 8;
223                                         break;
224                                       default:
225 -                                       if (!skb && !capable(CAP_NET_RAW)) {
226 +                                       if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
227                                                 pp_ptr = optptr + 3;
228                                                 goto error;
229                                         }
230 @@ -445,7 +445,7 @@ int ip_options_compile(struct ip_options
231                                 opt->router_alert = optptr - iph;
232                         break;
233                       case IPOPT_CIPSO:
234 -                       if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
235 +                       if ((!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) || opt->cipso) {
236                                 pp_ptr = optptr;
237                                 goto error;
238                         }
239 @@ -458,7 +458,7 @@ int ip_options_compile(struct ip_options
240                       case IPOPT_SEC:
241                       case IPOPT_SID:
242                       default:
243 -                       if (!skb && !capable(CAP_NET_RAW)) {
244 +                       if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
245                                 pp_ptr = optptr;
246                                 goto error;
247                         }
248 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/netfilter/ipt_LOG.c linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/netfilter/ipt_LOG.c
249 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/netfilter/ipt_LOG.c        2007-08-11 21:54:37.000000000 -0400
250 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/netfilter/ipt_LOG.c        2007-11-14 16:00:55.000000000 -0500
251 @@ -49,6 +49,8 @@ static void dump_packet(const struct nf_
252         else
253                 logflags = NF_LOG_MASK;
254  
255 +       printk("TAG=%d ", skb->skb_tag);
256 +
257         ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);
258         if (ih == NULL) {
259                 printk("TRUNCATED");
260 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/raw.c linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/raw.c
261 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/ipv4/raw.c      2007-10-29 21:23:59.000000000 -0400
262 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/ipv4/raw.c      2007-11-14 17:02:08.000000000 -0500
263 @@ -103,7 +103,7 @@ static void raw_v4_unhash(struct sock *s
264  
265  struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
266                              __be32 raddr, __be32 laddr,
267 -                            int dif)
268 +                            int dif, int tag)
269  {
270         struct hlist_node *node;
271  
272 @@ -112,6 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
273  
274                 if (inet->num == num                                    &&
275                     !(inet->daddr && inet->daddr != raddr)              &&
276 +                   (!sk->sk_nx_info || tag == 1 || sk->sk_nid == tag)  &&
277                     v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
278                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
279                         goto found; /* gotcha */
280 @@ -161,7 +162,7 @@ int raw_v4_input(struct sk_buff *skb, st
281                 goto out;
282         sk = __raw_v4_lookup(__sk_head(head), iph->protocol,
283                              iph->saddr, iph->daddr,
284 -                            skb->dev->ifindex);
285 +                            skb->dev->ifindex, skb->skb_tag);
286  
287         while (sk) {
288                 delivered = 1;
289 @@ -174,7 +175,7 @@ int raw_v4_input(struct sk_buff *skb, st
290                 }
291                 sk = __raw_v4_lookup(sk_next(sk), iph->protocol,
292                                      iph->saddr, iph->daddr,
293 -                                    skb->dev->ifindex);
294 +                                    skb->dev->ifindex, skb->skb_tag);
295         }
296  out:
297         read_unlock(&raw_v4_lock);
298 @@ -315,7 +316,7 @@ static int raw_send_hdrinc(struct sock *
299         }
300  
301         err = -EPERM;
302 -       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
303 +       if (!nx_check(0, VS_ADMIN) && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET) &&
304                 sk->sk_nx_info &&
305                 !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
306                 goto error_free;
307 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/Kconfig linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/Kconfig
308 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/Kconfig       2007-07-21 18:00:27.000000000 -0400
309 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/Kconfig       2007-11-14 15:27:12.000000000 -0500
310 @@ -389,6 +389,13 @@ config NETFILTER_XT_TARGET_TCPMSS
311  
312           To compile it as a module, choose M here.  If unsure, say N.
313  
314 +config NETFILTER_XT_TARGET_SETXID
315 +       tristate '"SETXID" target support'
316 +       depends on NETFILTER_XTABLES
317 +       help
318 +         This option adds a `SETXID' target, which allows you to alter the
319 +         xid of a socket.
320 +
321  config NETFILTER_XT_MATCH_COMMENT
322         tristate  '"comment" match support'
323         depends on NETFILTER_XTABLES
324 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/Makefile linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/Makefile
325 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/Makefile      2007-07-21 17:58:59.000000000 -0400
326 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/Makefile      2007-11-14 15:25:53.000000000 -0500
327 @@ -37,6 +37,7 @@ obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_co
328  obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
329  
330  # targets
331 +obj-$(CONFIG_NETFILTER_XT_TARGET_SETXID) += xt_SETXID.o
332  obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
333  obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
334  obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
335 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/nf_conntrack_core.c linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/nf_conntrack_core.c
336 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/nf_conntrack_core.c   2007-07-21 18:00:27.000000000 -0400
337 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/nf_conntrack_core.c   2007-11-14 16:39:09.000000000 -0500
338 @@ -726,6 +726,8 @@ init_conntrack(const struct nf_conntrack
339  
340         /* Overload tuple linked list to put us in unconfirmed list. */
341         list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
342 +       conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
343 +       conntrack->xid[IP_CT_DIR_REPLY] = -1;
344  
345         write_unlock_bh(&nf_conntrack_lock);
346  
347 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/xt_MARK.c linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/xt_MARK.c
348 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/xt_MARK.c     2007-07-21 17:59:00.000000000 -0400
349 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/xt_MARK.c     2007-11-15 13:57:04.000000000 -0500
350 @@ -5,13 +5,18 @@
351   * This program is free software; you can redistribute it and/or modify
352   * it under the terms of the GNU General Public License version 2 as
353   * published by the Free Software Foundation.
354 + *
355   */
356  
357  #include <linux/module.h>
358 +#include <linux/version.h>
359  #include <linux/skbuff.h>
360  #include <linux/ip.h>
361  #include <net/checksum.h>
362 +#include <net/route.h>
363 +#include <net/inet_hashtables.h>
364  
365 +#include <net/netfilter/nf_conntrack.h>
366  #include <linux/netfilter/x_tables.h>
367  #include <linux/netfilter/xt_MARK.h>
368  
369 @@ -21,6 +26,48 @@ MODULE_DESCRIPTION("ip[6]tables MARK mod
370  MODULE_ALIAS("ipt_MARK");
371  MODULE_ALIAS("ip6t_MARK");
372  
373 +static inline u_int16_t
374 +get_dst_port(struct nf_conntrack_tuple *tuple)
375 +{
376 +       switch (tuple->dst.protonum) {
377 +       case IPPROTO_GRE:
378 +               /* XXX Truncate 32-bit GRE key to 16 bits */
379 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
380 +               return tuple->dst.u.gre.key;
381 +#else
382 +               return htons(ntohl(tuple->dst.u.gre.key));
383 +#endif  
384 +       case IPPROTO_ICMP:
385 +               /* Bind on ICMP echo ID */
386 +               return tuple->src.u.icmp.id;
387 +       case IPPROTO_TCP:
388 +               return tuple->dst.u.tcp.port;
389 +       case IPPROTO_UDP:
390 +               return tuple->dst.u.udp.port;
391 +       default:
392 +               return tuple->dst.u.all;
393 +       }
394 +}
395 +
396 +static inline u_int16_t
397 +get_src_port(struct nf_conntrack_tuple *tuple)
398 +{
399 +       switch (tuple->dst.protonum) {
400 +       case IPPROTO_GRE:
401 +               /* XXX Truncate 32-bit GRE key to 16 bits */
402 +               return htons(ntohl(tuple->src.u.gre.key));
403 +       case IPPROTO_ICMP:
404 +               /* Bind on ICMP echo ID */
405 +               return tuple->src.u.icmp.id;
406 +       case IPPROTO_TCP:
407 +               return tuple->src.u.tcp.port;
408 +       case IPPROTO_UDP:
409 +               return tuple->src.u.udp.port;
410 +       default:
411 +               return tuple->src.u.all;
412 +       }
413 +}
414 +
415  static unsigned int
416  target_v0(struct sk_buff **pskb,
417           const struct net_device *in,
418 @@ -44,7 +91,7 @@ target_v1(struct sk_buff **pskb,
419           const void *targinfo)
420  {
421         const struct xt_mark_target_info_v1 *markinfo = targinfo;
422 -       int mark = 0;
423 +       int mark = -1;
424  
425         switch (markinfo->mode) {
426         case XT_MARK_SET:
427 @@ -58,9 +105,52 @@ target_v1(struct sk_buff **pskb,
428         case XT_MARK_OR:
429                 mark = (*pskb)->mark | markinfo->mark;
430                 break;
431 +
432 +       case XT_MARK_COPYXID: {
433 +               enum ip_conntrack_info ctinfo;
434 +               struct sock *connection_sk;
435 +               int dif;
436 +
437 +               struct nf_conn *ct = nf_ct_get((*pskb), &ctinfo);
438 +               extern struct inet_hashinfo tcp_hashinfo;
439 +               enum ip_conntrack_dir dir;
440 +
441 +               if (!ct) 
442 +                       break;
443 +               dir = CTINFO2DIR(ctinfo);
444 +               u_int32_t src_ip = ct->tuplehash[dir].tuple.src.u3.ip;
445 +               u_int16_t src_port = get_src_port(&ct->tuplehash[dir].tuple);
446 +
447 +               u_int32_t ip;
448 +               u_int16_t port;
449 +
450 +               dif = ((struct rtable *)(*pskb)->dst)->rt_iif;
451 +               ip = ct->tuplehash[dir].tuple.dst.u3.ip;
452 +               port = get_dst_port(&ct->tuplehash[dir].tuple);
453 +
454 +               if ((*pskb)->sk) 
455 +                       connection_sk = (*pskb)->sk;
456 +               else {
457 +                       connection_sk = inet_lookup(&tcp_hashinfo, src_ip, src_port, ip, port, dif);
458 +               }
459 +
460 +               if (connection_sk) {
461 +#ifdef REQUIRESFIXFROMSAPAN
462 +                       connection_sk->sk_peercred.gid = connection_sk->sk_peercred.uid = ct->xid[dir];
463 +                       ct->xid[!dir]=connection_sk->sk_xid;
464 +                       /*connection_sk->sk_peercred.gid = connection_sk->sk_peercred.uid = connection_sk->sk_xid;*/
465 +                       if (connection_sk->sk_xid != 0) 
466 +                               mark = connection_sk->sk_xid;
467 +#endif
468 +                       if (connection_sk != (*pskb)->sk)
469 +                               sock_put(connection_sk);
470 +               }
471 +               break;
472 +               }
473         }
474  
475 -       (*pskb)->mark = mark;
476 +       if (mark != -1)
477 +               (*pskb)->mark = mark;
478         return XT_CONTINUE;
479  }
480  
481 @@ -92,7 +182,8 @@ checkentry_v1(const char *tablename,
482  
483         if (markinfo->mode != XT_MARK_SET
484             && markinfo->mode != XT_MARK_AND
485 -           && markinfo->mode != XT_MARK_OR) {
486 +           && markinfo->mode != XT_MARK_OR
487 +           && markinfo->mode != XT_MARK_COPYXID) {
488                 printk(KERN_WARNING "MARK: unknown mode %u\n",
489                        markinfo->mode);
490                 return 0;
491 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/xt_SETXID.c linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/xt_SETXID.c
492 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/netfilter/xt_SETXID.c   1969-12-31 19:00:00.000000000 -0500
493 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/netfilter/xt_SETXID.c   2007-11-14 16:20:02.000000000 -0500
494 @@ -0,0 +1,79 @@
495 +#include <linux/module.h>
496 +#include <linux/skbuff.h>
497 +#include <linux/ip.h>
498 +#include <net/checksum.h>
499 +#include <linux/vs_network.h>
500 +
501 +#include <linux/netfilter/x_tables.h>
502 +#include <linux/netfilter/xt_SETXID.h>
503 +
504 +MODULE_LICENSE("GPL");
505 +MODULE_AUTHOR("");
506 +MODULE_DESCRIPTION("");
507 +MODULE_ALIAS("ipt_SETXID");
508 +
509 +static unsigned int
510 +target_v1(struct sk_buff **pskb,
511 +         const struct net_device *in,
512 +         const struct net_device *out,
513 +         unsigned int hooknum,
514 +         const struct xt_target *target,
515 +         const void *targinfo)
516 +{
517 +       const struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
518 +
519 +       switch (setxidinfo->mode) {
520 +       case XT_SET_PACKET_XID:
521 +                (*pskb)->skb_tag = setxidinfo->mark;
522 +               break;
523 +       }
524 +       return XT_CONTINUE;
525 +}
526 +
527 +
528 +static int
529 +checkentry_v1(const char *tablename,
530 +             const void *entry,
531 +             const struct xt_target *target,
532 +             void *targinfo,
533 +             unsigned int hook_mask)
534 +{
535 +       struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
536 +
537 +       if (setxidinfo->mode != XT_SET_PACKET_XID) {
538 +               printk(KERN_WARNING "SETXID: unknown mode %u\n",
539 +                      setxidinfo->mode);
540 +               return 0;
541 +       }
542 +
543 +       return 1;
544 +}
545 +
546 +static struct xt_target xt_setxid_target[] = {
547 +       {
548 +               .name           = "SETXID",
549 +               .family         = AF_INET,
550 +               .revision       = 1,
551 +               .checkentry     = checkentry_v1,
552 +               .target         = target_v1,
553 +               .targetsize     = sizeof(struct xt_setxid_target_info_v1),
554 +               .table          = "mangle",
555 +               .me             = THIS_MODULE,
556 +       }
557 +};
558 +
559 +static int __init init(void)
560 +{
561 +       int err;
562 +
563 +       err = xt_register_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
564 +       return err;
565 +}
566 +
567 +static void __exit fini(void)
568 +{
569 +       xt_unregister_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
570 +}
571 +
572 +module_init(init);
573 +module_exit(fini);
574 diff -Nurp linux-2.6.22.10-vs2.3.0.29-pl03/net/packet/af_packet.c linux-2.6.22.10-vs2.3.0.29-pl04/net/packet/af_packet.c
575 --- linux-2.6.22.10-vs2.3.0.29-pl03/net/packet/af_packet.c      2007-07-21 18:00:27.000000000 -0400
576 +++ linux-2.6.22.10-vs2.3.0.29-pl04/net/packet/af_packet.c      2007-11-15 13:57:04.000000000 -0500
577 @@ -78,6 +78,7 @@
578  #include <linux/poll.h>
579  #include <linux/module.h>
580  #include <linux/init.h>
581 +#include <linux/vs_network.h>
582  
583  #ifdef CONFIG_INET
584  #include <net/inet_common.h>
585 @@ -420,6 +421,10 @@ static inline unsigned int run_filter(st
586                                       unsigned int res)
587  {
588         struct sk_filter *filter;
589 +       int tag = skb->skb_tag;
590 +
591 +       if (sk->sk_nx_info && !(tag == 1 || sk->sk_nid == tag))
592 +               return 0;
593  
594         rcu_read_lock_bh();
595         filter = rcu_dereference(sk->sk_filter);
596 @@ -984,7 +989,7 @@ static int packet_create(struct socket *
597         __be16 proto = (__force __be16)protocol; /* weird, but documented */
598         int err;
599  
600 -       if (!capable(CAP_NET_RAW))
601 +       if (!nx_capable(CAP_NET_RAW, NXC_RAW_SEND))
602                 return -EPERM;
603         if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW &&
604             sock->type != SOCK_PACKET)