From nobody@FreeBSD.org  Tue Sep  1 09:23:51 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F390F1065672
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  1 Sep 2009 09:23:50 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E29368FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  1 Sep 2009 09:23:50 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n819NoHX016448
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 1 Sep 2009 09:23:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n819Noq0016429;
	Tue, 1 Sep 2009 09:23:50 GMT
	(envelope-from nobody)
Message-Id: <200909010923.n819Noq0016429@www.freebsd.org>
Date: Tue, 1 Sep 2009 09:23:50 GMT
From: Aurlien Ansel <aurelien.ansel@netasq.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [IPSec] Tunnel with IPv4 and IPv6
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         138439
>Category:       kern
>Synopsis:       [IPSec] Tunnel with IPv4 and IPv6
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    vanhu
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 01 09:30:06 UTC 2009
>Closed-Date:    
>Last-Modified:  Wed Sep 16 12:00:16 UTC 2009
>Originator:     Aurlien Ansel
>Release:        7.2-STABLE
>Organization:
NETASQ
>Environment:
FreeBSD aureliena2.netasq.com 7.2-STABLE FreeBSD 7.2-STABLE #3: Tue Sep  1 10:49:57 CEST 2009     root@aureliena2.netasq.com:/usr/src/sys/i386/compile/NOYAU  i386
>Description:
The component Setkey of the port 'ipsec-tools' refuse the SP for a tunnel with IPv4 in IPv6. Setkey respond 'Invalid Argument'.
That comes from the kernelland, from netipsec/key.c.
An extract of my setkey.sh :

spdadd 222.222.222.0/24 111.111.111.0/24 any -P out ipsec 
 esp/tunnel/2001::2-2001::1/require;

spdadd 111.111.111.0/24 222.222.222.0/24 any -P in ipsec 
 esp/tunnel/2001::1-2001::2/require;


/!\ The patch attached is NOT a fix, it's a help to show where the problem comes from !!!!!!
>How-To-Repeat:
With the component setkey try : 
spdadd 222.222.222.0/24 111.111.111.0/24 any -P out ipsec 
 esp/tunnel/2001::2-2001::1/require;
without the patch attached and after with it.
The first time Setkey will respond 'invalid argument', the second time it will be OK.
>Fix:


Patch attached with submission follows:

--- key.c.backup	2009-08-31 18:02:20.000000000 +0200
+++ key.c	2009-09-01 11:10:32.000000000 +0200
@@ -1891,7 +1891,7 @@
 		_key_delsp(newsp);
 		return key_senderror(so, m, EINVAL);
 	}
-#if 1
+#if 0
 	if (newsp->req && newsp->req->saidx.src.sa.sa_family) {
 		struct sockaddr *sa;
 		sa = (struct sockaddr *)(src0 + 1);


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->vanhu 
Responsible-Changed-By: vanhu 
Responsible-Changed-When: Tue Sep 1 09:31:18 UTC 2009 
Responsible-Changed-Why:  
Already started to work on it with Aurelien. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=138439 
State-Changed-From-To: open->patched 
State-Changed-By: vanhu 
State-Changed-When: Wed Sep 16 11:49:07 UTC 2009 
State-Changed-Why:  
Commited to HEAD, probable feedback to STABLE/8 after 
8.0 release. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=138439 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138439: commit references a PR
Date: Wed, 16 Sep 2009 11:56:56 +0000 (UTC)

 Author: vanhu
 Date: Wed Sep 16 11:56:44 2009
 New Revision: 197250
 URL: http://svn.freebsd.org/changeset/base/197250
 
 Log:
   When checking traffic endpoint's adresses families in key_spdadd(),
   compare them together instead of comparing each one with respective
   tunnel endpoint.
   
   PR:	kern/138439
   Submitted by:	aurelien.ansel@netasq.com
   Obtained from:	NETASQ
   MFC after:	1 m
 
 Modified:
   head/sys/netipsec/key.c
 
 Modified: head/sys/netipsec/key.c
 ==============================================================================
 --- head/sys/netipsec/key.c	Wed Sep 16 08:38:47 2009	(r197249)
 +++ head/sys/netipsec/key.c	Wed Sep 16 11:56:44 2009	(r197250)
 @@ -1925,18 +1925,8 @@ key_spdadd(so, m, mhp)
  		return key_senderror(so, m, EINVAL);
  	}
  #if 1
 -	if (newsp->req && newsp->req->saidx.src.sa.sa_family) {
 -		struct sockaddr *sa;
 -		sa = (struct sockaddr *)(src0 + 1);
 -		if (sa->sa_family != newsp->req->saidx.src.sa.sa_family) {
 -			_key_delsp(newsp);
 -			return key_senderror(so, m, EINVAL);
 -		}
 -	}
 -	if (newsp->req && newsp->req->saidx.dst.sa.sa_family) {
 -		struct sockaddr *sa;
 -		sa = (struct sockaddr *)(dst0 + 1);
 -		if (sa->sa_family != newsp->req->saidx.dst.sa.sa_family) {
 +	if (newsp->req && newsp->req->saidx.src.sa.sa_family && newsp->req->saidx.dst.sa.sa_family) {
 +		if (newsp->req->saidx.src.sa.sa_family != newsp->req->saidx.dst.sa.sa_family) {
  			_key_delsp(newsp);
  			return key_senderror(so, m, EINVAL);
  		}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
