examples/ipsec-secgw: add stats interval argument
[dpdk.git] / doc / guides / sample_app_ug / ipsec_secgw.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2016-2017 Intel Corporation.
3     Copyright (C) 2020 Marvell International Ltd.
4
5 IPsec Security Gateway Sample Application
6 =========================================
7
8 The IPsec Security Gateway application is an example of a "real world"
9 application using DPDK cryptodev framework.
10
11 Overview
12 --------
13
14 The application demonstrates the implementation of a Security Gateway
15 (not IPsec compliant, see the Constraints section below) using DPDK based on RFC4301,
16 RFC4303, RFC3602 and RFC2404.
17
18 Internet Key Exchange (IKE) is not implemented, so only manual setting of
19 Security Policies and Security Associations is supported.
20
21 The Security Policies (SP) are implemented as ACL rules, the Security
22 Associations (SA) are stored in a table and the routing is implemented
23 using LPM.
24
25 The application classifies the ports as *Protected* and *Unprotected*.
26 Thus, traffic received on an Unprotected or Protected port is consider
27 Inbound or Outbound respectively.
28
29 The application also supports complete IPsec protocol offload to hardware
30 (Look aside crypto accelerator or using ethernet device). It also support
31 inline ipsec processing by the supported ethernet device during transmission.
32 These modes can be selected during the SA creation configuration.
33
34 In case of complete protocol offload, the processing of headers(ESP and outer
35 IP header) is done by the hardware and the application does not need to
36 add/remove them during outbound/inbound processing.
37
38 For inline offloaded outbound traffic, the application will not do the LPM
39 lookup for routing, as the port on which the packet has to be forwarded will be
40 part of the SA. Security parameters will be configured on that port only, and
41 sending the packet on other ports could result in unencrypted packets being
42 sent out.
43
44 The Path for IPsec Inbound traffic is:
45
46 *  Read packets from the port.
47 *  Classify packets between IPv4 and ESP.
48 *  Perform Inbound SA lookup for ESP packets based on their SPI.
49 *  Perform Verification/Decryption (Not needed in case of inline ipsec).
50 *  Remove ESP and outer IP header (Not needed in case of protocol offload).
51 *  Inbound SP check using ACL of decrypted packets and any other IPv4 packets.
52 *  Routing.
53 *  Write packet to port.
54
55 The Path for the IPsec Outbound traffic is:
56
57 *  Read packets from the port.
58 *  Perform Outbound SP check using ACL of all IPv4 traffic.
59 *  Perform Outbound SA lookup for packets that need IPsec protection.
60 *  Add ESP and outer IP header (Not needed in case protocol offload).
61 *  Perform Encryption/Digest (Not needed in case of inline ipsec).
62 *  Routing.
63 *  Write packet to port.
64
65 The application supports two modes of operation: poll mode and event mode.
66
67 * In the poll mode a core receives packets from statically configured list
68   of eth ports and eth ports' queues.
69
70 * In the event mode a core receives packets as events. After packet processing
71   is done core submits them back as events to an event device. This enables
72   multicore scaling and HW assisted scheduling by making use of the event device
73   capabilities. The event mode configuration is predefined. All packets reaching
74   given eth port will arrive at the same event queue. All event queues are mapped
75   to all event ports. This allows all cores to receive traffic from all ports.
76   Since the underlying event device might have varying capabilities, the worker
77   threads can be drafted differently to maximize performance. For example, if an
78   event device - eth device pair has Tx internal port, then application can call
79   rte_event_eth_tx_adapter_enqueue() instead of regular rte_event_enqueue_burst().
80   So a thread which assumes that the device pair has internal port will not be the
81   right solution for another pair. The infrastructure added for the event mode aims
82   to help application to have multiple worker threads by maximizing performance from
83   every type of event device without affecting existing paths/use cases. The worker
84   to be used will be determined by the operating conditions and the underlying device
85   capabilities. **Currently the application provides non-burst, internal port worker
86   threads and supports inline protocol only.** It also provides infrastructure for
87   non-internal port however does not define any worker threads.
88
89 Additionally the event mode introduces two submodes of processing packets:
90
91 * Driver submode: This submode has bare minimum changes in the application to support
92   IPsec. There are no lookups, no routing done in the application. And for inline
93   protocol use case, the worker thread resembles l2fwd worker thread as the IPsec
94   processing is done entirely in HW. This mode can be used to benchmark the raw
95   performance of the HW. The driver submode is selected with --single-sa option
96   (used also by poll mode). When --single-sa option is used in conjunction with event
97   mode then index passed to --single-sa is ignored.
98
99 * App submode: This submode has all the features currently implemented with the
100   application (non librte_ipsec path). All the lookups, routing follows existing
101   methods and report numbers that can be compared against regular poll mode
102   benchmark numbers.
103
104 Constraints
105 -----------
106
107 *  No IPv6 options headers.
108 *  No AH mode.
109 *  Supported algorithms: AES-CBC, AES-CTR, AES-GCM, 3DES-CBC, HMAC-SHA1 and NULL.
110 *  Each SA must be handle by a unique lcore (*1 RX queue per port*).
111
112 Compiling the Application
113 -------------------------
114
115 To compile the sample application see :doc:`compiling`.
116
117 The application is located in the ``ipsec-secgw`` sub-directory.
118
119
120 Running the Application
121 -----------------------
122
123 The application has a number of command line options::
124
125
126    ./<build_dir>/examples/dpdk-ipsec-secgw [EAL options] --
127                         -p PORTMASK -P -u PORTMASK -j FRAMESIZE
128                         -l -w REPLAY_WINDOW_SIZE -e -a
129                         -c SAD_CACHE_SIZE
130                         -t STATISTICS_INTERVAL
131                         -s NUMBER_OF_MBUFS_IN_PACKET_POOL
132                         -f CONFIG_FILE_PATH
133                         --config (port,queue,lcore)[,(port,queue,lcore)]
134                         --single-sa SAIDX
135                         --cryptodev_mask MASK
136                         --transfer-mode MODE
137                         --event-schedule-type TYPE
138                         --rxoffload MASK
139                         --txoffload MASK
140                         --reassemble NUM
141                         --mtu MTU
142                         --frag-ttl FRAG_TTL_NS
143
144 Where:
145
146 *   ``-p PORTMASK``: Hexadecimal bitmask of ports to configure.
147
148 *   ``-P``: *optional*. Sets all ports to promiscuous mode so that packets are
149     accepted regardless of the packet's Ethernet MAC destination address.
150     Without this option, only packets with the Ethernet MAC destination address
151     set to the Ethernet address of the port are accepted (default is enabled).
152
153 *   ``-u PORTMASK``: hexadecimal bitmask of unprotected ports
154
155 *   ``-j FRAMESIZE``: *optional*. data buffer size (in bytes),
156     in other words maximum data size for one segment.
157     Packets with length bigger then FRAMESIZE still can be received,
158     but will be segmented.
159     Default value: RTE_MBUF_DEFAULT_BUF_SIZE (2176)
160     Minimum value: RTE_MBUF_DEFAULT_BUF_SIZE (2176)
161     Maximum value: UINT16_MAX (65535).
162
163 *   ``-l``: enables code-path that uses librte_ipsec.
164
165 *   ``-w REPLAY_WINDOW_SIZE``: specifies the IPsec sequence number replay window
166     size for each Security Association (available only with librte_ipsec
167     code path).
168
169 *   ``-e``: enables Security Association extended sequence number processing
170     (available only with librte_ipsec code path).
171
172 *   ``-a``: enables Security Association sequence number atomic behavior
173     (available only with librte_ipsec code path).
174
175 *   ``-c``: specifies the SAD cache size. Stores the most recent SA in a per
176     lcore cache. Cache represents flat array containing SA's indexed by SPI.
177     Zero value disables cache.
178     Default value: 128.
179
180 *   ``-t``: specifies the statistics screen update interval in seconds. If set
181     to zero or omitted statistics screen is disabled.
182     Default value: 0.
183
184 *   ``-s``: sets number of mbufs in packet pool, if not provided number of mbufs
185     will be calculated based on number of cores, eth ports and crypto queues.
186
187 *   ``-f CONFIG_FILE_PATH``: the full path of text-based file containing all
188     configuration items for running the application (See Configuration file
189     syntax section below). ``-f CONFIG_FILE_PATH`` **must** be specified.
190     **ONLY** the UNIX format configuration file is accepted.
191
192 *   ``--config (port,queue,lcore)[,(port,queue,lcore)]``: in poll mode determines
193     which queues from which ports are mapped to which cores. In event mode this
194     option is not used as packets are dynamically scheduled to cores by HW.
195
196 *   ``--single-sa SAIDX``: in poll mode use a single SA for outbound traffic,
197     bypassing the SP on both Inbound and Outbound. This option is meant for
198     debugging/performance purposes. In event mode selects driver submode, SA index
199     value is ignored.
200
201 *   ``--cryptodev_mask MASK``: hexadecimal bitmask of the crypto devices
202     to configure.
203
204 *   ``--transfer-mode MODE``: sets operating mode of the application
205     "poll"  : packet transfer via polling (default)
206     "event" : Packet transfer via event device
207
208 *   ``--event-schedule-type TYPE``: queue schedule type, applies only when
209     --transfer-mode is set to event.
210     "ordered"  : Ordered (default)
211     "atomic"   : Atomic
212     "parallel" : Parallel
213     When --event-schedule-type is set as RTE_SCHED_TYPE_ORDERED/ATOMIC, event
214     device will ensure the ordering. Ordering will be lost when tried in PARALLEL.
215
216 *   ``--rxoffload MASK``: RX HW offload capabilities to enable/use on this port
217     (bitmask of RTE_ETH_RX_OFFLOAD_* values). It is an optional parameter and
218     allows user to disable some of the RX HW offload capabilities.
219     By default all HW RX offloads are enabled.
220
221 *   ``--txoffload MASK``: TX HW offload capabilities to enable/use on this port
222     (bitmask of RTE_ETH_TX_OFFLOAD_* values). It is an optional parameter and
223     allows user to disable some of the TX HW offload capabilities.
224     By default all HW TX offloads are enabled.
225
226 *   ``--reassemble NUM``: max number of entries in reassemble fragment table.
227     Zero value disables reassembly functionality.
228     Default value: 0.
229
230 *   ``--mtu MTU``: MTU value (in bytes) on all attached ethernet ports.
231     Outgoing packets with length bigger then MTU will be fragmented.
232     Incoming packets with length bigger then MTU will be discarded.
233     Default value: 1500.
234
235 *   ``--frag-ttl FRAG_TTL_NS``: fragment lifetime (in nanoseconds).
236     If packet is not reassembled within this time, received fragments
237     will be discarded. Fragment lifetime should be decreased when
238     there is a high fragmented traffic loss in high bandwidth networks.
239     Should be lower for low number of reassembly buckets.
240     Valid values: from 1 ns to 10 s. Default value: 10000000 (10 s).
241
242
243 The mapping of lcores to port/queues is similar to other l3fwd applications.
244
245 For example, given the following command line to run application in poll mode::
246
247     ./<build_dir>/examples/dpdk-ipsec-secgw -l 20,21 -n 4 --socket-mem 0,2048       \
248            --vdev "crypto_null" -- -p 0xf -P -u 0x3             \
249            --config="(0,0,20),(1,0,20),(2,0,21),(3,0,21)"       \
250            -f /path/to/config_file --transfer-mode poll         \
251
252 where each option means:
253
254 *   The ``-l`` option enables cores 20 and 21.
255
256 *   The ``-n`` option sets memory 4 channels.
257
258 *   The ``--socket-mem`` to use 2GB on socket 1.
259
260 *   The ``--vdev "crypto_null"`` option creates virtual NULL cryptodev PMD.
261
262 *   The ``-p`` option enables ports (detected) 0, 1, 2 and 3.
263
264 *   The ``-P`` option enables promiscuous mode.
265
266 *   The ``-u`` option sets ports 0 and 1 as unprotected, leaving 2 and 3 as protected.
267
268 *   The ``--config`` option enables one queue per port with the following mapping:
269
270     +----------+-----------+-----------+---------------------------------------+
271     | **Port** | **Queue** | **lcore** | **Description**                       |
272     |          |           |           |                                       |
273     +----------+-----------+-----------+---------------------------------------+
274     | 0        | 0         | 20        | Map queue 0 from port 0 to lcore 20.  |
275     |          |           |           |                                       |
276     +----------+-----------+-----------+---------------------------------------+
277     | 1        | 0         | 20        | Map queue 0 from port 1 to lcore 20.  |
278     |          |           |           |                                       |
279     +----------+-----------+-----------+---------------------------------------+
280     | 2        | 0         | 21        | Map queue 0 from port 2 to lcore 21.  |
281     |          |           |           |                                       |
282     +----------+-----------+-----------+---------------------------------------+
283     | 3        | 0         | 21        | Map queue 0 from port 3 to lcore 21.  |
284     |          |           |           |                                       |
285     +----------+-----------+-----------+---------------------------------------+
286
287 *   The ``-f /path/to/config_file`` option enables the application read and
288     parse the configuration file specified, and configures the application
289     with a given set of SP, SA and Routing entries accordingly. The syntax of
290     the configuration file will be explained below in more detail. Please
291     **note** the parser only accepts UNIX format text file. Other formats
292     such as DOS/MAC format will cause a parse error.
293
294 *   The ``--transfer-mode`` option selects poll mode for processing packets.
295
296 Similarly for example, given the following command line to run application in
297 event app mode::
298
299     ./<build_dir>/examples/dpdk-ipsec-secgw -c 0x3 -- -P -p 0x3 -u 0x1       \
300            -f /path/to/config_file --transfer-mode event \
301            --event-schedule-type parallel                \
302
303 where each option means:
304
305 *   The ``-c`` option selects cores 0 and 1 to run on.
306
307 *   The ``-P`` option enables promiscuous mode.
308
309 *   The ``-p`` option enables ports (detected) 0 and 1.
310
311 *   The ``-u`` option sets ports 0 as unprotected, leaving 1 as protected.
312
313 *   The ``-f /path/to/config_file`` option has the same behavior as in poll
314     mode example.
315
316 *   The ``--transfer-mode`` option selects event mode for processing packets.
317
318 *   The ``--event-schedule-type`` option selects parallel ordering of event queues.
319
320
321 Refer to the *DPDK Getting Started Guide* for general information on running
322 applications and the Environment Abstraction Layer (EAL) options.
323
324 The application would do a best effort to "map" crypto devices to cores, with
325 hardware devices having priority. Basically, hardware devices if present would
326 be assigned to a core before software ones.
327 This means that if the application is using a single core and both hardware
328 and software crypto devices are detected, hardware devices will be used.
329
330 A way to achieve the case where you want to force the use of virtual crypto
331 devices is to only use the Ethernet devices needed (via the allow flag)
332 and therefore implicitly blocking all hardware crypto devices.
333
334 For example, something like the following command line:
335
336 .. code-block:: console
337
338     ./<build_dir>/examples/dpdk-ipsec-secgw -l 20,21 -n 4 --socket-mem 0,2048 \
339             -a 81:00.0 -a 81:00.1 -a 81:00.2 -a 81:00.3 \
340             --vdev "crypto_aesni_mb" --vdev "crypto_null" \
341             -- \
342             -p 0xf -P -u 0x3 --config="(0,0,20),(1,0,20),(2,0,21),(3,0,21)" \
343             -f sample.cfg
344
345
346 Configurations
347 --------------
348
349 The following sections provide the syntax of configurations to initialize
350 your SP, SA, Routing, Flow and Neighbour tables.
351 Configurations shall be specified in the configuration file to be passed to
352 the application. The file is then parsed by the application. The successful
353 parsing will result in the appropriate rules being applied to the tables
354 accordingly.
355
356
357 Configuration File Syntax
358 ~~~~~~~~~~~~~~~~~~~~~~~~~
359
360 As mention in the overview, the Security Policies are ACL rules.
361 The application parsers the rules specified in the configuration file and
362 passes them to the ACL table, and replicates them per socket in use.
363
364 Following are the configuration file syntax.
365
366 General rule syntax
367 ^^^^^^^^^^^^^^^^^^^
368
369 The parse treats one line in the configuration file as one configuration
370 item (unless the line concatenation symbol exists). Every configuration
371 item shall follow the syntax of either SP, SA, Routing, Flow or Neighbour
372 rules specified below.
373
374 The configuration parser supports the following special symbols:
375
376  * Comment symbol **#**. Any character from this symbol to the end of
377    line is treated as comment and will not be parsed.
378
379  * Line concatenation symbol **\\**. This symbol shall be placed in the end
380    of the line to be concatenated to the line below. Multiple lines'
381    concatenation is supported.
382
383
384 SP rule syntax
385 ^^^^^^^^^^^^^^
386
387 The SP rule syntax is shown as follows:
388
389 .. code-block:: console
390
391     sp <ip_ver> <dir> esp <action> <priority> <src_ip> <dst_ip>
392     <proto> <sport> <dport>
393
394
395 where each options means:
396
397 ``<ip_ver>``
398
399  * IP protocol version
400
401  * Optional: No
402
403  * Available options:
404
405    * *ipv4*: IP protocol version 4
406    * *ipv6*: IP protocol version 6
407
408 ``<dir>``
409
410  * The traffic direction
411
412  * Optional: No
413
414  * Available options:
415
416    * *in*: inbound traffic
417    * *out*: outbound traffic
418
419 ``<action>``
420
421  * IPsec action
422
423  * Optional: No
424
425  * Available options:
426
427    * *protect <SA_idx>*: the specified traffic is protected by SA rule
428      with id SA_idx
429    * *bypass*: the specified traffic traffic is bypassed
430    * *discard*: the specified traffic is discarded
431
432 ``<priority>``
433
434  * Rule priority
435
436  * Optional: Yes, default priority 0 will be used
437
438  * Syntax: *pri <id>*
439
440 ``<src_ip>``
441
442  * The source IP address and mask
443
444  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
445
446  * Syntax:
447
448    * *src X.X.X.X/Y* for IPv4
449    * *src XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
450
451 ``<dst_ip>``
452
453  * The destination IP address and mask
454
455  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
456
457  * Syntax:
458
459    * *dst X.X.X.X/Y* for IPv4
460    * *dst XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
461
462 ``<proto>``
463
464  * The protocol start and end range
465
466  * Optional: yes, default range of 0 to 0 will be used
467
468  * Syntax: *proto X:Y*
469
470 ``<sport>``
471
472  * The source port start and end range
473
474  * Optional: yes, default range of 0 to 0 will be used
475
476  * Syntax: *sport X:Y*
477
478 ``<dport>``
479
480  * The destination port start and end range
481
482  * Optional: yes, default range of 0 to 0 will be used
483
484  * Syntax: *dport X:Y*
485
486 Example SP rules:
487
488 .. code-block:: console
489
490     sp ipv4 out esp protect 105 pri 1 dst 192.168.115.0/24 sport 0:65535 \
491     dport 0:65535
492
493     sp ipv6 in esp bypass pri 1 dst 0000:0000:0000:0000:5555:5555:\
494     0000:0000/96 sport 0:65535 dport 0:65535
495
496
497 SA rule syntax
498 ^^^^^^^^^^^^^^
499
500 The successfully parsed SA rules will be stored in an array table.
501
502 The SA rule syntax is shown as follows:
503
504 .. code-block:: console
505
506     sa <dir> <spi> <cipher_algo> <cipher_key> <auth_algo> <auth_key>
507     <mode> <src_ip> <dst_ip> <action_type> <port_id> <fallback>
508     <flow-direction> <port_id> <queue_id> <udp-encap>
509
510 where each options means:
511
512 ``<dir>``
513
514  * The traffic direction
515
516  * Optional: No
517
518  * Available options:
519
520    * *in*: inbound traffic
521    * *out*: outbound traffic
522
523 ``<spi>``
524
525  * The SPI number
526
527  * Optional: No
528
529  * Syntax: unsigned integer number
530
531 ``<cipher_algo>``
532
533  * Cipher algorithm
534
535  * Optional: Yes, unless <aead_algo> is not used
536
537  * Available options:
538
539    * *null*: NULL algorithm
540    * *aes-128-cbc*: AES-CBC 128-bit algorithm
541    * *aes-192-cbc*: AES-CBC 192-bit algorithm
542    * *aes-256-cbc*: AES-CBC 256-bit algorithm
543    * *aes-128-ctr*: AES-CTR 128-bit algorithm
544    * *3des-cbc*: 3DES-CBC 192-bit algorithm
545
546  * Syntax: *cipher_algo <your algorithm>*
547
548 ``<cipher_key>``
549
550  * Cipher key, NOT available when 'null' algorithm is used
551
552  * Optional: Yes, unless <aead_algo> is not used.
553    Must be followed by <cipher_algo> option
554
555  * Syntax: Hexadecimal bytes (0x0-0xFF) concatenate by colon symbol ':'.
556    The number of bytes should be as same as the specified cipher algorithm
557    key size.
558
559    For example: *cipher_key A1:B2:C3:D4:A1:B2:C3:D4:A1:B2:C3:D4:
560    A1:B2:C3:D4*
561
562 ``<auth_algo>``
563
564  * Authentication algorithm
565
566  * Optional: Yes, unless <aead_algo> is not used
567
568  * Available options:
569
570     * *null*: NULL algorithm
571     * *sha1-hmac*: HMAC SHA1 algorithm
572
573 ``<auth_key>``
574
575  * Authentication key, NOT available when 'null' or 'aes-128-gcm' algorithm
576    is used.
577
578  * Optional: Yes, unless <aead_algo> is not used.
579    Must be followed by <auth_algo> option
580
581  * Syntax: Hexadecimal bytes (0x0-0xFF) concatenate by colon symbol ':'.
582    The number of bytes should be as same as the specified authentication
583    algorithm key size.
584
585    For example: *auth_key A1:B2:C3:D4:A1:B2:C3:D4:A1:B2:C3:D4:A1:B2:C3:D4:
586    A1:B2:C3:D4*
587
588 ``<aead_algo>``
589
590  * AEAD algorithm
591
592  * Optional: Yes, unless <cipher_algo> and <auth_algo> are not used
593
594  * Available options:
595
596    * *aes-128-gcm*: AES-GCM 128-bit algorithm
597    * *aes-192-gcm*: AES-GCM 192-bit algorithm
598    * *aes-256-gcm*: AES-GCM 256-bit algorithm
599
600  * Syntax: *cipher_algo <your algorithm>*
601
602 ``<aead_key>``
603
604  * Cipher key, NOT available when 'null' algorithm is used
605
606  * Optional: Yes, unless <cipher_algo> and <auth_algo> are not used.
607    Must be followed by <aead_algo> option
608
609  * Syntax: Hexadecimal bytes (0x0-0xFF) concatenate by colon symbol ':'.
610    Last 4 bytes of the provided key will be used as 'salt' and so, the
611    number of bytes should be same as the sum of specified AEAD algorithm
612    key size and salt size (4 bytes).
613
614    For example: *aead_key A1:B2:C3:D4:A1:B2:C3:D4:A1:B2:C3:D4:
615    A1:B2:C3:D4:A1:B2:C3:D4*
616
617 ``<mode>``
618
619  * The operation mode
620
621  * Optional: No
622
623  * Available options:
624
625    * *ipv4-tunnel*: Tunnel mode for IPv4 packets
626    * *ipv6-tunnel*: Tunnel mode for IPv6 packets
627    * *transport*: transport mode
628
629  * Syntax: mode XXX
630
631 ``<src_ip>``
632
633  * The source IP address. This option is not available when
634    transport mode is used
635
636  * Optional: Yes, default address 0.0.0.0 will be used
637
638  * Syntax:
639
640    * *src X.X.X.X* for IPv4
641    * *src XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX* for IPv6
642
643 ``<dst_ip>``
644
645  * The destination IP address. This option is not available when
646    transport mode is used
647
648  * Optional: Yes, default address 0.0.0.0 will be used
649
650  * Syntax:
651
652    * *dst X.X.X.X* for IPv4
653    * *dst XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX* for IPv6
654
655 ``<type>``
656
657  * Action type to specify the security action. This option specify
658    the SA to be performed with look aside protocol offload to HW
659    accelerator or protocol offload on ethernet device or inline
660    crypto processing on the ethernet device during transmission.
661
662  * Optional: Yes, default type *no-offload*
663
664  * Available options:
665
666    * *lookaside-protocol-offload*: look aside protocol offload to HW accelerator
667    * *inline-protocol-offload*: inline protocol offload on ethernet device
668    * *inline-crypto-offload*: inline crypto processing on ethernet device
669    * *no-offload*: no offloading to hardware
670
671  ``<port_id>``
672
673  * Port/device ID of the ethernet/crypto accelerator for which the SA is
674    configured. For *inline-crypto-offload* and *inline-protocol-offload*, this
675    port will be used for routing. The routing table will not be referred in
676    this case.
677
678  * Optional: No, if *type* is not *no-offload*
679
680  * Syntax:
681
682    * *port_id X* X is a valid device number in decimal
683
684  ``<fallback>``
685
686  * Action type for ingress IPsec packets that inline processor failed to
687    process. Only a combination of *inline-crypto-offload* as a primary
688    session and *lookaside-none* as a fall-back session is supported at the
689    moment.
690
691    If used in conjunction with IPsec window, its width needs be increased
692    due to different processing times of inline and lookaside modes which
693    results in packet reordering.
694
695  * Optional: Yes.
696
697  * Available options:
698
699    * *lookaside-none*: use automatically chosen cryptodev to process packets
700
701  * Syntax:
702
703    * *fallback lookaside-none*
704
705 ``<flow-direction>``
706
707  * Option for redirecting a specific inbound ipsec flow of a port to a specific
708    queue of that port.
709
710  * Optional: Yes.
711
712  * Available options:
713
714    * *port_id*: Port ID of the NIC for which the SA is configured.
715    * *queue_id*: Queue ID to which traffic should be redirected.
716
717  ``<udp-encap>``
718
719  * Option to enable IPsec UDP encapsulation for NAT Traversal.
720    Only *lookaside-protocol-offload* mode is supported at the moment.
721
722  * Optional: Yes, it is disabled by default
723
724  * Syntax:
725
726    * *udp-encap*
727
728  ``<mss>``
729
730  * Maximum segment size for TSO offload, available for egress SAs only.
731
732  * Optional: Yes, TSO offload not set by default
733
734  * Syntax:
735
736    * *mss N* N is the segment size in bytes
737
738
739 Example SA rules:
740
741 .. code-block:: console
742
743     sa out 5 cipher_algo null auth_algo null mode ipv4-tunnel \
744     src 172.16.1.5 dst 172.16.2.5
745
746     sa out 25 cipher_algo aes-128-cbc \
747     cipher_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3 \
748     auth_algo sha1-hmac \
749     auth_key c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3:c3 \
750     mode ipv6-tunnel \
751     src 1111:1111:1111:1111:1111:1111:1111:5555 \
752     dst 2222:2222:2222:2222:2222:2222:2222:5555
753
754     sa in 105 aead_algo aes-128-gcm \
755     aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
756     mode ipv4-tunnel src 172.16.2.5 dst 172.16.1.5
757
758     sa out 5 cipher_algo aes-128-cbc cipher_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
759     auth_algo sha1-hmac auth_key 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 \
760     mode ipv4-tunnel src 172.16.1.5 dst 172.16.2.5 \
761     type lookaside-protocol-offload port_id 4
762
763     sa in 35 aead_algo aes-128-gcm \
764     aead_key de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef \
765     mode ipv4-tunnel src 172.16.2.5 dst 172.16.1.5 \
766     type inline-crypto-offload port_id 0
767
768     sa in 117 cipher_algo null auth_algo null mode ipv4-tunnel src 172.16.2.7 \
769     dst 172.16.1.7 flow-direction 0 2
770
771 Routing rule syntax
772 ^^^^^^^^^^^^^^^^^^^
773
774 The Routing rule syntax is shown as follows:
775
776 .. code-block:: console
777
778     rt <ip_ver> <src_ip> <dst_ip> <port>
779
780
781 where each options means:
782
783 ``<ip_ver>``
784
785  * IP protocol version
786
787  * Optional: No
788
789  * Available options:
790
791    * *ipv4*: IP protocol version 4
792    * *ipv6*: IP protocol version 6
793
794 ``<src_ip>``
795
796  * The source IP address and mask
797
798  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
799
800  * Syntax:
801
802    * *src X.X.X.X/Y* for IPv4
803    * *src XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
804
805 ``<dst_ip>``
806
807  * The destination IP address and mask
808
809  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
810
811  * Syntax:
812
813    * *dst X.X.X.X/Y* for IPv4
814    * *dst XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
815
816 ``<port>``
817
818  * The traffic output port id
819
820  * Optional: yes, default output port 0 will be used
821
822  * Syntax: *port X*
823
824 Example SP rules:
825
826 .. code-block:: console
827
828     rt ipv4 dst 172.16.1.5/32 port 0
829
830     rt ipv6 dst 1111:1111:1111:1111:1111:1111:1111:5555/116 port 0
831
832 Flow rule syntax
833 ^^^^^^^^^^^^^^^^
834
835 Flow rule enables the usage of hardware classification capabilities to match specific
836 ingress traffic and redirect the packets to the specified queue. This feature is
837 optional and relies on hardware ``rte_flow`` support.
838
839 The flow rule syntax is shown as follows:
840
841 .. code-block:: console
842
843     flow <ip_ver> <src_ip> <dst_ip> <port> <queue>
844
845
846 where each options means:
847
848 ``<ip_ver>``
849
850  * IP protocol version
851
852  * Optional: No
853
854  * Available options:
855
856    * *ipv4*: IP protocol version 4
857    * *ipv6*: IP protocol version 6
858
859 ``<src_ip>``
860
861  * The source IP address and mask
862
863  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
864
865  * Syntax:
866
867    * *src X.X.X.X/Y* for IPv4
868    * *src XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
869
870 ``<dst_ip>``
871
872  * The destination IP address and mask
873
874  * Optional: Yes, default address 0.0.0.0 and mask of 0 will be used
875
876  * Syntax:
877
878    * *dst X.X.X.X/Y* for IPv4
879    * *dst XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/Y* for IPv6
880
881 ``<port>``
882
883  * The traffic input port id
884
885  * Optional: yes, default input port 0 will be used
886
887  * Syntax: *port X*
888
889 ``<queue>``
890
891  * The traffic input queue id
892
893  * Optional: yes, default input queue 0 will be used
894
895  * Syntax: *queue X*
896
897 Example flow rules:
898
899 .. code-block:: console
900
901     flow ipv4 dst 172.16.1.5/32 port 0 queue 0
902
903     flow ipv6 dst 1111:1111:1111:1111:1111:1111:1111:5555/116 port 1 queue 0
904
905
906 Neighbour rule syntax
907 ^^^^^^^^^^^^^^^^^^^^^
908
909 The Neighbour rule syntax is shown as follows:
910
911 .. code-block:: console
912
913     neigh <port> <dst_mac>
914
915
916 where each options means:
917
918 ``<port>``
919
920  * The output port id
921
922  * Optional: No
923
924  * Syntax: *port X*
925
926 ``<dst_mac>``
927
928  * The destination ethernet address to use for that port
929
930  * Optional: No
931
932  * Syntax:
933
934    * XX:XX:XX:XX:XX:XX
935
936 Example Neighbour rules:
937
938 .. code-block:: console
939
940     neigh port 0 DE:AD:BE:EF:01:02
941
942 Test directory
943 --------------
944
945 The test directory contains scripts for testing the various encryption
946 algorithms.
947
948 The purpose of the scripts is to automate ipsec-secgw testing
949 using another system running linux as a DUT.
950
951 The user must setup the following environment variables:
952
953 *   ``SGW_PATH``: path to the ipsec-secgw binary to test.
954
955 *   ``REMOTE_HOST``: IP address/hostname of the DUT.
956
957 *   ``REMOTE_IFACE``: interface name for the test-port on the DUT.
958
959 *   ``ETH_DEV``: ethernet device to be used on the SUT by DPDK ('-a <pci-id>')
960
961 Also the user can optionally setup:
962
963 *   ``SGW_LCORE``: lcore to run ipsec-secgw on (default value is 0)
964
965 *   ``CRYPTO_DEV``: crypto device to be used ('-a <pci-id>'). If none specified
966     appropriate vdevs will be created by the script
967
968 Scripts can be used for multiple test scenarios. To check all available
969 options run:
970
971 .. code-block:: console
972
973     /bin/bash run_test.sh -h
974
975 Note that most of the tests require the appropriate crypto PMD/device to be
976 available.
977
978 Server configuration
979 ~~~~~~~~~~~~~~~~~~~~
980
981 Two servers are required for the tests, SUT and DUT.
982
983 Make sure the user from the SUT can ssh to the DUT without entering the password.
984 To enable this feature keys must be setup on the DUT.
985
986 ``ssh-keygen`` will make a private & public key pair on the SUT.
987
988 ``ssh-copy-id`` <user name>@<target host name> on the SUT will copy the public
989 key to the DUT. It will ask for credentials so that it can upload the public key.
990
991 The SUT and DUT are connected through at least 2 NIC ports.
992
993 One NIC port is expected to be managed by linux on both machines and will be
994 used as a control path.
995
996 The second NIC port (test-port) should be bound to DPDK on the SUT, and should
997 be managed by linux on the DUT.
998
999 The script starts ``ipsec-secgw`` with 2 NIC devices: ``test-port`` and
1000 ``tap vdev``.
1001
1002 It then configures the local tap interface and the remote interface and IPsec
1003 policies in the following way:
1004
1005 Traffic going over the test-port in both directions has to be protected by IPsec.
1006
1007 Traffic going over the TAP port in both directions does not have to be protected.
1008
1009 i.e:
1010
1011 DUT OS(NIC1)--(IPsec)-->(NIC1)ipsec-secgw(TAP)--(plain)-->(TAP)SUT OS
1012
1013 SUT OS(TAP)--(plain)-->(TAP)psec-secgw(NIC1)--(IPsec)-->(NIC1)DUT OS
1014
1015 It then tries to perform some data transfer using the scheme described above.
1016
1017 Usage
1018 ~~~~~
1019
1020 In the ipsec-secgw/test directory run
1021
1022 /bin/bash run_test.sh <options> <ipsec_mode>
1023
1024 Available options:
1025
1026 *   ``-4`` Perform tests with use of IPv4. One or both [-46] options needs to be
1027     selected.
1028
1029 *   ``-6`` Perform tests with use of IPv6. One or both [-46] options needs to be
1030     selected.
1031
1032 *   ``-m`` Add IPSec tunnel mixed IP version tests - outer IP version different
1033     than inner. Inner IP version will match selected option [-46].
1034
1035 *   ``-i`` Run tests in inline mode. Regular tests will not be invoked.
1036
1037 *   ``-f`` Run tests for fallback mechanism. Regular tests will not be invoked.
1038
1039 *   ``-l`` Run tests in legacy mode only. It cannot be used with options [-fsc].
1040     On default library mode is used.
1041
1042 *   ``-s`` Run all tests with reassembly support. On default only tests for
1043     fallback mechanism use reassembly support.
1044
1045 *   ``-c`` Run tests with use of cpu-crypto. For inline tests it will not be
1046     applied. On default lookaside-none is used.
1047
1048 *   ``-p`` Perform packet validation tests. Option [-46] is not required.
1049
1050 *   ``-h`` Show usage.
1051
1052 If <ipsec_mode> is specified, only tests for that mode will be invoked. For the
1053 list of available modes please refer to run_test.sh.