1 From 5d0cfcf3f26b5aafe91f23fa9095461bdf83c074 Mon Sep 17 00:00:00 2001
2 From: S.Çağlar Onur <caglar@cs.princeton.edu>
3 Date: Tue, 7 Dec 2010 11:06:08 -0500
4 Subject: [PATCH] linux-2.6-521-packet-tagging.patch
7 include/linux/skbuff.h | 2 ++
8 net/core/skbuff.c | 2 ++
10 net/ipv4/af_inet.c | 2 ++
11 net/ipv4/netfilter/ipt_LOG.c | 2 ++
12 5 files changed, 10 insertions(+), 0 deletions(-)
14 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
15 index 8f462cd..78eb029 100644
16 --- a/include/linux/skbuff.h
17 +++ b/include/linux/skbuff.h
18 @@ -391,6 +391,8 @@ struct sk_buff {
26 sk_buff_data_t transport_header;
27 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
28 index 8327d2e..26c3cde 100644
29 --- a/net/core/skbuff.c
30 +++ b/net/core/skbuff.c
31 @@ -208,6 +208,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
32 skb->mac_header = ~0U;
35 + if (!in_interrupt()) skb->skb_tag = nx_current_nid(); else skb->skb_tag = 0;
36 /* make sure we initialize shinfo sequentially */
37 shinfo = skb_shinfo(skb);
38 atomic_set(&shinfo->dataref, 1);
39 @@ -560,6 +561,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
42 new->vlan_tci = old->vlan_tci;
43 + new->skb_tag = old->skb_tag;
45 skb_copy_secmark(new, old);
47 diff --git a/net/core/sock.c b/net/core/sock.c
48 index d84879f..53cb689 100644
51 @@ -1073,6 +1073,8 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
52 sk->sk_prot = sk->sk_prot_creator = prot;
54 sock_net_set(sk, get_net(net));
55 + if (!in_interrupt())
56 + sk->sk_mark = nx_current_nid();
57 atomic_set(&sk->sk_wmem_alloc, 1);
59 sock_update_classid(sk);
60 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
61 index 4408728..9e8942b 100644
62 --- a/net/ipv4/af_inet.c
63 +++ b/net/ipv4/af_inet.c
64 @@ -181,6 +181,8 @@ static int inet_autobind(struct sock *sk)
67 inet->sport = htons(inet->num);
68 + sk->sk_xid = vx_current_xid();
69 + if (!in_interrupt()) sk->sk_nid = nx_current_nid(); else sk->sk_nid=0;
73 diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
74 index acc44c6..ac29a8c 100644
75 --- a/net/ipv4/netfilter/ipt_LOG.c
76 +++ b/net/ipv4/netfilter/ipt_LOG.c
77 @@ -45,6 +45,8 @@ static void dump_packet(const struct nf_loginfo *info,
79 logflags = NF_LOG_MASK;
81 + printk("TAG=%d ", skb->skb_tag);
83 ih = skb_header_pointer(skb, iphoff, sizeof(_iph), &_iph);