IPsec Functionality

Warning

For NVIDIA® BlueField®-2 DPUs only: If your target application utilizes 100Gb/s or higher bandwidth, where a substantial part of the bandwidth is allocated for IPsec traffic, please refer to the NVIDIA BlueField-2 DPUs Product Release Notes to learn about a potential bandwidth limitation. To access the relevant product release notes, please contact your NVIDIA sales representative.

BlueField DPU can offload IPsec operations transparently from the host CPU. This means that the host does not need to be aware that network traffic is encrypted before hitting the wire or decrypted after coming off the wire. IPsec operations can be run on the DPU in software on the Arm cores or in the accelerator block.

Please refer to the community post "BlueField IP Forwarding and IPsec SPI RSS" for configuration and tuning instructions for optimal performance results.

Warning

This feature is supported only on BlueField-2 based platforms.

IPsec hardware crypto offload, also known as IPsec inline offload or IPsec aware offload, enables the user to offload IPsec crypto encryption and decryption operations to the hardware, leaving the encapsulation/decapsulation task to the software.

Please refer to the MLNX_OFED documentation under Features Overview and Configuration > Ethernet Network > IPsec Crypto Offload for more information on enabling and configuring this feature.

Please note that to use IPsec crypto offload with OVS, you must disable hardware offloads.

Warning

This feature is supported only on BlueField-2 based platforms.

IPsec full offload offloads both IPsec crypto and IPsec encapsulation to the hardware. IPsec full offload is configured on the Arm via the uplink netdev. The following figure illustrates IPsec full offload operation in hardware.

IPsec_Full_Offload.png

Configuring IPsec Full Offload

Warning

If you are working directly with the ip xfrm tool, you must use the /opt/mellanox/iproute2/sbin/ip to benefit from IPsec full offload support.

Explicitly enable IPsec full offload on the Arm cores before full offload rule is configured.

Warning

If an OVS VXLAN tunnel configuration already exists, please stop openvswitch service prior to performing the steps below and restart the service afterwards.

  1. Move the eswitch mode to legacy. Run on Arm:

    Copy
    Copied!
                

    devlink dev eswitch set pci/0000:03:00.0 mode legacy

    Warning

    Changing switchdev mode (legacy/switchdev) causes a recovery on the PF. Therefore, please allow 5 seconds between each command.

    If this command produces an error, please refer to "Unable to configure legacy mode" troubleshooting topic.

  2. Set the IPsec to full offload. Run on Arm:

    Copy
    Copied!
                

    echo full > /sys/class/net/p0/compat/devlink/ipsec_mode

  3. Enable firmware steering. Run on Arm:

    Copy
    Copied!
                

    echo dmfs > /sys/bus/pci/devices/0000\:03\:00.0/net/p0/compat/devlink/steering_mode

  4. Enable the eswitch switchdev mode. Run on Arm:

    Copy
    Copied!
                

    devlink dev eswitch set pci/0000:03:00.0 mode switchdev

  5. To enable IPsec full offload on the second port, please perform steps 2-5 on pci/0000:03:00.1.

Warning

To use IPsec full offload with strongSwan, please refer to section "IPsec Full Offload strongSwan Support".

To configure IPsec rules, please follow the instructions in MLNX_OFED documentation under Features Overview and Configuration > Ethernet Network > IPsec Crypto Offload > Configuring Security Associations for IPsec Offloads but, instead of the parameter "offload", use "full_offload" to achieve IPsec full offload.

Configuring IPsec Rules with iproute2

The following example configures IPsec full offload rules with local address 192.168.1.64 and remote address 192.168.1.65:

Copy
Copied!
            

ip xfrm state add src 192.168.1.64/24 dst 192.168.1.65/24 proto esp spi 0x4834535d reqid 0x4834535d mode transport aead 'rfc4106(gcm(aes))' 0xc57f6f084ebf8c6a71dd9a053c2e03b94c658a9bf00dd25780e73948931d10d08058a27c 128 full_offload dev p0 dir out sel src 192.168.1.64 dst 192.168.1.65 ip xfrm state add src 192.168.1.65/24 dst 192.168.1.64/24 proto esp spi 0x2be60844 reqid 0x2be60844 mode transport aead 'rfc4106(gcm(aes))' 0xacca06b66489011d3c1c21f1a36d925cf7449d3aeaa6fe534446c3a8f8bd5f5fdc266589 128 full_offload dev p0 dir in sel src 192.168.1.65 dst 192.168.1.64 sudo ip xfrm policy add src 192.168.1.64 dst 192.168.1.65 dir out tmpl src 192.168.1.64/24 dst 192.168.1.65/24 proto esp reqid 0x4834535d mode transport sudo ip xfrm policy add src 192.168.1.65 dst 192.168.1.64 dir in tmpl src 192.168.1.65/24 dst 192.168.1.64/24 proto esp reqid 0x2be60844 mode transport sudo ip xfrm policy add src 192.168.1.65 dst 192.168.1.64 dir fwd tmpl src 192.168.1.65/24 dst 192.168.1.64/24 proto esp reqid 0x2be60844 mode transport


IPsec Full Offload strongSwan Support

BlueField DPU supports configuring IPsec rules using strongSwan 5.9.0bf (yet to be upstreamed) which supports new fields in swanctl.conf file.

The following figure illustrates an example with two BlueField DPUs , Left and Right, operating with a secured VXLAN channel .

strongSwan_Example.png

Support for strongSwan IPsec full HW offload requires using VXLAN together with IPSec as shown here .

  1. Follow the procedure under section "Configuring IPsec Full Offload".

  2. Follow the procedure under section "VXLAN Tunneling Offload" to configure VXLAN on Arm.

    Warning

    Make sure the MTU of the PF used by VXLAN is at least 50 bytes larger than VXLAN-REP MTU.

  3. Enable tc offloading. Run:

    Copy
    Copied!
                

    ethtool -K <PF> hw-tc-offload on

    Warning

    Do not add the PF itself using "ovs-vsctl add-port" to the OVS.

Setting IPSec Full Offload Using strongSwan

strongSwan configures IPSec HW full offload using a new value added to its configuration file swanctl.conf.

The file should be placed under "sysconfdir" which by default can be found at /etc/swanctl/swanctl.conf.

The terms Left (BFL) and Right (BFR) are used to identify the two nodes that communicate (corresponding with the figure under section "IPsec Full Offload strongSwan Support").

In this example, 192.168.50.1 is used for the left PF uplink and 192.168.50.2 for the right PF uplink.

Copy
Copied!
            

connections { BFL-BFR { local_addrs = 192.168.50.1 remote_addrs = 192.168.50.2   local { auth = psk id = host1 } remote { auth = psk id = host2 }   children { bf { local_ts = 192.168.50.1/24 [udp/4789] remote_ts = 192.168.50.2/24 [udp/4789] esp_proposals = aes128gcm128-x25519-esn mode = transport policies_fwd_out = yes hw_offload = full } } version = 2 mobike = no reauth_time = 0 proposals = aes128-sha256-x25519 } }   secrets { ike-BF { id-host1 = host1 id-host2 = host2 secret = 0sv+NkxY9LLZvwj4qCC2o/gGrWDF2d21jL } }

Warning

BFB installation will place two example swanctl.conf files for both Left and Right nodes (BFL.swanctl.conf and BFR.swanctl.conf respectively) in the strongSwan conf.d directory. Please move one of them manually to the other machine and edit it according to your configuration.

Note that:

  • "hw_offload = full" is responsible for configuring IPSec HW full offload

    Full offload support has been added to the existing hw_offload field and preserves backward compatibility

    Value

    Description

    Note

    no

    Do not configure HW offload, fail if not supported

    Existing

    yes

    Configure crypto HW offload if supported by the kernel, fail if not supported

    Existing

    auto

    Configure crypto HW offload if supported by the kernel, do not fail

    Existing

    full

    Configure full HW offload if supported by the kernel, fail if not supported

    New

    Warning

    Whenever the value of hw_offload is changed, strongSwan configuration must be reloaded.

    Warning

    Switching to crypto HW offload requires setting up devlink/ipsec_mode to "none" beforehand.

    Warning

    Switching to full HW offload requires setting up devlink/ipsec_mode to "full" beforehand

  • "[udp/4789]" is crucial for instructing strongSwan to IPSec only VXLAN communication

    Warning

    Full HW offload can only be done on what is streamed over VXLAN.

Mind the following limitations:

Field

Limitation

reauth_time

Ignored if set

rekey_time

Do not use. Ignored if set.

rekey_bytes

Do not use. Not supported and will fail if it is set.

rekey_packets

Use for rekeying

Running strongSwan Example

Notes:

  • IPsec daemons are started by systemd strongswan-starter.service

  • Use systemctl [start | stop | restart] to control IPsec daemons through strongswan-starter.service. For example, to restart, the command systemctl restart strongswan-starter.service will effectively do the same thing as ipsec restart.

    Important

    Do not use ipsec script to restart/stop/start.

    If you are using the ipsec script, then, in order to restart or start the daemons, openssl.cnf.orig must be copied to openssl.cnf before performing ipsec restart or ipsec start. Then openssl.cnf.mlnx can be copied to openssl.cnf after restart or start. Failing to do so can result in errors since openssl.cnf.mlnx allows IPsec PK and RNG hardware offload via the OpenSSL plugin.

    • On Ubuntu/Debian/Yocto, openssl.cnf* can be found under /etc/ssl/

    • On CentOS, openssl.cnf* can be found under /etc/pki/tls/

  • The strongSwan package installs openssl.cnf config files to enable hardware offload of PK and RNG operations via the OpenSSL plugin

  • The OpenSSL dynamic engine is used to carry out the offload to hardware. OpenSSL dynamic engine ID is "pka".

Procedure:

  1. Perform the following on Left and Right devices (corresponding with the figure under section "IPsec Full Offload strongSwan Support").

    Copy
    Copied!
                

    # systemctl start strongswan-starter.service # swanctl --load-all

    The following should appear.

    Copy
    Copied!
                

    Starting strongSwan 5.9.0bf IPsec [starter]... no files found matching '/etc/ipsec.d/*.conf' # deprecated keyword 'plutodebug' in config setup # deprecated keyword 'virtual_private' in config setup loaded ike secret 'ike-BF' no authorities found, 0 unloaded no pools found, 0 unloaded loaded connection 'BFL-BFR' successfully loaded 1 connections, 0 unloaded

  2. Perform the actual connection on one side only (client, Left in this case).

    Copy
    Copied!
                

    # swanctl -i --child bf

    The following should appear.

    Copy
    Copied!
                

    [IKE] initiating IKE_SA BFL-BFR[1] to 192.168.50.2 [ENC] generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ] [NET] sending packet: from 192.168.50.1[500] to 192.168.50.2[500] (240 bytes) [NET] received packet: from 192.168.50.2[500] to 192.168.50.1[500] (273 bytes) [ENC] parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(FRAG_SUP) N(HASH_ALG) N(CHDLESS_SUP) N(MULT_AUTH) ] [CFG] selected proposal: IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/CURVE_25519 [IKE] received 1 cert requests for an unknown ca [IKE] authentication of 'host1' (myself) with pre-shared key [IKE] establishing CHILD_SA bf{1} [ENC] generating IKE_AUTH request 1 [ IDi N(INIT_CONTACT) IDr AUTH N(USE_TRANSP) SA TSi TSr N(MULT_AUTH) N(EAP_ONLY) N(MSG_ID_SYN_SUP) ] [NET] sending packet: from 192.168.50.1[500] to 192.168.50.2[500] (256 bytes) [NET] received packet: from 192.168.50.2[500] to 192.168.50.1[500] (224 bytes) [ENC] parsed IKE_AUTH response 1 [ IDr AUTH N(USE_TRANSP) SA TSi TSr N(AUTH_LFT) ] [IKE] authentication of 'host2' with pre-shared key successful [IKE] IKE_SA BFL-BFR[1] established between 192.168.50.1[host1]...192.168.50.2[host2] [IKE] scheduling reauthentication in 10027s [IKE] maximum IKE_SA lifetime 11107s [CFG] selected proposal: ESP:AES_GCM_16_128/NO_EXT_SEQ [IKE] CHILD_SA bf{1} established with SPIs ce543905_i c60e98a2_o and TS 192.168.50.1/32 === 192.168.50.2/32 initiate completed successfully

    You may now send encrypted data over the HOST VF interface (192.168.70.[1|2]) configured for VXLAN.

Building strongSwan

Do this only if you want to build your own BFB and would like to rebuild strongSwan.

  1. strongSwan IPsec full version can be found here (tag: 5.9.0bf).

  2. Install dependencies mentioned here. libgmp-dev is missing from that list, so make sure to install that as well.

  3. Git clone https://github.com/Mellanox/strongswan.git.

  4. Git checkout BF-5.9.0.

  5. Run "autogen.sh" within the strongSwan repo.

  6. Run the following:

    Copy
    Copied!
                

    configure --enable-openssl --disable-random --prefix=/usr/local --sysconfdir=/etc --enable-systemd make make install

Note:

  • --enable-systemd enables the systemd service for strongSwan service present inside github repo (see step 3) at init/systemd-starter/strongswan-starter.service.in. This service file is meant for Ubuntu, Debian and Yocto distributions. For CentOS, the contents of the above file must be replaced by the one present in systemd-conf/strongswan-starter.service.in.centos (inside the github repo) before running the configure script above.

  • When building strongSwan on your own, the openssl.cnf.mlnx file, required for PK and RNG HW offload via OpenSSL plugin, is not installed. It must be copied over manually from github repo inside the openssl-conf directory. See section "Running Strongswan Example" for important notes.

    Warning

    The openssl.cnf.mlnx file references PKA engine shared objects. libpka (version 1.3 or later) and openssl (version 1.1.1) must be installed for this to work.

IPsec Full Offload and OVS Offload

IPsec full offload configuration works with and is transparent to OVS offload. This means all packets from OVS offload are encrypted by IPsec rules.

The following figure illustrates the interaction between IPsec full offload and OVS VXLAN offload.

IPsec_Full_Offload_and_OVS_Offload.png

Warning

OVS offload and IPsec IPv6 do not work together.


© Copyright 2023, NVIDIA. Last updated on Sep 9, 2023.