blob: a75807b971b3e1b452d6b272ab3b8077afebd4d1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * IP Payload Compression Protocol (IPComp) - RFC3173.
3 *
4 * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +09008 * Software Foundation; either version 2 of the License, or (at your option)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * any later version.
10 *
11 * Todo:
12 * - Tunable compression parameters.
13 * - Compression stats.
14 * - Adaptive compression.
15 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/crypto.h>
Herbert Xu4999f362007-11-07 02:21:47 -080018#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/pfkeyv2.h>
20#include <linux/percpu.h>
21#include <linux/smp.h>
22#include <linux/list.h>
23#include <linux/vmalloc.h>
24#include <linux/rtnetlink.h>
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -080025#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <net/ip.h>
27#include <net/xfrm.h>
28#include <net/icmp.h>
29#include <net/ipcomp.h>
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020030#include <net/protocol.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
32struct ipcomp_tfms {
33 struct list_head list;
Herbert Xue4d5b792006-08-26 18:12:40 +100034 struct crypto_comp **tfms;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 int users;
36};
37
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -080038static DEFINE_MUTEX(ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static void **ipcomp_scratches;
40static int ipcomp_scratch_users;
41static LIST_HEAD(ipcomp_tfms_list);
42
43static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
44{
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 struct ipcomp_data *ipcd = x->data;
Arnaldo Carvalho de Meloeddc9ec2007-04-20 22:47:35 -070046 const int plen = skb->len;
47 int dlen = IPCOMP_SCRATCH_SIZE;
48 const u8 *start = skb->data;
49 const int cpu = get_cpu();
50 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
51 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
52 int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 if (err)
55 goto out;
56
57 if (dlen < (plen + sizeof(struct ip_comp_hdr))) {
58 err = -EINVAL;
59 goto out;
60 }
61
62 err = pskb_expand_head(skb, 0, dlen - plen, GFP_ATOMIC);
63 if (err)
64 goto out;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090065
Herbert Xuda952312006-07-11 13:50:09 -070066 skb->truesize += dlen - plen;
67 __skb_put(skb, dlen - plen);
Arnaldo Carvalho de Melo27d7ff42007-03-31 11:55:19 -030068 skb_copy_to_linear_data(skb, scratch, dlen);
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090069out:
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 put_cpu();
71 return err;
72}
73
Herbert Xue6956332006-04-01 00:52:46 -080074static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
Herbert Xu2614fa52008-01-29 21:11:46 -080076 int nexthdr;
Herbert Xu364c6ba2006-06-09 16:10:40 -070077 int err = -ENOMEM;
Herbert Xu31a4ab92006-05-27 23:06:13 -070078 struct ip_comp_hdr *ipch;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Herbert Xu364c6ba2006-06-09 16:10:40 -070080 if (skb_linearize_cow(skb))
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090081 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 skb->ip_summed = CHECKSUM_NONE;
84
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090085 /* Remove ipcomp header and decompress original payload */
Herbert Xu31a4ab92006-05-27 23:06:13 -070086 ipch = (void *)skb->data;
Herbert Xu2614fa52008-01-29 21:11:46 -080087 nexthdr = ipch->nexthdr;
88
Arnaldo Carvalho de Melob0e380b2007-04-10 21:21:55 -070089 skb->transport_header = skb->network_header + sizeof(*ipch);
Herbert Xu31a4ab92006-05-27 23:06:13 -070090 __skb_pull(skb, sizeof(*ipch));
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 err = ipcomp_decompress(x, skb);
Herbert Xu631a6692007-10-10 15:46:21 -070092 if (err)
93 goto out;
94
Herbert Xu2614fa52008-01-29 21:11:46 -080095 err = nexthdr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +090097out:
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 return err;
99}
100
101static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
102{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 struct ipcomp_data *ipcd = x->data;
Herbert Xuceb1eec2007-10-10 15:45:52 -0700104 const int plen = skb->len;
Arnaldo Carvalho de Meloeddc9ec2007-04-20 22:47:35 -0700105 int dlen = IPCOMP_SCRATCH_SIZE;
Herbert Xuceb1eec2007-10-10 15:45:52 -0700106 u8 *start = skb->data;
Arnaldo Carvalho de Meloeddc9ec2007-04-20 22:47:35 -0700107 const int cpu = get_cpu();
108 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
109 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
Herbert Xu21e43182008-02-28 11:23:17 -0800110 int err;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900111
Herbert Xu21e43182008-02-28 11:23:17 -0800112 local_bh_disable();
113 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
114 local_bh_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 if (err)
116 goto out;
117
118 if ((dlen + sizeof(struct ip_comp_hdr)) >= plen) {
119 err = -EMSGSIZE;
120 goto out;
121 }
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen);
124 put_cpu();
125
Herbert Xuceb1eec2007-10-10 15:45:52 -0700126 pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 return 0;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900128
129out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 put_cpu();
131 return err;
132}
133
134static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
135{
136 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 struct ip_comp_hdr *ipch;
138 struct ipcomp_data *ipcd = x->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Herbert Xuceb1eec2007-10-10 15:45:52 -0700140 if (skb->len < ipcd->threshold) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 /* Don't bother compressing */
142 goto out_ok;
143 }
144
Herbert Xu364c6ba2006-06-09 16:10:40 -0700145 if (skb_linearize_cow(skb))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 goto out_ok;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 err = ipcomp_compress(x, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150 if (err) {
151 goto out_ok;
152 }
153
154 /* Install ipcomp header, convert into ipcomp datagram. */
Herbert Xu87bdc482007-10-10 15:45:25 -0700155 ipch = ip_comp_hdr(skb);
Herbert Xu37fedd32007-10-10 15:44:44 -0700156 ipch->nexthdr = *skb_mac_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 ipch->flags = 0;
158 ipch->cpi = htons((u16 )ntohl(x->id.spi));
Herbert Xu37fedd32007-10-10 15:44:44 -0700159 *skb_mac_header(skb) = IPPROTO_COMP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160out_ok:
Herbert Xuceb1eec2007-10-10 15:45:52 -0700161 skb_push(skb, -skb_network_offset(skb));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 return 0;
163}
164
165static void ipcomp4_err(struct sk_buff *skb, u32 info)
166{
Al Viroa94cfd12006-09-27 18:47:24 -0700167 __be32 spi;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 struct iphdr *iph = (struct iphdr *)skb->data;
169 struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2));
170 struct xfrm_state *x;
171
Arnaldo Carvalho de Melo88c76642007-03-13 14:43:18 -0300172 if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
173 icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 return;
175
Alexey Dobriyan4195f812006-05-22 16:53:22 -0700176 spi = htonl(ntohs(ipch->cpi));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr,
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900178 spi, IPPROTO_COMP, AF_INET);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 if (!x)
180 return;
YOSHIFUJI Hideakia7d632b2008-04-14 04:09:00 -0700181 NETDEBUG(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/" NIPQUAD_FMT "\n",
Patrick McHardy64ce2072005-08-09 20:50:53 -0700182 spi, NIPQUAD(iph->daddr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 xfrm_state_put(x);
184}
185
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900186/* We always hold one tunnel user reference to indicate a tunnel */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
188{
189 struct xfrm_state *t;
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 t = xfrm_state_alloc();
192 if (t == NULL)
193 goto out;
194
195 t->id.proto = IPPROTO_IPIP;
196 t->id.spi = x->props.saddr.a4;
197 t->id.daddr.a4 = x->id.daddr.a4;
198 memcpy(&t->sel, &x->sel, sizeof(t->sel));
199 t->props.family = AF_INET;
Herbert Xue40b3282007-11-13 21:39:08 -0800200 t->props.mode = x->props.mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 t->props.saddr.a4 = x->props.saddr.a4;
202 t->props.flags = x->props.flags;
Herbert Xu72cb6962005-06-20 13:18:08 -0700203
204 if (xfrm_init_state(t))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 goto error;
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 atomic_set(&t->tunnel_users, 1);
208out:
209 return t;
210
211error:
212 t->km.state = XFRM_STATE_DEAD;
213 xfrm_state_put(t);
214 t = NULL;
215 goto out;
216}
217
218/*
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800219 * Must be protected by xfrm_cfg_mutex. State and tunnel user references are
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 * always incremented on success.
221 */
222static int ipcomp_tunnel_attach(struct xfrm_state *x)
223{
224 int err = 0;
225 struct xfrm_state *t;
226
227 t = xfrm_state_lookup((xfrm_address_t *)&x->id.daddr.a4,
YOSHIFUJI Hideakie905a9e2007-02-09 23:24:47 +0900228 x->props.saddr.a4, IPPROTO_IPIP, AF_INET);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 if (!t) {
230 t = ipcomp_tunnel_create(x);
231 if (!t) {
232 err = -EINVAL;
233 goto out;
234 }
235 xfrm_state_insert(t);
236 xfrm_state_hold(t);
237 }
238 x->tunnel = t;
239 atomic_inc(&t->tunnel_users);
240out:
241 return err;
242}
243
244static void ipcomp_free_scratches(void)
245{
246 int i;
247 void **scratches;
248
249 if (--ipcomp_scratch_users)
250 return;
251
252 scratches = ipcomp_scratches;
253 if (!scratches)
254 return;
255
Jesper Juhl63903ca2006-04-18 14:51:44 -0700256 for_each_possible_cpu(i)
257 vfree(*per_cpu_ptr(scratches, i));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
259 free_percpu(scratches);
260}
261
262static void **ipcomp_alloc_scratches(void)
263{
264 int i;
265 void **scratches;
266
267 if (ipcomp_scratch_users++)
268 return ipcomp_scratches;
269
270 scratches = alloc_percpu(void *);
271 if (!scratches)
272 return NULL;
273
274 ipcomp_scratches = scratches;
275
KAMEZAWA Hiroyuki6f912042006-04-10 22:52:50 -0700276 for_each_possible_cpu(i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE);
278 if (!scratch)
279 return NULL;
280 *per_cpu_ptr(scratches, i) = scratch;
281 }
282
283 return scratches;
284}
285
Herbert Xue4d5b792006-08-26 18:12:40 +1000286static void ipcomp_free_tfms(struct crypto_comp **tfms)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287{
288 struct ipcomp_tfms *pos;
289 int cpu;
290
291 list_for_each_entry(pos, &ipcomp_tfms_list, list) {
292 if (pos->tfms == tfms)
293 break;
294 }
295
296 BUG_TRAP(pos);
297
298 if (--pos->users)
299 return;
300
301 list_del(&pos->list);
302 kfree(pos);
303
304 if (!tfms)
305 return;
306
KAMEZAWA Hiroyuki6f912042006-04-10 22:52:50 -0700307 for_each_possible_cpu(cpu) {
Herbert Xue4d5b792006-08-26 18:12:40 +1000308 struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu);
309 crypto_free_comp(tfm);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 }
311 free_percpu(tfms);
312}
313
Herbert Xue4d5b792006-08-26 18:12:40 +1000314static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315{
316 struct ipcomp_tfms *pos;
Herbert Xue4d5b792006-08-26 18:12:40 +1000317 struct crypto_comp **tfms;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 int cpu;
319
320 /* This can be any valid CPU ID so we don't need locking. */
Herbert Xu6fc8b9e2005-08-18 14:36:59 -0700321 cpu = raw_smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 list_for_each_entry(pos, &ipcomp_tfms_list, list) {
Herbert Xue4d5b792006-08-26 18:12:40 +1000324 struct crypto_comp *tfm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
326 tfms = pos->tfms;
327 tfm = *per_cpu_ptr(tfms, cpu);
328
Herbert Xue4d5b792006-08-26 18:12:40 +1000329 if (!strcmp(crypto_comp_name(tfm), alg_name)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 pos->users++;
331 return tfms;
332 }
333 }
334
335 pos = kmalloc(sizeof(*pos), GFP_KERNEL);
336 if (!pos)
337 return NULL;
338
339 pos->users = 1;
340 INIT_LIST_HEAD(&pos->list);
341 list_add(&pos->list, &ipcomp_tfms_list);
342
Herbert Xue4d5b792006-08-26 18:12:40 +1000343 pos->tfms = tfms = alloc_percpu(struct crypto_comp *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 if (!tfms)
345 goto error;
346
KAMEZAWA Hiroyuki6f912042006-04-10 22:52:50 -0700347 for_each_possible_cpu(cpu) {
Herbert Xue4d5b792006-08-26 18:12:40 +1000348 struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
349 CRYPTO_ALG_ASYNC);
Herbert Xu4999f362007-11-07 02:21:47 -0800350 if (IS_ERR(tfm))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 goto error;
352 *per_cpu_ptr(tfms, cpu) = tfm;
353 }
354
355 return tfms;
356
357error:
358 ipcomp_free_tfms(tfms);
359 return NULL;
360}
361
362static void ipcomp_free_data(struct ipcomp_data *ipcd)
363{
364 if (ipcd->tfms)
365 ipcomp_free_tfms(ipcd->tfms);
366 ipcomp_free_scratches();
367}
368
369static void ipcomp_destroy(struct xfrm_state *x)
370{
371 struct ipcomp_data *ipcd = x->data;
372 if (!ipcd)
373 return;
374 xfrm_state_delete_tunnel(x);
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800375 mutex_lock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 ipcomp_free_data(ipcd);
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800377 mutex_unlock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 kfree(ipcd);
379}
380
Herbert Xu72cb6962005-06-20 13:18:08 -0700381static int ipcomp_init_state(struct xfrm_state *x)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
383 int err;
384 struct ipcomp_data *ipcd;
385 struct xfrm_algo_desc *calg_desc;
386
387 err = -EINVAL;
388 if (!x->calg)
389 goto out;
390
391 if (x->encap)
392 goto out;
393
Herbert Xue40b3282007-11-13 21:39:08 -0800394 x->props.header_len = 0;
395 switch (x->props.mode) {
396 case XFRM_MODE_TRANSPORT:
397 break;
398 case XFRM_MODE_TUNNEL:
399 x->props.header_len += sizeof(struct iphdr);
400 break;
401 default:
402 goto out;
403 }
404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 err = -ENOMEM;
Panagiotis Issaris0da974f2006-07-21 14:51:30 -0700406 ipcd = kzalloc(sizeof(*ipcd), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 if (!ipcd)
408 goto out;
409
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800410 mutex_lock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 if (!ipcomp_alloc_scratches())
412 goto error;
413
414 ipcd->tfms = ipcomp_alloc_tfms(x->calg->alg_name);
415 if (!ipcd->tfms)
416 goto error;
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800417 mutex_unlock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
Masahide NAKAMURA7e49e6d2006-09-22 15:05:15 -0700419 if (x->props.mode == XFRM_MODE_TUNNEL) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 err = ipcomp_tunnel_attach(x);
421 if (err)
422 goto error_tunnel;
423 }
424
425 calg_desc = xfrm_calg_get_byname(x->calg->alg_name, 0);
426 BUG_ON(!calg_desc);
427 ipcd->threshold = calg_desc->uinfo.comp.threshold;
428 x->data = ipcd;
429 err = 0;
430out:
431 return err;
432
433error_tunnel:
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800434 mutex_lock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435error:
436 ipcomp_free_data(ipcd);
Arjan van de Ven4a3e2f72006-03-20 22:33:17 -0800437 mutex_unlock(&ipcomp_resource_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 kfree(ipcd);
439 goto out;
440}
441
Eric Dumazet533cb5b2008-01-30 19:11:50 -0800442static const struct xfrm_type ipcomp_type = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 .description = "IPCOMP4",
444 .owner = THIS_MODULE,
445 .proto = IPPROTO_COMP,
446 .init_state = ipcomp_init_state,
447 .destructor = ipcomp_destroy,
448 .input = ipcomp_input,
449 .output = ipcomp_output
450};
451
452static struct net_protocol ipcomp4_protocol = {
453 .handler = xfrm4_rcv,
454 .err_handler = ipcomp4_err,
455 .no_policy = 1,
456};
457
458static int __init ipcomp4_init(void)
459{
460 if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) {
461 printk(KERN_INFO "ipcomp init: can't add xfrm type\n");
462 return -EAGAIN;
463 }
464 if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) {
465 printk(KERN_INFO "ipcomp init: can't add protocol\n");
466 xfrm_unregister_type(&ipcomp_type, AF_INET);
467 return -EAGAIN;
468 }
469 return 0;
470}
471
472static void __exit ipcomp4_fini(void)
473{
474 if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0)
475 printk(KERN_INFO "ip ipcomp close: can't remove protocol\n");
476 if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0)
477 printk(KERN_INFO "ip ipcomp close: can't remove xfrm type\n");
478}
479
480module_init(ipcomp4_init);
481module_exit(ipcomp4_fini);
482
483MODULE_LICENSE("GPL");
484MODULE_DESCRIPTION("IP Payload Compression Protocol (IPComp) - RFC3173");
485MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
486
Masahide NAKAMURAd3d6dd32007-06-26 23:57:49 -0700487MODULE_ALIAS_XFRM_TYPE(AF_INET, XFRM_PROTO_COMP);