1 diff -Nurp 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 2006-06-18 03:49:35.000000000 +0200
3 +++ linux-2.6.22-520/include/linux/netfilter/xt_MARK.h 2008-02-15 20:36:43.000000000 +0100
4 @@ -11,6 +11,7 @@ enum {
11 struct xt_mark_target_info_v1 {
12 diff -Nurp 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 1970-01-01 01:00:00.000000000 +0100
14 +++ linux-2.6.22-520/include/linux/netfilter/xt_SETXID.h 2008-02-15 20:36:43.000000000 +0100
16 +#ifndef _XT_SETXID_H_target
17 +#define _XT_SETXID_H_target
24 +struct xt_setxid_target_info_v1 {
29 +#endif /*_XT_SETXID_H_target*/
30 diff -Nurp 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 2006-06-18 03:49:35.000000000 +0200
32 +++ linux-2.6.22-520/include/linux/netfilter_ipv4/ipt_MARK.h 2008-02-15 20:36:43.000000000 +0100
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
39 #define ipt_mark_target_info_v1 xt_mark_target_info_v1
41 diff -Nurp 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 1970-01-01 01:00:00.000000000 +0100
43 +++ linux-2.6.22-520/include/linux/netfilter_ipv4/ipt_SETXID.h 2008-02-15 20:36:43.000000000 +0100
45 +#ifndef _IPT_SETXID_H_target
46 +#define _IPT_SETXID_H_target
48 +/* Backwards compatibility for old userspace */
50 +#include <linux/netfilter/xt_SETXID.h>
53 +#define IPT_SET_PACKET_XID XT_SET_PACKET_XID
55 +#define ipt_setxid_target_info_v1 xt_setxid_target_info_v1
57 +#endif /*_IPT_SETXID_H_target*/
58 diff -Nurp 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-22 00:00:24.000000000 +0200
60 +++ linux-2.6.22-520/include/linux/skbuff.h 2008-02-15 20:36:43.000000000 +0100
61 @@ -302,6 +302,7 @@ struct sk_buff {
67 sk_buff_data_t transport_header;
68 sk_buff_data_t network_header;
69 diff -Nurp 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-22 00:00:24.000000000 +0200
71 +++ linux-2.6.22-520/include/linux/socket.h 2008-02-15 20:36:43.000000000 +0100
72 @@ -288,6 +288,8 @@ struct ucred {
76 +#define SO_SETXID SO_PEERCRED
81 diff -Nurp 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-15 20:36:27.000000000 +0100
83 +++ linux-2.6.22-520/include/linux/vserver/network.h 2008-02-15 20:36:43.000000000 +0100
84 @@ -45,6 +45,8 @@ static inline uint64_t __nxf_init_set(vo
87 #define NXC_RAW_ICMP 0x00000100
88 +#define NXC_RAW_SOCKET 0x00000200
89 +#define NXC_RAW_SEND 0x00000400
93 diff -Nurp linux-2.6.22-510/include/linux/vserver/network.h.orig linux-2.6.22-520/include/linux/vserver/network.h.orig
94 --- linux-2.6.22-510/include/linux/vserver/network.h.orig 1970-01-01 01:00:00.000000000 +0100
95 +++ linux-2.6.22-520/include/linux/vserver/network.h.orig 2008-02-15 20:36:27.000000000 +0100
97 +#ifndef _VX_NETWORK_H
98 +#define _VX_NETWORK_H
100 +#include <linux/types.h>
103 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
108 +#define NXF_INFO_PRIVATE 0x00000008
110 +#define NXF_SINGLE_IP 0x00000100
111 +#define NXF_LBACK_REMAP 0x00000200
112 +#define NXF_LBACK_ALLOW 0x00000400
114 +#define NXF_HIDE_NETIF 0x02000000
115 +#define NXF_HIDE_LBACK 0x04000000
117 +#define NXF_STATE_SETUP (1ULL << 32)
118 +#define NXF_STATE_ADMIN (1ULL << 34)
120 +#define NXF_SC_HELPER (1ULL << 36)
121 +#define NXF_PERSISTENT (1ULL << 38)
123 +#define NXF_ONE_TIME (0x0005ULL << 32)
126 +#define NXF_INIT_SET (__nxf_init_set())
128 +static inline uint64_t __nxf_init_set(void) {
129 + return NXF_STATE_ADMIN
130 +#ifdef CONFIG_VSERVER_AUTO_LBACK
134 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
143 +#define NXC_RAW_ICMP 0x00000100
148 +#define NXA_TYPE_IPV4 0x0001
149 +#define NXA_TYPE_IPV6 0x0002
151 +#define NXA_TYPE_NONE 0x0000
152 +#define NXA_TYPE_ANY 0x00FF
154 +#define NXA_TYPE_ADDR 0x0010
155 +#define NXA_TYPE_MASK 0x0020
156 +#define NXA_TYPE_RANGE 0x0040
158 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
160 +#define NXA_MOD_BCAST 0x0100
161 +#define NXA_MOD_LBACK 0x0200
163 +#define NXA_LOOPBACK 0x1000
165 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
166 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
170 +#include <linux/list.h>
171 +#include <linux/spinlock.h>
172 +#include <linux/rcupdate.h>
173 +#include <linux/in.h>
174 +#include <linux/in6.h>
175 +#include <asm/atomic.h>
178 + struct nx_addr_v4 *next;
179 + struct in_addr ip[2];
180 + struct in_addr mask;
186 + struct nx_addr_v6 *next;
187 + struct in6_addr ip;
188 + struct in6_addr mask;
195 + struct hlist_node nx_hlist; /* linked list of nxinfos */
196 + nid_t nx_id; /* vnet id */
197 + atomic_t nx_usecnt; /* usage count */
198 + atomic_t nx_tasks; /* tasks count */
199 + int nx_state; /* context state */
201 + uint64_t nx_flags; /* network flag word */
202 + uint64_t nx_ncaps; /* network capabilities */
204 + struct in_addr v4_lback; /* Loopback address */
205 + struct in_addr v4_bcast; /* Broadcast address */
206 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
208 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
210 + char nx_name[65]; /* network context name */
216 +#define NXS_HASHED 0x0001
217 +#define NXS_SHUTDOWN 0x0100
218 +#define NXS_RELEASED 0x8000
220 +extern struct nx_info *lookup_nx_info(int);
222 +extern int get_nid_list(int, unsigned int *, int);
223 +extern int nid_is_hashed(nid_t);
225 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
227 +extern long vs_net_change(struct nx_info *, unsigned int);
232 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
234 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
236 +#define NX_IPV6(n) (0)
239 +#endif /* __KERNEL__ */
240 +#endif /* _VX_NETWORK_H */
241 diff -Nurp linux-2.6.22-510/include/net/netfilter/nf_conntrack.h linux-2.6.22-520/include/net/netfilter/nf_conntrack.h
242 --- linux-2.6.22-510/include/net/netfilter/nf_conntrack.h 2007-07-22 00:00:24.000000000 +0200
243 +++ linux-2.6.22-520/include/net/netfilter/nf_conntrack.h 2008-02-15 20:36:43.000000000 +0100
244 @@ -131,6 +131,9 @@ struct nf_conn
245 /* Storage reserved for other modules: */
246 union nf_conntrack_proto proto;
248 + /* PLANETLAB. VNET-specific */
249 + xid_t xid[IP_CT_DIR_MAX];
251 /* features dynamically at the end: helper, nat (both optional) */
254 diff -Nurp linux-2.6.22-510/include/net/raw.h linux-2.6.22-520/include/net/raw.h
255 --- linux-2.6.22-510/include/net/raw.h 2007-05-04 15:55:46.000000000 +0200
256 +++ linux-2.6.22-520/include/net/raw.h 2008-02-15 20:36:43.000000000 +0100
257 @@ -36,7 +36,7 @@ extern rwlock_t raw_v4_lock;
259 extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
260 __be32 raddr, __be32 laddr,
264 extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash);
266 diff -Nurp linux-2.6.22-510/net/core/skbuff.c linux-2.6.22-520/net/core/skbuff.c
267 --- linux-2.6.22-510/net/core/skbuff.c 2007-07-22 00:00:25.000000000 +0200
268 +++ linux-2.6.22-520/net/core/skbuff.c 2008-02-15 20:36:44.000000000 +0100
270 #include <linux/rtnetlink.h>
271 #include <linux/init.h>
272 #include <linux/scatterlist.h>
273 +#include <linux/vs_network.h>
275 #include <net/protocol.h>
277 @@ -174,6 +175,7 @@ struct sk_buff *__alloc_skb(unsigned int
279 skb_reset_tail_pointer(skb);
280 skb->end = skb->tail + size;
281 + skb->skb_tag = nx_current_nid();
282 /* make sure we initialize shinfo sequentially */
283 shinfo = skb_shinfo(skb);
284 atomic_set(&shinfo->dataref, 1);
285 @@ -443,6 +445,8 @@ struct sk_buff *skb_clone(struct sk_buff
289 + /* Sapan: Cloned skbs aren't owned by anyone. Let the cloner decide who it belongs to. */
291 atomic_inc(&(skb_shinfo(skb)->dataref));
294 @@ -492,6 +496,7 @@ static void copy_skb_header(struct sk_bu
295 new->tc_index = old->tc_index;
297 skb_copy_secmark(new, old);
298 + new->skb_tag = old->skb_tag;
299 atomic_set(&new->users, 1);
300 skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
301 skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
302 diff -Nurp linux-2.6.22-510/net/core/sock.c linux-2.6.22-520/net/core/sock.c
303 --- linux-2.6.22-510/net/core/sock.c 2008-02-15 20:36:20.000000000 +0100
304 +++ linux-2.6.22-520/net/core/sock.c 2008-02-15 20:36:44.000000000 +0100
305 @@ -444,6 +444,19 @@ set_sndbuf:
310 + if (current_vx_info()) {
314 + if (val < 0 || val > MAX_S_CONTEXT) {
323 /* Don't error on this BSD doesn't and if you think
324 about it this is right. Otherwise apps have to
325 @@ -573,7 +586,7 @@ set_rcvbuf:
326 char devname[IFNAMSIZ];
329 - if (!capable(CAP_NET_RAW)) {
330 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
334 diff -Nurp linux-2.6.22-510/net/ipv4/af_inet.c linux-2.6.22-520/net/ipv4/af_inet.c
335 --- linux-2.6.22-510/net/ipv4/af_inet.c 2008-02-15 20:36:20.000000000 +0100
336 +++ linux-2.6.22-520/net/ipv4/af_inet.c 2008-02-15 21:33:42.000000000 +0100
337 @@ -178,6 +178,8 @@ static int inet_autobind(struct sock *sk
340 inet->sport = htons(inet->num);
341 + sk->sk_xid = vx_current_xid();
342 + sk->sk_nid = nx_current_nid();
346 @@ -312,6 +314,9 @@ lookup_protocol:
347 if ((protocol == IPPROTO_ICMP) &&
348 nx_capable(answer->capability, NXC_RAW_ICMP))
350 + if (sock->type == SOCK_RAW &&
351 + nx_capable(answer->capability, NXC_RAW_SOCKET))
353 if (answer->capability > 0 && !capable(answer->capability))
356 diff -Nurp linux-2.6.22-510/net/ipv4/icmp.c linux-2.6.22-520/net/ipv4/icmp.c
357 --- linux-2.6.22-510/net/ipv4/icmp.c 2008-02-15 20:36:42.000000000 +0100
358 +++ linux-2.6.22-520/net/ipv4/icmp.c 2008-02-15 20:36:44.000000000 +0100
359 @@ -709,7 +709,7 @@ static void icmp_unreach(struct sk_buff
360 if ((raw_sk = sk_head(&raw_v4_htable[hash])) != NULL) {
361 while ((raw_sk = __raw_v4_lookup(raw_sk, protocol, iph->daddr,
363 - skb->dev->ifindex)) != NULL) {
364 + skb->dev->ifindex, skb->skb_tag)) != NULL) {
365 raw_err(raw_sk, skb, info);
366 raw_sk = sk_next(raw_sk);
367 iph = (struct iphdr *)skb->data;
368 diff -Nurp linux-2.6.22-510/net/ipv4/ip_options.c linux-2.6.22-520/net/ipv4/ip_options.c
369 --- linux-2.6.22-510/net/ipv4/ip_options.c 2007-07-22 00:00:25.000000000 +0200
370 +++ linux-2.6.22-520/net/ipv4/ip_options.c 2008-02-15 20:36:44.000000000 +0100
371 @@ -409,7 +409,7 @@ int ip_options_compile(struct ip_options
375 - if (!skb && !capable(CAP_NET_RAW)) {
376 + if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
380 @@ -445,7 +445,7 @@ int ip_options_compile(struct ip_options
381 opt->router_alert = optptr - iph;
384 - if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
385 + if ((!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) || opt->cipso) {
389 @@ -458,7 +458,7 @@ int ip_options_compile(struct ip_options
393 - if (!skb && !capable(CAP_NET_RAW)) {
394 + if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
398 diff -Nurp linux-2.6.22-510/net/ipv4/netfilter/ipt_LOG.c linux-2.6.22-520/net/ipv4/netfilter/ipt_LOG.c
399 --- linux-2.6.22-510/net/ipv4/netfilter/ipt_LOG.c 2008-02-15 20:35:53.000000000 +0100
400 +++ linux-2.6.22-520/net/ipv4/netfilter/ipt_LOG.c 2008-02-15 20:36:44.000000000 +0100
401 @@ -49,6 +49,8 @@ static void dump_packet(const struct nf_
403 logflags = NF_LOG_MASK;
405 + printk("TAG=%d ", skb->skb_tag);
407 ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);
410 diff -Nurp linux-2.6.22-510/net/ipv4/raw.c linux-2.6.22-520/net/ipv4/raw.c
411 --- linux-2.6.22-510/net/ipv4/raw.c 2008-02-15 20:36:20.000000000 +0100
412 +++ linux-2.6.22-520/net/ipv4/raw.c 2008-02-15 20:36:44.000000000 +0100
413 @@ -103,7 +103,7 @@ static void raw_v4_unhash(struct sock *s
415 struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
416 __be32 raddr, __be32 laddr,
420 struct hlist_node *node;
422 @@ -112,6 +112,7 @@ struct sock *__raw_v4_lookup(struct sock
424 if (inet->num == num &&
425 !(inet->daddr && inet->daddr != raddr) &&
426 + (!sk->sk_nx_info || tag == 1 || sk->sk_nid == tag) &&
427 v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
428 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
429 goto found; /* gotcha */
430 @@ -161,7 +162,7 @@ int raw_v4_input(struct sk_buff *skb, st
432 sk = __raw_v4_lookup(__sk_head(head), iph->protocol,
433 iph->saddr, iph->daddr,
434 - skb->dev->ifindex);
435 + skb->dev->ifindex, skb->skb_tag);
439 @@ -174,7 +175,7 @@ int raw_v4_input(struct sk_buff *skb, st
441 sk = __raw_v4_lookup(sk_next(sk), iph->protocol,
442 iph->saddr, iph->daddr,
443 - skb->dev->ifindex);
444 + skb->dev->ifindex, skb->skb_tag);
447 read_unlock(&raw_v4_lock);
448 @@ -315,7 +316,7 @@ static int raw_send_hdrinc(struct sock *
452 - if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
453 + if (!nx_check(0, VS_ADMIN) && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET) &&
455 !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
457 diff -Nurp linux-2.6.22-510/net/netfilter/Kconfig linux-2.6.22-520/net/netfilter/Kconfig
458 --- linux-2.6.22-510/net/netfilter/Kconfig 2007-07-22 00:00:27.000000000 +0200
459 +++ linux-2.6.22-520/net/netfilter/Kconfig 2008-02-15 20:36:44.000000000 +0100
460 @@ -389,6 +389,13 @@ config NETFILTER_XT_TARGET_TCPMSS
462 To compile it as a module, choose M here. If unsure, say N.
464 +config NETFILTER_XT_TARGET_SETXID
465 + tristate '"SETXID" target support'
466 + depends on NETFILTER_XTABLES
468 + This option adds a `SETXID' target, which allows you to alter the
471 config NETFILTER_XT_MATCH_COMMENT
472 tristate '"comment" match support'
473 depends on NETFILTER_XTABLES
474 diff -Nurp linux-2.6.22-510/net/netfilter/Makefile linux-2.6.22-520/net/netfilter/Makefile
475 --- linux-2.6.22-510/net/netfilter/Makefile 2007-07-21 23:58:59.000000000 +0200
476 +++ linux-2.6.22-520/net/netfilter/Makefile 2008-02-15 20:36:44.000000000 +0100
477 @@ -37,6 +37,7 @@ obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_co
478 obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
481 +obj-$(CONFIG_NETFILTER_XT_TARGET_SETXID) += xt_SETXID.o
482 obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
483 obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
484 obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
485 diff -Nurp linux-2.6.22-510/net/netfilter/nf_conntrack_core.c linux-2.6.22-520/net/netfilter/nf_conntrack_core.c
486 --- linux-2.6.22-510/net/netfilter/nf_conntrack_core.c 2007-07-22 00:00:27.000000000 +0200
487 +++ linux-2.6.22-520/net/netfilter/nf_conntrack_core.c 2008-02-15 20:36:44.000000000 +0100
488 @@ -726,6 +726,8 @@ init_conntrack(const struct nf_conntrack
490 /* Overload tuple linked list to put us in unconfirmed list. */
491 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
492 + conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
493 + conntrack->xid[IP_CT_DIR_REPLY] = -1;
495 write_unlock_bh(&nf_conntrack_lock);
497 diff -Nurp linux-2.6.22-510/net/netfilter/xt_MARK.c linux-2.6.22-520/net/netfilter/xt_MARK.c
498 --- linux-2.6.22-510/net/netfilter/xt_MARK.c 2007-07-21 23:59:00.000000000 +0200
499 +++ linux-2.6.22-520/net/netfilter/xt_MARK.c 2008-02-15 20:36:44.000000000 +0100
501 * This program is free software; you can redistribute it and/or modify
502 * it under the terms of the GNU General Public License version 2 as
503 * published by the Free Software Foundation.
507 #include <linux/module.h>
508 +#include <linux/version.h>
509 #include <linux/skbuff.h>
510 #include <linux/ip.h>
511 #include <net/checksum.h>
512 +#include <net/route.h>
513 +#include <net/inet_hashtables.h>
515 +#include <net/netfilter/nf_conntrack.h>
516 #include <linux/netfilter/x_tables.h>
517 #include <linux/netfilter/xt_MARK.h>
519 @@ -21,6 +26,48 @@ MODULE_DESCRIPTION("ip[6]tables MARK mod
520 MODULE_ALIAS("ipt_MARK");
521 MODULE_ALIAS("ip6t_MARK");
523 +static inline u_int16_t
524 +get_dst_port(struct nf_conntrack_tuple *tuple)
526 + switch (tuple->dst.protonum) {
528 + /* XXX Truncate 32-bit GRE key to 16 bits */
529 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
530 + return tuple->dst.u.gre.key;
532 + return htons(ntohl(tuple->dst.u.gre.key));
535 + /* Bind on ICMP echo ID */
536 + return tuple->src.u.icmp.id;
538 + return tuple->dst.u.tcp.port;
540 + return tuple->dst.u.udp.port;
542 + return tuple->dst.u.all;
546 +static inline u_int16_t
547 +get_src_port(struct nf_conntrack_tuple *tuple)
549 + switch (tuple->dst.protonum) {
551 + /* XXX Truncate 32-bit GRE key to 16 bits */
552 + return htons(ntohl(tuple->src.u.gre.key));
554 + /* Bind on ICMP echo ID */
555 + return tuple->src.u.icmp.id;
557 + return tuple->src.u.tcp.port;
559 + return tuple->src.u.udp.port;
561 + return tuple->src.u.all;
566 target_v0(struct sk_buff **pskb,
567 const struct net_device *in,
568 @@ -44,7 +91,7 @@ target_v1(struct sk_buff **pskb,
569 const void *targinfo)
571 const struct xt_mark_target_info_v1 *markinfo = targinfo;
575 switch (markinfo->mode) {
577 @@ -58,8 +105,49 @@ target_v1(struct sk_buff **pskb,
579 mark = (*pskb)->mark | markinfo->mark;
582 + case XT_MARK_COPYXID: {
583 + enum ip_conntrack_info ctinfo;
584 + struct sock *connection_sk;
587 + struct nf_conn *ct = nf_ct_get((*pskb), &ctinfo);
588 + extern struct inet_hashinfo tcp_hashinfo;
589 + enum ip_conntrack_dir dir;
593 + dir = CTINFO2DIR(ctinfo);
594 + u_int32_t src_ip = ct->tuplehash[dir].tuple.src.u3.ip;
595 + u_int16_t src_port = get_src_port(&ct->tuplehash[dir].tuple);
600 + dif = ((struct rtable *)(*pskb)->dst)->rt_iif;
601 + ip = ct->tuplehash[dir].tuple.dst.u3.ip;
602 + port = get_dst_port(&ct->tuplehash[dir].tuple);
605 + connection_sk = (*pskb)->sk;
607 + connection_sk = inet_lookup(&tcp_hashinfo, src_ip, src_port, ip, port, dif);
610 + if (connection_sk) {
611 + connection_sk->sk_peercred.gid = connection_sk->sk_peercred.uid = ct->xid[dir];
612 + ct->xid[!dir]=connection_sk->sk_xid;
613 + connection_sk->sk_peercred.gid = connection_sk->sk_peercred.uid = connection_sk->sk_xid;
614 + if (connection_sk->sk_xid != 0)
615 + mark = connection_sk->sk_xid;
616 + if (connection_sk != (*pskb)->sk)
617 + sock_put(connection_sk);
624 (*pskb)->mark = mark;
627 @@ -92,7 +180,8 @@ checkentry_v1(const char *tablename,
629 if (markinfo->mode != XT_MARK_SET
630 && markinfo->mode != XT_MARK_AND
631 - && markinfo->mode != XT_MARK_OR) {
632 + && markinfo->mode != XT_MARK_OR
633 + && markinfo->mode != XT_MARK_COPYXID) {
634 printk(KERN_WARNING "MARK: unknown mode %u\n",
637 diff -Nurp linux-2.6.22-510/net/netfilter/xt_SETXID.c linux-2.6.22-520/net/netfilter/xt_SETXID.c
638 --- linux-2.6.22-510/net/netfilter/xt_SETXID.c 1970-01-01 01:00:00.000000000 +0100
639 +++ linux-2.6.22-520/net/netfilter/xt_SETXID.c 2008-02-15 20:36:44.000000000 +0100
641 +#include <linux/module.h>
642 +#include <linux/skbuff.h>
643 +#include <linux/ip.h>
644 +#include <net/checksum.h>
645 +#include <linux/vs_network.h>
647 +#include <linux/netfilter/x_tables.h>
648 +#include <linux/netfilter/xt_SETXID.h>
650 +MODULE_LICENSE("GPL");
652 +MODULE_DESCRIPTION("");
653 +MODULE_ALIAS("ipt_SETXID");
656 +target_v1(struct sk_buff **pskb,
657 + const struct net_device *in,
658 + const struct net_device *out,
659 + unsigned int hooknum,
660 + const struct xt_target *target,
661 + const void *targinfo)
663 + const struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
665 + switch (setxidinfo->mode) {
666 + case XT_SET_PACKET_XID:
667 + (*pskb)->skb_tag = setxidinfo->mark;
670 + return XT_CONTINUE;
675 +checkentry_v1(const char *tablename,
677 + const struct xt_target *target,
679 + unsigned int hook_mask)
681 + struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
683 + if (setxidinfo->mode != XT_SET_PACKET_XID) {
684 + printk(KERN_WARNING "SETXID: unknown mode %u\n",
692 +static struct xt_target xt_setxid_target[] = {
697 + .checkentry = checkentry_v1,
698 + .target = target_v1,
699 + .targetsize = sizeof(struct xt_setxid_target_info_v1),
705 +static int __init init(void)
709 + err = xt_register_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
713 +static void __exit fini(void)
715 + xt_unregister_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
720 diff -Nurp linux-2.6.22-510/net/packet/af_packet.c linux-2.6.22-520/net/packet/af_packet.c
721 --- linux-2.6.22-510/net/packet/af_packet.c 2007-07-22 00:00:27.000000000 +0200
722 +++ linux-2.6.22-520/net/packet/af_packet.c 2008-02-15 22:28:15.000000000 +0100
724 #include <linux/poll.h>
725 #include <linux/module.h>
726 #include <linux/init.h>
727 +#include <linux/vs_network.h>
730 #include <net/inet_common.h>
731 @@ -324,6 +325,9 @@ static int packet_sendmsg_spkt(struct ki
735 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SEND))
739 * Get and verify the address.
741 @@ -420,6 +424,10 @@ static inline unsigned int run_filter(st
744 struct sk_filter *filter;
745 + int tag = skb->skb_tag;
747 + if (sk->sk_nx_info && !(tag == 1 || sk->sk_nid == tag))
751 filter = rcu_dereference(sk->sk_filter);
752 @@ -711,6 +719,9 @@ static int packet_sendmsg(struct kiocb *
754 int ifindex, err, reserve = 0;
756 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SEND))
760 * Get and verify the address.
762 @@ -984,7 +995,7 @@ static int packet_create(struct socket *
763 __be16 proto = (__force __be16)protocol; /* weird, but documented */
766 - if (!capable(CAP_NET_RAW))
767 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET))
769 if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW &&
770 sock->type != SOCK_PACKET)