Libreswan's Online Documentation
View the Project on GitHub libreswan/libreswan.github.io
SupportThis GSOC 2017 project aimed at implementing the RFC 8229 - TCP Encapsulation of IKE and IPsec Packets. According to this, support was added for TCP encapsulation of packets in Pluto(Libreswan IKE daemon) to route out of stringent networks allowing only TCP traffic.
The RFC was in the draft stage when the project was started, but as of now, has been accepted as RFC 8229. There weren’t any major changes between the draft and the final RFC. The problem addressed is that when UDP is blocked on networks behind strict NATs, IKE should fall back to using TCP encapsulation and route out. The RFC specifies various standards for implementing this. It was ensured that the MUSTs in the RFC are implemented, so that Libreswan could be used as a client or a server with other standard implementations. Important thing to note is that kernel changes are yet to be made, so as of now Pluto ends up just negotiating the IPsec SA details, but installs an ESP/ESPinUDP SA. Three new ipsec.conf parameters were introduced and they direct the implementation of these changes:-
The last two are per conn options to be defined in a connection on the client side when required.
These features have been implemented during the project duration:-
All the listening, receiving and sending logic for TCP was implemented using callbacks in libevent’s evconnlistener and bufferevent structures. Some core structures had to be updated to have new members. Few new test cases were added specific to these changes. The different test cases test different functionalities - fallback to TCP from UDP, direct TCP, NAT and rekey.
A side task was adding of IPsec policy holes for IKE packets. Pluto initially used socket bypass options for these, but now bypass policies are added for the IKE ports and also for ICMPv6 neighbor discovery packets.
Some extras in the RFC that weren’t implemented due to time and difficulty constraints:-
These things comprise the future tasks that could be implemented to have a robust support for TCP.
The current implementation successfully interoperated with an unreleased implementation by Apple Inc.
All the relevant changes were made in three commits:
This project was done by Mayank Totale(mtotale@gmail.com) as a part of his Google Summer of Code, under the guidance of Paul Wouters.