blob: 080a3458926296099f5a96306f848bdc45b27a3c [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * esp_encrypt.c : IPSec ESP encrypt node
3 *
4 * Copyright (c) 2015 Cisco 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>
Klement Sekera4b089f22018-04-17 18:04:57 +020021#include <vnet/udp/udp.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070022
23#include <vnet/ipsec/ipsec.h>
24#include <vnet/ipsec/esp.h>
25
Ed Warnickecb9cada2015-12-08 15:45:58 -070026#define foreach_esp_encrypt_next \
27_(DROP, "error-drop") \
Sergio Gonzalez Monroy1b6f9022016-12-12 10:37:49 +000028_(IP4_LOOKUP, "ip4-lookup") \
29_(IP6_LOOKUP, "ip6-lookup") \
Ed Warnickecb9cada2015-12-08 15:45:58 -070030_(INTERFACE_OUTPUT, "interface-output")
31
32#define _(v, s) ESP_ENCRYPT_NEXT_##v,
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070033typedef enum
34{
Ed Warnickecb9cada2015-12-08 15:45:58 -070035 foreach_esp_encrypt_next
36#undef _
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070037 ESP_ENCRYPT_N_NEXT,
Ed Warnickecb9cada2015-12-08 15:45:58 -070038} esp_encrypt_next_t;
39
40#define foreach_esp_encrypt_error \
41 _(RX_PKTS, "ESP pkts received") \
42 _(NO_BUFFER, "No buffer (packet dropped)") \
43 _(DECRYPTION_FAILED, "ESP encryption failed") \
44 _(SEQ_CYCLED, "sequence number cycled")
45
46
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070047typedef enum
48{
Ed Warnickecb9cada2015-12-08 15:45:58 -070049#define _(sym,str) ESP_ENCRYPT_ERROR_##sym,
50 foreach_esp_encrypt_error
51#undef _
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070052 ESP_ENCRYPT_N_ERROR,
Ed Warnickecb9cada2015-12-08 15:45:58 -070053} esp_encrypt_error_t;
54
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070055static char *esp_encrypt_error_strings[] = {
Ed Warnickecb9cada2015-12-08 15:45:58 -070056#define _(sym,string) string,
57 foreach_esp_encrypt_error
58#undef _
59};
60
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070061typedef struct
62{
Neale Ranns8d7c5022019-02-06 01:41:05 -080063 u32 sa_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070064 u32 spi;
65 u32 seq;
Klement Sekera4b089f22018-04-17 18:04:57 +020066 u8 udp_encap;
Ed Warnickecb9cada2015-12-08 15:45:58 -070067 ipsec_crypto_alg_t crypto_alg;
68 ipsec_integ_alg_t integ_alg;
69} esp_encrypt_trace_t;
70
71/* packet trace format function */
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070072static u8 *
73format_esp_encrypt_trace (u8 * s, va_list * args)
Ed Warnickecb9cada2015-12-08 15:45:58 -070074{
75 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
76 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070077 esp_encrypt_trace_t *t = va_arg (*args, esp_encrypt_trace_t *);
Ed Warnickecb9cada2015-12-08 15:45:58 -070078
Neale Ranns8d7c5022019-02-06 01:41:05 -080079 s = format (s, "esp: sa-index %d spi %u seq %u crypto %U integrity %U%s",
80 t->sa_index, t->spi, t->seq,
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070081 format_ipsec_crypto_alg, t->crypto_alg,
Klement Sekera4b089f22018-04-17 18:04:57 +020082 format_ipsec_integ_alg, t->integ_alg,
83 t->udp_encap ? " udp-encap-enabled" : "");
Ed Warnickecb9cada2015-12-08 15:45:58 -070084 return s;
85}
86
87always_inline void
Damjan Marion067cd622018-07-11 12:47:43 +020088esp_encrypt_cbc (vlib_main_t * vm, ipsec_crypto_alg_t alg,
“mukeshyadav1984”72454dd2017-11-28 10:52:34 -080089 u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv)
Ed Warnickecb9cada2015-12-08 15:45:58 -070090{
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080091 ipsec_proto_main_t *em = &ipsec_proto_main;
Damjan Marion067cd622018-07-11 12:47:43 +020092 u32 thread_index = vm->thread_index;
Marco Varlesef616d102017-11-09 15:16:20 +010093#if OPENSSL_VERSION_NUMBER >= 0x10100000L
94 EVP_CIPHER_CTX *ctx = em->per_thread_data[thread_index].encrypt_ctx;
95#else
Damjan Marion586afd72017-04-05 19:18:20 +020096 EVP_CIPHER_CTX *ctx = &(em->per_thread_data[thread_index].encrypt_ctx);
Marco Varlesef616d102017-11-09 15:16:20 +010097#endif
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070098 const EVP_CIPHER *cipher = NULL;
Ed Warnickecb9cada2015-12-08 15:45:58 -070099 int out_len;
100
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700101 ASSERT (alg < IPSEC_CRYPTO_N_ALG);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700102
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800103 if (PREDICT_FALSE
104 (em->ipsec_proto_main_crypto_algs[alg].type == IPSEC_CRYPTO_ALG_NONE))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105 return;
106
Damjan Marion586afd72017-04-05 19:18:20 +0200107 if (PREDICT_FALSE
108 (alg != em->per_thread_data[thread_index].last_encrypt_alg))
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700109 {
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800110 cipher = em->ipsec_proto_main_crypto_algs[alg].type;
Damjan Marion586afd72017-04-05 19:18:20 +0200111 em->per_thread_data[thread_index].last_encrypt_alg = alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700112 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700113
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700114 EVP_EncryptInit_ex (ctx, cipher, NULL, key, iv);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700116 EVP_EncryptUpdate (ctx, out, &out_len, in, in_len);
117 EVP_EncryptFinal_ex (ctx, out + out_len, &out_len);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700118}
119
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200120always_inline uword
121esp_encrypt_inline (vlib_main_t * vm,
122 vlib_node_runtime_t * node, vlib_frame_t * from_frame,
123 int is_ip6)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700124{
Damjan Marionc98275f2019-03-06 14:05:01 +0100125 u32 *from = vlib_frame_vector_args (from_frame);
126 u32 n_left_from = from_frame->n_vectors;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700127 ipsec_main_t *im = &ipsec_main;
“mukeshyadav1984”72454dd2017-11-28 10:52:34 -0800128 ipsec_proto_main_t *em = &ipsec_proto_main;
Damjan Marionc98275f2019-03-06 14:05:01 +0100129 u32 new_bufs[VLIB_FRAME_SIZE];
130 vlib_buffer_t *i_bufs[VLIB_FRAME_SIZE], **ib = i_bufs;
131 vlib_buffer_t *o_bufs[VLIB_FRAME_SIZE], **ob = o_bufs;
132 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
133 u32 n_alloc, thread_index = vm->thread_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700134
Damjan Marionc98275f2019-03-06 14:05:01 +0100135 n_alloc = vlib_buffer_alloc (vm, new_bufs, n_left_from);
136 if (n_alloc != n_left_from)
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700137 {
Klement Sekera2e02ba02018-11-30 14:37:03 +0100138 vlib_node_increment_counter (vm, node->node_index,
Damjan Marionc98275f2019-03-06 14:05:01 +0100139 ESP_ENCRYPT_ERROR_NO_BUFFER,
140 n_left_from - n_alloc);
141 if (n_alloc == 0)
142 goto done;
143 n_left_from = n_alloc;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700144 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700145
Damjan Marionc98275f2019-03-06 14:05:01 +0100146 vlib_get_buffers (vm, from, ib, n_left_from);
147 vlib_get_buffers (vm, new_bufs, ob, n_left_from);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700148
149 while (n_left_from > 0)
150 {
Damjan Marionc98275f2019-03-06 14:05:01 +0100151 u32 sa_index0;
152 ipsec_sa_t *sa0;
153 ip4_and_esp_header_t *oh0 = 0;
154 ip6_and_esp_header_t *ih6_0, *oh6_0 = 0;
155 ip4_and_udp_and_esp_header_t *iuh0, *ouh0 = 0;
156 esp_header_t *o_esp0;
157 esp_footer_t *f0;
158 u8 ip_udp_hdr_size;
159 u8 next_hdr_type;
160 u32 ip_proto = 0;
161 u8 transport_mode = 0;
162 u32 esp_seq_err;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700163
Damjan Marionc98275f2019-03-06 14:05:01 +0100164 next[0] = ESP_ENCRYPT_NEXT_DROP;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700165
Damjan Marionc98275f2019-03-06 14:05:01 +0100166 sa_index0 = vnet_buffer (ib[0])->ipsec.sad_index;
167 sa0 = pool_elt_at_index (im->sad, sa_index0);
168
169 vlib_prefetch_combined_counter (&ipsec_sa_counters, thread_index,
170 sa_index0);
171
172 esp_seq_err = esp_seq_advance (sa0);
173
174 /* grab free buffer */
175 ob[0]->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
176 ob[0]->current_data = sizeof (ethernet_header_t);
177 iuh0 = vlib_buffer_get_current (ib[0]);
178
179 if (is_ip6)
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700180 {
Damjan Marionc98275f2019-03-06 14:05:01 +0100181 ih6_0 = vlib_buffer_get_current (ib[0]);
182 next_hdr_type = IP_PROTOCOL_IPV6;
183 oh6_0 = vlib_buffer_get_current (ob[0]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700184
Damjan Marionc98275f2019-03-06 14:05:01 +0100185 oh6_0->ip6.ip_version_traffic_class_and_flow_label =
186 ih6_0->ip6.ip_version_traffic_class_and_flow_label;
187 oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
188 ip_udp_hdr_size = sizeof (ip6_header_t);
189 o_esp0 = vlib_buffer_get_current (ob[0]) + ip_udp_hdr_size;
190 oh6_0->ip6.hop_limit = 254;
191 oh6_0->ip6.src_address.as_u64[0] = ih6_0->ip6.src_address.as_u64[0];
192 oh6_0->ip6.src_address.as_u64[1] = ih6_0->ip6.src_address.as_u64[1];
193 oh6_0->ip6.dst_address.as_u64[0] = ih6_0->ip6.dst_address.as_u64[0];
194 oh6_0->ip6.dst_address.as_u64[1] = ih6_0->ip6.dst_address.as_u64[1];
195 o_esp0->spi = clib_net_to_host_u32 (sa0->spi);
196 o_esp0->seq = clib_net_to_host_u32 (sa0->seq);
197 ip_proto = ih6_0->ip6.protocol;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700198
Damjan Marionc98275f2019-03-06 14:05:01 +0100199 next[0] = ESP_ENCRYPT_NEXT_IP6_LOOKUP;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700200 }
Damjan Marionc98275f2019-03-06 14:05:01 +0100201 else
202 {
203 next_hdr_type = IP_PROTOCOL_IP_IN_IP;
204 oh0 = vlib_buffer_get_current (ob[0]);
205 ouh0 = vlib_buffer_get_current (ob[0]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700206
Damjan Marionc98275f2019-03-06 14:05:01 +0100207 oh0->ip4.ip_version_and_header_length = 0x45;
208 oh0->ip4.tos = iuh0->ip4.tos;
209 oh0->ip4.fragment_id = 0;
210 oh0->ip4.flags_and_fragment_offset = 0;
211 oh0->ip4.ttl = 254;
212 if (sa0->udp_encap)
213 {
214 ouh0->udp.src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
215 ouh0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
216 ouh0->udp.checksum = 0;
217 ouh0->ip4.protocol = IP_PROTOCOL_UDP;
218 ip_udp_hdr_size = sizeof (udp_header_t) + sizeof (ip4_header_t);
219 }
220 else
221 {
222 oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
223 ip_udp_hdr_size = sizeof (ip4_header_t);
224 }
225 o_esp0 = vlib_buffer_get_current (ob[0]) + ip_udp_hdr_size;
226 oh0->ip4.src_address.as_u32 = iuh0->ip4.src_address.as_u32;
227 oh0->ip4.dst_address.as_u32 = iuh0->ip4.dst_address.as_u32;
228 o_esp0->spi = clib_net_to_host_u32 (sa0->spi);
229 o_esp0->seq = clib_net_to_host_u32 (sa0->seq);
230 ip_proto = iuh0->ip4.protocol;
231
232 next[0] = ESP_ENCRYPT_NEXT_IP4_LOOKUP;
233 }
234
235 if (PREDICT_TRUE (!is_ip6 && sa0->is_tunnel && !sa0->is_tunnel_ip6))
236 {
237 oh0->ip4.src_address.as_u32 = sa0->tunnel_src_addr.ip4.as_u32;
238 oh0->ip4.dst_address.as_u32 = sa0->tunnel_dst_addr.ip4.as_u32;
239
240 next[0] = sa0->dpo[IPSEC_PROTOCOL_ESP].dpoi_next_node;
241 vnet_buffer (ob[0])->ip.adj_index[VLIB_TX] =
242 sa0->dpo[IPSEC_PROTOCOL_ESP].dpoi_index;
243 }
244 else if (is_ip6 && sa0->is_tunnel && sa0->is_tunnel_ip6)
245 {
246 oh6_0->ip6.src_address.as_u64[0] =
247 sa0->tunnel_src_addr.ip6.as_u64[0];
248 oh6_0->ip6.src_address.as_u64[1] =
249 sa0->tunnel_src_addr.ip6.as_u64[1];
250 oh6_0->ip6.dst_address.as_u64[0] =
251 sa0->tunnel_dst_addr.ip6.as_u64[0];
252 oh6_0->ip6.dst_address.as_u64[1] =
253 sa0->tunnel_dst_addr.ip6.as_u64[1];
254
255 next[0] = sa0->dpo[IPSEC_PROTOCOL_ESP].dpoi_next_node;
256 vnet_buffer (ob[0])->ip.adj_index[VLIB_TX] =
257 sa0->dpo[IPSEC_PROTOCOL_ESP].dpoi_index;
258 }
259 else
260 {
261 next_hdr_type = ip_proto;
262 if (vnet_buffer (ib[0])->sw_if_index[VLIB_TX] != ~0)
263 {
264 transport_mode = 1;
265 ethernet_header_t *ieh0, *oeh0;
266 ieh0 =
267 (ethernet_header_t *) ((u8 *)
268 vlib_buffer_get_current (ib[0]) -
269 sizeof (ethernet_header_t));
270 oeh0 = (ethernet_header_t *) ob[0]->data;
271 clib_memcpy_fast (oeh0, ieh0, sizeof (ethernet_header_t));
272 next[0] = ESP_ENCRYPT_NEXT_INTERFACE_OUTPUT;
273 vnet_buffer (ob[0])->sw_if_index[VLIB_TX] =
274 vnet_buffer (ib[0])->sw_if_index[VLIB_TX];
275 }
276
277 if (is_ip6)
278 vlib_buffer_advance (ib[0], sizeof (ip6_header_t));
279 else
280 vlib_buffer_advance (ib[0], sizeof (ip4_header_t));
281 }
282
283 ASSERT (sa0->crypto_alg < IPSEC_CRYPTO_N_ALG);
284 vlib_increment_combined_counter
285 (&ipsec_sa_counters, thread_index, sa_index0,
286 1, ib[0]->current_length);
287
288 if (PREDICT_TRUE (sa0->crypto_alg != IPSEC_CRYPTO_ALG_NONE))
289 {
290
291 const int BLOCK_SIZE =
292 em->ipsec_proto_main_crypto_algs[sa0->crypto_alg].block_size;
293 const int IV_SIZE =
294 em->ipsec_proto_main_crypto_algs[sa0->crypto_alg].iv_size;
295 int blocks = 1 + (ib[0]->current_length + 1) / BLOCK_SIZE;
296
297 /* pad packet in input buffer */
298 u8 pad_bytes = BLOCK_SIZE * blocks - 2 - ib[0]->current_length;
299 u8 i;
300 u8 *padding =
301 vlib_buffer_get_current (ib[0]) + ib[0]->current_length;
302 ib[0]->current_length = BLOCK_SIZE * blocks;
303 for (i = 0; i < pad_bytes; ++i)
304 {
305 padding[i] = i + 1;
306 }
307 f0 = vlib_buffer_get_current (ib[0]) + ib[0]->current_length - 2;
308 f0->pad_length = pad_bytes;
309 f0->next_header = next_hdr_type;
310
311 ob[0]->current_length = ip_udp_hdr_size + sizeof (esp_header_t) +
312 BLOCK_SIZE * blocks + IV_SIZE;
313
314 vnet_buffer (ob[0])->sw_if_index[VLIB_RX] =
315 vnet_buffer (ib[0])->sw_if_index[VLIB_RX];
316
317 u8 iv[em->ipsec_proto_main_crypto_algs[sa0->crypto_alg].iv_size];
318 RAND_bytes (iv, sizeof (iv));
319
320 clib_memcpy_fast ((u8 *) vlib_buffer_get_current (ob[0]) +
321 ip_udp_hdr_size + sizeof (esp_header_t), iv,
322 em->ipsec_proto_main_crypto_algs[sa0->
323 crypto_alg].iv_size);
324
325 esp_encrypt_cbc (vm, sa0->crypto_alg,
326 (u8 *) vlib_buffer_get_current (ib[0]),
327 (u8 *) vlib_buffer_get_current (ob[0]) +
328 ip_udp_hdr_size + sizeof (esp_header_t) +
329 IV_SIZE, BLOCK_SIZE * blocks,
330 sa0->crypto_key.data, iv);
331 }
332
333 ob[0]->current_length +=
334 hmac_calc (sa0->integ_alg, sa0->integ_key.data,
335 sa0->integ_key.len, (u8 *) o_esp0,
336 ob[0]->current_length - ip_udp_hdr_size,
337 vlib_buffer_get_current (ob[0]) + ob[0]->current_length,
338 sa0->use_esn, sa0->seq_hi);
339
340
341 if (is_ip6)
342 {
343 oh6_0->ip6.payload_length =
344 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, ob[0]) -
345 sizeof (ip6_header_t));
346 }
347 else
348 {
349 oh0->ip4.length =
350 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, ob[0]));
351 oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
352 if (sa0->udp_encap)
353 {
354 ouh0->udp.length =
355 clib_host_to_net_u16 (clib_net_to_host_u16
356 (oh0->ip4.length) -
357 ip4_header_bytes (&oh0->ip4));
358 }
359 }
360
361 if (transport_mode)
362 vlib_buffer_reset (ob[0]);
363
364 if (PREDICT_FALSE (esp_seq_err))
365 {
366 ob[0]->error = node->errors[ESP_ENCRYPT_ERROR_SEQ_CYCLED];
367 next[0] = ESP_ENCRYPT_NEXT_DROP;
368 }
369
370 if (PREDICT_FALSE (ib[0]->flags & VLIB_BUFFER_IS_TRACED))
371 {
372 if (ob[0])
373 {
374 ob[0]->flags |= VLIB_BUFFER_IS_TRACED;
375 ob[0]->trace_index = ib[0]->trace_index;
376 esp_encrypt_trace_t *tr =
377 vlib_add_trace (vm, node, ob[0], sizeof (*tr));
378 tr->sa_index = sa_index0;
379 tr->spi = sa0->spi;
380 tr->seq = sa0->seq - 1;
381 tr->udp_encap = sa0->udp_encap;
382 tr->crypto_alg = sa0->crypto_alg;
383 tr->integ_alg = sa0->integ_alg;
384 }
385 }
386
387 /* next */
388 n_left_from -= 1;
389 ib += 1;
390 ob += 1;
391 next += 1;
392 }
393
394 vlib_node_increment_counter (vm, node->node_index,
395 ESP_ENCRYPT_ERROR_RX_PKTS, n_alloc);
396
397 vlib_buffer_enqueue_to_next (vm, node, new_bufs, nexts, n_alloc);
398done:
399 vlib_buffer_free (vm, from, from_frame->n_vectors);
400 return n_alloc;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700401}
402
Klement Sekerab8f35442018-10-29 13:38:19 +0100403VLIB_NODE_FN (esp4_encrypt_node) (vlib_main_t * vm,
404 vlib_node_runtime_t * node,
405 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200406{
407 return esp_encrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ );
408}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700409
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700410/* *INDENT-OFF* */
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200411VLIB_REGISTER_NODE (esp4_encrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200412 .name = "esp4-encrypt",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700413 .vector_size = sizeof (u32),
414 .format_trace = format_esp_encrypt_trace,
415 .type = VLIB_NODE_TYPE_INTERNAL,
416
417 .n_errors = ARRAY_LEN(esp_encrypt_error_strings),
418 .error_strings = esp_encrypt_error_strings,
419
420 .n_next_nodes = ESP_ENCRYPT_N_NEXT,
421 .next_nodes = {
422#define _(s,n) [ESP_ENCRYPT_NEXT_##s] = n,
423 foreach_esp_encrypt_next
424#undef _
425 },
426};
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700427/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700428
Klement Sekerab8f35442018-10-29 13:38:19 +0100429VLIB_NODE_FN (esp6_encrypt_node) (vlib_main_t * vm,
430 vlib_node_runtime_t * node,
431 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200432{
433 return esp_encrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ );
434}
435
436/* *INDENT-OFF* */
437VLIB_REGISTER_NODE (esp6_encrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200438 .name = "esp6-encrypt",
439 .vector_size = sizeof (u32),
440 .format_trace = format_esp_encrypt_trace,
441 .type = VLIB_NODE_TYPE_INTERNAL,
442
443 .n_errors = ARRAY_LEN(esp_encrypt_error_strings),
444 .error_strings = esp_encrypt_error_strings,
445
446 .n_next_nodes = ESP_ENCRYPT_N_NEXT,
447 .next_nodes = {
448#define _(s,n) [ESP_ENCRYPT_NEXT_##s] = n,
449 foreach_esp_encrypt_next
450#undef _
451 },
452};
453/* *INDENT-ON* */
454
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700455/*
456 * fd.io coding-style-patch-verification: ON
457 *
458 * Local Variables:
459 * eval: (c-set-style "gnu")
460 * End:
461 */