image image image image image

Warning

YOU ARE VIEWING AN OUTDATED DOCUMENT.

On This Page

Transparent IPsec Encryption and Decryption

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.

IPsec Hardware Offload: Crypto Offload

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.

IPsec Hardware Offload: Full Offload

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.

Configuring IPsec Full Offload

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.

  1. Delete the two SFs created on the BlueField device upon boot (one per port if the port is in switchdev mode). Run:

    # sudo mlnx-sf -a remove --uuid <UUID1>
    # sudo mlnx-sf -a remove --uuid <UUID2>

    You may retrieve the UUID (unique device ID) information by running the following command:

    # /opt/mellanox/iproute2/sbin/devlink dev show
    pci/0000:03:00.0
    pci/0000:03:00.1
    mdev/0214613e-60a3-4437-8de6-efbb41d8436e
    mdev/d3116441-04fb-4ea1-a2b3-63fb739e0f4a

    For example:

    # sudo mlnx-sf -a remove --uuid 0214613e-60a3-4437-8de6-efbb41d8436e
    # sudo mlnx-sf -a remove --uuid d3116441-04fb-4ea1-a2b3-63fb739e0f4a
  2. Move the SR-IOV mode to legacy. Run on Arm:

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

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

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

    echo full > /sys/class/net/p0/compat/devlink/ipsec_mode
  4. Enable firmware steering. Run on Arm:

    echo dmfs > /sys/bus/pci/devices/0000\:03\:00.0/net/p0/compat/devlink/steering_mode
  5. Enable the switchdev SR-IOV mode. Run on Arm:

    devlink dev eswitch set pci/0000:03:00.0 mode switchdev
  6. To enable IPsec full offload on the second port, please perform steps 2-5 on pci/0000:03:00.1.

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:

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 DPUsLeft and Right, operating with a secured VXLAN channel. 

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.

    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: 

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

    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. 

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
   }
}

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

    ValueDescriptionNote
    noDo not configure HW offload, fail if not supportedExisting
    yesConfigure crypto HW offload if supported by the kernel, fail if not supportedExisting
    autoConfigure crypto HW offload if supported by the kernel, do not failExisting
    fullConfigure full HW offload if supported by the kernel, fail if not supportedNew

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

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

    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

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

Mind the following limitations:

FieldLimitation
reauth_timeIgnored if set
rekey_timeDo not use. Ignored if set.
rekey_bytesDo not use. Not supported and will fail if it is set.
rekey_packetsUse 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

    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"). 

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

    The following should appear. 

    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). 

    # swanctl -i --child bf

    The following should appear. 

    [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:

    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. 

    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.

OVS offload and IPsec IPv6 do not work together.