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