aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipcomp.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-21 01:47:35 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:10 -0400
commiteddc9ec53be2ecdbf4efe0efd4a83052594f0ac0 (patch)
tree4a38ab4dbd9d61fdf5a5ea6ed61463e0b9e33ba7 /net/ipv4/ipcomp.c
parente023dd643798c4f06c16466af90b4d250e4b8bd7 (diff)
[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipcomp.c')
-rw-r--r--net/ipv4/ipcomp.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index aa704b88f014..8eb46064c525 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -43,21 +43,15 @@ static LIST_HEAD(ipcomp_tfms_list);
43 43
44static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) 44static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
45{ 45{
46 int err, plen, dlen;
47 struct ipcomp_data *ipcd = x->data; 46 struct ipcomp_data *ipcd = x->data;
48 u8 *start, *scratch; 47 const int plen = skb->len;
49 struct crypto_comp *tfm; 48 int dlen = IPCOMP_SCRATCH_SIZE;
50 int cpu; 49 const u8 *start = skb->data;
51 50 const int cpu = get_cpu();
52 plen = skb->len; 51 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
53 dlen = IPCOMP_SCRATCH_SIZE; 52 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
54 start = skb->data; 53 int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
55 54
56 cpu = get_cpu();
57 scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
58 tfm = *per_cpu_ptr(ipcd->tfms, cpu);
59
60 err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
61 if (err) 55 if (err)
62 goto out; 56 goto out;
63 57
@@ -90,7 +84,7 @@ static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
90 skb->ip_summed = CHECKSUM_NONE; 84 skb->ip_summed = CHECKSUM_NONE;
91 85
92 /* Remove ipcomp header and decompress original payload */ 86 /* Remove ipcomp header and decompress original payload */
93 iph = skb->nh.iph; 87 iph = ip_hdr(skb);
94 ipch = (void *)skb->data; 88 ipch = (void *)skb->data;
95 iph->protocol = ipch->nexthdr; 89 iph->protocol = ipch->nexthdr;
96 skb->h.raw = skb->nh.raw + sizeof(*ipch); 90 skb->h.raw = skb->nh.raw + sizeof(*ipch);
@@ -103,23 +97,16 @@ out:
103 97
104static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb) 98static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
105{ 99{
106 int err, plen, dlen, ihlen;
107 struct iphdr *iph = skb->nh.iph;
108 struct ipcomp_data *ipcd = x->data; 100 struct ipcomp_data *ipcd = x->data;
109 u8 *start, *scratch; 101 const int ihlen = ip_hdrlen(skb);
110 struct crypto_comp *tfm; 102 const int plen = skb->len - ihlen;
111 int cpu; 103 int dlen = IPCOMP_SCRATCH_SIZE;
104 u8 *start = skb->data + ihlen;
105 const int cpu = get_cpu();
106 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
107 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
108 int err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
112 109
113 ihlen = iph->ihl * 4;
114 plen = skb->len - ihlen;
115 dlen = IPCOMP_SCRATCH_SIZE;
116 start = skb->data + ihlen;
117
118 cpu = get_cpu();
119 scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
120 tfm = *per_cpu_ptr(ipcd->tfms, cpu);
121
122 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
123 if (err) 110 if (err)
124 goto out; 111 goto out;
125 112
@@ -142,12 +129,11 @@ out:
142static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb) 129static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
143{ 130{
144 int err; 131 int err;
145 struct iphdr *iph;
146 struct ip_comp_hdr *ipch; 132 struct ip_comp_hdr *ipch;
147 struct ipcomp_data *ipcd = x->data; 133 struct ipcomp_data *ipcd = x->data;
148 int hdr_len = 0; 134 int hdr_len = 0;
135 struct iphdr *iph = ip_hdr(skb);
149 136
150 iph = skb->nh.iph;
151 iph->tot_len = htons(skb->len); 137 iph->tot_len = htons(skb->len);
152 hdr_len = iph->ihl * 4; 138 hdr_len = iph->ihl * 4;
153 if ((skb->len - hdr_len) < ipcd->threshold) { 139 if ((skb->len - hdr_len) < ipcd->threshold) {
@@ -159,7 +145,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
159 goto out_ok; 145 goto out_ok;
160 146
161 err = ipcomp_compress(x, skb); 147 err = ipcomp_compress(x, skb);
162 iph = skb->nh.iph; 148 iph = ip_hdr(skb);
163 149
164 if (err) { 150 if (err) {
165 goto out_ok; 151 goto out_ok;