From: jpo234@netscape.net Subject: Re: Sending complete IPv6 packets without bypassing netfilter/IPsec Date: Fri, 16 Jan 2009 09:54:49 -0500 Message-ID: <8CB4601836E6983-2F30-1123@webmail-stg-d07.sysops.aol.com> References: <8CB45DED3262281-2F30-8C9@webmail-stg-d07.sysops.aol.com> <200901161256.15744.remi.denis-courmont@nokia.com> <8CB45E27B3643B3-2F30-917@webmail-stg-d07.sysops.aol.com> <200901161609.53283.remi.denis-courmont@nokia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE To: remi.denis-courmont@nokia.com, netdev@vger.kernel.org Return-path: Received: from imo-m12.mx.aol.com ([64.12.143.100]:19053 "EHLO imo-m12.mail.aol.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755785AbZAPOzH convert rfc822-to-8bit (ORCPT ); Fri, 16 Jan 2009 09:55:07 -0500 In-Reply-To: <200901161609.53283.remi.denis-courmont@nokia.com> Sender: netdev-owner@vger.kernel.org List-ID: > -----Original Message----- > From: R=C3=A9mi Denis-Courmont > To: ext jpo234@netscape.net > Cc: netdev@vger.kernel.org > Sent: Fri, 16 Jan 2009 3:09 pm > Subject: Re: Sending complete IPv6 packets without bypassing=20 netfilter/IPsec > On Friday 16 January 2009 13:12:40 ext jpo234@netscape.net, you wrote= : > > R=C3=A9mi, > > sorry, but a transport-layer raw socket is something I'd like to=20 avoid. > > The reason is, that I get the ready made packets from a tun device. > > Then you have the source address from the packet read from the TUN=20 device. But in my case this is a meaningless address that must not be visible=20 to the outside world. Maybe I should really go into details here. Please be patient, this is=20 going to be a lengthy mail. What I'm trying to do is to send IPsec encrypted OLSR messages. OLSR=20 messages as generated by the OLSR routing daemon are directed to the=20 IPv4 broadcast address or the all hosts multicast address for IPv6. For= =20 reasons that I won't explain in detail here I'm stuck with=20 255.255.255.255 and FE01::1. One OLSR daemon can sent messages to multiple interfaces, all of them=20 with the same destination address (e.g. the multicast/broadcast=20 address). IPsec tunnels are identified by a tuple {protocol,spi,dest=20 addr}. Protocol (ESP) and SPI are fixed and the destination address is=20 the same. Bugger. This means I can't specify different IPsec tunne l=20 associations for different interfaces, because they would only differ=20 in the source address which is not part of the tuple. The scheme I came up with is the following: I have a daemon that opens a tun device. This tun device has a local=20 address, say 1.2.3.254/24 (for readability I'm using IPv4). Then I'm=20 specifying IPsec SAs: Tunnel1: 1.2.3.254->1.2.3.ifidx1 SPI KEY; Tunnel2: 1.2.3.254->1.2.3.ifidx2 SPI KEY; ifidx1 and ifidx2 are the interface indices of the two network=20 interfaces that the OLSR daemon uses. Than I can add IPsec policies: 192.168.10.1->255.255.255.255 shall use Tunnel1 192.168.11.1->255.255.255.255 shall use Tunnel2 192.168.10.1 is the IP address of the first interface, 192.168.11.1 the= =20 address of the second interface. IPsec dutifully encrypts the packets and then the routing code stuffs=20 them into the above mentioned tun device. The encrypted packets have=20 the following addresses: for encrypted OLSR packets for interface 1: src 1.2.3.254 dst=20 1.2.3.ifidx1 for encrypted OLSR packets for interface 2: src 1.2.3.254 dst=20 1.2.3.ifidx2 Inside my daemon I simply extract the interface index from the=20 destination address, put another one (broadcast/multicast) in its place= =20 and send the packet out over their original destination interface. OLSR= =20 requires that the packets have the correct source address, though. IPv4= =20 is easy: just use 0.0.0.0 as source address and the stack will fill in=20 the right one. Works f ine here. Unfortunately this does not work for=20 IPv6, hence my question. Thanks for your time and kind regards Joerg