[Openswan Users] Compression with Linux kernel 2.6

Herbert Xu herbert at gondor.apana.org.au
Sat May 14 09:33:28 CEST 2005


On Fri, May 13, 2005 at 06:03:59PM +0200, Paul Wouters wrote:
> 
> Thanks Herbert!
> 
> Applied to HEAD.

Sorry, that patch only works for the first negotiation.  Here is an
incremental patch that makes it work for all subsequent ones too.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-------------- next part --------------
Index: programs/pluto/kernel_netlink.c
===================================================================
RCS file: /public/cvs/openswan-2/programs/pluto/kernel_netlink.c,v
retrieving revision 1.26
diff -u -r1.26 kernel_netlink.c
--- programs/pluto/kernel_netlink.c	13 May 2005 15:57:28 -0000	1.26
+++ programs/pluto/kernel_netlink.c	13 May 2005 22:31:40 -0000
@@ -1025,6 +1025,7 @@
 	} u;
 	char data[1024];
     } rsp;
+    static int get_cpi_bug;
 
     memset(&req, 0, sizeof(req));
     req.n.nlmsg_flags = NLM_F_REQUEST;
@@ -1036,25 +1037,22 @@
     req.spi.info.reqid = reqid;
     req.spi.info.id.proto = proto;
     req.spi.info.family = src->u.v4.sin_family;
-    req.spi.min = min;
-    req.spi.max = max;
 
     req.n.nlmsg_len = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.spi)));
 
     rsp.n.nlmsg_type = XFRM_MSG_NEWSA;
 
 retry:
+    req.spi.min = get_cpi_bug ? htonl(min) : min;
+    req.spi.max = get_cpi_bug ? htonl(max) : max;
+
     if (!send_netlink_msg(&req.n, &rsp.n, sizeof(rsp), "Get SPI", text_said))
 	return 0;
     else if (rsp.n.nlmsg_type == NLMSG_ERROR)
     {
-	static int get_cpi_bug;
-
 	if (rsp.u.e.error == -EINVAL && proto == IPPROTO_COMP && !get_cpi_bug)
 	{
 	    get_cpi_bug = 1;
-	    req.spi.min = htonl(min);
-	    req.spi.max = htonl(max);
 	    openswan_log("netlink_get_spi: Enabling workaround for"
 			 " kernel CPI allocation bug");
 	    goto retry;


More information about the Users mailing list