IPsec work and question about Linux routing?

Markku Savela <[email protected]>
Newsgroups gmane.network.routing.click
Message-ID <[email protected]>
I've been trying to add some RFC-4301 features into existing
IPsec. This is still very rough coding, haven't gotten to
test the inbound yet, due to problems getting the packets
out (see below).

The simple usermode test configuration (attached) does not
quite do what I want: it does not route the tunneled packets
coming in from tun0 (src=192.168.0.14, dst=192.168.0.15) to
eth1 as I expected (packets seem to disappear, I see them
on tun0 using wireshark).

The old simple-ipsec configuration

http://read.cs.ucla.edu/click/examples/simple-ipsec.click

Uses FromDevice/ToDevice and has to some dummy ARP handling
due to this. I thought KernelTun would be much easier and
cleaner to use, but it looks like the kernel does not do
the routing from tun device?

r is there some tweak that would enable it?
I do have the normal ip forward enabled...

cat /proc/sys/net/ipv4/ip_forward
1


My setup on Ubuntu linux (tun0 from Click)

eth1 Link encap:Ethernet  HWaddr 00:13:3b:02:b3:96
      inet addr:192.168.0.14  Bcast:192.168.0.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

tun0      Link encap:UNSPEC  HWaddr 
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
   inet addr:10.0.0.1  P-t-P:10.0.0.1  Mask:255.0.0.0
   UP POINTOPOINT RUNNING NOARP PROMISC MULTICAST  MTU:1500  Metric:1

_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click
ipsec.click (text/plain, 4.2 KB)
//
// IPsec test configuration
//

AddressInfo(
	// The "inner net" protected by the IPsec, and address of this host there
	net 10.0.0.1/8,
	// Address of the remote security gateway
	sgw 192.168.0.15,
	// My outer source address (I wish I didn't need to specify this)
	me 192.168.0.14)

host :: KernelTun(net);


t1 :: IPsecAdapter(ESP,AUTH 2,ENCR 12);
s1 :: IPsecSelector(REMOTE net);
a1 :: IPsecPolicyAction(TUNNEL sgw me, PROPOSAL t1);

// IPsec([SELECTOR, ACTION]*...) - the RFC-4301 SPD and SAD component
//
// 2 input ports:
//
// [0]IPsec - outbound IPv4/IPv6 packets. Check the packet
// and route the packet to output port based on the policy
// If the port is for IPsec transform, annotate packet with
// the security association (SA).
//
// [1]IPsec - policy check for inbound IPv4/IPv6 packets.
// Check the packet and applied IPsec against the policy.
// If the packet has IPsec, the tranformation/decapsulation
// must have been done and the packet annotated with the
// security association (SA) -- see IPsecInbound element.

// 4..N output ports:
//
// IPsec[0] - BYPASS outbound packets from input port 0
// (packets that don't require IPsec).
//
// IPsec[1] - inbound packets from input port 1 which PASS
// the policy checks.
//
// IPsec[2] - inbound or outbound packets that fail policy
// check (DISCARD)
//
// IPsec[3] - outbound packets which triggered ACQUIRE
// processing that was not completed -- complete security
// association not available. The packet is annotated with
// the LARVAL outbound SA, that triggered ACQUIRE.
//
// IPsec[4..N-1] - the supported outbound IPsec transform
// pipelines. The first element in chain must be derived
// from IPsecTransform, which provides the transform/proposal
// information for the IPsec element (IPsecAdapter is one, and
// provides adaptation of security association to the "old"
// SADataTuple, which is used by existing old elements).

host ->
     // using "fixed" policy with only one selector to
     // action (s1 -> a1)
     [0] ipsec::IPsec(SELECTOR s1, ACTION a1);

ipsec[0] -> host;	// BYPASS
ipsec[1] -> host;	// PASS
ipsec[2] -> Discard;	// DISCARD
ipsec[3] -> Discard;	// ACQUIRE
// For now, only one example pipeline using old
// element for "HMAC-SHA + AES" (only for IPv4)
ipsec[4]
    -> t1
    -> IPsecESPEncap()
    -> IPsecAuthHMACSHA1(0)
    -> IPsecAES(1)
    -> IPsecEncap(esp)
    -> FixIPSrc(me)
    -> host;


// IPsecInbound - the IPsec frontend for inbound IPv4/IPv6 packets.
//
// 1 input port:
//
// [0]IPsecInbound - check if the packet requires IPsec processing
// (has ESP or AH) and route to appropriate output port.
//
// 1..N ouput ports:
//
// [0]IPsecInbound - plain inbound IP packets, not having IPsec
// headers -- annotation for security association is NULL.
//
// [1..N-1] - the supported inbound IPsec transform pipelines.
// The first element in chain must be derived from IPsecTransform,
// which provides the transform/proposal information for the IPsec
// element (IPsecAdapter is one, and provides adaptation of security
// association to the "old" SADataTuple, which is used by existing
// old elements).
// The packet is passed to output as is (no decapsulation in IPsecInbound),
// but the annotation for the inbound security association determined
// by the AH or ESP is set.

FromDevice(eth1)
	-> Strip(14)
	-> inbound :: IPsecInbound(ipsec);

inbound[0]
	-> [1] ipsec;
// For now, only one example pipeline using old
// element for "HMAC-SHA + AES" (only for IPv4)
inbound[1]
	-> [1]t1[1]
	-> StripIPHeader()
	-> IPsecAES(0)
	-> IPsecAuthHMACSHA1(1)
	-> IPsecESPUnencap()
	-> CheckIPHeader()
	-> [1] ipsec;

// IPsecKM(IPSEC, [SELECTOR, SA]*...)
//
// Simple fixed manual key provider for processing the
// ACQUIRE generated by the IPsec. The ACQUIRE matching
// the sgw (selector vpn) is served by the provided fixed
// key data (sa) resulting one inbound and one outbound
// SA.
//
// IPsecKM would be the base class for elements that
// implement real key management like IKE, either
// directly within Click or provide a adapter to
// external key manager.

vpn :: IPsecSelector(REMOTE sgw);
sa :: IPsecSAData(
   SPI 1000,
   PROTO 3,
   ENCR 12 \<0123456789abcdef0123456789abcdef>,
   AUTH 2  \<0123456789abcdef0123456789abcdef>);
km::IPsecKM(ipsec, SELECTOR vpn, SA sa);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.