ipsec: split ipsec nodes into ip4/ip6 nodes
[vpp.git] / src / plugins / dpdk / ipsec / esp_encrypt.c
1 /*
2  * esp_encrypt.c : IPSec ESP encrypt node using DPDK Cryptodev
3  *
4  * Copyright (c) 2017 Intel and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <vnet/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21
22 #include <vnet/ipsec/ipsec.h>
23 #include <vnet/ipsec/esp.h>
24 #include <vnet/udp/udp.h>
25 #include <dpdk/ipsec/ipsec.h>
26 #include <dpdk/device/dpdk.h>
27 #include <dpdk/device/dpdk_priv.h>
28
29 #define foreach_esp_encrypt_next                   \
30 _(DROP, "error-drop")                              \
31 _(IP4_LOOKUP, "ip4-lookup")                        \
32 _(IP6_LOOKUP, "ip6-lookup")                        \
33 _(INTERFACE_OUTPUT, "interface-output")
34
35 #define _(v, s) ESP_ENCRYPT_NEXT_##v,
36 typedef enum
37 {
38   foreach_esp_encrypt_next
39 #undef _
40     ESP_ENCRYPT_N_NEXT,
41 } esp_encrypt_next_t;
42
43 #define foreach_esp_encrypt_error                   \
44  _(RX_PKTS, "ESP pkts received")                    \
45  _(SEQ_CYCLED, "Sequence number cycled")            \
46  _(ENQ_FAIL, "Enqueue failed to crypto device")     \
47  _(DISCARD, "Not enough crypto operations, discarding frame")  \
48  _(SESSION, "Failed to get crypto session")         \
49  _(NOSUP, "Cipher/Auth not supported")
50
51
52 typedef enum
53 {
54 #define _(sym,str) ESP_ENCRYPT_ERROR_##sym,
55   foreach_esp_encrypt_error
56 #undef _
57     ESP_ENCRYPT_N_ERROR,
58 } esp_encrypt_error_t;
59
60 static char *esp_encrypt_error_strings[] = {
61 #define _(sym,string) string,
62   foreach_esp_encrypt_error
63 #undef _
64 };
65
66 vlib_node_registration_t dpdk_esp4_encrypt_node;
67 vlib_node_registration_t dpdk_esp6_encrypt_node;
68
69 typedef struct
70 {
71   ipsec_crypto_alg_t crypto_alg;
72   ipsec_integ_alg_t integ_alg;
73   u8 packet_data[64];
74 } esp_encrypt_trace_t;
75
76 /* packet trace format function */
77 static u8 *
78 format_esp_encrypt_trace (u8 * s, va_list * args)
79 {
80   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
81   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
82   esp_encrypt_trace_t *t = va_arg (*args, esp_encrypt_trace_t *);
83   ip4_header_t *ih4 = (ip4_header_t *) t->packet_data;
84   u32 indent = format_get_indent (s), offset;
85
86   s = format (s, "cipher %U auth %U\n",
87               format_ipsec_crypto_alg, t->crypto_alg,
88               format_ipsec_integ_alg, t->integ_alg);
89
90   if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
91     {
92       s = format (s, "%U%U", format_white_space, indent,
93                   format_ip6_header, ih4);
94       offset = sizeof (ip6_header_t);
95     }
96   else
97     {
98       s = format (s, "%U%U", format_white_space, indent,
99                   format_ip4_header, ih4);
100       offset = ip4_header_bytes (ih4);
101     }
102
103   s = format (s, "\n%U%U", format_white_space, indent,
104               format_esp_header, t->packet_data + offset);
105
106   return s;
107 }
108
109 always_inline uword
110 dpdk_esp_encrypt_inline (vlib_main_t * vm,
111                          vlib_node_runtime_t * node,
112                          vlib_frame_t * from_frame, int is_ip6)
113 {
114   u32 n_left_from, *from, *to_next, next_index;
115   ipsec_main_t *im = &ipsec_main;
116   u32 thread_idx = vlib_get_thread_index ();
117   dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
118   crypto_resource_t *res = 0;
119   ipsec_sa_t *sa0 = 0;
120   crypto_alg_t *cipher_alg = 0, *auth_alg = 0;
121   struct rte_cryptodev_sym_session *session = 0;
122   u32 ret, last_sa_index = ~0;
123   u8 numa = rte_socket_id ();
124   u8 is_aead = 0;
125   crypto_worker_main_t *cwm =
126     vec_elt_at_index (dcm->workers_main, thread_idx);
127   struct rte_crypto_op **ops = cwm->ops;
128
129   from = vlib_frame_vector_args (from_frame);
130   n_left_from = from_frame->n_vectors;
131
132   ret = crypto_alloc_ops (numa, ops, n_left_from);
133   if (ret)
134     {
135       if (is_ip6)
136         vlib_node_increment_counter (vm, dpdk_esp6_encrypt_node.index,
137                                      ESP_ENCRYPT_ERROR_DISCARD, 1);
138       else
139         vlib_node_increment_counter (vm, dpdk_esp4_encrypt_node.index,
140                                      ESP_ENCRYPT_ERROR_DISCARD, 1);
141       /* Discard whole frame */
142       return n_left_from;
143     }
144
145   next_index = ESP_ENCRYPT_NEXT_DROP;
146
147   while (n_left_from > 0)
148     {
149       u32 n_left_to_next;
150
151       vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
152
153       while (n_left_from > 0 && n_left_to_next > 0)
154         {
155           clib_error_t *error;
156           u32 bi0;
157           vlib_buffer_t *b0 = 0;
158           u32 sa_index0;
159           ip4_and_esp_header_t *ih0, *oh0 = 0;
160           ip6_and_esp_header_t *ih6_0, *oh6_0 = 0;
161           ip4_and_udp_and_esp_header_t *ouh0 = 0;
162           esp_header_t *esp0;
163           esp_footer_t *f0;
164           u8 next_hdr_type;
165           u32 iv_size;
166           u16 orig_sz;
167           u8 trunc_size;
168           u16 rewrite_len;
169           u16 udp_encap_adv = 0;
170           struct rte_mbuf *mb0 = 0;
171           struct rte_crypto_op *op;
172           u16 res_idx;
173
174           bi0 = from[0];
175           from += 1;
176           n_left_from -= 1;
177
178           b0 = vlib_get_buffer (vm, bi0);
179           ih0 = vlib_buffer_get_current (b0);
180           mb0 = rte_mbuf_from_vlib_buffer (b0);
181
182           /* ih0/ih6_0 */
183           CLIB_PREFETCH (ih0, sizeof (ih6_0[0]), LOAD);
184           /* f0 */
185           CLIB_PREFETCH (vlib_buffer_get_tail (b0), 20, STORE);
186           /* mb0 */
187           CLIB_PREFETCH (mb0, CLIB_CACHE_LINE_BYTES, STORE);
188
189           op = ops[0];
190           ops += 1;
191           ASSERT (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
192
193           dpdk_op_priv_t *priv = crypto_op_get_priv (op);
194
195           u16 op_len =
196             sizeof (op[0]) + sizeof (op[0].sym[0]) + sizeof (priv[0]);
197           CLIB_PREFETCH (op, op_len, STORE);
198
199           sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
200
201           if (sa_index0 != last_sa_index)
202             {
203               sa0 = pool_elt_at_index (im->sad, sa_index0);
204
205               cipher_alg =
206                 vec_elt_at_index (dcm->cipher_algs, sa0->crypto_alg);
207               auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
208
209               is_aead = (cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD);
210
211               if (is_aead)
212                 auth_alg = cipher_alg;
213
214               res_idx = get_resource (cwm, sa0);
215
216               if (PREDICT_FALSE (res_idx == (u16) ~ 0))
217                 {
218                   clib_warning ("unsupported SA by thread index %u",
219                                 thread_idx);
220                   if (is_ip6)
221                     vlib_node_increment_counter (vm,
222                                                  dpdk_esp6_encrypt_node.index,
223                                                  ESP_ENCRYPT_ERROR_NOSUP, 1);
224                   else
225                     vlib_node_increment_counter (vm,
226                                                  dpdk_esp4_encrypt_node.index,
227                                                  ESP_ENCRYPT_ERROR_NOSUP, 1);
228                   to_next[0] = bi0;
229                   to_next += 1;
230                   n_left_to_next -= 1;
231                   goto trace;
232                 }
233               res = vec_elt_at_index (dcm->resource, res_idx);
234
235               error = crypto_get_session (&session, sa_index0, res, cwm, 1);
236               if (PREDICT_FALSE (error || !session))
237                 {
238                   clib_warning ("failed to get crypto session");
239                   if (is_ip6)
240                     vlib_node_increment_counter (vm,
241                                                  dpdk_esp6_encrypt_node.index,
242                                                  ESP_ENCRYPT_ERROR_SESSION,
243                                                  1);
244                   else
245                     vlib_node_increment_counter (vm,
246                                                  dpdk_esp4_encrypt_node.index,
247                                                  ESP_ENCRYPT_ERROR_SESSION,
248                                                  1);
249                   to_next[0] = bi0;
250                   to_next += 1;
251                   n_left_to_next -= 1;
252                   goto trace;
253                 }
254
255               last_sa_index = sa_index0;
256             }
257
258           if (PREDICT_FALSE (esp_seq_advance (sa0)))
259             {
260               clib_warning ("sequence number counter has cycled SPI %u",
261                             sa0->spi);
262               if (is_ip6)
263                 vlib_node_increment_counter (vm,
264                                              dpdk_esp6_encrypt_node.index,
265                                              ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
266               else
267                 vlib_node_increment_counter (vm,
268                                              dpdk_esp4_encrypt_node.index,
269                                              ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
270               //TODO: rekey SA
271               to_next[0] = bi0;
272               to_next += 1;
273               n_left_to_next -= 1;
274               goto trace;
275             }
276
277           orig_sz = b0->current_length;
278
279           /* TODO multi-seg support - total_length_not_including_first_buffer */
280           sa0->total_data_size += b0->current_length;
281
282           res->ops[res->n_ops] = op;
283           res->bi[res->n_ops] = bi0;
284           res->n_ops += 1;
285
286           dpdk_gcm_cnt_blk *icb = &priv->cb;
287
288           crypto_set_icb (icb, sa0->salt, sa0->seq, sa0->seq_hi);
289
290           iv_size = cipher_alg->iv_len;
291           trunc_size = auth_alg->trunc_size;
292
293           /* if UDP encapsulation is used adjust the address of the IP header */
294           if (sa0->udp_encap && !is_ip6)
295             udp_encap_adv = sizeof (udp_header_t);
296
297           if (sa0->is_tunnel)
298             {
299               rewrite_len = 0;
300               if (!is_ip6 && !sa0->is_tunnel_ip6)       /* ip4inip4 */
301                 {
302                   /* in tunnel mode send it back to FIB */
303                   priv->next = DPDK_CRYPTO_INPUT_NEXT_IP4_LOOKUP;
304                   u8 adv = sizeof (ip4_header_t) + udp_encap_adv +
305                     sizeof (esp_header_t) + iv_size;
306                   vlib_buffer_advance (b0, -adv);
307                   oh0 = vlib_buffer_get_current (b0);
308                   ouh0 = vlib_buffer_get_current (b0);
309                   next_hdr_type = IP_PROTOCOL_IP_IN_IP;
310                   /*
311                    * oh0->ip4.ip_version_and_header_length = 0x45;
312                    * oh0->ip4.tos = ih0->ip4.tos;
313                    * oh0->ip4.fragment_id = 0;
314                    * oh0->ip4.flags_and_fragment_offset = 0;
315                    */
316                   oh0->ip4.checksum_data_64[0] =
317                     clib_host_to_net_u64 (0x45ULL << 56);
318                   /*
319                    * oh0->ip4.ttl = 254;
320                    * oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
321                    */
322                   oh0->ip4.checksum_data_32[2] =
323                     clib_host_to_net_u32 (0xfe320000);
324
325                   oh0->ip4.src_address.as_u32 =
326                     sa0->tunnel_src_addr.ip4.as_u32;
327                   oh0->ip4.dst_address.as_u32 =
328                     sa0->tunnel_dst_addr.ip4.as_u32;
329
330                   if (sa0->udp_encap)
331                     {
332                       oh0->ip4.protocol = IP_PROTOCOL_UDP;
333                       esp0 = &ouh0->esp;
334                     }
335                   else
336                     esp0 = &oh0->esp;
337                   esp0->spi = clib_host_to_net_u32 (sa0->spi);
338                   esp0->seq = clib_host_to_net_u32 (sa0->seq);
339                 }
340               else if (is_ip6 && sa0->is_tunnel_ip6)    /* ip6inip6 */
341                 {
342                   /* in tunnel mode send it back to FIB */
343                   priv->next = DPDK_CRYPTO_INPUT_NEXT_IP6_LOOKUP;
344
345                   u8 adv =
346                     sizeof (ip6_header_t) + sizeof (esp_header_t) + iv_size;
347                   vlib_buffer_advance (b0, -adv);
348                   ih6_0 = (ip6_and_esp_header_t *) ih0;
349                   oh6_0 = vlib_buffer_get_current (b0);
350
351                   next_hdr_type = IP_PROTOCOL_IPV6;
352
353                   oh6_0->ip6.ip_version_traffic_class_and_flow_label =
354                     ih6_0->ip6.ip_version_traffic_class_and_flow_label;
355
356                   oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
357                   oh6_0->ip6.hop_limit = 254;
358                   oh6_0->ip6.src_address.as_u64[0] =
359                     sa0->tunnel_src_addr.ip6.as_u64[0];
360                   oh6_0->ip6.src_address.as_u64[1] =
361                     sa0->tunnel_src_addr.ip6.as_u64[1];
362                   oh6_0->ip6.dst_address.as_u64[0] =
363                     sa0->tunnel_dst_addr.ip6.as_u64[0];
364                   oh6_0->ip6.dst_address.as_u64[1] =
365                     sa0->tunnel_dst_addr.ip6.as_u64[1];
366                   esp0 = &oh6_0->esp;
367                   oh6_0->esp.spi = clib_host_to_net_u32 (sa0->spi);
368                   oh6_0->esp.seq = clib_host_to_net_u32 (sa0->seq);
369                 }
370               else              /* unsupported ip4inip6, ip6inip4 */
371                 {
372                   if (is_ip6)
373                     vlib_node_increment_counter (vm,
374                                                  dpdk_esp6_encrypt_node.index,
375                                                  ESP_ENCRYPT_ERROR_NOSUP, 1);
376                   else
377                     vlib_node_increment_counter (vm,
378                                                  dpdk_esp4_encrypt_node.index,
379                                                  ESP_ENCRYPT_ERROR_NOSUP, 1);
380                   to_next[0] = bi0;
381                   to_next += 1;
382                   n_left_to_next -= 1;
383                   goto trace;
384                 }
385               vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
386             }
387           else                  /* transport mode */
388             {
389               priv->next = DPDK_CRYPTO_INPUT_NEXT_INTERFACE_OUTPUT;
390               rewrite_len = vnet_buffer (b0)->ip.save_rewrite_length;
391               u16 adv = sizeof (esp_header_t) + iv_size + udp_encap_adv;
392               vlib_buffer_advance (b0, -adv - rewrite_len);
393               u8 *src = ((u8 *) ih0) - rewrite_len;
394               u8 *dst = vlib_buffer_get_current (b0);
395               oh0 = vlib_buffer_get_current (b0) + rewrite_len;
396
397               if (is_ip6)
398                 {
399                   orig_sz -= sizeof (ip6_header_t);
400                   ih6_0 = (ip6_and_esp_header_t *) ih0;
401                   next_hdr_type = ih6_0->ip6.protocol;
402                   memmove (dst, src, rewrite_len + sizeof (ip6_header_t));
403                   oh6_0 = (ip6_and_esp_header_t *) oh0;
404                   oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
405                   esp0 = &oh6_0->esp;
406                 }
407               else              /* ipv4 */
408                 {
409                   u16 ip_size = ip4_header_bytes (&ih0->ip4);
410                   orig_sz -= ip_size;
411                   next_hdr_type = ih0->ip4.protocol;
412                   memmove (dst, src, rewrite_len + ip_size);
413                   oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
414                   esp0 = (esp_header_t *) (((u8 *) oh0) + ip_size);
415                   if (sa0->udp_encap)
416                     {
417                       oh0->ip4.protocol = IP_PROTOCOL_UDP;
418                       esp0 = (esp_header_t *)
419                         (((u8 *) oh0) + ip_size + udp_encap_adv);
420                     }
421                   else
422                     {
423                       oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
424                       esp0 = (esp_header_t *) (((u8 *) oh0) + ip_size);
425                     }
426                 }
427               esp0->spi = clib_host_to_net_u32 (sa0->spi);
428               esp0->seq = clib_host_to_net_u32 (sa0->seq);
429             }
430
431           if (sa0->udp_encap && ouh0)
432             {
433               ouh0->udp.src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
434               ouh0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
435               ouh0->udp.checksum = 0;
436             }
437           ASSERT (is_pow2 (cipher_alg->boundary));
438           u16 mask = cipher_alg->boundary - 1;
439           u16 pad_payload_len = ((orig_sz + 2) + mask) & ~mask;
440           u8 pad_bytes = pad_payload_len - 2 - orig_sz;
441
442           u8 *padding =
443             vlib_buffer_put_uninit (b0, pad_bytes + 2 + trunc_size);
444
445           /* The extra pad bytes would be overwritten by the digest */
446           if (pad_bytes)
447             clib_memcpy (padding, pad_data, 16);
448
449           f0 = (esp_footer_t *) (padding + pad_bytes);
450           f0->pad_length = pad_bytes;
451           f0->next_header = next_hdr_type;
452
453           if (is_ip6)
454             {
455               u16 len = b0->current_length - sizeof (ip6_header_t);
456               oh6_0->ip6.payload_length =
457                 clib_host_to_net_u16 (len - rewrite_len);
458             }
459           else
460             {
461               oh0->ip4.length =
462                 clib_host_to_net_u16 (b0->current_length - rewrite_len);
463               oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
464               if (sa0->udp_encap && ouh0)
465                 {
466                   ouh0->udp.length =
467                     clib_host_to_net_u16 (clib_net_to_host_u16
468                                           (ouh0->ip4.length) -
469                                           ip4_header_bytes (&ouh0->ip4));
470                 }
471             }
472
473           vnet_buffer (b0)->sw_if_index[VLIB_RX] =
474             vnet_buffer (b0)->sw_if_index[VLIB_RX];
475           b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
476
477           /* mbuf packet starts at ESP header */
478           mb0->data_len = vlib_buffer_get_tail (b0) - ((u8 *) esp0);
479           mb0->pkt_len = vlib_buffer_get_tail (b0) - ((u8 *) esp0);
480           mb0->data_off = ((void *) esp0) - mb0->buf_addr;
481
482           u32 cipher_off, cipher_len, auth_len = 0;
483           u32 *aad = NULL;
484
485           u8 *digest = vlib_buffer_get_tail (b0) - trunc_size;
486           u64 digest_paddr =
487             mb0->buf_physaddr + digest - ((u8 *) mb0->buf_addr);
488
489           if (!is_aead && cipher_alg->alg == RTE_CRYPTO_CIPHER_AES_CBC)
490             {
491               cipher_off = sizeof (esp_header_t);
492               cipher_len = iv_size + pad_payload_len;
493             }
494           else                  /* CTR/GCM */
495             {
496               u32 *esp_iv = (u32 *) (esp0 + 1);
497               esp_iv[0] = sa0->seq;
498               esp_iv[1] = sa0->seq_hi;
499
500               cipher_off = sizeof (esp_header_t) + iv_size;
501               cipher_len = pad_payload_len;
502             }
503
504           if (is_aead)
505             {
506               aad = (u32 *) priv->aad;
507               aad[0] = clib_host_to_net_u32 (sa0->spi);
508               aad[1] = clib_host_to_net_u32 (sa0->seq);
509
510               /* aad[3] should always be 0 */
511               if (PREDICT_FALSE (sa0->use_esn))
512                 aad[2] = clib_host_to_net_u32 (sa0->seq_hi);
513               else
514                 aad[2] = 0;
515             }
516           else
517             {
518               auth_len =
519                 vlib_buffer_get_tail (b0) - ((u8 *) esp0) - trunc_size;
520               if (sa0->use_esn)
521                 {
522                   u32 *_digest = (u32 *) digest;
523                   _digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
524                   auth_len += 4;
525                 }
526             }
527
528           crypto_op_setup (is_aead, mb0, op, session, cipher_off, cipher_len,
529                            0, auth_len, (u8 *) aad, digest, digest_paddr);
530
531         trace:
532           if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
533             {
534               esp_encrypt_trace_t *tr =
535                 vlib_add_trace (vm, node, b0, sizeof (*tr));
536               tr->crypto_alg = sa0->crypto_alg;
537               tr->integ_alg = sa0->integ_alg;
538               u8 *p = vlib_buffer_get_current (b0);
539               if (!sa0->is_tunnel)
540                 p += vnet_buffer (b0)->ip.save_rewrite_length;
541               clib_memcpy (tr->packet_data, p, sizeof (tr->packet_data));
542             }
543         }
544       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
545     }
546   if (is_ip6)
547     {
548       vlib_node_increment_counter (vm, dpdk_esp6_encrypt_node.index,
549                                    ESP_ENCRYPT_ERROR_RX_PKTS,
550                                    from_frame->n_vectors);
551
552       crypto_enqueue_ops (vm, cwm, 1, dpdk_esp6_encrypt_node.index,
553                           ESP_ENCRYPT_ERROR_ENQ_FAIL, numa);
554     }
555   else
556     {
557       vlib_node_increment_counter (vm, dpdk_esp4_encrypt_node.index,
558                                    ESP_ENCRYPT_ERROR_RX_PKTS,
559                                    from_frame->n_vectors);
560
561       crypto_enqueue_ops (vm, cwm, 1, dpdk_esp4_encrypt_node.index,
562                           ESP_ENCRYPT_ERROR_ENQ_FAIL, numa);
563     }
564
565   crypto_free_ops (numa, ops, cwm->ops + from_frame->n_vectors - ops);
566
567   return from_frame->n_vectors;
568 }
569
570 static uword
571 dpdk_esp4_encrypt_node_fn (vlib_main_t * vm,
572                            vlib_node_runtime_t * node,
573                            vlib_frame_t * from_frame)
574 {
575   return dpdk_esp_encrypt_inline (vm, node, from_frame, 0 /*is_ip6 */ );
576 }
577
578 /* *INDENT-OFF* */
579 VLIB_REGISTER_NODE (dpdk_esp4_encrypt_node) = {
580   .function = dpdk_esp4_encrypt_node_fn,
581   .name = "dpdk4-esp-encrypt",
582   .flags = VLIB_NODE_FLAG_IS_OUTPUT,
583   .vector_size = sizeof (u32),
584   .format_trace = format_esp_encrypt_trace,
585   .n_errors = ARRAY_LEN (esp_encrypt_error_strings),
586   .error_strings = esp_encrypt_error_strings,
587   .n_next_nodes = 1,
588   .next_nodes =
589     {
590       [ESP_ENCRYPT_NEXT_DROP] = "error-drop",
591     }
592 };
593 /* *INDENT-ON* */
594
595 VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp4_encrypt_node,
596                               dpdk_esp4_encrypt_node_fn);
597
598 static uword
599 dpdk_esp6_encrypt_node_fn (vlib_main_t * vm,
600                            vlib_node_runtime_t * node,
601                            vlib_frame_t * from_frame)
602 {
603   return dpdk_esp_encrypt_inline (vm, node, from_frame, 1 /*is_ip6 */ );
604 }
605
606 /* *INDENT-OFF* */
607 VLIB_REGISTER_NODE (dpdk_esp6_encrypt_node) = {
608   .function = dpdk_esp6_encrypt_node_fn,
609   .name = "dpdk6-esp-encrypt",
610   .flags = VLIB_NODE_FLAG_IS_OUTPUT,
611   .vector_size = sizeof (u32),
612   .format_trace = format_esp_encrypt_trace,
613   .n_errors = ARRAY_LEN (esp_encrypt_error_strings),
614   .error_strings = esp_encrypt_error_strings,
615   .n_next_nodes = 1,
616   .next_nodes =
617     {
618       [ESP_ENCRYPT_NEXT_DROP] = "error-drop",
619     }
620 };
621 /* *INDENT-ON* */
622
623 VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp6_encrypt_node,
624                               dpdk_esp6_encrypt_node_fn);
625 /*
626  * fd.io coding-style-patch-verification: ON
627  *
628  * Local Variables:
629  * eval: (c-set-style "gnu")
630  * End:
631  */