blob: f20f620eb3cb3821199ef0dee96a1c6f1a8559af [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
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080041typedef struct
42{
43 ipsec_integ_alg_t integ_alg;
Neale Rannsde847272018-11-28 01:38:34 -080044 u32 seq_num;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080045} ah_decrypt_trace_t;
46
47/* packet trace format function */
48static u8 *
49format_ah_decrypt_trace (u8 * s, va_list * args)
50{
51 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
52 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
53 ah_decrypt_trace_t *t = va_arg (*args, ah_decrypt_trace_t *);
54
Neale Rannsde847272018-11-28 01:38:34 -080055 s = format (s, "ah: integrity %U seq-num %d",
56 format_ipsec_integ_alg, t->integ_alg, t->seq_num);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -080057 return s;
58}
59
Filip Tehlar6230eea2019-05-21 08:11:21 +000060typedef struct
61{
62 union
63 {
64 struct
65 {
66 u8 hop_limit;
67 u8 nexthdr;
68 u32 ip_version_traffic_class_and_flow_label;
69 };
70
71 struct
72 {
73 u8 ttl;
74 u8 tos;
75 };
76 };
77 u32 sa_index;
78 u32 seq;
Neale Ranns5b891102021-06-28 13:31:28 +000079 u32 seq_hi;
Filip Tehlar6230eea2019-05-21 08:11:21 +000080 u8 icv_padding_len;
81 u8 icv_size;
82 u8 ip_hdr_size;
83 i16 current_data;
84 u8 nexthdr_cached;
85} ah_decrypt_packet_data_t;
86
87static_always_inline void
88ah_process_ops (vlib_main_t * vm, vlib_node_runtime_t * node,
89 vnet_crypto_op_t * ops, vlib_buffer_t * b[], u16 * nexts)
90{
91 u32 n_fail, n_ops = vec_len (ops);
92 vnet_crypto_op_t *op = ops;
93
94 if (n_ops == 0)
95 return;
96
97 n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
98
99 while (n_fail)
100 {
101 ASSERT (op - ops < n_ops);
102
103 if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
104 {
105 u32 bi = op->user_data;
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100106 ah_decrypt_set_next_index (
107 b[bi], node, vm->thread_index, AH_DECRYPT_ERROR_INTEG_ERROR, bi,
108 nexts, AH_DECRYPT_NEXT_DROP, vnet_buffer (b[bi])->ipsec.sad_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000109 n_fail--;
110 }
111 op++;
112 }
113}
114
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200115always_inline uword
116ah_decrypt_inline (vlib_main_t * vm,
117 vlib_node_runtime_t * node, vlib_frame_t * from_frame,
118 int is_ip6)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800119{
Filip Tehlar6230eea2019-05-21 08:11:21 +0000120 u32 n_left, *from;
121 u32 thread_index = vm->thread_index;
122 u16 buffer_data_size = vlib_buffer_get_default_data_size (vm);
123 ah_decrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data;
124 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
125 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800126 ipsec_main_t *im = &ipsec_main;
Filip Tehlar6230eea2019-05-21 08:11:21 +0000127 ipsec_per_thread_data_t *ptd = vec_elt_at_index (im->ptd, thread_index);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800128 from = vlib_frame_vector_args (from_frame);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000129 n_left = from_frame->n_vectors;
130 ipsec_sa_t *sa0 = 0;
131 u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800132
Filip Tehlar6230eea2019-05-21 08:11:21 +0000133 clib_memset (pkt_data, 0, VLIB_FRAME_SIZE * sizeof (pkt_data[0]));
134 vlib_get_buffers (vm, from, b, n_left);
135 clib_memset_u16 (nexts, -1, n_left);
136 vec_reset_length (ptd->integ_ops);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800137
Filip Tehlar6230eea2019-05-21 08:11:21 +0000138 while (n_left > 0)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800139 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000140 ah_header_t *ah0;
141 ip4_header_t *ih4;
142 ip6_header_t *ih6;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800143
Filip Tehlar6230eea2019-05-21 08:11:21 +0000144 if (vnet_buffer (b[0])->ipsec.sad_index != current_sa_index)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800145 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000146 if (current_sa_index != ~0)
147 vlib_increment_combined_counter (&ipsec_sa_counters, thread_index,
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100148 current_sa_index, current_sa_pkts,
Filip Tehlar6230eea2019-05-21 08:11:21 +0000149 current_sa_bytes);
150 current_sa_index = vnet_buffer (b[0])->ipsec.sad_index;
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000151 sa0 = ipsec_sa_get (current_sa_index);
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800152
Filip Tehlar6230eea2019-05-21 08:11:21 +0000153 current_sa_bytes = current_sa_pkts = 0;
Neale Rannseba31ec2019-02-17 18:04:27 +0000154 vlib_prefetch_combined_counter (&ipsec_sa_counters,
Filip Tehlar6230eea2019-05-21 08:11:21 +0000155 thread_index, current_sa_index);
156 }
157
Benoît Ganne5527a782022-01-18 15:56:41 +0100158 if (PREDICT_FALSE ((u16) ~0 == sa0->thread_index))
Neale Rannsf62a8c02019-04-02 08:13:33 +0000159 {
160 /* this is the first packet to use this SA, claim the SA
161 * for this thread. this could happen simultaneously on
162 * another thread */
Neale Ranns1a52d372021-02-04 11:33:32 +0000163 clib_atomic_cmp_and_swap (&sa0->thread_index, ~0,
Neale Rannsf62a8c02019-04-02 08:13:33 +0000164 ipsec_sa_assign_thread (thread_index));
165 }
166
Neale Ranns1a52d372021-02-04 11:33:32 +0000167 if (PREDICT_TRUE (thread_index != sa0->thread_index))
Neale Rannsf62a8c02019-04-02 08:13:33 +0000168 {
Neale Rannsaa7d7662021-02-10 08:42:49 +0000169 vnet_buffer (b[0])->ipsec.thread_index = sa0->thread_index;
Neale Rannsf62a8c02019-04-02 08:13:33 +0000170 next[0] = AH_DECRYPT_NEXT_HANDOFF;
171 goto next;
172 }
173
Filip Tehlar6230eea2019-05-21 08:11:21 +0000174 pd->sa_index = current_sa_index;
175
176 ih4 = vlib_buffer_get_current (b[0]);
177 ih6 = vlib_buffer_get_current (b[0]);
178 pd->current_data = b[0]->current_data;
179
180 if (is_ip6)
181 {
182 ip6_ext_header_t *prev = NULL;
Klement Sekera769145c2019-03-06 11:59:57 +0100183 ah0 =
184 ip6_ext_header_find (vm, b[0], ih6, IP_PROTOCOL_IPSEC_AH, &prev);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000185 pd->ip_hdr_size = sizeof (ip6_header_t);
186 ASSERT ((u8 *) ah0 - (u8 *) ih6 == pd->ip_hdr_size);
187 }
188 else
189 {
190 if (ip4_is_fragment (ih4))
191 {
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100192 ah_decrypt_set_next_index (
193 b[0], node, vm->thread_index, AH_DECRYPT_ERROR_DROP_FRAGMENTS,
194 0, next, AH_DECRYPT_NEXT_DROP, current_sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000195 goto next;
196 }
197 pd->ip_hdr_size = ip4_header_bytes (ih4);
198 ah0 = (ah_header_t *) ((u8 *) ih4 + pd->ip_hdr_size);
199 }
200
201 pd->seq = clib_host_to_net_u32 (ah0->seq_no);
202
203 /* anti-replay check */
Neale Ranns5b891102021-06-28 13:31:28 +0000204 if (ipsec_sa_anti_replay_and_sn_advance (sa0, pd->seq, ~0, false,
205 &pd->seq_hi))
Filip Tehlar6230eea2019-05-21 08:11:21 +0000206 {
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100207 ah_decrypt_set_next_index (b[0], node, vm->thread_index,
208 AH_DECRYPT_ERROR_REPLAY, 0, next,
209 AH_DECRYPT_NEXT_DROP, current_sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000210 goto next;
211 }
212
213 current_sa_bytes += b[0]->current_length;
214 current_sa_pkts += 1;
215
216 pd->icv_size = sa0->integ_icv_size;
217 pd->nexthdr_cached = ah0->nexthdr;
218 if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
219 {
220 if (PREDICT_FALSE (ipsec_sa_is_set_USE_ESN (sa0) &&
221 pd->current_data + b[0]->current_length
222 + sizeof (u32) > buffer_data_size))
223 {
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100224 ah_decrypt_set_next_index (
225 b[0], node, vm->thread_index, AH_DECRYPT_ERROR_NO_TAIL_SPACE,
226 0, next, AH_DECRYPT_NEXT_DROP, current_sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000227 goto next;
228 }
229
230 vnet_crypto_op_t *op;
231 vec_add2_aligned (ptd->integ_ops, op, 1, CLIB_CACHE_LINE_BYTES);
232 vnet_crypto_op_init (op, sa0->integ_op_id);
233
234 op->src = (u8 *) ih4;
235 op->len = b[0]->current_length;
236 op->digest = (u8 *) ih4 - pd->icv_size;
237 op->flags = VNET_CRYPTO_OP_FLAG_HMAC_CHECK;
238 op->digest_len = pd->icv_size;
239 op->key_index = sa0->integ_key_index;
240 op->user_data = b - bufs;
241 if (ipsec_sa_is_set_USE_ESN (sa0))
242 {
Neale Ranns5b891102021-06-28 13:31:28 +0000243 u32 seq_hi = clib_host_to_net_u32 (pd->seq_hi);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000244
245 op->len += sizeof (seq_hi);
246 clib_memcpy (op->src + b[0]->current_length, &seq_hi,
247 sizeof (seq_hi));
248 }
249 clib_memcpy (op->digest, ah0->auth_data, pd->icv_size);
250 clib_memset (ah0->auth_data, 0, pd->icv_size);
Neale Rannseba31ec2019-02-17 18:04:27 +0000251
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200252 if (is_ip6)
Klement Sekera611864f2018-09-26 11:19:00 +0200253 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000254 pd->ip_version_traffic_class_and_flow_label =
255 ih6->ip_version_traffic_class_and_flow_label;
256 pd->hop_limit = ih6->hop_limit;
257 ih6->ip_version_traffic_class_and_flow_label = 0x60;
258 ih6->hop_limit = 0;
259 pd->nexthdr = ah0->nexthdr;
260 pd->icv_padding_len =
261 ah_calc_icv_padding_len (pd->icv_size, 1 /* is_ipv6 */ );
Klement Sekera611864f2018-09-26 11:19:00 +0200262 }
263 else
264 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000265 pd->tos = ih4->tos;
266 pd->ttl = ih4->ttl;
267 ih4->tos = 0;
268 ih4->ttl = 0;
269 ih4->checksum = 0;
270 pd->icv_padding_len =
271 ah_calc_icv_padding_len (pd->icv_size, 0 /* is_ipv6 */ );
Klement Sekera611864f2018-09-26 11:19:00 +0200272 }
Filip Tehlar6230eea2019-05-21 08:11:21 +0000273 }
Klement Sekera611864f2018-09-26 11:19:00 +0200274
Filip Tehlar6230eea2019-05-21 08:11:21 +0000275 next:
276 n_left -= 1;
277 pd += 1;
278 next += 1;
279 b += 1;
280 }
Neale Rannsde847272018-11-28 01:38:34 -0800281
Filip Tehlar6230eea2019-05-21 08:11:21 +0000282 n_left = from_frame->n_vectors;
283 next = nexts;
284 pd = pkt_data;
285 b = bufs;
286
287 vlib_node_increment_counter (vm, node->node_index, AH_DECRYPT_ERROR_RX_PKTS,
288 n_left);
289 vlib_increment_combined_counter (&ipsec_sa_counters, thread_index,
290 current_sa_index, current_sa_pkts,
291 current_sa_bytes);
292
293 ah_process_ops (vm, node, ptd->integ_ops, bufs, nexts);
294
295 while (n_left > 0)
296 {
297 ip4_header_t *oh4;
298 ip6_header_t *oh6;
Neale Rannse11203e2021-09-21 12:34:19 +0000299 u64 n_lost = 0;
Filip Tehlar6230eea2019-05-21 08:11:21 +0000300
301 if (next[0] < AH_DECRYPT_N_NEXT)
302 goto trace;
303
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000304 sa0 = ipsec_sa_get (pd->sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000305
306 if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
307 {
Neale Rannse11203e2021-09-21 12:34:19 +0000308 /* redo the anti-reply check. see esp_decrypt for details */
Neale Ranns5b891102021-06-28 13:31:28 +0000309 if (ipsec_sa_anti_replay_and_sn_advance (sa0, pd->seq, pd->seq_hi,
310 true, NULL))
Neale Ranns3b9374f2019-08-01 04:45:15 -0700311 {
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100312 ah_decrypt_set_next_index (b[0], node, vm->thread_index,
313 AH_DECRYPT_ERROR_REPLAY, 0, next,
314 AH_DECRYPT_NEXT_DROP, pd->sa_index);
Neale Ranns3b9374f2019-08-01 04:45:15 -0700315 goto trace;
316 }
Neale Rannse11203e2021-09-21 12:34:19 +0000317 n_lost = ipsec_sa_anti_replay_advance (sa0, thread_index, pd->seq,
318 pd->seq_hi);
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100319 vlib_prefetch_simple_counter (
320 &ipsec_sa_err_counters[IPSEC_SA_ERROR_LOST], thread_index,
321 pd->sa_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000322 }
323
324 u16 ah_hdr_len = sizeof (ah_header_t) + pd->icv_size
325 + pd->icv_padding_len;
326 vlib_buffer_advance (b[0], pd->ip_hdr_size + ah_hdr_len);
327 b[0]->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
328
329 if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
330 { /* tunnel mode */
331 if (PREDICT_TRUE (pd->nexthdr_cached == IP_PROTOCOL_IP_IN_IP))
332 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
333 else if (pd->nexthdr_cached == IP_PROTOCOL_IPV6)
334 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
335 else
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800336 {
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100337 ah_decrypt_set_next_index (b[0], node, vm->thread_index,
338 AH_DECRYPT_ERROR_DECRYPTION_FAILED, 0,
339 next, AH_DECRYPT_NEXT_DROP,
340 pd->sa_index);
Damjan Marion1f4e1cb2019-03-28 19:19:31 +0100341 goto trace;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800342 }
Filip Tehlar6230eea2019-05-21 08:11:21 +0000343 }
344 else
345 { /* transport mode */
346 if (is_ip6)
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800347 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000348 vlib_buffer_advance (b[0], -sizeof (ip6_header_t));
349 oh6 = vlib_buffer_get_current (b[0]);
350 if (ah_hdr_len >= sizeof (ip6_header_t))
351 clib_memcpy (oh6, b[0]->data + pd->current_data,
352 sizeof (ip6_header_t));
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200353 else
Filip Tehlar6230eea2019-05-21 08:11:21 +0000354 memmove (oh6, b[0]->data + pd->current_data,
355 sizeof (ip6_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800356
Filip Tehlar6230eea2019-05-21 08:11:21 +0000357 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
358 oh6->protocol = pd->nexthdr;
359 oh6->hop_limit = pd->hop_limit;
360 oh6->ip_version_traffic_class_and_flow_label =
361 pd->ip_version_traffic_class_and_flow_label;
362 oh6->payload_length =
363 clib_host_to_net_u16 (vlib_buffer_length_in_chain
364 (vm, b[0]) - sizeof (ip6_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800365 }
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800366 else
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800367 {
Filip Tehlar6230eea2019-05-21 08:11:21 +0000368 vlib_buffer_advance (b[0], -sizeof (ip4_header_t));
369 oh4 = vlib_buffer_get_current (b[0]);
370 if (ah_hdr_len >= sizeof (ip4_header_t))
371 clib_memcpy (oh4, b[0]->data + pd->current_data,
372 sizeof (ip4_header_t));
373 else
374 memmove (oh4, b[0]->data + pd->current_data,
375 sizeof (ip4_header_t));
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800376
Filip Tehlar6230eea2019-05-21 08:11:21 +0000377 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
378 oh4->ip_version_and_header_length = 0x45;
379 oh4->fragment_id = 0;
380 oh4->flags_and_fragment_offset = 0;
381 oh4->protocol = pd->nexthdr_cached;
382 oh4->length =
383 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b[0]));
384 oh4->ttl = pd->ttl;
385 oh4->tos = pd->tos;
386 oh4->checksum = ip4_header_checksum (oh4);
387 }
388 }
389
Neale Rannse11203e2021-09-21 12:34:19 +0000390 if (PREDICT_FALSE (n_lost))
Arthur de Kerhorad95b062022-11-16 19:12:05 +0100391 vlib_increment_simple_counter (
392 &ipsec_sa_err_counters[IPSEC_SA_ERROR_LOST], thread_index,
393 pd->sa_index, n_lost);
Neale Rannse11203e2021-09-21 12:34:19 +0000394
Filip Tehlar6230eea2019-05-21 08:11:21 +0000395 vnet_buffer (b[0])->sw_if_index[VLIB_TX] = (u32) ~ 0;
396 trace:
397 if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
398 {
Neale Rannsc5fe57d2021-02-25 16:01:28 +0000399 sa0 = ipsec_sa_get (vnet_buffer (b[0])->ipsec.sad_index);
Filip Tehlar6230eea2019-05-21 08:11:21 +0000400 ah_decrypt_trace_t *tr =
401 vlib_add_trace (vm, node, b[0], sizeof (*tr));
402 tr->integ_alg = sa0->integ_alg;
403 tr->seq_num = pd->seq;
404 }
405
406 n_left -= 1;
407 pd += 1;
408 next += 1;
409 b += 1;
410 }
411
412 n_left = from_frame->n_vectors;
413 vlib_buffer_enqueue_to_next (vm, node, from, nexts, n_left);
414
415 return n_left;
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800416}
417
Klement Sekerab8f35442018-10-29 13:38:19 +0100418VLIB_NODE_FN (ah4_decrypt_node) (vlib_main_t * vm,
419 vlib_node_runtime_t * node,
420 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200421{
422 return ah_decrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ );
423}
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800424
425/* *INDENT-OFF* */
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200426VLIB_REGISTER_NODE (ah4_decrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200427 .name = "ah4-decrypt",
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800428 .vector_size = sizeof (u32),
429 .format_trace = format_ah_decrypt_trace,
430 .type = VLIB_NODE_TYPE_INTERNAL,
431
Neale Ranns93688d72022-08-09 03:34:51 +0000432 .n_errors = AH_DECRYPT_N_ERROR,
433 .error_counters = ah_decrypt_error_counters,
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800434
435 .n_next_nodes = AH_DECRYPT_N_NEXT,
436 .next_nodes = {
Neale Rannsf62a8c02019-04-02 08:13:33 +0000437 [AH_DECRYPT_NEXT_DROP] = "ip4-drop",
438 [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
439 [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
Neale Ranns4a56f4e2019-12-23 04:10:25 +0000440 [AH_DECRYPT_NEXT_HANDOFF] = "ah4-decrypt-handoff",
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800441 },
442};
443/* *INDENT-ON* */
444
Klement Sekerab8f35442018-10-29 13:38:19 +0100445VLIB_NODE_FN (ah6_decrypt_node) (vlib_main_t * vm,
446 vlib_node_runtime_t * node,
447 vlib_frame_t * from_frame)
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200448{
449 return ah_decrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ );
450}
451
452/* *INDENT-OFF* */
453VLIB_REGISTER_NODE (ah6_decrypt_node) = {
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200454 .name = "ah6-decrypt",
455 .vector_size = sizeof (u32),
456 .format_trace = format_ah_decrypt_trace,
457 .type = VLIB_NODE_TYPE_INTERNAL,
458
Neale Ranns93688d72022-08-09 03:34:51 +0000459 .n_errors = AH_DECRYPT_N_ERROR,
460 .error_counters = ah_decrypt_error_counters,
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200461
462 .n_next_nodes = AH_DECRYPT_N_NEXT,
463 .next_nodes = {
Neale Rannsf62a8c02019-04-02 08:13:33 +0000464 [AH_DECRYPT_NEXT_DROP] = "ip6-drop",
465 [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
466 [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
Neale Ranns4a56f4e2019-12-23 04:10:25 +0000467 [AH_DECRYPT_NEXT_HANDOFF] = "ah6-decrypt-handoff",
Klement Sekerabe5a5dd2018-10-09 16:05:48 +0200468 },
469};
470/* *INDENT-ON* */
471
Neale Ranns2d498302021-02-25 08:38:58 +0000472#ifndef CLIB_MARCH_VARIANT
473
474static clib_error_t *
475ah_decrypt_init (vlib_main_t *vm)
476{
477 ipsec_main_t *im = &ipsec_main;
478
479 im->ah4_dec_fq_index =
480 vlib_frame_queue_main_init (ah4_decrypt_node.index, 0);
481 im->ah6_dec_fq_index =
482 vlib_frame_queue_main_init (ah6_decrypt_node.index, 0);
483
484 return 0;
485}
486
487VLIB_INIT_FUNCTION (ah_decrypt_init);
488
489#endif
490
“mukeshyadav1984”430ac932017-11-23 02:39:33 -0800491/*
492 * fd.io coding-style-patch-verification: ON
493 *
494 * Local Variables:
495 * eval: (c-set-style "gnu")
496 * End:
497 */