blob: 57b30f452e535af5b658523b4ad7a0b5522d1223 [file] [log] [blame]
Gabriel Oginski4e88e042022-06-29 12:54:30 +00001.. _vpp_sswan_doc:
2
3VPP-SSWAN
4=======================
5
6``VPP-SSWAN`` is a StrongSwan plugin that helps offloading Strongswan IPsec ESP
7process from Linux Kernel to ``VPP``.
8
Fan Zhangad215f22023-03-01 14:45:46 +00009The ``VPP-SSWAN`` takes advantage of ``StrongSwan`` extendable plugin design
10and translates ``StrongSwan`` SA creation/deletion and routing
11update operations into ``VPP`` C API calls. The successful execution of the
12API calls means the operations shall be performed by VPP smoothly.
13
14Inside ``VPP-SSWAN``, the kernel-vpp plugin is an interface to the IPsec and
15networking backend for `VPP <https://wiki.fd.io/view/VPP>`__ platform using
16the `VPP C API <https://wiki.fd.io/view/VPP/How_To_Use_The_C_API>`__.
Gabriel Oginski4e88e042022-06-29 12:54:30 +000017It provides address and routing lookup functionality and installs routes for
18IPsec traffic.
Fan Zhangad215f22023-03-01 14:45:46 +000019
20The plugin also installs and maintains Security Associations and Policies to
21the `VPP IPsec <https://wiki.fd.io/view/VPP/IPSec_and_IKEv2#IPSec>`__.
22
23Since ``StrongSwan`` expects both IKE and IPsec traffic coming through the
24same network protected interfaces, the ``VPP-SSWAN`` expects the IKE traffic
25being diverted to Linux Kernel through the help of
26`VPP Linux Control Plane <https://s3-docs.fd.io/vpp/22.10/developer/plugins/
27lcp.html>`__. It is important to notice that due to LCP is a Tun/Tap interface,
28the IPsec performance will be limited by it if Transport mode of IPsec is used.
Gabriel Oginski4e88e042022-06-29 12:54:30 +000029
30Prerequisites
31-------------
32
33``VPP`` in release mode should be built before compiling ``vpp-swan plugin``.
Fan Zhangad215f22023-03-01 14:45:46 +000034User may install ``StrongSwan`` prior to compile the plugin. However the
35plugin requires downloading ``StrongSwan`` source to include some of its
36header files to compile ``VPP-SSWAN``. In addition ``libsystemd-dev``
37should be installed prior to compile the plugin.
38
39Please Note: ONLY Strongswan version ``5.9.5`` and ``5.9.6`` were tested with
40this plugin.
Gabriel Oginski4e88e042022-06-29 12:54:30 +000041
42Build VPP Strongswan Plugin
43-------------
44
Fan Zhangad215f22023-03-01 14:45:46 +000045``VPP-SSWAN`` requires ``StrongSwan`` source to compile. To obtain
46``StrongSwan`` the simplest way is to run the following commands:
47
48::
49
50 cd path/to/vpp/external/strongswan/vpp_swan/
51 make all
52
53Or you may download ``StrongSwan`` from its github page. It is recommended to
54use ``Strongswan`` version ``5.9.6`` or ``5.9.5`` for ``VPP-SSWAN`` to be
55compiled and integrate. The following steps are required for manually download
56``Strongswan`` source:
Gabriel Oginski4e88e042022-06-29 12:54:30 +000057
58- download strongswan source code to:
59``path/to/vpp/build/external/downloads``
60
61- unzip source code strongswan to:
62``path/to/vpp/build-root/build-vpp-native/external/sswan``
63
64- check if you have installed packages: ``libsystemd-dev`` on your OS
65
66- configure strongswan by:
Fan Zhangad215f22023-03-01 14:45:46 +000067``./autogen.sh``
Gabriel Oginski4e88e042022-06-29 12:54:30 +000068``./configure --prefix=/usr --sysconfdir=/etc --enable-libipsec
69--enable-systemd --enable-swanctl --disable-gmp --enable-openssl``
70
Gabriel Oginski4e88e042022-06-29 12:54:30 +000071- compile ``vpp-swan plugin`` by:
72
73::
74
Fan Zhangad215f22023-03-01 14:45:46 +000075 cd path/to/vpp/external/strongswan/vpp_swan/
76 make
Gabriel Oginski4e88e042022-06-29 12:54:30 +000077
Fan Zhangad215f22023-03-01 14:45:46 +000078Build/install Strongswan (Optional)
Gabriel Oginski4e88e042022-06-29 12:54:30 +000079-------------
80
Fan Zhangad215f22023-03-01 14:45:46 +000081In case you haven't installed ``Strongswan`` yet, you may use the following
82simple command to compile and install ``Strongswan`` from the downloaded source.
Gabriel Oginski4e88e042022-06-29 12:54:30 +000083
84::
85
Fan Zhangad215f22023-03-01 14:45:46 +000086 cd path/to/vpp/external/strongswan/vpp_swan/
87 make pull-swan
88 make install-swan
Gabriel Oginski4e88e042022-06-29 12:54:30 +000089
Fan Zhangad215f22023-03-01 14:45:46 +000090Install VPP-SWAN plugin into StrongSwan
Gabriel Oginski4e88e042022-06-29 12:54:30 +000091-------------
92
Fan Zhangad215f22023-03-01 14:45:46 +000093After the ``VPP-SSWAN`` plugin has been built and ``Strongswan`` was installed,
94the following command will install the ``VPP-SSWAN`` plugin into ``Strongswan``.
Gabriel Oginski4e88e042022-06-29 12:54:30 +000095
96::
97
Fan Zhangad215f22023-03-01 14:45:46 +000098 cd path/to/vpp/external/strongswan/vpp_swan/
99 make install
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000100
Fan Zhangad215f22023-03-01 14:45:46 +0000101Or you can manually copy ``libstrongswan-kernel-vpp.so`` into:
102``/usr/lib/ipsec/plugins``,
103and also ``kernel-vpp.conf`` into: ``/etc/strongswan.d/charon/``
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000104
Fan Zhangad215f22023-03-01 14:45:46 +0000105Now you can restart ``Strongswan`` by executing the following command:
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000106
107::
108
109 systemctl restart strongswan.service
110
111Configuration Strongswan
112-------------
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000113
Fan Zhangad215f22023-03-01 14:45:46 +0000114As an example, ``swanctl.conf`` file provides an example configuration to
115initialize connections between two endpoints.
116
117You may update the file based on your need and Copy into:
118``/etc/swanctl/conf.d/swanctl.conf``
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000119
120Configuration VPP
121-------------
122
Fan Zhangad215f22023-03-01 14:45:46 +0000123Some special treatment to VPP are required in your VPP ``startup.conf``.
124Since we use ``Strongswan`` to process IKE messages, we should disable VPP's
125IKEv2 plugin. Also as mentioned ``Linux Control Plane`` plugin is needed to
126route the traffic between VPP interface and Tun/Tap interface. To do so, simply
127adding the following commands:
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000128
129::
130
131 plugins {
132 plugin linux_cp_plugin.so { enable }
133 plugin ikev2_plugin.so { disable }
134 }
135
136 linux-cp {
137 lcp-sync
138 }
139
Fan Zhangad215f22023-03-01 14:45:46 +0000140Running VPP
141-------------
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000142
Fan Zhangad215f22023-03-01 14:45:46 +0000143Based on the provided sample ``swanctl.conf``, the following commands are
144required to be executed in ``VPP``:
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000145
146::
147
148 lcp create eth2 host-if eth2
149 set interface state eth2 up
150 set interface ip address eth2 192.168.0.2/24
151 set int state eth1 up
152 set int ip addr eth1 192.168.200.1/24
153
Fan Zhangad215f22023-03-01 14:45:46 +0000154In the commands above we assume ``eth2`` is the WAN interface to receive both
155IKE message and ESP encapsulated packets, and ``eth1`` is the LAN interface to
156receive plain packets to be encrypted. With the commands a ``Linux CP`` interface
157is created to mirror the ``eth2`` interface to Linux Kernel, and both interfaces
158were set the IP addresses followed by the ``swanctl.conf``.
159
160With the commands successfully executed and the security policy is succesfully
161agreed between two IKE daemons (one with VPP as IPsec processing engine), you may
162see the packets are encrypted/decrypted by VPP smoothly.
Gabriel Oginski4e88e042022-06-29 12:54:30 +0000163
164Misc
165-------------
166This plugin is based on:
167`https://github.com/matfabia/strongswan
168<https://github.com/matfabia/strongswan>`__
169
Fan Zhangad215f22023-03-01 14:45:46 +0000170Author: Matus Fabian <matfabia@cisco.com>