FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ipsec_tun.c
Go to the documentation of this file.
1 /*
2  * ipsec_tun.h : IPSEC tunnel protection
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/ipsec/ipsec_tun.h>
19 #include <vnet/ipsec/ipsec_itf.h>
20 #include <vnet/ipsec/esp.h>
21 #include <vnet/udp/udp_local.h>
22 #include <vnet/adj/adj_delegate.h>
23 #include <vnet/adj/adj_midchain.h>
24 #include <vnet/teib/teib.h>
25 
26 /* instantiate the bihash functions */
27 #include <vppinfra/bihash_8_16.h>
29 #include <vppinfra/bihash_24_16.h>
31 
32 #define IPSEC_TUN_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
33 #define IPSEC_TUN_DEFAULT_HASH_MEMORY_SIZE 512 << 20
34 
35 /**
36  * The logger
37  */
39 
40 /**
41  * Pool of tunnel protection objects
42  */
44 
45 /**
46  * Adj delegate registered type
47  */
49 
50 /**
51  * Adj index to TX SA mapping
52  */
54 
56 
57 /**
58  * The DB of all added per-nh tunnel protectiond
59  */
61 {
62  /** A hash table key'd on IP (4 or 6) address */
64  /** If the interface is P2P then there is only one protect
65  * object associated with the auto-adj for each NH proto */
68 
70 {
71  /** Per-interface vector */
74 
76 
79 };
80 
81 #define ITP_DBG(_itp, _fmt, _args...) \
82 { \
83  vlib_log_debug(ipsec_tun_protect_logger, \
84  "[%U]: " _fmt, \
85  format_ipsec_tun_protect, \
86  _itp, ##_args); \
87 }
88 
89 #define ITP_DBG2(_fmt, _args...) \
90 { \
91  vlib_log_debug(ipsec_tun_protect_logger, \
92  _fmt, ##_args); \
93 }
94 
96 
97 void
99 {
100  if (0 == ipsec_tun_node_regs[af]++)
101  {
102  if (AF_IP4 == af)
103  {
104  ipsec_register_udp_port (UDP_DST_PORT_ipsec);
105  ip4_register_protocol (IP_PROTOCOL_IPSEC_ESP,
106  ipsec4_tun_input_node.index);
107  }
108  else
109  ip6_register_protocol (IP_PROTOCOL_IPSEC_ESP,
110  ipsec6_tun_input_node.index);
111  }
112 }
113 
114 void
116 {
117  ASSERT (0 != ipsec_tun_node_regs[af]);
118  if (0 == --ipsec_tun_node_regs[af])
119  {
120  if (AF_IP4 == af)
121  {
122  ipsec_unregister_udp_port (UDP_DST_PORT_ipsec);
123  ip4_unregister_protocol (IP_PROTOCOL_IPSEC_ESP);
124  }
125  else
126  ip6_unregister_protocol (IP_PROTOCOL_IPSEC_ESP);
127  }
128 }
129 
130 static inline const ipsec_tun_protect_t *
132 {
133  if (ad == NULL)
134  return (NULL);
136 }
137 
138 static u32
140  const ipsec_tun_protect_t * itp)
141 {
142  ipsec_main_t *im;
143  ipsec_sa_t *sa;
144  u32 next;
145 
146  if (!(itp->itp_flags & IPSEC_PROTECT_ITF))
147  {
148  if (ip46_address_is_ip4 (&itp->itp_tun.src))
149  linkt = VNET_LINK_IP4;
150  else
151  linkt = VNET_LINK_IP6;
152  }
153 
154  sa = ipsec_sa_get (itp->itp_out_sa);
155  im = &ipsec_main;
156  next = 0;
157 
158  if ((sa->crypto_alg == IPSEC_CRYPTO_ALG_NONE &&
159  sa->integ_alg == IPSEC_INTEG_ALG_NONE) &&
160  !(itp->itp_flags & IPSEC_PROTECT_ITF))
161  next = (VNET_LINK_IP4 == linkt ? im->esp4_no_crypto_tun_node_index :
162  im->esp6_no_crypto_tun_node_index);
163  else if (itp->itp_flags & IPSEC_PROTECT_L2)
164  next = (VNET_LINK_IP4 == linkt ? im->esp4_encrypt_l2_tun_node_index :
165  im->esp6_encrypt_l2_tun_node_index);
166  else
167  {
168  switch (linkt)
169  {
170  case VNET_LINK_IP4:
171  next = im->esp4_encrypt_tun_node_index;
172  break;
173  case VNET_LINK_IP6:
174  next = im->esp6_encrypt_tun_node_index;
175  break;
176  case VNET_LINK_MPLS:
177  next = im->esp_mpls_encrypt_tun_node_index;
178  break;
179  case VNET_LINK_ARP:
180  case VNET_LINK_NSH:
181  case VNET_LINK_ETHERNET:
182  ASSERT (0);
183  break;
184  }
185  }
186  return (next);
187 }
188 
189 static void
191 {
193  INDEX_INVALID);
194 
195  if (NULL == itp)
196  {
199  }
200  else
201  {
205  }
206 }
207 
208 static index_t
210 {
212  uword *p;
213 
214  if (vec_len (itp_db.id_itf) <= sw_if_index)
215  return INDEX_INVALID;
216 
218  return (itp_db.id_itf[sw_if_index].id_itp);
219 
220  idi = &itp_db.id_itf[sw_if_index];
221  p = hash_get_mem (idi->id_hash, nh);
222 
223  if (NULL == p)
224  {
225  return INDEX_INVALID;
226  }
227  return (p[0]);
228 }
229 
230 static void
232  const ipsec_tun_protect_t * itp)
233 {
234  const ipsec_sa_t *sa;
235  u32 sai;
236 
237  if (ip46_address_is_zero (&itp->itp_crypto.dst))
238  return;
239 
240  /* *INDENT-OFF* */
242  ({
243  sa = ipsec_sa_get (sai);
244 
247  .sa_index = sai,
248  .flags = itp->itp_flags,
249  .sw_if_index = itp->itp_sw_if_index,
250  };
251 
252  /*
253  * The key is formed from the tunnel's destination
254  * as the packet lookup is done from the packet's source
255  */
256  if (ip46_address_is_ip4 (&itp->itp_crypto.dst))
257  {
259  .value = res,
260  };
262 
264  clib_host_to_net_u32 (sa->spi));
265 
266  if (!clib_bihash_is_initialised_8_16 (&im->tun4_protect_by_key))
267  clib_bihash_init_8_16 (&im->tun4_protect_by_key,
268  "IPSec IPv4 tunnels",
271 
272  clib_bihash_add_del_8_16 (&im->tun4_protect_by_key, bkey, 1);
274  }
275  else
276  {
278  .key = {
279  .remote_ip = itp->itp_crypto.dst.ip6,
280  .spi = clib_host_to_net_u32 (sa->spi),
281  },
282  .value = res,
283  };
285 
286  if (!clib_bihash_is_initialised_24_16 (&im->tun6_protect_by_key))
287  clib_bihash_init_24_16 (&im->tun6_protect_by_key,
288  "IPSec IPv6 tunnels",
291  clib_bihash_add_del_24_16 (&im->tun6_protect_by_key, bkey, 1);
293  }
294  }))
295  /* *INDENT-ON* */
296 }
297 
298 static adj_walk_rc_t
300 {
301  ipsec_tun_protect_t *itp = arg;
303  itp - ipsec_tun_protect_pool);
304  ipsec_tun_protect_add_adj (ai, itp);
305 
306  if (itp->itp_flags & IPSEC_PROTECT_ITF)
307  ipsec_itf_adj_stack (ai, itp->itp_out_sa);
308 
309  return (ADJ_WALK_RC_CONTINUE);
310 }
311 
312 static void
314 {
315  /*
316  * add the delegate to the adj
317  */
319  fib_protocol_t nh_proto;
320  ip46_address_t nh;
321 
323  itp->itp_sw_if_index,
325 
326  idi = &itp_db.id_itf[itp->itp_sw_if_index];
327 
329  {
330  if (INDEX_INVALID == idi->id_itp)
331  {
332  // ipsec_tun_protect_feature_set (itp, 1);
333  }
334  idi->id_itp = itp - ipsec_tun_protect_pool;
335 
336  FOR_EACH_FIB_IP_PROTOCOL (nh_proto)
338  nh_proto, ipsec_tun_protect_adj_add, itp);
339  }
340  else
341  {
342  if (NULL == idi->id_hash)
343  {
344  idi->id_hash =
345  hash_create_mem (0, sizeof (ip_address_t), sizeof (uword));
346  /*
347  * enable the encrypt feature for egress if this is the first addition
348  * on this interface
349  */
350  // ipsec_tun_protect_feature_set (itp, 1);
351  }
352 
354 
355  /*
356  * walk all the adjs with the same nh on this interface
357  * to associate them with this protection
358  */
359  nh_proto = ip_address_to_46 (itp->itp_key, &nh);
360 
362  nh_proto, &nh, ipsec_tun_protect_adj_add, itp);
363 
365  AF_IP6 : AF_IP4);
366  }
367 }
368 
369 static void
371  const ipsec_tun_protect_t * itp)
372 {
373  const ipsec_sa_t *sa;
374 
375  /* *INDENT-OFF* */
377  ({
378  if (ip46_address_is_ip4 (&itp->itp_crypto.dst))
379  {
380  ipsec4_tunnel_kv_t key;
381  clib_bihash_kv_8_16_t res, *bkey = (clib_bihash_kv_8_16_t*)&key;
382 
383  ipsec4_tunnel_mk_key(&key, &itp->itp_crypto.dst.ip4,
384  clib_host_to_net_u32 (sa->spi));
385 
386  if (!clib_bihash_search_8_16 (&im->tun4_protect_by_key, bkey, &res))
387  {
388  clib_bihash_add_del_8_16 (&im->tun4_protect_by_key, bkey, 0);
389  ipsec_tun_unregister_nodes(AF_IP4);
390  }
391  }
392  else
393  {
395  .key = {
396  .remote_ip = itp->itp_crypto.dst.ip6,
397  .spi = clib_host_to_net_u32 (sa->spi),
398  },
399  };
401 
402  if (!clib_bihash_search_24_16 (&im->tun6_protect_by_key, bkey, &res))
403  {
404  clib_bihash_add_del_24_16 (&im->tun6_protect_by_key, bkey, 0);
406  }
407  }
408  }));
409  /* *INDENT-ON* */
410 }
411 
412 static adj_walk_rc_t
414 {
415  ipsec_tun_protect_t *itp = arg;
416 
418  ipsec_tun_protect_add_adj (ai, NULL);
419 
420  if (itp->itp_flags & IPSEC_PROTECT_ITF)
422 
423  return (ADJ_WALK_RC_CONTINUE);
424 }
425 
426 static void
428 {
430  fib_protocol_t nh_proto;
431  ip46_address_t nh;
432 
433  nh_proto = ip_address_to_46 (itp->itp_key, &nh);
434  idi = &itp_db.id_itf[itp->itp_sw_if_index];
435 
437  {
438  // ipsec_tun_protect_feature_set (itp, 0);
439  idi->id_itp = INDEX_INVALID;
440 
441  FOR_EACH_FIB_IP_PROTOCOL (nh_proto)
443  nh_proto, ipsec_tun_protect_adj_remove, itp);
444  }
445  else
446  {
448  nh_proto, &nh, ipsec_tun_protect_adj_remove, itp);
449 
450  hash_unset_mem (idi->id_hash, itp->itp_key);
451 
452  if (0 == hash_elts (idi->id_hash))
453  {
454  // ipsec_tun_protect_feature_set (itp, 0);
455  hash_free (idi->id_hash);
456  idi->id_hash = NULL;
457  }
459  AF_IP6 : AF_IP4);
460  }
461 }
462 
463 static void
465 {
466  ipsec_sa_t *sa;
467 
468  /* *INDENT-OFF* */
470  ({
471  if (ipsec_sa_is_set_IS_TUNNEL (sa))
472  {
473  itp->itp_crypto.src = ip_addr_46 (&sa->tunnel.t_dst);
474  itp->itp_crypto.dst = ip_addr_46 (&sa->tunnel.t_src);
475  if (!(itp->itp_flags & IPSEC_PROTECT_ITF))
476  {
477  ipsec_sa_set_IS_PROTECT (sa);
478  itp->itp_flags |= IPSEC_PROTECT_ENCAPED;
479  }
480  }
481  else
482  {
483  itp->itp_crypto.src = itp->itp_tun.src;
484  itp->itp_crypto.dst = itp->itp_tun.dst;
485  itp->itp_flags &= ~IPSEC_PROTECT_ENCAPED;
486  }
487  }));
488  /* *INDENT-ON* */
489 }
490 
491 static void
493  ipsec_tun_protect_t * itp, u32 sa_out, u32 * sas_in)
494 {
495  index_t sai;
496  u32 ii;
497 
498  itp->itp_n_sa_in = vec_len (sas_in);
499  for (ii = 0; ii < itp->itp_n_sa_in; ii++)
500  itp->itp_in_sas[ii] = sas_in[ii];
501  itp->itp_out_sa = sa_out;
502 
503  ipsec_sa_lock (itp->itp_out_sa);
504 
505  /* *INDENT-OFF* */
507  ({
508  ipsec_sa_lock(sai);
509  }));
511  /* *INDENT-ON* */
512 
513  /*
514  * add to the DB against each SA
515  */
518 
519  ITP_DBG (itp, "configured");
520 }
521 
522 static void
524 {
525  ipsec_sa_t *sa;
526  index_t sai;
527 
528  /* *INDENT-OFF* */
530  ({
531  ipsec_sa_unset_IS_PROTECT (sa);
532  }));
533 
536 
538 
540  ({
541  ipsec_sa_unlock(sai);
542  }));
543  /* *INDENT-ON* */
544  ITP_DBG (itp, "unconfigured");
545 }
546 
547 static void
549  const teib_entry_t * ne)
550 {
551  if (NULL != ne)
552  {
553  const fib_prefix_t *pfx;
554 
555  pfx = teib_entry_get_nh (ne);
556 
557  ip46_address_copy (&itp->itp_tun.dst, &pfx->fp_addr);
558  }
559  else
561 }
562 
563 int
565  const ip_address_t * nh, u32 sa_out, u32 * sas_in)
566 {
567  ipsec_tun_protect_t *itp;
568  u32 itpi, ii, *saip;
569  ipsec_main_t *im;
570  int rv;
571 
572  ITP_DBG2 ("update: %U/%U",
575 
576  if (vec_len (sas_in) > ITP_MAX_N_SA_IN)
577  {
578  rv = VNET_API_ERROR_LIMIT_EXCEEDED;
579  goto out;
580  }
581 
582  rv = 0;
583  im = &ipsec_main;
584  if (NULL == nh)
585  nh = &IP_ADDR_ALL_0;
587 
588  vec_foreach_index (ii, sas_in)
589  {
590  sas_in[ii] = ipsec_sa_find_and_lock (sas_in[ii]);
591  if (~0 == sas_in[ii])
592  {
593  rv = VNET_API_ERROR_INVALID_VALUE;
594  goto out;
595  }
596  }
597 
599 
600  if (~0 == sa_out)
601  {
602  rv = VNET_API_ERROR_INVALID_VALUE;
603  goto out;
604  }
605 
606  if (INDEX_INVALID == itpi)
607  {
608  vnet_device_class_t *dev_class;
610  vnet_main_t *vnm;
611  u8 is_l2;
612 
613  vnm = vnet_get_main ();
615  dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
616 
617  if (NULL == dev_class->ip_tun_desc)
618  {
619  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
620  goto out;
621  }
622 
624 
626  itp->itp_ai = ADJ_INDEX_INVALID;
627 
628  itp->itp_n_sa_in = vec_len (sas_in);
629  for (ii = 0; ii < itp->itp_n_sa_in; ii++)
630  itp->itp_in_sas[ii] = sas_in[ii];
631  itp->itp_out_sa = sa_out;
632 
633  itp->itp_key = clib_mem_alloc (sizeof (*itp->itp_key));
634  ip_address_copy (itp->itp_key, nh);
635 
636  rv = dev_class->ip_tun_desc (sw_if_index,
637  &itp->itp_tun.src,
638  &itp->itp_tun.dst, &is_l2);
639 
640  if (rv)
641  goto out;
642 
643  if (ip46_address_is_zero (&itp->itp_tun.src))
644  {
645  /*
646  * must be one of those pesky ipsec interfaces that has no encap.
647  * the encap then MUST come from the tunnel mode SA.
648  */
649  ipsec_sa_t *sa;
650 
651  sa = ipsec_sa_get (itp->itp_out_sa);
652 
653  if (!ipsec_sa_is_set_IS_TUNNEL (sa))
654  {
655  rv = VNET_API_ERROR_INVALID_DST_ADDRESS;
656  goto out;
657  }
658 
659  itp->itp_flags |= IPSEC_PROTECT_ITF;
660  }
661  else if (ip46_address_is_zero (&itp->itp_tun.dst))
662  {
663  /* tunnel has no destination address, presumably because it's p2mp
664  in which case we use the nh that this is protection for */
666  (itp, teib_entry_find (sw_if_index, nh));
667  }
668 
669  if (is_l2)
670  itp->itp_flags |= IPSEC_PROTECT_L2;
671 
672  /*
673  * add to the tunnel DB for ingress
674  * - if the SA is in trasnport mode, then the packates will arrive
675  * with the IP src,dst of the protected tunnel, in which case we can
676  * simply strip the IP header and hand the payload to the protocol
677  * appropriate input handler
678  * - if the SA is in tunnel mode then there are two IP headers present
679  * one for the crytpo tunnel endpoints (described in the SA) and one
680  * for the tunnel endpoints. The outer IP headers in the srriving
681  * packets will have the crypto endpoints. So the DB needs to contain
682  * the crpto endpoint. Once the crypto header is stripped, revealing,
683  * the tunnel-IP we have 2 choices:
684  * 1) do a tunnel lookup based on the revealed header
685  * 2) skip the tunnel lookup and assume that the packet matches the
686  * one that is protected here.
687  * If we did 1) then we would allow our peer to use the SA for tunnel
688  * X to inject traffic onto tunnel Y, this is not good. If we do 2)
689  * then we don't verify that the peer is indeed using SA for tunnel
690  * X and addressing tunnel X. So we take a compromise, once the SA
691  * matches to tunnel X we veriy that the inner IP matches the value
692  * of the tunnel we are protecting, else it's dropped.
693  */
694  ipsec_tun_protect_config (im, itp, sa_out, sas_in);
695  }
696  else
697  {
698  /* updating SAs only */
700 
702  ipsec_tun_protect_config (im, itp, sa_out, sas_in);
703  }
704 
706  vec_foreach (saip, sas_in) ipsec_sa_unlock (*saip);
707  vec_free (sas_in);
708 
709 out:
710  return (rv);
711 }
712 
713 int
715 {
716  ipsec_tun_protect_t *itp;
717  ipsec_main_t *im;
718  index_t itpi;
719 
720  ITP_DBG2 ("delete: %U/%U",
723 
724  im = &ipsec_main;
725  if (NULL == nh)
726  nh = &IP_ADDR_ALL_0;
727 
729 
730  if (INDEX_INVALID == itpi)
731  return (VNET_API_ERROR_NO_SUCH_ENTRY);
732 
733  itp = ipsec_tun_protect_get (itpi);
735 
736  if (ADJ_INDEX_INVALID != itp->itp_ai)
737  adj_unlock (itp->itp_ai);
738 
739  clib_mem_free (itp->itp_key);
741 
742  return (0);
743 }
744 
745 void
747 {
748  index_t itpi;
749 
750  /* *INDENT-OFF* */
752  {
753  fn (itpi, ctx);
754  }
755  /* *INDENT-ON* */
756 }
757 
758 void
761 {
763  ip_address_t *key;
764  index_t itpi;
765 
766  if (vec_len (itp_db.id_itf) <= sw_if_index)
767  return;
768 
769  idi = &itp_db.id_itf[sw_if_index];
770 
771  /* *INDENT-OFF* */
772  hash_foreach(key, itpi, idi->id_hash,
773  ({
774  fn (itpi, ctx);
775  }));
776  /* *INDENT-ON* */
777  if (INDEX_INVALID != idi->id_itp)
778  fn (idi->id_itp, ctx);
779 }
780 
781 static void
783  void *data)
784 {
785  ipsec_tun_protect_t *itp;
786  index_t itpi;
787 
789  return;
790 
791  /* Only p2p tunnels supported */
793  if (itpi == INDEX_INVALID)
794  return;
795 
796  itp = ipsec_tun_protect_get (itpi);
797 
798  if (is_enable)
799  {
800  u32 decrypt_tun = ip46_address_is_ip4 (&itp->itp_crypto.dst) ?
803 
806  itp->itp_flags |= IPSEC_PROTECT_FEAT;
807  }
808  else
809  {
810  u32 eth_in =
811  vlib_get_node_by_name (vlib_get_main (), (u8 *) "ethernet-input")
812  ->index;
813 
816  itp->itp_flags &= ~IPSEC_PROTECT_FEAT;
817  }
818 
819  /* Propagate flag change into lookup entries */
822 }
823 
824 static void
826 {
827  /* remove our delegate */
830 }
831 
832 static void
834 {
837 }
838 
839 static void
841 {
842  /* add our delegate if there is protection for this neighbour */
844  ip_adjacency_t *adj;
845  index_t itpi;
846 
847  if (!adj_is_midchain (ai))
848  return;
849 
850  adj = adj_get (ai);
851 
852  ip_address_from_46 (&adj->sub_type.midchain.next_hop,
853  adj->ia_nh_proto, &ip);
854 
855  itpi = ipsec_tun_protect_find (adj->rewrite_header.sw_if_index, &ip);
856 
857  if (INDEX_INVALID != itpi)
859 }
860 
861 static u8 *
863 {
864  const ipsec_tun_protect_t *itp;
865 
867  s = format (s, "ipsec-tun-protect:\n%U", format_ipsec_tun_protect, itp);
868 
869  return (s);
870 }
871 
872 static void
874 {
875  ipsec_tun_protect_t *itp;
876  index_t itpi;
877 
879  teib_entry_get_peer (ne));
880 
881  if (INDEX_INVALID == itpi)
882  return;
883 
884  itp = ipsec_tun_protect_get (itpi);
889 
890  ITP_DBG (itp, "teib-added");
891 }
892 
893 static void
895 {
896  ipsec_tun_protect_t *itp;
897  index_t itpi;
898 
900  teib_entry_get_peer (ne));
901 
902  if (INDEX_INVALID == itpi)
903  return;
904 
905  itp = ipsec_tun_protect_get (itpi);
909 
910  ITP_DBG (itp, "teib-removed");
911 }
912 
913 /**
914  * VFT registered with the adjacency delegate
915  */
921 };
922 
925  .nv_deleted = ipsec_tun_teib_entry_deleted,
926 };
927 
928 static void
930 {
931  ipsec_main_t *im;
932 
933  im = &ipsec_main;
934 
935  if (AF_IP4 == af)
936  clib_bihash_init_8_16 (&im->tun4_protect_by_key,
937  "IPSec IPv4 tunnels", n_buckets, table_size);
938  else
939  clib_bihash_init_24_16 (&im->tun6_protect_by_key,
940  "IPSec IPv6 tunnels", n_buckets, table_size);
941 }
942 
943 static clib_error_t *
945 {
946  ipsec_main_t *im;
947 
948  im = &ipsec_main;
949  clib_bihash_init_24_16 (&im->tun6_protect_by_key,
950  "IPSec IPv6 tunnels",
953  clib_bihash_init_8_16 (&im->tun4_protect_by_key,
954  "IPSec IPv4 tunnels",
957 
958  /* set up feature nodes to drop outbound packets with no crypto alg set */
959  im->esp4_no_crypto_tun_node_index =
960  vlib_get_node_by_name (vm, (u8 *) "esp4-no-crypto")->index;
961  im->esp6_no_crypto_tun_node_index =
962  vlib_get_node_by_name (vm, (u8 *) "esp6-no-crypto")->index;
963  im->esp6_encrypt_l2_tun_node_index =
964  vlib_get_node_by_name (vm, (u8 *) "esp6-encrypt-tun")->index;
965  im->esp4_encrypt_l2_tun_node_index =
966  vlib_get_node_by_name (vm, (u8 *) "esp4-encrypt-tun")->index;
967 
970 
972 
974 
976 
977  return 0;
978 }
979 
981 
982 static clib_error_t *
984 {
985  unformat_input_t sub_input;
986 
988  {
989  if (unformat (input, "ip4 %U", unformat_vlib_cli_sub_input, &sub_input))
990  {
991  uword table_size = ~0;
992  u32 n_buckets = ~0;
993 
994  while (unformat_check_input (&sub_input) != UNFORMAT_END_OF_INPUT)
995  {
996  if (unformat (&sub_input, "num-buckets %u", &n_buckets))
997  ;
998  else
999  return clib_error_return (0, "unknown input `%U'",
1000  format_unformat_error, &sub_input);
1001  }
1002 
1003  ipsec_tun_table_init (AF_IP4, table_size, n_buckets);
1004  }
1005  else if (unformat (input, "ip6 %U", unformat_vlib_cli_sub_input,
1006  &sub_input))
1007  {
1008  uword table_size = ~0;
1009  u32 n_buckets = ~0;
1010 
1011  while (unformat_check_input (&sub_input) != UNFORMAT_END_OF_INPUT)
1012  {
1013  if (unformat (&sub_input, "num-buckets %u", &n_buckets))
1014  ;
1015  else
1016  return clib_error_return (0, "unknown input `%U'",
1017  format_unformat_error, &sub_input);
1018  }
1019 
1020  ipsec_tun_table_init (AF_IP6, table_size, n_buckets);
1021  }
1022  else
1023  return clib_error_return (0, "unknown input `%U'",
1024  format_unformat_error, input);
1025  }
1026 
1027  return 0;
1028 }
1029 
1031 
1032 /*
1033  * fd.io coding-style-patch-verification: ON
1034  *
1035  * Local Variables:
1036  * eval: (c-set-style "gnu")
1037  * End:
1038  */
ipsec_itf_adj_stack
void ipsec_itf_adj_stack(adj_index_t ai, u32 sai)
Definition: ipsec_itf.c:64
ip_address
Definition: ip_types.h:79
ip4_unregister_protocol
void ip4_unregister_protocol(u32 protocolx)
Definition: ip4_forward.c:1907
ipsec_tun_protect_adj_remove
static adj_walk_rc_t ipsec_tun_protect_adj_remove(adj_index_t ai, void *arg)
Definition: ipsec_tun.c:413
ipsec_tun_adj_delegate_vft
const static adj_delegate_vft_t ipsec_tun_adj_delegate_vft
VFT registered with the adjacency delegate.
Definition: ipsec_tun.c:916
adj_delegate_remove
void adj_delegate_remove(adj_index_t ai, adj_delegate_type_t type)
Remove a delegate from an adjacency.
Definition: adj_delegate.c:65
ipsec_tun_register_nodes
void ipsec_tun_register_nodes(ip_address_family_t af)
Definition: ipsec_tun.c:98
im
vnet_interface_main_t * im
Definition: interface_output.c:395
ip_addr_46
#define ip_addr_46(_a)
Definition: ip_types.h:90
ipsec_tun_protect_itf_db_t_::id_itp
index_t id_itp
If the interface is P2P then there is only one protect object associated with the auto-adj for each N...
Definition: ipsec_tun.c:66
adj_midchain.h
ipsec_tun.h
adj_delegate_t_::ad_index
index_t ad_index
The index passed by the provider to identify its delegate instance.
Definition: adj_delegate.h:66
ip_adjacency_t_::ia_nh_proto
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
Definition: adj.h:350
bihash_8_16.h
ipsec_tun_protect_pool
ipsec_tun_protect_t * ipsec_tun_protect_pool
Pool of tunnel protection objects.
Definition: ipsec_tun.c:43
ipsec4_tunnel_mk_key
static void ipsec4_tunnel_mk_key(ipsec4_tunnel_kv_t *k, const ip4_address_t *ip, u32 spi)
Definition: ipsec_tun.h:63
bihash_template.c
vnet_feature_register
void vnet_feature_register(vnet_feature_update_cb_t cb, void *data)
Definition: feature.c:29
vnet_device_class_t
struct _vnet_device_class vnet_device_class_t
adj_delegate_vft_t_
An ADJ delegate virtual function table.
Definition: adj_delegate.h:94
ipsec_tun_protect_t_::itp_tun
ipsec_ep_t itp_tun
Definition: ipsec_tun.h:124
ipsec_tun_lkup_result_t_::tun_index
u32 tun_index
Definition: ipsec_tun.h:41
ipsec_tun_protect_db_t_::id_itf
ipsec_tun_protect_itf_db_t * id_itf
Per-interface vector.
Definition: ipsec_tun.c:72
ipsec_tun_protect_t_::itp_flags
ipsec_protect_flags_t itp_flags
Definition: ipsec_tun.h:121
ipsec6_tun_input_node
vlib_node_registration_t ipsec6_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec6_tun_input_node)
Definition: ipsec_tun_in.c:407
adj_delegate_t_
Adj delegate.
Definition: adj_delegate.h:50
FOR_EACH_FIB_IP_PROTOCOL
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:69
ipsec_tun_protect_from_const_base
static const ipsec_tun_protect_t * ipsec_tun_protect_from_const_base(const adj_delegate_t *ad)
Definition: ipsec_tun.c:131
tunnel_t_::t_src
ip_address_t t_src
Definition: tunnel.h:87
VNET_LINK_ETHERNET
@ VNET_LINK_ETHERNET
Definition: interface.h:350
itp_db
static ipsec_tun_protect_db_t itp_db
Definition: ipsec_tun.c:75
ADJ_INDEX_INVALID
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
ipsec_tun_protect_t_::itp_ai
adj_index_t itp_ai
Definition: ipsec_tun.h:122
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
vlib_log_class_t
u32 vlib_log_class_t
Definition: vlib.h:52
ip46_address_reset
static void ip46_address_reset(ip46_address_t *ip46)
Definition: ip46_address.h:74
next
u16 * next
Definition: nat44_ei_out2in.c:718
vlib_log_register_class
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:339
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:311
adj_walk_rc_t
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
ip46_address_is_ip4
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
Definition: ip46_address.h:55
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
ipsec_tun_protect_db_t
struct ipsec_tun_protect_db_t_ ipsec_tun_protect_db_t
ipsec_tun_protect_set_crypto_addr
static void ipsec_tun_protect_set_crypto_addr(ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:464
ipsec_config
static clib_error_t * ipsec_config(vlib_main_t *vm, unformat_input_t *input)
Definition: ipsec_tun.c:983
adj_unlock
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:358
ipsec_tun_protect_itf_db_t_::id_hash
uword * id_hash
A hash table key'd on IP (4 or 6) address.
Definition: ipsec_tun.c:63
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
ipsec_sa_find_and_lock
index_t ipsec_sa_find_and_lock(u32 id)
Definition: ipsec_sa.c:383
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
AF_IP4
@ AF_IP4
Definition: ip_types.h:23
ipsec_tun_protect_t_::itp_sw_if_index
u32 itp_sw_if_index
Definition: ipsec_tun.h:117
ipsec_tun_teib_vft
const static teib_vft_t ipsec_tun_teib_vft
Definition: ipsec_tun.c:923
ipsec_tun_protect_adj_delegate_adj_deleted
static void ipsec_tun_protect_adj_delegate_adj_deleted(adj_delegate_t *ad)
Definition: ipsec_tun.c:825
IPSEC_TUN_DEFAULT_HASH_MEMORY_SIZE
#define IPSEC_TUN_DEFAULT_HASH_MEMORY_SIZE
Definition: ipsec_tun.c:33
VNET_LINK_ARP
@ VNET_LINK_ARP
Definition: interface.h:351
sa_out
u32 sa_out
Definition: ipsec.api:280
ipsec_tun_protect_adj_delegate_adj_modified
static void ipsec_tun_protect_adj_delegate_adj_modified(adj_delegate_t *ad)
Definition: ipsec_tun.c:833
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
ip4_register_protocol
void ip4_register_protocol(u32 protocol, u32 node_index)
Definition: ip4_forward.c:1895
vnet_get_device_class
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
Definition: interface_funcs.h:124
unformat_input_t
struct _unformat_input_t unformat_input_t
ipsec_tun_protect_get_adj_next
static u32 ipsec_tun_protect_get_adj_next(vnet_link_t linkt, const ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:139
ipsec_main_t::esp4_decrypt_tun_node_index
u32 esp4_decrypt_tun_node_index
Definition: ipsec.h:140
clib_bihash_kv_24_16_t
Definition: bihash_24_16.h:40
ipsec_sa_t::tunnel
tunnel_t tunnel
Definition: ipsec_sa.h:206
ipsec_tun_protect_rx_db_remove
static void ipsec_tun_protect_rx_db_remove(ipsec_main_t *im, const ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:370
adj_nbr_midchain_update_next_node
void adj_nbr_midchain_update_next_node(adj_index_t adj_index, u32 next_node)
Update the VLIB node to which packets are sent post processing.
Definition: adj_midchain.c:246
teib_entry_get_nh
const fib_prefix_t * teib_entry_get_nh(const teib_entry_t *te)
Definition: teib.c:96
IPSEC_TUN_PROTECT_DEFAULT_DB_ENTRY
const static ipsec_tun_protect_itf_db_t IPSEC_TUN_PROTECT_DEFAULT_DB_ENTRY
Definition: ipsec_tun.c:77
ip_address_from_46
void ip_address_from_46(const ip46_address_t *nh, fib_protocol_t fproto, ip_address_t *ip)
Definition: ip_types.c:259
key
typedef key
Definition: ipsec_types.api:88
ipsec_unregister_udp_port
void ipsec_unregister_udp_port(u16 port)
Definition: ipsec.c:128
ipsec_tun_teib_entry_deleted
static void ipsec_tun_teib_entry_deleted(const teib_entry_t *ne)
Definition: ipsec_tun.c:894
VLIB_CONFIG_FUNCTION
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:181
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
esp.h
ipsec4_tunnel_kv_t
Definition: ipsec_tun.h:48
teib.h
FOR_EACH_IPSEC_PROTECT_INPUT_SAI
#define FOR_EACH_IPSEC_PROTECT_INPUT_SAI(_itp, _sai, body)
Definition: ipsec_tun.h:130
ITP_DBG
#define ITP_DBG(_itp, _fmt, _args...)
Definition: ipsec_tun.c:81
ipsec_tun_protect_adj_delegate_adj_created
static void ipsec_tun_protect_adj_delegate_adj_created(adj_index_t ai)
Definition: ipsec_tun.c:840
ipsec_tun_protect_adj_add
static adj_walk_rc_t ipsec_tun_protect_adj_add(adj_index_t ai, void *arg)
Definition: ipsec_tun.c:299
teib_entry_t_
Definition: teib.c:33
adj_delegate_add
int adj_delegate_add(ip_adjacency_t *adj, adj_delegate_type_t adt, index_t adi)
Add a delegate to an adjacency.
Definition: adj_delegate.c:107
ipsec_itf_adj_unstack
void ipsec_itf_adj_unstack(adj_index_t ai)
Definition: ipsec_itf.c:58
format_ipsec_tun_protect
u8 * format_ipsec_tun_protect(u8 *s, va_list *args)
Definition: ipsec_format.c:356
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_node_t::index
u32 index
Definition: node.h:269
IP_ADDRESS_V4_ALL_0S
#define IP_ADDRESS_V4_ALL_0S
Definition: ip_types.h:86
vnet_sw_interface_is_p2p
int vnet_sw_interface_is_p2p(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface.c:1314
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
ipsec_tun_protect_t_
Definition: ipsec_tun.h:107
ipsec_itf.h
ipsec_sa_get
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
Definition: ipsec_sa.h:519
adj_delegate_type_t
enum adj_delegate_type_t_ adj_delegate_type_t
A Delagate is a means to implement the Delagation design pattern; the extension of an object's functi...
hash_free
#define hash_free(h)
Definition: hash.h:310
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
ipsec_tun_protect_find
static index_t ipsec_tun_protect_find(u32 sw_if_index, const ip_address_t *nh)
Definition: ipsec_tun.c:209
ipsec_tun_table_init
static void ipsec_tun_table_init(ip_address_family_t af, uword table_size, u32 n_buckets)
Definition: ipsec_tun.c:929
ipsec_main_t
Definition: ipsec.h:108
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
adj_delegate_t_::ad_adj_index
adj_index_t ad_adj_index
The ADJ entry object to which the delagate is attached.
Definition: adj_delegate.h:55
vlib_config_function_runtime_t
Definition: init.h:68
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
udp_local.h
ipsec_tun_protect_itf_db_t_
The DB of all added per-nh tunnel protectiond.
Definition: ipsec_tun.c:60
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
ipsec_tun_protect_update
int ipsec_tun_protect_update(u32 sw_if_index, const ip_address_t *nh, u32 sa_out, u32 *sas_in)
Definition: ipsec_tun.c:564
format_ip_address
u8 * format_ip_address(u8 *s, va_list *args)
Definition: ip_types.c:21
VNET_LINK_NSH
@ VNET_LINK_NSH
Definition: interface.h:352
uword
u64 uword
Definition: types.h:112
hash_create_mem
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:660
ipsec_main
ipsec_main_t ipsec_main
Definition: ipsec.c:28
VNET_LINK_MPLS
@ VNET_LINK_MPLS
Definition: interface.h:349
arc_index
u8 arc_index
Definition: nat44_ei_hairpinning.c:590
ipsec_tun_protect_sa_by_adj_index
index_t * ipsec_tun_protect_sa_by_adj_index
Adj index to TX SA mapping.
Definition: ipsec_tun.c:53
ipsec_tun_protect_walk_cb_t
walk_rc_t(* ipsec_tun_protect_walk_cb_t)(index_t itpi, void *arg)
Definition: ipsec_tun.h:153
ipsec_tun_protect_t_::itp_crypto
ipsec_ep_t itp_crypto
Definition: ipsec_tun.h:119
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
ipsec_tun_protect_t_::itp_out_sa
index_t itp_out_sa
Definition: ipsec_tun.h:110
hash_foreach
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:441
ipsec_tun_protect_update_from_teib
static void ipsec_tun_protect_update_from_teib(ipsec_tun_protect_t *itp, const teib_entry_t *ne)
Definition: ipsec_tun.c:548
adj_delegate.h
ipsec_sa_unlock
void ipsec_sa_unlock(index_t sai)
Definition: ipsec_sa.c:357
ipsec_tun_lkup_result_t_
result of a lookup in the protection bihash
Definition: ipsec_tun.h:39
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
adj_delegate_register_new_type
adj_delegate_type_t adj_delegate_register_new_type(const adj_delegate_vft_t *vft)
adj_delegate_register_new_type
Definition: adj_delegate.c:218
teib_vft_t_
Definition: teib.h:72
ipsec_tun_protect_itf_db_t
struct ipsec_tun_protect_itf_db_t_ ipsec_tun_protect_itf_db_t
The DB of all added per-nh tunnel protectiond.
ipsec_register_udp_port
void ipsec_register_udp_port(u16 port)
Definition: ipsec.c:153
nh
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ipsec_ep_t_::dst
ip46_address_t dst
Definition: ipsec_tun.h:102
ip_address_to_46
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
Definition: ip_types.c:252
feature_main
vnet_feature_main_t feature_main
Definition: pnat_test_stubs.h:27
ipsec6_tunnel_kv_t_
Definition: ipsec_tun.h:77
ip_adjacency_t_
IP unicast adjacency.
Definition: adj.h:235
ipsec_sa_lock
void ipsec_sa_lock(index_t sai)
Definition: ipsec_sa.c:370
bihash_24_16.h
unformat_vlib_cli_sub_input
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
Definition: cli.c:163
ipsec_tun_protect_add_adj
static void ipsec_tun_protect_add_adj(adj_index_t ai, const ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:190
ipsec_ep_t_::src
ip46_address_t src
Definition: ipsec_tun.h:101
N_AF
#define N_AF
Definition: ip_types.h:27
ip46_address_copy
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
Definition: ip46_address.h:123
ipsec_sa_t::crypto_alg
ipsec_crypto_alg_t crypto_alg
Definition: ipsec_sa.h:217
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
ipsec_tunnel_protect_init
static clib_error_t * ipsec_tunnel_protect_init(vlib_main_t *vm)
Definition: ipsec_tun.c:944
ipsec_tun_node_regs
static u32 ipsec_tun_node_regs[N_AF]
Definition: ipsec_tun.c:95
ipsec_tun_protect_tx_db_add
static void ipsec_tun_protect_tx_db_add(ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:313
ipsec_tun_protect_unconfig
static void ipsec_tun_protect_unconfig(ipsec_main_t *im, ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:523
ip46_address_is_zero
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
data
u8 data[128]
Definition: ipsec_types.api:92
ipsec_sa_t
Definition: ipsec_sa.h:116
hash_elts
static uword hash_elts(void *v)
Definition: hash.h:118
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
ip_adjacency_t_::sub_type
union ip_adjacency_t_::@144 sub_type
vlib_get_node_by_name
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
vnet_feature_modify_end_node
u32 vnet_feature_modify_end_node(u8 arc_index, u32 sw_if_index, u32 end_node_index)
Definition: feature.c:380
teib_register
void teib_register(const teib_vft_t *vft)
Definition: teib.c:408
clib_bihash_kv_8_16_t
8 octet key, 8 octet key value pair
Definition: bihash_8_16.h:41
ipsec4_tun_input_node
vlib_node_registration_t ipsec4_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec4_tun_input_node)
Definition: ipsec_tun_in.c:388
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:576
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
IPSEC_TUN_DEFAULT_HASH_NUM_BUCKETS
#define IPSEC_TUN_DEFAULT_HASH_NUM_BUCKETS
Definition: ipsec_tun.c:32
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:455
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
ipsec_tun_protect_rx_db_add
static void ipsec_tun_protect_rx_db_add(ipsec_main_t *im, const ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:231
ip6_unregister_protocol
void ip6_unregister_protocol(u32 protocol)
Definition: ip6_forward.c:1691
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
ipsec_tun_protect_adj_delegate_format
static u8 * ipsec_tun_protect_adj_delegate_format(const adj_delegate_t *aed, u8 *s)
Definition: ipsec_tun.c:862
teib_entry_get_sw_if_index
u32 teib_entry_get_sw_if_index(const teib_entry_t *te)
accessors for the opaque struct
Definition: teib.c:72
adj_get_link_type
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
Definition: adj.c:530
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_get_sup_hw_interface
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:92
ipsec_tun_unregister_nodes
void ipsec_tun_unregister_nodes(ip_address_family_t af)
Definition: ipsec_tun.c:115
adj_delegate_vft_t_::adv_adj_deleted
adj_delegate_adj_deleted_t adv_adj_deleted
Definition: adj_delegate.h:96
ipsec_tun_protect_t_::itp_in_sas
index_t itp_in_sas[ITP_MAX_N_SA_IN]
Definition: ipsec_tun.h:115
ipsec_tun_protect_del
int ipsec_tun_protect_del(u32 sw_if_index, const ip_address_t *nh)
Definition: ipsec_tun.c:714
teib_vft_t_::nv_added
teib_entry_added_t nv_added
Definition: teib.h:74
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
tunnel_t_::t_dst
ip_address_t t_dst
Definition: tunnel.h:88
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
teib_entry_get_peer
const ip_address_t * teib_entry_get_peer(const teib_entry_t *te)
Definition: teib.c:90
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
AF_IP6
@ AF_IP6
Definition: ip_types.h:24
ipsec_tun_protect_t_::itp_key
ip_address_t * itp_key
Definition: ipsec_tun.h:126
IP_ADDR_ALL_0
const ip_address_t IP_ADDR_ALL_0
Definition: ipsec_tun.c:55
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
ITP_MAX_N_SA_IN
#define ITP_MAX_N_SA_IN
Definition: ipsec_tun.h:105
vlib_main_t
Definition: main.h:102
vnet_link_t
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
pool_get_zero
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:258
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
hash_unset_mem
#define hash_unset_mem(h, key)
Definition: hash.h:291
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
ip
vl_api_address_t ip
Definition: l2.api:558
adj_nbr_walk_nh
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
Definition: adj_nbr.c:684
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
teib_entry_find
teib_entry_t * teib_entry_find(u32 sw_if_index, const ip_address_t *peer)
Definition: teib.c:114
ipsec_tun_protect_logger
vlib_log_class_t ipsec_tun_protect_logger
The logger.
Definition: ipsec_tun.c:38
ADJ_WALK_RC_CONTINUE
@ ADJ_WALK_RC_CONTINUE
Definition: adj_types.h:44
ipsec_sa_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:218
adj_nbr_walk
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk all adjacencies on a link for a given next-hop protocol.
Definition: adj_nbr.c:592
adj_is_midchain
u8 adj_is_midchain(adj_index_t ai)
Definition: adj_midchain.c:29
ip6_register_protocol
void ip6_register_protocol(u32 protocol, u32 node_index)
Definition: ip6_forward.c:1679
ipsec_tun_protect_tx_db_remove
static void ipsec_tun_protect_tx_db_remove(ipsec_tun_protect_t *itp)
Definition: ipsec_tun.c:427
FOR_EACH_IPSEC_PROTECT_INPUT_SA
#define FOR_EACH_IPSEC_PROTECT_INPUT_SA(_itp, _sa, body)
Definition: ipsec_tun.h:138
rv
int __clib_unused rv
Definition: application.c:491
ipsec_tun_protect_db_t_
Definition: ipsec_tun.c:69
ipsec_main_t::esp6_decrypt_tun_node_index
u32 esp6_decrypt_tun_node_index
Definition: ipsec.h:146
ipsec_tun_protect_get
static ipsec_tun_protect_t * ipsec_tun_protect_get(u32 index)
Definition: ipsec_tun.h:172
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
ip_address_copy
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
Definition: ip_types.c:133
ipsec_tun_protect_walk_itf
void ipsec_tun_protect_walk_itf(u32 sw_if_index, ipsec_tun_protect_walk_cb_t fn, void *ctx)
Definition: ipsec_tun.c:759
ipsec_tun_teib_entry_added
static void ipsec_tun_teib_entry_added(const teib_entry_t *ne)
Definition: ipsec_tun.c:873
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
adj_nbr_midchain_reset_next_node
void adj_nbr_midchain_reset_next_node(adj_index_t adj_index)
Return the adjacency's next node to its default value.
Definition: adj_midchain.c:272
ITP_DBG2
#define ITP_DBG2(_fmt, _args...)
Definition: ipsec_tun.c:89
vnet_feature_main_t::device_input_feature_arc_index
u8 device_input_feature_arc_index
Feature arc index for device-input.
Definition: feature.h:112
adj_get
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:470
ipsec_sa_t::spi
u32 spi
Definition: ipsec_sa.h:131
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:253
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
ipsec_tun_protect_walk
void ipsec_tun_protect_walk(ipsec_tun_protect_walk_cb_t fn, void *ctx)
Definition: ipsec_tun.c:746
ipsec_tun_protect_t_::itp_n_sa_in
u32 itp_n_sa_in
Definition: ipsec_tun.h:114
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
ipsec_tun_protect_config
static void ipsec_tun_protect_config(ipsec_main_t *im, ipsec_tun_protect_t *itp, u32 sa_out, u32 *sas_in)
Definition: ipsec_tun.c:492
ip_address_family_t
enum ip_address_family_t_ ip_address_family_t
ipsec_tun_adj_delegate_type
static adj_delegate_type_t ipsec_tun_adj_delegate_type
Adj delegate registered type.
Definition: ipsec_tun.c:48
ip_adjacency_t_::midchain
struct ip_adjacency_t_::@144::@146 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
ipsec_tun_feature_update
static void ipsec_tun_feature_update(u32 sw_if_index, u8 arc_index, u8 is_enable, void *data)
Definition: ipsec_tun.c:782