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-06-06 17:07:56.000000000 -0400
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-06-06 17:07:56.000000000 -0400
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 -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-06-06 17:07:56.000000000 -0400
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 -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-06-06 17:07:56.000000000 -0400
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 -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-06-06 17:07:56.000000000 -0400
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-06-06 17:07:56.000000000 -0400
76 +#define SO_SETXID SO_PEERCRED
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-06-06 17:07:48.000000000 -0400
83 +++ linux-2.6.22-520/include/linux/vserver/network.h 2008-06-06 17:07:56.000000000 -0400
85 #define NXC_TUN_CREATE 0x00000001
87 #define NXC_RAW_ICMP 0x00000100
88 +#define NXC_RAW_SOCKET 0x00000200
89 +#define NXC_RAW_SEND 0x00000400
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-06-06 17:07:56.000000000 -0400
97 /* Storage reserved for other modules: */
98 union nf_conntrack_proto proto;
100 + /* PLANETLAB. VNET-specific */
101 + int xid[IP_CT_DIR_MAX];
103 /* features dynamically at the end: helper, nat (both optional) */
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-06-06 17:07:56.000000000 -0400
111 extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
112 __be32 raddr, __be32 laddr,
116 extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash);
118 diff -Nurb linux-2.6.22-510/net/core/dev.c linux-2.6.22-520/net/core/dev.c
119 --- linux-2.6.22-510/net/core/dev.c 2008-06-06 17:07:48.000000000 -0400
120 +++ linux-2.6.22-520/net/core/dev.c 2008-06-06 17:07:56.000000000 -0400
121 @@ -1803,6 +1803,7 @@
122 * the ingress scheduler, you just cant add policies on ingress.
126 static int ing_filter(struct sk_buff *skb)
129 @@ -1832,13 +1833,20 @@
133 +/* The code already makes the assumption that packet handlers run
134 + * sequentially on the same CPU. -Sapan */
135 +DEFINE_PER_CPU(int, sknid_elevator);
137 int netif_receive_skb(struct sk_buff *skb)
139 struct packet_type *ptype, *pt_prev;
140 struct net_device *orig_dev;
141 int ret = NET_RX_DROP;
142 + int *cur_elevator=&__get_cpu_var(sknid_elevator);
147 /* if we've gotten here through NAPI, check netpoll */
148 if (skb->dev->poll && netpoll_rx(skb))
150 @@ -1873,8 +1881,9 @@
152 list_for_each_entry_rcu(ptype, &ptype_all, list) {
153 if (!ptype->dev || ptype->dev == skb->dev) {
156 ret = deliver_skb(skb, pt_prev, orig_dev);
161 @@ -1912,8 +1921,22 @@
165 + /* We don't want the packet handlers to throw the packet away
166 + * if we want the taps to treat it again - Sapan */
167 + if (*cur_elevator) {
168 + atomic_inc(&skb->users);
172 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
173 + if (*cur_elevator > 0) {
174 + skb->skb_tag = *cur_elevator;
175 + list_for_each_entry_rcu(ptype, &ptype_all, list) {
176 + if (!ptype->dev || ptype->dev == skb->dev) {
177 + ret = deliver_skb(skb, ptype, orig_dev);
183 /* Jamal, now you will not able to escape explaining
184 @@ -1922,6 +1945,13 @@
188 + if (*cur_elevator) {
189 + /* We have a packet */
198 @@ -3780,6 +3810,7 @@
199 EXPORT_SYMBOL(net_enable_timestamp);
200 EXPORT_SYMBOL(net_disable_timestamp);
201 EXPORT_SYMBOL(dev_get_flags);
202 +EXPORT_PER_CPU_SYMBOL(sknid_elevator);
204 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
205 EXPORT_SYMBOL(br_handle_frame_hook);
206 diff -Nurb linux-2.6.22-510/net/core/skbuff.c linux-2.6.22-520/net/core/skbuff.c
207 --- linux-2.6.22-510/net/core/skbuff.c 2007-07-08 19:32:17.000000000 -0400
208 +++ linux-2.6.22-520/net/core/skbuff.c 2008-06-06 17:07:56.000000000 -0400
210 #include <linux/rtnetlink.h>
211 #include <linux/init.h>
212 #include <linux/scatterlist.h>
213 +#include <linux/vs_network.h>
215 #include <net/protocol.h>
219 skb_reset_tail_pointer(skb);
220 skb->end = skb->tail + size;
221 + if (!in_interrupt()) skb->skb_tag = nx_current_nid(); else skb->skb_tag = 0;
222 /* make sure we initialize shinfo sequentially */
223 shinfo = skb_shinfo(skb);
224 atomic_set(&shinfo->dataref, 1);
229 + /* Sapan: Cloned skbs aren't owned by anyone. Let the cloner decide who it belongs to. */
231 atomic_inc(&(skb_shinfo(skb)->dataref));
235 new->tc_index = old->tc_index;
237 skb_copy_secmark(new, old);
238 + new->skb_tag = old->skb_tag;
239 atomic_set(&new->users, 1);
240 skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
241 skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
242 diff -Nurb linux-2.6.22-510/net/core/sock.c linux-2.6.22-520/net/core/sock.c
243 --- linux-2.6.22-510/net/core/sock.c 2008-06-06 17:07:48.000000000 -0400
244 +++ linux-2.6.22-520/net/core/sock.c 2008-06-06 17:07:56.000000000 -0400
250 + if (current_vx_info()) {
254 + if (val < 0 || val > MAX_S_CONTEXT) {
263 /* Don't error on this BSD doesn't and if you think
264 about it this is right. Otherwise apps have to
266 char devname[IFNAMSIZ];
269 - if (!capable(CAP_NET_RAW)) {
270 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
274 diff -Nurb linux-2.6.22-510/net/ipv4/af_inet.c linux-2.6.22-520/net/ipv4/af_inet.c
275 --- linux-2.6.22-510/net/ipv4/af_inet.c 2008-06-06 17:07:48.000000000 -0400
276 +++ linux-2.6.22-520/net/ipv4/af_inet.c 2008-06-06 17:07:56.000000000 -0400
280 inet->sport = htons(inet->num);
281 + sk->sk_xid = vx_current_xid();
282 + if (!in_interrupt()) sk->sk_nid = nx_current_nid(); else sk->sk_nid=0;
287 if ((protocol == IPPROTO_ICMP) &&
288 nx_capable(answer->capability, NXC_RAW_ICMP))
290 + if (sock->type == SOCK_RAW &&
291 + nx_capable(answer->capability, NXC_RAW_SOCKET))
293 if (answer->capability > 0 && !capable(answer->capability))
296 diff -Nurb linux-2.6.22-510/net/ipv4/icmp.c linux-2.6.22-520/net/ipv4/icmp.c
297 --- linux-2.6.22-510/net/ipv4/icmp.c 2008-06-06 17:07:55.000000000 -0400
298 +++ linux-2.6.22-520/net/ipv4/icmp.c 2008-06-06 17:07:56.000000000 -0400
300 if ((raw_sk = sk_head(&raw_v4_htable[hash])) != NULL) {
301 while ((raw_sk = __raw_v4_lookup(raw_sk, protocol, iph->daddr,
303 - skb->dev->ifindex)) != NULL) {
304 + skb->dev->ifindex, skb->skb_tag)) != NULL) {
305 raw_err(raw_sk, skb, info);
306 raw_sk = sk_next(raw_sk);
307 iph = (struct iphdr *)skb->data;
308 diff -Nurb linux-2.6.22-510/net/ipv4/ip_options.c linux-2.6.22-520/net/ipv4/ip_options.c
309 --- linux-2.6.22-510/net/ipv4/ip_options.c 2007-07-08 19:32:17.000000000 -0400
310 +++ linux-2.6.22-520/net/ipv4/ip_options.c 2008-06-06 17:07:56.000000000 -0400
315 - if (!skb && !capable(CAP_NET_RAW)) {
316 + if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
321 opt->router_alert = optptr - iph;
324 - if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
325 + if ((!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) || opt->cipso) {
333 - if (!skb && !capable(CAP_NET_RAW)) {
334 + if (!skb && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET)) {
338 diff -Nurb linux-2.6.22-510/net/ipv4/netfilter/ipt_LOG.c linux-2.6.22-520/net/ipv4/netfilter/ipt_LOG.c
339 --- linux-2.6.22-510/net/ipv4/netfilter/ipt_LOG.c 2008-06-06 17:07:43.000000000 -0400
340 +++ linux-2.6.22-520/net/ipv4/netfilter/ipt_LOG.c 2008-06-06 17:07:56.000000000 -0400
343 logflags = NF_LOG_MASK;
345 + printk("TAG=%d ", skb->skb_tag);
347 ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);
350 diff -Nurb linux-2.6.22-510/net/ipv4/raw.c linux-2.6.22-520/net/ipv4/raw.c
351 --- linux-2.6.22-510/net/ipv4/raw.c 2008-06-06 17:07:48.000000000 -0400
352 +++ linux-2.6.22-520/net/ipv4/raw.c 2008-06-06 17:07:56.000000000 -0400
355 struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
356 __be32 raddr, __be32 laddr,
360 struct hlist_node *node;
364 if (inet->num == num &&
365 !(inet->daddr && inet->daddr != raddr) &&
366 + (!sk->sk_nx_info || tag == 1 || sk->sk_nid == tag) &&
367 v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
368 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
369 goto found; /* gotcha */
372 sk = __raw_v4_lookup(__sk_head(head), iph->protocol,
373 iph->saddr, iph->daddr,
374 - skb->dev->ifindex);
375 + skb->dev->ifindex, skb->skb_tag);
381 sk = __raw_v4_lookup(sk_next(sk), iph->protocol,
382 iph->saddr, iph->daddr,
383 - skb->dev->ifindex);
384 + skb->dev->ifindex, skb->skb_tag);
387 read_unlock(&raw_v4_lock);
392 - if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
393 + if (!nx_check(0, VS_ADMIN) && !nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET) &&
395 !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
397 diff -Nurb linux-2.6.22-510/net/netfilter/Kconfig linux-2.6.22-520/net/netfilter/Kconfig
398 --- linux-2.6.22-510/net/netfilter/Kconfig 2007-07-08 19:32:17.000000000 -0400
399 +++ linux-2.6.22-520/net/netfilter/Kconfig 2008-06-06 17:07:56.000000000 -0400
402 To compile it as a module, choose M here. If unsure, say N.
404 +config NETFILTER_XT_TARGET_SETXID
405 + tristate '"SETXID" target support'
406 + depends on NETFILTER_XTABLES
408 + This option adds a `SETXID' target, which allows you to alter the
411 config NETFILTER_XT_MATCH_COMMENT
412 tristate '"comment" match support'
413 depends on NETFILTER_XTABLES
414 diff -Nurb linux-2.6.22-510/net/netfilter/Makefile linux-2.6.22-520/net/netfilter/Makefile
415 --- linux-2.6.22-510/net/netfilter/Makefile 2007-07-08 19:32:17.000000000 -0400
416 +++ linux-2.6.22-520/net/netfilter/Makefile 2008-06-06 17:07:56.000000000 -0400
418 obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
421 +obj-$(CONFIG_NETFILTER_XT_TARGET_SETXID) += xt_SETXID.o
422 obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o
423 obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
424 obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
425 diff -Nurb linux-2.6.22-510/net/netfilter/nf_conntrack_core.c linux-2.6.22-520/net/netfilter/nf_conntrack_core.c
426 --- linux-2.6.22-510/net/netfilter/nf_conntrack_core.c 2007-07-08 19:32:17.000000000 -0400
427 +++ linux-2.6.22-520/net/netfilter/nf_conntrack_core.c 2008-06-06 17:07:56.000000000 -0400
430 /* Overload tuple linked list to put us in unconfirmed list. */
431 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
432 + conntrack->xid[IP_CT_DIR_ORIGINAL] = -1;
433 + conntrack->xid[IP_CT_DIR_REPLY] = -1;
435 write_unlock_bh(&nf_conntrack_lock);
437 diff -Nurb linux-2.6.22-510/net/netfilter/xt_MARK.c linux-2.6.22-520/net/netfilter/xt_MARK.c
438 --- linux-2.6.22-510/net/netfilter/xt_MARK.c 2007-07-08 19:32:17.000000000 -0400
439 +++ linux-2.6.22-520/net/netfilter/xt_MARK.c 2008-06-07 17:55:26.000000000 -0400
441 * This program is free software; you can redistribute it and/or modify
442 * it under the terms of the GNU General Public License version 2 as
443 * published by the Free Software Foundation.
447 #include <linux/module.h>
448 +#include <linux/version.h>
449 #include <linux/skbuff.h>
450 #include <linux/ip.h>
451 #include <net/checksum.h>
452 +#include <net/route.h>
453 +#include <net/inet_hashtables.h>
455 +#include <net/netfilter/nf_conntrack.h>
456 #include <linux/netfilter/x_tables.h>
457 #include <linux/netfilter/xt_MARK.h>
460 MODULE_ALIAS("ipt_MARK");
461 MODULE_ALIAS("ip6t_MARK");
463 +static inline u_int16_t
464 +get_dst_port(struct nf_conntrack_tuple *tuple)
466 + switch (tuple->dst.protonum) {
468 + /* XXX Truncate 32-bit GRE key to 16 bits */
469 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
470 + return tuple->dst.u.gre.key;
472 + return htons(ntohl(tuple->dst.u.gre.key));
475 + /* Bind on ICMP echo ID */
476 + return tuple->src.u.icmp.id;
478 + return tuple->dst.u.tcp.port;
480 + return tuple->dst.u.udp.port;
482 + return tuple->dst.u.all;
486 +static inline u_int16_t
487 +get_src_port(struct nf_conntrack_tuple *tuple)
489 + switch (tuple->dst.protonum) {
491 + /* XXX Truncate 32-bit GRE key to 16 bits */
492 + return htons(ntohl(tuple->src.u.gre.key));
494 + /* Bind on ICMP echo ID */
495 + return tuple->src.u.icmp.id;
497 + return tuple->src.u.tcp.port;
499 + return tuple->src.u.udp.port;
501 + return tuple->src.u.all;
506 target_v0(struct sk_buff **pskb,
507 const struct net_device *in,
512 +extern DEFINE_PER_CPU(int, sknid_elevator);
515 target_v1(struct sk_buff **pskb,
516 const struct net_device *in,
518 const void *targinfo)
520 const struct xt_mark_target_info_v1 *markinfo = targinfo;
522 + enum ip_conntrack_info ctinfo;
523 + struct sock *connection_sk;
525 + struct nf_conn *ct;
526 + extern struct inet_hashinfo tcp_hashinfo;
527 + enum ip_conntrack_dir dir;
531 + u_int16_t proto, src_port;
537 switch (markinfo->mode) {
541 mark = (*pskb)->mark | markinfo->mark;
544 + case XT_MARK_COPYXID:
546 + ct = nf_ct_get((*pskb), &ctinfo);
550 + dir = CTINFO2DIR(ctinfo);
551 + src_ip = ct->tuplehash[dir].tuple.src.u3.ip;
552 + dst_ip = ct->tuplehash[dir].tuple.dst.u3.ip;
553 + src_port = get_src_port(&ct->tuplehash[dir].tuple);
554 + proto = ct->tuplehash[dir].tuple.dst.protonum;
556 + dif = ((struct rtable *)(*pskb)->dst)->rt_iif;
557 + ip = ct->tuplehash[dir].tuple.dst.u3.ip;
558 + port = get_dst_port(&ct->tuplehash[dir].tuple);
560 + if (proto == 1 || proto == 17) {
561 + if ((*pskb)->mark>0) /* The packet is marked, it's going out */
563 + //if (ct->xid[0]>0 && ct->xid[0]!=(*pskb)->mark)
564 + /*printk(KERN_CRIT "xt_MARK log: %d/%d/%d/%d\n",ct->xid[0],(*pskb)->mark,hooknum==NF_IP_LOCAL_IN,proto);*/
566 + ct->xid[0]=(*pskb)->mark;
569 + if (ct->xid[0] > 0) {
574 + else if (proto == 6) {
576 + connection_sk = (*pskb)->sk;
577 + sock_hold(connection_sk);
580 + connection_sk = inet_lookup_established(&tcp_hashinfo, src_ip, src_port, ip, port, dif);
583 + if (connection_sk) {
584 + if (connection_sk->sk_state == TCP_TIME_WAIT) {
585 + inet_twsk_put(inet_twsk(connection_sk));
588 + connection_sk->sk_peercred.gid = connection_sk->sk_peercred.uid = ct->xid[dir];
589 + ct->xid[!dir]=connection_sk->sk_nid;
590 + if (connection_sk->sk_nid != 0)
591 + mark = connection_sk->sk_nid;
592 + sock_put(connection_sk);
600 (*pskb)->mark = mark;
603 + curtag=&__get_cpu_var(sknid_elevator);
604 + if (mark > 0 && *curtag==-2)
613 checkentry_v0(const char *tablename,
617 if (markinfo->mode != XT_MARK_SET
618 && markinfo->mode != XT_MARK_AND
619 - && markinfo->mode != XT_MARK_OR) {
620 + && markinfo->mode != XT_MARK_OR
621 + && markinfo->mode != XT_MARK_COPYXID) {
622 printk(KERN_WARNING "MARK: unknown mode %u\n",
625 diff -Nurb linux-2.6.22-510/net/netfilter/xt_SETXID.c linux-2.6.22-520/net/netfilter/xt_SETXID.c
626 --- linux-2.6.22-510/net/netfilter/xt_SETXID.c 1969-12-31 19:00:00.000000000 -0500
627 +++ linux-2.6.22-520/net/netfilter/xt_SETXID.c 2008-06-06 17:07:56.000000000 -0400
629 +#include <linux/module.h>
630 +#include <linux/skbuff.h>
631 +#include <linux/ip.h>
632 +#include <net/checksum.h>
633 +#include <linux/vs_network.h>
635 +#include <linux/netfilter/x_tables.h>
636 +#include <linux/netfilter/xt_SETXID.h>
638 +MODULE_LICENSE("GPL");
640 +MODULE_DESCRIPTION("");
641 +MODULE_ALIAS("ipt_SETXID");
644 +target_v1(struct sk_buff **pskb,
645 + const struct net_device *in,
646 + const struct net_device *out,
647 + unsigned int hooknum,
648 + const struct xt_target *target,
649 + const void *targinfo)
651 + const struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
653 + switch (setxidinfo->mode) {
654 + case XT_SET_PACKET_XID:
655 + (*pskb)->skb_tag = setxidinfo->mark;
658 + return XT_CONTINUE;
663 +checkentry_v1(const char *tablename,
665 + const struct xt_target *target,
667 + unsigned int hook_mask)
669 + struct xt_setxid_target_info_v1 *setxidinfo = targinfo;
671 + if (setxidinfo->mode != XT_SET_PACKET_XID) {
672 + printk(KERN_WARNING "SETXID: unknown mode %u\n",
680 +static struct xt_target xt_setxid_target[] = {
685 + .checkentry = checkentry_v1,
686 + .target = target_v1,
687 + .targetsize = sizeof(struct xt_setxid_target_info_v1),
693 +static int __init init(void)
697 + err = xt_register_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
701 +static void __exit fini(void)
703 + xt_unregister_targets(xt_setxid_target, ARRAY_SIZE(xt_setxid_target));
708 diff -Nurb linux-2.6.22-510/net/packet/af_packet.c linux-2.6.22-520/net/packet/af_packet.c
709 --- linux-2.6.22-510/net/packet/af_packet.c 2007-07-08 19:32:17.000000000 -0400
710 +++ linux-2.6.22-520/net/packet/af_packet.c 2008-06-07 18:30:41.000000000 -0400
712 #include <linux/poll.h>
713 #include <linux/module.h>
714 #include <linux/init.h>
715 +#include <linux/vs_network.h>
718 #include <net/inet_common.h>
719 @@ -246,10 +247,13 @@
721 static const struct proto_ops packet_ops_spkt;
723 +extern DEFINE_PER_CPU(int, sknid_elevator);
724 static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
727 struct sockaddr_pkt *spkt;
728 + int tag = skb->skb_tag;
729 + int *elevator=&__get_cpu_var(sknid_elevator);
732 * When we registered the protocol we saved the socket in the data
734 * so that this procedure is noop.
738 + * (18:05:41) daniel_hozac: where?
739 + * (18:05:58) daniel_hozac: we already have filters on PF_PACKET, don't we?
740 + * (18:05:58) er: in packet_rcv_skpt
741 + * (18:07:33) daniel_hozac: oh, that's evil.
744 + if (sk->sk_nx_info && !(tag == 1 || sk->sk_nid == tag)) {
748 + else if (!sk->sk_nx_info && *elevator) {
749 + /* Root has already seen this packet */
753 if (skb->pkt_type == PACKET_LOOPBACK)
760 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SEND))
764 * Get and verify the address.
769 struct sk_filter *filter;
770 + int tag = skb->skb_tag;
771 + int *elevator=&__get_cpu_var(sknid_elevator);
773 + if (sk->sk_nx_info && !(tag == 1 || sk->sk_nid == tag)) {
777 + else if (!sk->sk_nx_info && *elevator) {
778 + /* Root has already seen this packet */
783 filter = rcu_dereference(sk->sk_filter);
786 int ifindex, err, reserve = 0;
788 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SEND))
792 * Get and verify the address.
795 __be16 proto = (__force __be16)protocol; /* weird, but documented */
798 - if (!capable(CAP_NET_RAW))
799 + if (!nx_capable(CAP_NET_RAW, NXC_RAW_SOCKET))
802 if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW &&
803 sock->type != SOCK_PACKET)
804 return -ESOCKTNOSUPPORT;