FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ah_encrypt.c
Go to the documentation of this file.
1 /*
2  * ah_encrypt.c : IPSec AH 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>
21 
22 #include <vnet/ipsec/ipsec.h>
23 #include <vnet/ipsec/esp.h>
24 #include <vnet/ipsec/ah.h>
25 #include <vnet/tunnel/tunnel_dp.h>
26 
27 #define foreach_ah_encrypt_next \
28  _ (DROP, "error-drop") \
29  _ (HANDOFF, "handoff") \
30  _ (INTERFACE_OUTPUT, "interface-output")
31 
32 
33 #define _(v, s) AH_ENCRYPT_NEXT_##v,
34 typedef enum
35 {
37 #undef _
40 
41 #define foreach_ah_encrypt_error \
42  _ (RX_PKTS, "AH pkts received") \
43  _ (CRYPTO_ENGINE_ERROR, "crypto engine error (packet dropped)") \
44  _ (SEQ_CYCLED, "sequence number cycled (packet dropped)")
45 
46 typedef enum
47 {
48 #define _(sym,str) AH_ENCRYPT_ERROR_##sym,
50 #undef _
53 
54 static char *ah_encrypt_error_strings[] = {
55 #define _(sym,string) string,
57 #undef _
58 };
59 
60 typedef struct
61 {
66  ipsec_integ_alg_t integ_alg;
68 
69 /* packet trace format function */
70 static u8 *
71 format_ah_encrypt_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_encrypt_trace_t *t = va_arg (*args, ah_encrypt_trace_t *);
76 
77  s = format (s, "ah: sa-index %d spi %u (0x%08x) seq %u:%u integrity %U",
78  t->sa_index, t->spi, t->spi, t->seq_hi, t->seq_lo,
80  return s;
81 }
82 
86 {
87  u32 n_fail, n_ops = vec_len (ops);
88  vnet_crypto_op_t *op = ops;
89 
90  if (n_ops == 0)
91  return;
92 
93  n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
94 
95  while (n_fail)
96  {
97  ASSERT (op - ops < n_ops);
98 
99  if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
100  {
101  u32 bi = op->user_data;
102  b[bi]->error = node->errors[AH_ENCRYPT_ERROR_CRYPTO_ENGINE_ERROR];
103  nexts[bi] = AH_ENCRYPT_NEXT_DROP;
104  n_fail--;
105  }
106  op++;
107  }
108 }
109 
110 typedef struct
111 {
112  union
113  {
114  /* Variable fields in the IP header not covered by the AH
115  * integrity check */
116  struct
117  {
120  };
121  struct
122  {
125  };
126  };
131 
135  int is_ip6)
136 {
138  int icv_size = 0;
140  n_left = frame->n_vectors;
142  ah_encrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data;
147  ipsec_sa_t *sa0 = 0;
148  ip4_and_ah_header_t *ih0, *oh0 = 0;
149  ip6_and_ah_header_t *ih6_0, *oh6_0 = 0;
150  u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
151  const static ip4_header_t ip4_hdr_template = {
153  .protocol = IP_PROTOCOL_IPSEC_AH,
154  };
155  const static ip6_header_t ip6_hdr_template = {
157  .protocol = IP_PROTOCOL_IPSEC_AH,
158  };
159 
160  clib_memset (pkt_data, 0, VLIB_FRAME_SIZE * sizeof (pkt_data[0]));
164 
165  while (n_left > 0)
166  {
167  u8 ip_hdr_size;
168  u8 next_hdr_type;
169 
170  if (vnet_buffer (b[0])->ipsec.sad_index != current_sa_index)
171  {
172  if (current_sa_index != ~0)
174  current_sa_index,
175  current_sa_pkts,
176  current_sa_bytes);
177  current_sa_index = vnet_buffer (b[0])->ipsec.sad_index;
178  sa0 = ipsec_sa_get (current_sa_index);
179 
180  current_sa_bytes = current_sa_pkts = 0;
181  }
182 
183  pd->sa_index = current_sa_index;
184  next[0] = AH_ENCRYPT_NEXT_DROP;
185 
186  if (PREDICT_FALSE (~0 == sa0->thread_index))
187  {
188  /* this is the first packet to use this SA, claim the SA
189  * for this thread. this could happen simultaneously on
190  * another thread */
193  }
194 
195  if (PREDICT_TRUE (thread_index != sa0->thread_index))
196  {
197  vnet_buffer (b[0])->ipsec.thread_index = sa0->thread_index;
198  next[0] = AH_ENCRYPT_NEXT_HANDOFF;
199  goto next;
200  }
201 
202  if (PREDICT_FALSE (esp_seq_advance (sa0)))
203  {
204  b[0]->error = node->errors[AH_ENCRYPT_ERROR_SEQ_CYCLED];
205  pd->skip = 1;
206  goto next;
207  }
208 
209  current_sa_pkts += 1;
210  current_sa_bytes += b[0]->current_length;
211 
212  ssize_t adv;
213  ih0 = vlib_buffer_get_current (b[0]);
214 
215  if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
216  {
217  if (is_ip6)
218  adv = -sizeof (ip6_and_ah_header_t);
219  else
220  adv = -sizeof (ip4_and_ah_header_t);
221  }
222  else
223  {
224  adv = -sizeof (ah_header_t);
225  }
226 
227  icv_size = sa0->integ_icv_size;
228  const u8 padding_len = ah_calc_icv_padding_len (icv_size, is_ip6);
229  adv -= padding_len;
230  /* transport mode save the eth header before it is overwritten */
231  if (PREDICT_FALSE (!ipsec_sa_is_set_IS_TUNNEL (sa0)))
232  {
233  const u32 l2_len = vnet_buffer (b[0])->ip.save_rewrite_length;
234  u8 *l2_hdr_in = (u8 *) vlib_buffer_get_current (b[0]) - l2_len;
235 
236  u8 *l2_hdr_out = l2_hdr_in + adv - icv_size;
237 
238  clib_memcpy_le32 (l2_hdr_out, l2_hdr_in, l2_len);
239  }
240 
241  vlib_buffer_advance (b[0], adv - icv_size);
242 
243  if (is_ip6)
244  {
245  ih6_0 = (ip6_and_ah_header_t *) ih0;
246  ip_hdr_size = sizeof (ip6_header_t);
247  oh6_0 = vlib_buffer_get_current (b[0]);
248  pd->current_data = b[0]->current_data;
249  pd->hop_limit = ih6_0->ip6.hop_limit;
250 
251  oh6_0->ip6.ip_version_traffic_class_and_flow_label =
252  ih6_0->ip6.ip_version_traffic_class_and_flow_label;
253 
254  if (PREDICT_FALSE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
255  {
256  ip6_set_dscp_network_order (&oh6_0->ip6, sa0->tunnel.t_dscp);
257  tunnel_encap_fixup_6o6 (sa0->tunnel_flags, &ih6_0->ip6,
258  &oh6_0->ip6);
259  }
261  oh6_0->ip6.ip_version_traffic_class_and_flow_label;
262 
263  if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
264  {
265  next_hdr_type = IP_PROTOCOL_IPV6;
266  }
267  else
268  {
269  next_hdr_type = ih6_0->ip6.protocol;
270  memmove (oh6_0, ih6_0, sizeof (ip6_header_t));
271  }
272 
273  clib_memcpy_fast (&oh6_0->ip6, &ip6_hdr_template, 8);
274  oh6_0->ah.reserved = 0;
275  oh6_0->ah.nexthdr = next_hdr_type;
276  oh6_0->ah.spi = clib_net_to_host_u32 (sa0->spi);
277  oh6_0->ah.seq_no = clib_net_to_host_u32 (sa0->seq);
278  oh6_0->ip6.payload_length =
279  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b[0]) -
280  sizeof (ip6_header_t));
281  oh6_0->ah.hdrlen =
282  (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2;
283  }
284  else
285  {
286  ip_hdr_size = sizeof (ip4_header_t);
287  oh0 = vlib_buffer_get_current (b[0]);
288  pd->ttl = ih0->ip4.ttl;
289 
290  if (PREDICT_FALSE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
291  {
292  if (sa0->tunnel.t_dscp)
293  pd->tos = sa0->tunnel.t_dscp << 2;
294  else
295  {
296  pd->tos = ih0->ip4.tos;
297 
298  if (!(sa0->tunnel_flags &
299  TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
300  pd->tos &= 0x3;
301  if (!(sa0->tunnel_flags &
302  TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN))
303  pd->tos &= 0xfc;
304  }
305  }
306  else
307  {
308  pd->tos = ih0->ip4.tos;
309  }
310 
311  pd->current_data = b[0]->current_data;
312  clib_memset (oh0, 0, sizeof (ip4_and_ah_header_t));
313 
314  if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
315  {
316  next_hdr_type = IP_PROTOCOL_IP_IN_IP;
317  }
318  else
319  {
320  next_hdr_type = ih0->ip4.protocol;
321  memmove (oh0, ih0, sizeof (ip4_header_t));
322  }
323 
324  clib_memcpy_fast (&oh0->ip4, &ip4_hdr_template,
325  sizeof (ip4_header_t) -
326  sizeof (ip4_address_pair_t));
327 
328  oh0->ip4.length =
329  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b[0]));
330  oh0->ah.spi = clib_net_to_host_u32 (sa0->spi);
331  oh0->ah.seq_no = clib_net_to_host_u32 (sa0->seq);
332  oh0->ah.nexthdr = next_hdr_type;
333  oh0->ah.hdrlen =
334  (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2;
335  }
336 
337  if (PREDICT_TRUE (!is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
338  !ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)))
339  {
340  clib_memcpy_fast (&oh0->ip4.address_pair,
341  &sa0->ip4_hdr.address_pair,
342  sizeof (ip4_address_pair_t));
343 
344  next[0] = sa0->dpo.dpoi_next_node;
345  vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = sa0->dpo.dpoi_index;
346  }
347  else if (is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
348  ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))
349  {
350  clib_memcpy_fast (&oh6_0->ip6.src_address,
351  &sa0->ip6_hdr.src_address,
352  sizeof (ip6_address_t) * 2);
353  next[0] = sa0->dpo.dpoi_next_node;
354  vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = sa0->dpo.dpoi_index;
355  }
356 
357  if (PREDICT_TRUE (sa0->integ_op_id))
358  {
359  vnet_crypto_op_t *op;
361  vnet_crypto_op_init (op, sa0->integ_op_id);
362  op->src = vlib_buffer_get_current (b[0]);
363  op->len = b[0]->current_length;
364  op->digest = vlib_buffer_get_current (b[0]) + ip_hdr_size +
365  sizeof (ah_header_t);
366  clib_memset (op->digest, 0, icv_size);
367  op->digest_len = icv_size;
368  op->key_index = sa0->integ_key_index;
369  op->user_data = b - bufs;
370  if (ipsec_sa_is_set_USE_ESN (sa0))
371  {
372  u32 seq_hi = clib_host_to_net_u32 (sa0->seq_hi);
373 
374  op->len += sizeof (seq_hi);
375  clib_memcpy (op->src + b[0]->current_length, &seq_hi,
376  sizeof (seq_hi));
377  }
378  }
379 
380  if (!ipsec_sa_is_set_IS_TUNNEL (sa0))
381  {
382  next[0] = AH_ENCRYPT_NEXT_INTERFACE_OUTPUT;
383  vlib_buffer_advance (b[0], -sizeof (ethernet_header_t));
384  }
385 
386  next:
387  if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
388  {
389  sa0 = ipsec_sa_get (pd->sa_index);
390  ah_encrypt_trace_t *tr =
391  vlib_add_trace (vm, node, b[0], sizeof (*tr));
392  tr->spi = sa0->spi;
393  tr->seq_lo = sa0->seq;
394  tr->seq_hi = sa0->seq_hi;
395  tr->integ_alg = sa0->integ_alg;
396  tr->sa_index = pd->sa_index;
397  }
398 
399  n_left -= 1;
400  next += 1;
401  pd += 1;
402  b += 1;
403  }
404 
405  n_left = frame->n_vectors;
406  next = nexts;
407  pd = pkt_data;
408  b = bufs;
409 
410  vlib_node_increment_counter (vm, node->node_index,
411  AH_ENCRYPT_ERROR_RX_PKTS, n_left);
413  current_sa_index, current_sa_pkts,
414  current_sa_bytes);
415 
417 
418  while (n_left)
419  {
420  if (pd->skip)
421  goto next_pkt;
422 
423  if (is_ip6)
424  {
425  oh6_0 = (ip6_and_ah_header_t *) (b[0]->data + pd->current_data);
426  oh6_0->ip6.hop_limit = pd->hop_limit;
427  oh6_0->ip6.ip_version_traffic_class_and_flow_label =
429  }
430  else
431  {
432  oh0 = (ip4_and_ah_header_t *) (b[0]->data + pd->current_data);
433  oh0->ip4.ttl = pd->ttl;
434  oh0->ip4.tos = pd->tos;
435  oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
436  }
437 
438  next_pkt:
439  n_left -= 1;
440  next += 1;
441  pd += 1;
442  b += 1;
443  }
444 
445  n_left = frame->n_vectors;
447 
448  return n_left;
449 }
450 
454 {
455  return ah_encrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ );
456 }
457 
458 /* *INDENT-OFF* */
460  .name = "ah4-encrypt",
461  .vector_size = sizeof (u32),
462  .format_trace = format_ah_encrypt_trace,
464 
465  .n_errors = ARRAY_LEN(ah_encrypt_error_strings),
466  .error_strings = ah_encrypt_error_strings,
467 
468  .n_next_nodes = AH_ENCRYPT_N_NEXT,
469  .next_nodes = {
470  [AH_ENCRYPT_NEXT_DROP] = "ip4-drop",
471  [AH_ENCRYPT_NEXT_HANDOFF] = "ah4-encrypt-handoff",
472  [AH_ENCRYPT_NEXT_INTERFACE_OUTPUT] = "interface-output",
473  },
474 };
475 /* *INDENT-ON* */
476 
480 {
481  return ah_encrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ );
482 }
483 
484 /* *INDENT-OFF* */
486  .name = "ah6-encrypt",
487  .vector_size = sizeof (u32),
488  .format_trace = format_ah_encrypt_trace,
490 
491  .n_errors = ARRAY_LEN(ah_encrypt_error_strings),
492  .error_strings = ah_encrypt_error_strings,
493 
494  .n_next_nodes = AH_ENCRYPT_N_NEXT,
495  .next_nodes = {
496  [AH_ENCRYPT_NEXT_DROP] = "ip6-drop",
497  [AH_ENCRYPT_NEXT_HANDOFF] = "ah6-encrypt-handoff",
498  [AH_ENCRYPT_NEXT_INTERFACE_OUTPUT] = "interface-output",
499  },
500 };
501 /* *INDENT-ON* */
502 
503 #ifndef CLIB_MARCH_VARIANT
504 
505 static clib_error_t *
507 {
509 
510  im->ah4_enc_fq_index =
512  im->ah6_enc_fq_index =
514 
515  return 0;
516 }
517 
519 
520 #endif
521 
522 /*
523  * fd.io coding-style-patch-verification: ON
524  *
525  * Local Variables:
526  * eval: (c-set-style "gnu")
527  * End:
528  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ah_encrypt_packet_data_t::ttl
u8 ttl
Definition: ah_encrypt.c:123
ipsec.h
ipsec_per_thread_data_t::integ_ops
vnet_crypto_op_t * integ_ops
Definition: ipsec.h:101
vnet_crypto_op_t::digest
u8 * digest
Definition: crypto.h:299
ip4_header_t::address_pair
ip4_address_pair_t address_pair
Definition: ip4_packet.h:127
tunnel_t_::t_dscp
ip_dscp_t t_dscp
Definition: tunnel.h:93
dpo_id_t_::dpoi_next_node
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:186
vnet_crypto_op_init
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
Definition: crypto.h:528
im
vnet_interface_main_t * im
Definition: interface_output.c:415
vnet_crypto_op_t::digest_len
u8 digest_len
Definition: crypto.h:268
ipsec_sa_t::integ_key_index
vnet_crypto_key_index_t integ_key_index
Definition: ipsec_sa.h:139
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
ah_encrypt_trace_t::seq_hi
u32 seq_hi
Definition: ah_encrypt.c:65
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
foreach_ah_encrypt_next
#define foreach_ah_encrypt_next
Definition: ah_encrypt.c:27
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
format_ah_encrypt_trace
static u8 * format_ah_encrypt_trace(u8 *s, va_list *args)
Definition: ah_encrypt.c:71
ah_process_ops
static_always_inline void ah_process_ops(vlib_main_t *vm, vlib_node_runtime_t *node, vnet_crypto_op_t *ops, vlib_buffer_t *b[], u16 *nexts)
Definition: ah_encrypt.c:84
format_ipsec_integ_alg
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:111
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
ah_encrypt_packet_data_t::current_data
i16 current_data
Definition: ah_encrypt.c:128
ah_header_t
Definition: ah.h:21
ipsec_sa_t::thread_index
u32 thread_index
Definition: ipsec_sa.h:129
vnet_crypto_op_t::status
vnet_crypto_op_status_t status
Definition: crypto.h:260
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
next
u16 * next
Definition: nat44_ei_out2in.c:718
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ipsec_sa_t::ip4_hdr
ip4_header_t ip4_hdr
Definition: ipsec_sa.h:166
vnet_crypto_op_t::src
u8 * src
Definition: crypto.h:277
u16
unsigned short u16
Definition: types.h:57
ah_encrypt_trace_t::spi
u32 spi
Definition: ah_encrypt.c:63
vnet_crypto_op_t::user_data
uword user_data
Definition: crypto.h:258
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
clib_memcpy_le32
static_always_inline void clib_memcpy_le32(u8 *dst, u8 *src, u8 len)
Definition: string.h:306
ip6_set_dscp_network_order
static_always_inline void ip6_set_dscp_network_order(ip6_header_t *ip6, ip_dscp_t dscp)
Definition: ip6_packet.h:357
ah4_encrypt_node
vlib_node_registration_t ah4_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_encrypt_node)
Definition: ah_encrypt.c:459
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
vlib_buffer_enqueue_to_next
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
ah_encrypt_packet_data_t::ip_version_traffic_class_and_flow_label
u32 ip_version_traffic_class_and_flow_label
Definition: ah_encrypt.c:118
ipsec_sa_t::integ_icv_size
u8 integ_icv_size
Definition: ipsec_sa.h:125
ip4_address_pair_t
Definition: ip4_packet.h:77
vnet_crypto_op_t::len
u32 len
Definition: crypto.h:287
vlib_frame_t
Definition: node.h:372
ipsec_sa_t::tunnel
tunnel_t tunnel
Definition: ipsec_sa.h:204
ah_encrypt_error_strings
static char * ah_encrypt_error_strings[]
Definition: ah_encrypt.c:54
vlib_buffer_length_in_chain
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:433
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
ip4_header_t
Definition: ip4_packet.h:87
ah_encrypt_next_t
ah_encrypt_next_t
Definition: ah_encrypt.c:34
ah_encrypt_packet_data_t::hop_limit
u8 hop_limit
Definition: ah_encrypt.c:119
vnet_crypto_op_t
Definition: crypto.h:255
vlib_frame_queue_main_init
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1561
vnet_crypto_op_t::key_index
u32 key_index
Definition: crypto.h:292
esp.h
i16
signed short i16
Definition: types.h:46
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
ah_encrypt_trace_t
Definition: ah_encrypt.c:60
tunnel_encap_fixup_6o6
static_always_inline void tunnel_encap_fixup_6o6(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip6_header_t *outer)
Definition: tunnel_dp.h:129
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
vnet_crypto_process_ops
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
Definition: crypto.c:99
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
ipsec_sa_get
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
Definition: ipsec_sa.h:605
AH_ENCRYPT_N_ERROR
@ AH_ENCRYPT_N_ERROR
Definition: ah_encrypt.c:51
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
ipsec_per_thread_data_t
Definition: ipsec.h:97
ipsec_sa_counters
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
Definition: ipsec_sa.c:27
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ah6_encrypt_node
vlib_node_registration_t ah6_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_encrypt_node)
Definition: ah_encrypt.c:485
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
ipsec_main_t
Definition: ipsec.h:108
ah_encrypt_packet_data_t::skip
u8 skip
Definition: ah_encrypt.c:127
ipsec_sa_t::tunnel_flags
tunnel_encap_decap_flags_t tunnel_flags
Definition: ipsec_sa.h:175
static_always_inline
#define static_always_inline
Definition: clib.h:112
ipsec_sa_t::seq
u32 seq
Definition: ipsec_sa.h:132
ah_encrypt_inline
static uword ah_encrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip6)
Definition: ah_encrypt.c:133
uword
u64 uword
Definition: types.h:112
ethernet_header_t
Definition: packet.h:52
ipsec_main
ipsec_main_t ipsec_main
Definition: ipsec.c:29
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
ah_encrypt_error_t
ah_encrypt_error_t
Definition: ah_encrypt.c:46
ah_encrypt_packet_data_t
Definition: ah_encrypt.c:110
ah_encrypt_trace_t::seq_lo
u32 seq_lo
Definition: ah_encrypt.c:64
ah_calc_icv_padding_len
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
Definition: ah.h:47
ipsec_sa_assign_thread
static u32 ipsec_sa_assign_thread(u32 thread_id)
Definition: ipsec_sa.h:598
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
ah.h
data
u8 data[128]
Definition: ipsec_types.api:95
vec_add2_aligned
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:656
ipsec_sa_t
Definition: ipsec_sa.h:116
is_ip6
bool is_ip6
Definition: ip.api:43
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
clib_atomic_cmp_and_swap
#define clib_atomic_cmp_and_swap(addr, old, new)
Definition: atomics.h:37
foreach_ah_encrypt_error
#define foreach_ah_encrypt_error
Definition: ah_encrypt.c:41
ipsec_sa_t::integ_op_id
vnet_crypto_op_id_t integ_op_id
Definition: ipsec_sa.h:149
ah_encrypt_init
static clib_error_t * ah_encrypt_init(vlib_main_t *vm)
Definition: ah_encrypt.c:506
n_left
u32 n_left
Definition: interface_output.c:1096
ipsec_sa_t::seq_hi
u32 seq_hi
Definition: ipsec_sa.h:133
ip6_header_t
Definition: ip6_packet.h:294
ip6_header_t::src_address
ip6_address_t src_address
Definition: ip6_packet.h:310
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
ip4_header_t::ip_version_and_header_length
u8 ip_version_and_header_length
Definition: ip4_packet.h:93
vlib_node_t
Definition: node.h:247
ah_encrypt_packet_data_t::sa_index
u32 sa_index
Definition: ah_encrypt.c:129
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
ah_encrypt_packet_data_t::tos
u8 tos
Definition: ah_encrypt.c:124
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
ipsec_sa_t::ip6_hdr
ip6_header_t ip6_hdr
Definition: ipsec_sa.h:167
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
ip4_header_checksum
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
ipsec_sa_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:216
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
ah_encrypt_trace_t::sa_index
u32 sa_index
Definition: ah_encrypt.c:62
vnet.h
api_errno.h
vlib_node_runtime_t
Definition: node.h:454
ah_encrypt_trace_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ah_encrypt.c:66
AH_ENCRYPT_N_NEXT
@ AH_ENCRYPT_N_NEXT
Definition: ah_encrypt.c:38
from
from
Definition: nat44_ei_hairpinning.c:415
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
ipsec_sa_t::spi
u32 spi
Definition: ipsec_sa.h:131
ip6_header_t::ip_version_traffic_class_and_flow_label
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:297
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vlib_increment_combined_counter
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
tunnel_dp.h
esp_seq_advance
static int esp_seq_advance(ipsec_sa_t *sa)
Definition: esp.h:96
ipsec_per_thread_data_t::crypto_ops
vnet_crypto_op_t * crypto_ops
Definition: ipsec.h:100
ipsec_sa_t::dpo
dpo_id_t dpo
Definition: ipsec_sa.h:136
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105