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