Setting tag linux-2.6-27-38
[linux-2.6.git] / linux-2.6-521-packet-tagging.patch
1 Index: linux-2.6.27.y/include/linux/skbuff.h
2 ===================================================================
3 --- linux-2.6.27.y.orig/include/linux/skbuff.h
4 +++ linux-2.6.27.y/include/linux/skbuff.h
5 @@ -330,6 +330,7 @@ struct sk_buff {
6  #endif
7  
8         __u32                   mark;
9 +#define skb_tag                        mark
10  
11         __u16                   vlan_tci;
12  
13 Index: linux-2.6.27.y/net/core/skbuff.c
14 ===================================================================
15 --- linux-2.6.27.y.orig/net/core/skbuff.c
16 +++ linux-2.6.27.y/net/core/skbuff.c
17 @@ -55,6 +55,7 @@
18  #include <linux/rtnetlink.h>
19  #include <linux/init.h>
20  #include <linux/scatterlist.h>
21 +#include <linux/vs_network.h>
22  
23  #include <net/protocol.h>
24  #include <net/dst.h>
25 @@ -197,6 +198,7 @@ struct sk_buff *__alloc_skb(unsigned int
26         skb->data = data;
27         skb_reset_tail_pointer(skb);
28         skb->end = skb->tail + size;
29 +       if (!in_interrupt()) skb->skb_tag = nx_current_nid(); else skb->skb_tag = 0;
30         /* make sure we initialize shinfo sequentially */
31         shinfo = skb_shinfo(skb);
32         atomic_set(&shinfo->dataref, 1);
33 @@ -448,6 +450,7 @@ static void __copy_skb_header(struct sk_
34  #endif
35  #endif
36         new->vlan_tci           = old->vlan_tci;
37 +       new->skb_tag            = old->skb_tag;
38  
39         skb_copy_secmark(new, old);
40  }
41 @@ -478,6 +481,8 @@ static struct sk_buff *__skb_clone(struc
42  #endif
43         atomic_set(&n->users, 1);
44  
45 +       /* Sapan: Cloned skbs aren't owned by anyone. Let the cloner decide who it belongs to. */
46 +
47         atomic_inc(&(skb_shinfo(skb)->dataref));
48         skb->cloned = 1;
49  
50 Index: linux-2.6.27.y/net/core/sock.c
51 ===================================================================
52 --- linux-2.6.27.y.orig/net/core/sock.c
53 +++ linux-2.6.27.y/net/core/sock.c
54 @@ -956,6 +956,8 @@ struct sock *sk_alloc(struct net *net, i
55                 sk->sk_prot = sk->sk_prot_creator = prot;
56                 sock_lock_init(sk);
57                 sock_net_set(sk, get_net(net));
58 +        if (!in_interrupt())
59 +            sk->sk_mark = nx_current_nid();
60         }
61  
62         return sk;
63 Index: linux-2.6.27.y/net/ipv4/af_inet.c
64 ===================================================================
65 --- linux-2.6.27.y.orig/net/ipv4/af_inet.c
66 +++ linux-2.6.27.y/net/ipv4/af_inet.c
67 @@ -181,6 +181,8 @@ static int inet_autobind(struct sock *sk
68                         return -EAGAIN;
69                 }
70                 inet->sport = htons(inet->num);
71 +               sk->sk_xid = vx_current_xid();
72 +               if (!in_interrupt()) sk->sk_nid = nx_current_nid(); else sk->sk_nid=0;
73         }
74         release_sock(sk);
75         return 0;
76 Index: linux-2.6.27.y/net/ipv4/netfilter/ipt_LOG.c
77 ===================================================================
78 --- linux-2.6.27.y.orig/net/ipv4/netfilter/ipt_LOG.c
79 +++ linux-2.6.27.y/net/ipv4/netfilter/ipt_LOG.c
80 @@ -45,6 +45,8 @@ static void dump_packet(const struct nf_
81         else
82                 logflags = NF_LOG_MASK;
83  
84 +       printk("TAG=%d ", skb->skb_tag);
85 +
86         ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);
87         if (ih == NULL) {
88                 printk("TRUNCATED");