[Openswan Users] Compression with Linux kernel 2.6

Herbert Xu herbert at gondor.apana.org.au
Sat May 14 00:27:45 CEST 2005


On Thu, May 12, 2005 at 02:38:55PM +0200, Paul Wouters wrote:
> 
> >If we really cared we can work around the problem in Openswan.  It's
> >just a matter of detecting the EINVAL return value from get_spi calls
> >on IPComp SAs, and then retrying the call with the maxspi's byte order
> >swapped.
> 
> That would be great actually.
> 
> Phillip, could you test such a patch from Herbert for us?

Here it is.
-- 
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.25
diff -u -r1.25 kernel_netlink.c
--- programs/pluto/kernel_netlink.c	11 May 2005 22:19:16 -0000	1.25
+++ programs/pluto/kernel_netlink.c	13 May 2005 13:27:03 -0000
@@ -1042,10 +1042,24 @@
     req.n.nlmsg_len = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(req.spi)));
 
     rsp.n.nlmsg_type = XFRM_MSG_NEWSA;
+
+retry:
     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;
+	}
+
 	loglog(RC_LOG_SERIOUS
 	    , "ERROR: netlink_get_spi for %s failed with errno %d: %s"
 	    , text_said


More information about the Users mailing list