blob: 1ad372a7de0abd9d4f061684ddea22db82fa59bd [file] [log] [blame]
“mukeshyadav1984”430ac932017-11-23 02:39:33 -08001/*
2 * ah_decrypt.c : IPSec AH decrypt 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>
21
22#include <vnet/ipsec/ipsec.h>
23#include <vnet/ipsec/esp.h>
24#include <vnet/ipsec/ah.h>
Neale Ranns918c1612019-02-21 23:34:59 -080025#include <vnet/ipsec/ipsec_io.h>
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080026
Neale Rannsf62a8c02019-04-02 08:13:33 +000027#define foreach_ah_decrypt_next \
28 _(DROP, "error-drop") \
29 _(IP4_INPUT, "ip4-input") \
30 _(IP6_INPUT, "ip6-input") \
31 _(HANDOFF, "handoff")
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080032
33#define _(v, s) AH_DECRYPT_NEXT_##v,
34typedef enum
35{
36 foreach_ah_decrypt_next
37#undef _
38 AH_DECRYPT_N_NEXT,
39} ah_decrypt_next_t;
40
Klement Sekerabe5a5dd2018-10-09 16:05:48 +020041#define foreach_ah_decrypt_error \
42 _ (RX_PKTS, "AH pkts received") \
43 _ (DECRYPTION_FAILED, "AH decryption failed") \
44 _ (INTEG_ERROR, "Integrity check failed") \
Filip Tehlar6230eea2019-05-21 08:11:21 +000045 _ (NO_TAIL_SPACE, "not enough buffer tail space (dropped)") \
46 _ (DROP_FRAGMENTS, "IP fragments drop") \
Klement Sekerabe5a5dd2018-10-09 16:05:48 +020047 _ (REPLAY, "SA replayed packet")
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080048
49typedef enum
50{
51#define _(sym,str) AH_DECRYPT_ERROR_##sym,
52 foreach_ah_decrypt_error
53#undef _
54 AH_DECRYPT_N_ERROR,
55} ah_decrypt_error_t;
56
57static char *ah_decrypt_error_strings[] = {
58#define _(sym,string) string,
59 foreach_ah_decrypt_error
60#undef _
61};
62
63typedef struct
64{
65 ipsec_integ_alg_t integ_alg;
Neale Rannsde847272018-11-28 01:38:34 -080066 u32 seq_num;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080067} ah_decrypt_trace_t;
68
69/* packet trace format function */
70static u8 *
71format_ah_decrypt_trace (u8 * s, va_list * args)
72{
73 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
74 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
75 ah_decrypt_trace_t *t = va_arg (*args, ah_decrypt_trace_t *);
76
Neale Rannsde847272018-11-28 01:38:34 -080077 s = format (s, "ah: integrity %U seq-num %d",
78 format_ipsec_integ_alg, t->integ_alg, t->seq_num);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080079 return s;
80}
81
Filip Tehlar6230eea2019-05-21 08:11:21 +000082typedef struct
83{
84 union
85 {
86 struct
87 {
88 u8 hop_limit;
89 u8 nexthdr;
90 u32 ip_version_traffic_class_and_flow_label;
91 };
92
93 struct
94 {
95 u8 ttl;
96 u8 tos;
97 };
98 };
99 u32 sa_index;
100 u32 seq;
Neale Ranns5b891102021-06-28 13:31:28 +0000101 u32 seq_hi;
Filip Tehlar6230eea2019-05-21 08:11:21 +0000102 u8 icv_padding_len;
103 u8 icv_size;
104 u8 ip_hdr_size;
105 i16 current_data;
106 u8 nexthdr_cached;
107} ah_decrypt_packet_data_t;
108
109static_always_inline void
110ah_process_ops (vlib_main_t * vm, vlib_node_runtime_t * node,
111 vnet_crypto_op_t * ops, vlib_buffer_t * b[], u16 * nexts)
112{
113 u32 n_fail, n_ops = vec_len (ops);
114 vnet_crypto_op_t *op = ops;
115
116 if (n_ops == 0)
117 return;
118
119 n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
120
121 while (n_fail)
122 {
123 ASSERT (op - ops < n_ops);
124
125 if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
126 {
127 u32 bi = op->user_data;
128 b[bi]->error = node->errors[AH_DECRYPT_ERROR_INTEG_ERROR];
129 nexts[bi] = AH_DECRYPT_NEXT_DROP;
130 n_fail--;
131 }
132 op++;
133 }
134}
135
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200136always_inline uword
137ah_decrypt_inline (vlib_main_t * vm,
138 vlib_node_runtime_t * node, vlib_frame_t * from_frame,
139 int is_ip6)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800140{
Filip Tehlar6230eea2019-05-21 08:11:21 +0000141 u32 n_left, *from;
142 u32 thread_index = vm->thread_index;
143 u16 buffer_data_size = vlib_buffer_get_default_data_size (vm);
144 ah_decrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data;
145 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
146 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800147 ipsec_main_t *im = &ipsec_main;
Filip Tehlar6230eea2019-05-21 08:11:21 +0000148 ipsec_per_thread_data_t *ptd = vec_elt_at_index (im->ptd, thread_index);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800149 from = vlib_frame_vector_args (from_frame);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000150 n_left = from_frame->n_vectors;
151 ipsec_sa_t *sa0 = 0;
152 u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800153
Filip Tehlar6230eea2019-05-21 08:11:21 +0000154 clib_memset (pkt_data, 0, VLIB_FRAME_SIZE * sizeof (pkt_data[0]));
155 vlib_get_buffers (vm, from, b, n_left);
156 clib_memset_u16 (nexts, -1, n_left);
157 vec_reset_length (ptd->integ_ops);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800158
Filip Tehlar6230eea2019-05-21 08:11:21 +0000159 while (n_left > 0)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800160 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000161 ah_header_t *ah0;
162 ip4_header_t *ih4;
163 ip6_header_t *ih6;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800164
Filip Tehlar6230eea2019-05-21 08:11:21 +0000165 if (vnet_buffer (b[0])->ipsec.sad_index != current_sa_index)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800166 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000167 if (current_sa_index != ~0)
168 vlib_increment_combined_counter (&ipsec_sa_counters, thread_index,
169 current_sa_index,
170 current_sa_pkts,
171 current_sa_bytes);
172 current_sa_index = vnet_buffer (b[0])->ipsec.sad_index;
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000173 sa0 = ipsec_sa_get (current_sa_index);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800174
Filip Tehlar6230eea2019-05-21 08:11:21 +0000175 current_sa_bytes = current_sa_pkts = 0;
Neale Rannseba31ec2019-02-17 18:04:27 +0000176 vlib_prefetch_combined_counter (&ipsec_sa_counters,
Filip Tehlar6230eea2019-05-21 08:11:21 +0000177 thread_index, current_sa_index);
178 }
179
Neale Ranns1a52d372021-02-04 11:33:32 +0000180 if (PREDICT_FALSE (~0 == sa0->thread_index))
Neale Rannsf62a8c02019-04-02 08:13:33 +0000181 {
182 /* this is the first packet to use this SA, claim the SA
183 * for this thread. this could happen simultaneously on
184 * another thread */
Neale Ranns1a52d372021-02-04 11:33:32 +0000185 clib_atomic_cmp_and_swap (&sa0->thread_index, ~0,
Neale Rannsf62a8c02019-04-02 08:13:33 +0000186 ipsec_sa_assign_thread (thread_index));
187 }
188
Neale Ranns1a52d372021-02-04 11:33:32 +0000189 if (PREDICT_TRUE (thread_index != sa0->thread_index))
Neale Rannsf62a8c02019-04-02 08:13:33 +0000190 {
Neale Rannsaa7d7662021-02-10 08:42:49 +0000191 vnet_buffer (b[0])->ipsec.thread_index = sa0->thread_index;
Neale Rannsf62a8c02019-04-02 08:13:33 +0000192 next[0] = AH_DECRYPT_NEXT_HANDOFF;
193 goto next;
194 }
195
Filip Tehlar6230eea2019-05-21 08:11:21 +0000196 pd->sa_index = current_sa_index;
197
198 ih4 = vlib_buffer_get_current (b[0]);
199 ih6 = vlib_buffer_get_current (b[0]);
200 pd->current_data = b[0]->current_data;
201
202 if (is_ip6)
203 {
204 ip6_ext_header_t *prev = NULL;
Klement Sekera769145c2019-03-06 11:59:57 +0100205 ah0 =
206 ip6_ext_header_find (vm, b[0], ih6, IP_PROTOCOL_IPSEC_AH, &prev);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000207 pd->ip_hdr_size = sizeof (ip6_header_t);
208 ASSERT ((u8 *) ah0 - (u8 *) ih6 == pd->ip_hdr_size);
209 }
210 else
211 {
212 if (ip4_is_fragment (ih4))
213 {
214 b[0]->error = node->errors[AH_DECRYPT_ERROR_DROP_FRAGMENTS];
215 next[0] = AH_DECRYPT_NEXT_DROP;
216 goto next;
217 }
218 pd->ip_hdr_size = ip4_header_bytes (ih4);
219 ah0 = (ah_header_t *) ((u8 *) ih4 + pd->ip_hdr_size);
220 }
221
222 pd->seq = clib_host_to_net_u32 (ah0->seq_no);
223
224 /* anti-replay check */
Neale Ranns5b891102021-06-28 13:31:28 +0000225 if (ipsec_sa_anti_replay_and_sn_advance (sa0, pd->seq, ~0, false,
226 &pd->seq_hi))
Filip Tehlar6230eea2019-05-21 08:11:21 +0000227 {
228 b[0]->error = node->errors[AH_DECRYPT_ERROR_REPLAY];
229 next[0] = AH_DECRYPT_NEXT_DROP;
230 goto next;
231 }
232
233 current_sa_bytes += b[0]->current_length;
234 current_sa_pkts += 1;
235
236 pd->icv_size = sa0->integ_icv_size;
237 pd->nexthdr_cached = ah0->nexthdr;
238 if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
239 {
240 if (PREDICT_FALSE (ipsec_sa_is_set_USE_ESN (sa0) &&
241 pd->current_data + b[0]->current_length
242 + sizeof (u32) > buffer_data_size))
243 {
244 b[0]->error = node->errors[AH_DECRYPT_ERROR_NO_TAIL_SPACE];
245 next[0] = AH_DECRYPT_NEXT_DROP;
246 goto next;
247 }
248
249 vnet_crypto_op_t *op;
250 vec_add2_aligned (ptd->integ_ops, op, 1, CLIB_CACHE_LINE_BYTES);
251 vnet_crypto_op_init (op, sa0->integ_op_id);
252
253 op->src = (u8 *) ih4;
254 op->len = b[0]->current_length;
255 op->digest = (u8 *) ih4 - pd->icv_size;
256 op->flags = VNET_CRYPTO_OP_FLAG_HMAC_CHECK;
257 op->digest_len = pd->icv_size;
258 op->key_index = sa0->integ_key_index;
259 op->user_data = b - bufs;
260 if (ipsec_sa_is_set_USE_ESN (sa0))
261 {
Neale Ranns5b891102021-06-28 13:31:28 +0000262 u32 seq_hi = clib_host_to_net_u32 (pd->seq_hi);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000263
264 op->len += sizeof (seq_hi);
265 clib_memcpy (op->src + b[0]->current_length, &seq_hi,
266 sizeof (seq_hi));
267 }
268 clib_memcpy (op->digest, ah0->auth_data, pd->icv_size);
269 clib_memset (ah0->auth_data, 0, pd->icv_size);
Neale Rannseba31ec2019-02-17 18:04:27 +0000270
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200271 if (is_ip6)
Klement Sekera611864f2018-09-26 11:19:00 +0200272 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000273 pd->ip_version_traffic_class_and_flow_label =
274 ih6->ip_version_traffic_class_and_flow_label;
275 pd->hop_limit = ih6->hop_limit;
276 ih6->ip_version_traffic_class_and_flow_label = 0x60;
277 ih6->hop_limit = 0;
278 pd->nexthdr = ah0->nexthdr;
279 pd->icv_padding_len =
280 ah_calc_icv_padding_len (pd->icv_size, 1 /* is_ipv6 */ );
Klement Sekera611864f2018-09-26 11:19:00 +0200281 }
282 else
283 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000284 pd->tos = ih4->tos;
285 pd->ttl = ih4->ttl;
286 ih4->tos = 0;
287 ih4->ttl = 0;
288 ih4->checksum = 0;
289 pd->icv_padding_len =
290 ah_calc_icv_padding_len (pd->icv_size, 0 /* is_ipv6 */ );
Klement Sekera611864f2018-09-26 11:19:00 +0200291 }
Filip Tehlar6230eea2019-05-21 08:11:21 +0000292 }
Klement Sekera611864f2018-09-26 11:19:00 +0200293
Filip Tehlar6230eea2019-05-21 08:11:21 +0000294 next:
295 n_left -= 1;
296 pd += 1;
297 next += 1;
298 b += 1;
299 }
Neale Rannsde847272018-11-28 01:38:34 -0800300
Filip Tehlar6230eea2019-05-21 08:11:21 +0000301 n_left = from_frame->n_vectors;
302 next = nexts;
303 pd = pkt_data;
304 b = bufs;
305
306 vlib_node_increment_counter (vm, node->node_index, AH_DECRYPT_ERROR_RX_PKTS,
307 n_left);
308 vlib_increment_combined_counter (&ipsec_sa_counters, thread_index,
309 current_sa_index, current_sa_pkts,
310 current_sa_bytes);
311
312 ah_process_ops (vm, node, ptd->integ_ops, bufs, nexts);
313
314 while (n_left > 0)
315 {
316 ip4_header_t *oh4;
317 ip6_header_t *oh6;
Neale Rannse11203e2021-09-21 12:34:19 +0000318 u64 n_lost = 0;
Filip Tehlar6230eea2019-05-21 08:11:21 +0000319
320 if (next[0] < AH_DECRYPT_N_NEXT)
321 goto trace;
322
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000323 sa0 = ipsec_sa_get (pd->sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000324
325 if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
326 {
Neale Rannse11203e2021-09-21 12:34:19 +0000327 /* redo the anti-reply check. see esp_decrypt for details */
Neale Ranns5b891102021-06-28 13:31:28 +0000328 if (ipsec_sa_anti_replay_and_sn_advance (sa0, pd->seq, pd->seq_hi,
329 true, NULL))
Neale Ranns3b9374f2019-08-01 04:45:15 -0700330 {
331 b[0]->error = node->errors[AH_DECRYPT_ERROR_REPLAY];
332 next[0] = AH_DECRYPT_NEXT_DROP;
333 goto trace;
334 }
Neale Rannse11203e2021-09-21 12:34:19 +0000335 n_lost = ipsec_sa_anti_replay_advance (sa0, thread_index, pd->seq,
336 pd->seq_hi);
337 vlib_prefetch_simple_counter (&ipsec_sa_lost_counters, thread_index,
338 pd->sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000339 }
340
341 u16 ah_hdr_len = sizeof (ah_header_t) + pd->icv_size
342 + pd->icv_padding_len;
343 vlib_buffer_advance (b[0], pd->ip_hdr_size + ah_hdr_len);
344 b[0]->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
345
346 if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
347 { /* tunnel mode */
348 if (PREDICT_TRUE (pd->nexthdr_cached == IP_PROTOCOL_IP_IN_IP))
349 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
350 else if (pd->nexthdr_cached == IP_PROTOCOL_IPV6)
351 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
352 else
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800353 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000354 b[0]->error = node->errors[AH_DECRYPT_ERROR_DECRYPTION_FAILED];
355 next[0] = AH_DECRYPT_NEXT_DROP;
Damjan Marion1f4e1cb2019-03-28 19:19:31 +0100356 goto trace;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800357 }
Filip Tehlar6230eea2019-05-21 08:11:21 +0000358 }
359 else
360 { /* transport mode */
361 if (is_ip6)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800362 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000363 vlib_buffer_advance (b[0], -sizeof (ip6_header_t));
364 oh6 = vlib_buffer_get_current (b[0]);
365 if (ah_hdr_len >= sizeof (ip6_header_t))
366 clib_memcpy (oh6, b[0]->data + pd->current_data,
367 sizeof (ip6_header_t));
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200368 else
Filip Tehlar6230eea2019-05-21 08:11:21 +0000369 memmove (oh6, b[0]->data + pd->current_data,
370 sizeof (ip6_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800371
Filip Tehlar6230eea2019-05-21 08:11:21 +0000372 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
373 oh6->protocol = pd->nexthdr;
374 oh6->hop_limit = pd->hop_limit;
375 oh6->ip_version_traffic_class_and_flow_label =
376 pd->ip_version_traffic_class_and_flow_label;
377 oh6->payload_length =
378 clib_host_to_net_u16 (vlib_buffer_length_in_chain
379 (vm, b[0]) - sizeof (ip6_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800380 }
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800381 else
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800382 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000383 vlib_buffer_advance (b[0], -sizeof (ip4_header_t));
384 oh4 = vlib_buffer_get_current (b[0]);
385 if (ah_hdr_len >= sizeof (ip4_header_t))
386 clib_memcpy (oh4, b[0]->data + pd->current_data,
387 sizeof (ip4_header_t));
388 else
389 memmove (oh4, b[0]->data + pd->current_data,
390 sizeof (ip4_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800391
Filip Tehlar6230eea2019-05-21 08:11:21 +0000392 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
393 oh4->ip_version_and_header_length = 0x45;
394 oh4->fragment_id = 0;
395 oh4->flags_and_fragment_offset = 0;
396 oh4->protocol = pd->nexthdr_cached;
397 oh4->length =
398 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b[0]));
399 oh4->ttl = pd->ttl;
400 oh4->tos = pd->tos;
401 oh4->checksum = ip4_header_checksum (oh4);
402 }
403 }
404
Neale Rannse11203e2021-09-21 12:34:19 +0000405 if (PREDICT_FALSE (n_lost))
406 vlib_increment_simple_counter (&ipsec_sa_lost_counters, thread_index,
407 pd->sa_index, n_lost);
408
Filip Tehlar6230eea2019-05-21 08:11:21 +0000409 vnet_buffer (b[0])->sw_if_index[VLIB_TX] = (u32) ~ 0;
410 trace:
411 if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
412 {
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000413 sa0 = ipsec_sa_get (vnet_buffer (b[0])->ipsec.sad_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000414 ah_decrypt_trace_t *tr =
415 vlib_add_trace (vm, node, b[0], sizeof (*tr));
416 tr->integ_alg = sa0->integ_alg;
417 tr->seq_num = pd->seq;
418 }
419
420 n_left -= 1;
421 pd += 1;
422 next += 1;
423 b += 1;
424 }
425
426 n_left = from_frame->n_vectors;
427 vlib_buffer_enqueue_to_next (vm, node, from, nexts, n_left);
428
429 return n_left;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800430}
431
Klement Sekerab8f35442018-10-29 13:38:19 +0100432VLIB_NODE_FN (ah4_decrypt_node) (vlib_main_t * vm,
433 vlib_node_runtime_t * node,
434 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200435{
436 return ah_decrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ );
437}
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800438
439/* *INDENT-OFF* */
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200440VLIB_REGISTER_NODE (ah4_decrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200441 .name = "ah4-decrypt",
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800442 .vector_size = sizeof (u32),
443 .format_trace = format_ah_decrypt_trace,
444 .type = VLIB_NODE_TYPE_INTERNAL,
445
446 .n_errors = ARRAY_LEN(ah_decrypt_error_strings),
447 .error_strings = ah_decrypt_error_strings,
448
449 .n_next_nodes = AH_DECRYPT_N_NEXT,
450 .next_nodes = {
Neale Rannsf62a8c02019-04-02 08:13:33 +0000451 [AH_DECRYPT_NEXT_DROP] = "ip4-drop",
452 [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
453 [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
Neale Ranns4a56f4e2019-12-23 04:10:25 +0000454 [AH_DECRYPT_NEXT_HANDOFF] = "ah4-decrypt-handoff",
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800455 },
456};
457/* *INDENT-ON* */
458
Klement Sekerab8f35442018-10-29 13:38:19 +0100459VLIB_NODE_FN (ah6_decrypt_node) (vlib_main_t * vm,
460 vlib_node_runtime_t * node,
461 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200462{
463 return ah_decrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ );
464}
465
466/* *INDENT-OFF* */
467VLIB_REGISTER_NODE (ah6_decrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200468 .name = "ah6-decrypt",
469 .vector_size = sizeof (u32),
470 .format_trace = format_ah_decrypt_trace,
471 .type = VLIB_NODE_TYPE_INTERNAL,
472
473 .n_errors = ARRAY_LEN(ah_decrypt_error_strings),
474 .error_strings = ah_decrypt_error_strings,
475
476 .n_next_nodes = AH_DECRYPT_N_NEXT,
477 .next_nodes = {
Neale Rannsf62a8c02019-04-02 08:13:33 +0000478 [AH_DECRYPT_NEXT_DROP] = "ip6-drop",
479 [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
480 [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
Neale Ranns4a56f4e2019-12-23 04:10:25 +0000481 [AH_DECRYPT_NEXT_HANDOFF] = "ah6-decrypt-handoff",
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200482 },
483};
484/* *INDENT-ON* */
485
Neale Ranns2d498302021-02-25 08:38:58 +0000486#ifndef CLIB_MARCH_VARIANT
487
488static clib_error_t *
489ah_decrypt_init (vlib_main_t *vm)
490{
491 ipsec_main_t *im = &ipsec_main;
492
493 im->ah4_dec_fq_index =
494 vlib_frame_queue_main_init (ah4_decrypt_node.index, 0);
495 im->ah6_dec_fq_index =
496 vlib_frame_queue_main_init (ah6_decrypt_node.index, 0);
497
498 return 0;
499}
500
501VLIB_INIT_FUNCTION (ah_decrypt_init);
502
503#endif
504
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800505/*
506 * fd.io coding-style-patch-verification: ON
507 *
508 * Local Variables:
509 * eval: (c-set-style "gnu")
510 * End:
511 */