FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
lisp_gpe_adjacency.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @file
17  * @brief Common utility functions for IPv4, IPv6 and L2 LISP-GPE adjacencys.
18  *
19  */
20 
21 #include <vnet/dpo/load_balance.h>
22 #include <lisp/lisp-cp/control.h>
27 #include <vnet/fib/fib_entry.h>
28 #include <vnet/adj/adj_midchain.h>
29 #include <vnet/udp/udp_inlines.h>
30 #include <vppinfra/bihash_24_8.h>
32 
33 /**
34  * Memory pool of all adjacencies
35  */
37 
38 /**
39  * Hash table of all adjacencies. key:{nh, itf}
40  * We never have an all zeros address since the interfaces are multi-access,
41  * therefore there is no ambiguity between a v4 and v6 next-hop, so we don't
42  * need to add the protocol to the key.
43  */
44 static
45 BVT (clib_bihash)
47 
48 #define LISP_ADJ_SET_KEY(_key, _itf, _nh) \
49 { \
50  _key.key[0] = ip_addr_v6((_nh)).as_u64[0]; \
51  _key.key[1] = ip_addr_v6((_nh)).as_u64[1]; \
52  _key.key[2] = (_itf); \
53 }
54 
56 {
57  BVT (clib_bihash_kv) kv;
58 
60 
61  if (BV (clib_bihash_search) (&lisp_adj_db, &kv, &kv) < 0)
62  {
63  return (INDEX_INVALID);
64  }
65  else
66  {
67  return (kv.value);
68  }
69 }
70 
71 static void
73 {
74  BVT (clib_bihash_kv) kv;
75 
77  kv.value = ai;
78 
79  BV (clib_bihash_add_del) (&lisp_adj_db, &kv, 1);
80 }
81 
82 static void
84 {
85  BVT (clib_bihash_kv) kv;
86 
88 
89  BV (clib_bihash_add_del) (&lisp_adj_db, &kv, 0);
90 }
91 
92 static lisp_gpe_adjacency_t *
94 {
95  return (pool_elt_at_index (lisp_adj_pool, lai));
96 }
97 
100 {
101  switch (ip_addr_version (&ladj->remote_rloc))
102  {
103  case AF_IP4:
105  case AF_IP6:
107  default:
108  ASSERT (0);
109  break;
110  }
112 }
113 
114 static void
115 ip46_address_to_ip_address (const ip46_address_t * a, ip_address_t * b)
116 {
117  if (ip46_address_is_ip4 (a))
118  {
119  clib_memset (b, 0, sizeof (*b));
120  ip_address_set (b, &a->ip4, AF_IP4);
121  }
122  else
123  {
124  ip_address_set (b, &a->ip6, AF_IP6);
125  }
126 }
127 
128 /**
129  * @brief Stack the tunnel's midchain on the IP forwarding chain of the via
130  */
131 static void
133 {
134  const lisp_gpe_tunnel_t *lgt;
135 
136  lgt = lisp_gpe_tunnel_get (ladj->tunnel_index);
137 
139  lgt->fib_entry_index,
141  (ladj));
142 }
143 
144 /**
145  * @brief Call back when restacking all adjacencies on a GRE interface
146  */
147 static adj_walk_rc_t
149 {
150  lisp_gpe_adjacency_t *ladj = ctx;
151 
152  lisp_gpe_adj_stack_one (ladj, ai);
153 
154  return (ADJ_WALK_RC_CONTINUE);
155 }
156 
157 static void
159 {
160  fib_protocol_t nh_proto;
161  ip46_address_t nh;
162 
163  nh_proto = ip_address_to_46 (&ladj->remote_rloc, &nh);
164 
165  /*
166  * walk all the adjacencies on th lisp interface and restack them
167  */
169  nh_proto, &nh, lisp_gpe_adj_walk_cb, ladj);
170 }
171 
174 {
175  switch (linkt)
176  {
177  case VNET_LINK_IP4:
178  return (LISP_GPE_NEXT_PROTO_IP4);
179  case VNET_LINK_IP6:
180  return (LISP_GPE_NEXT_PROTO_IP6);
181  case VNET_LINK_ETHERNET:
183  case VNET_LINK_NSH:
184  return (LISP_GPE_NEXT_PROTO_NSH);
185  default:
186  ASSERT (0);
187  }
188  return (LISP_GPE_NEXT_PROTO_IP4);
189 }
190 
191 #define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40
192 
193 static lisp_afi_e
195 {
196  switch (link)
197  {
198  case VNET_LINK_IP4:
199  return LISP_AFI_IP;
200  case VNET_LINK_IP6:
201  return LISP_AFI_IP6;
202  case VNET_LINK_ETHERNET:
203  return LISP_AFI_MAC;
204  default:
205  return LISP_AFI_NO_ADDR;
206  }
207 }
208 
209 static void
211  const ip_adjacency_t * adj,
212  vlib_buffer_t * b)
213 {
215  lisp_gpe_adjacency_t *ladj;
216  ip_address_t rloc;
217  index_t lai;
218  u32 si, di;
220  uword *feip;
221 
222  ip46_address_to_ip_address (&adj->sub_type.nbr.next_hop, &rloc);
223  si = vnet_buffer (b)->sw_if_index[VLIB_TX];
224  lai = lisp_adj_find (&rloc, si);
225  ASSERT (INDEX_INVALID != lai);
226 
227  ladj = pool_elt_at_index (lisp_adj_pool, lai);
228 
229  u8 *lisp_data = (u8 *) vlib_buffer_get_current (b);
230 
231  /* skip IP header */
232  if (is_v4_packet (lisp_data))
233  lisp_data += sizeof (ip4_header_t);
234  else
235  lisp_data += sizeof (ip6_header_t);
236 
237  /* skip UDP header */
238  lisp_data += sizeof (udp_header_t);
239  // TODO: skip TCP?
240 
241  /* skip LISP GPE header */
242  lisp_data += sizeof (lisp_gpe_header_t);
243 
244  i16 saved_current_data = b->current_data;
245  b->current_data = lisp_data - b->data;
246 
248  get_src_and_dst_eids_from_buffer (lcm, b, &src, &dst, afi);
249  b->current_data = saved_current_data;
251  if (PREDICT_FALSE (~0 == di))
252  {
253  clib_warning ("dst mapping not found (%U, %U)", format_gid_address,
255  return;
256  }
257 
258  feip = hash_get (lcm->fwd_entry_by_mapping_index, di);
259  if (PREDICT_FALSE (!feip))
260  return;
261 
263  clib_memset (&key, 0, sizeof (key));
264  key.fwd_entry_index = feip[0];
265  key.tunnel_index = ladj->tunnel_index;
266 
268  ALWAYS_ASSERT (p);
269 
270  /* compute payload length starting after GPE */
271  u32 bytes = b->current_length - (lisp_data - b->data - b->current_data);
273  p[0], 1, bytes);
274 }
275 
276 static void
278  const ip_adjacency_t * adj,
279  vlib_buffer_t * b, const void *data)
280 {
282 
283  if (lcm->flags & LISP_FLAG_STATS_ENABLED)
285 
286  /* Fixup the checksum and len fields in the LISP tunnel encap
287  * that was applied at the midchain node */
289 }
290 
291 /**
292  * @brief The LISP-GPE interface registered function to update, i.e.
293  * provide an rewrite string for, an adjacency.
294  */
295 void
297 {
298  const lisp_gpe_tunnel_t *lgt;
299  lisp_gpe_adjacency_t *ladj;
300  ip_adjacency_t *adj;
301  ip_address_t rloc;
302  vnet_link_t linkt;
303  adj_flags_t af;
304  index_t lai;
305 
306  adj = adj_get (ai);
307  ip46_address_to_ip_address (&adj->sub_type.nbr.next_hop, &rloc);
308 
309  /*
310  * find an existing or create a new adj
311  */
312  lai = lisp_adj_find (&rloc, sw_if_index);
313 
314  ASSERT (INDEX_INVALID != lai);
315 
316  ladj = pool_elt_at_index (lisp_adj_pool, lai);
317  lgt = lisp_gpe_tunnel_get (ladj->tunnel_index);
318  linkt = adj_get_link_type (ai);
320  if (VNET_LINK_ETHERNET == linkt)
322 
324  (ai, lisp_gpe_fixup, NULL, af,
327  (linkt)));
328 
329  lisp_gpe_adj_stack_one (ladj, ai);
330 }
331 
332 u8 *
335  vnet_link_t link_type, const void *dst_address)
336 {
337  ASSERT (0);
338  return (NULL);
339 }
340 
341 index_t
343  u32 overlay_table_id, u32 vni)
344 {
345  const lisp_gpe_sub_interface_t *l3s;
346  const lisp_gpe_tunnel_t *lgt;
347  lisp_gpe_adjacency_t *ladj;
348  index_t lai, l3si;
349 
350  /*
351  * first find the L3 sub-interface that corresponds to the loacl-rloc and vni
352  */
354  overlay_table_id,
355  vni);
356  l3s = lisp_gpe_sub_interface_get (l3si);
357 
358  /*
359  * find an existing or create a new adj
360  */
361  lai = lisp_adj_find (&pair->rmt_loc, l3s->sw_if_index);
362 
363  if (INDEX_INVALID == lai)
364  {
365 
366  pool_get (lisp_adj_pool, ladj);
367  clib_memset (ladj, 0, sizeof (*ladj));
368  lai = (ladj - lisp_adj_pool);
369 
370  ip_address_copy (&ladj->remote_rloc, &pair->rmt_loc);
371  ladj->vni = vni;
372  /* transfer the lock to the adj */
373  ladj->lisp_l3_sub_index = l3si;
374  ladj->sw_if_index = l3s->sw_if_index;
375 
376  /* if vni is non-default */
377  if (ladj->vni)
378  ladj->flags = LISP_GPE_FLAGS_I;
379 
380  /* work in lisp-gpe not legacy mode */
381  ladj->flags |= LISP_GPE_FLAGS_P;
382 
383  /*
384  * find the tunnel that will provide the underlying transport
385  * and hence the rewrite.
386  * The RLOC FIB index is default table - always.
387  */
389 
390  lgt = lisp_gpe_tunnel_get (ladj->tunnel_index);
391 
392  /*
393  * become of child of the RLOC FIB entry so we are updated when
394  * its reachability changes, allowing us to re-stack the midcahins
395  */
398  lai);
399 
400  lisp_adj_insert (&ladj->remote_rloc, ladj->sw_if_index, lai);
401  }
402  else
403  {
404  /* unlock the interface from the find. */
406  ladj = lisp_gpe_adjacency_get_i (lai);
407  }
408 
409  ladj->locks++;
410 
411  return (lai);
412 }
413 
414 /**
415  * @brief Get a pointer to a tunnel from a pointer to a FIB node
416  */
417 static lisp_gpe_adjacency_t *
419 {
420  return ((lisp_gpe_adjacency_t *)
421  ((char *) node -
423 }
424 
425 static void
427 {
428  const lisp_gpe_tunnel_t *lgt;
429 
430  /*
431  * no children so we are not counting locks. no-op.
432  * at least not counting
433  */
434  lisp_adj_remove (&ladj->remote_rloc, ladj->sw_if_index);
435 
436  /*
437  * unlock the resources this adj holds
438  */
439  lgt = lisp_gpe_tunnel_get (ladj->tunnel_index);
440 
442 
445 
446  pool_put (lisp_adj_pool, ladj);
447 }
448 
449 void
451 {
452  lisp_gpe_adjacency_t *ladj;
453 
454  ladj = lisp_gpe_adjacency_get_i (lai);
455 
456  ladj->locks--;
457 
458  if (0 == ladj->locks)
459  {
461  }
462 }
463 
464 const lisp_gpe_adjacency_t *
466 {
467  return (lisp_gpe_adjacency_get_i (lai));
468 }
469 
470 
471 /**
472  * @brief LISP GPE tunnel back walk
473  *
474  * The FIB entry through which this tunnel resolves has been updated.
475  * re-stack the midchain on the new forwarding.
476  */
480 {
482 
484 }
485 
486 static fib_node_t *
488 {
489  lisp_gpe_adjacency_t *ladj;
490 
492  return (&ladj->fib_node);
493 }
494 
495 static void
497 {
499 }
500 
503  .fnv_back_walk = lisp_gpe_adjacency_back_walk,
504  .fnv_last_lock = lisp_gpe_adjacency_last_fib_lock_gone,
505 };
506 
507 u8 *
508 format_lisp_gpe_adjacency (u8 * s, va_list * args)
509 {
510  lisp_gpe_adjacency_t *ladj = va_arg (*args, lisp_gpe_adjacency_t *);
512  va_arg (*args, lisp_gpe_adjacency_format_flags_t);
513 
515  {
516  s =
517  format (s, "index %d locks:%d\n", ladj - lisp_adj_pool, ladj->locks);
518  }
519 
520  s = format (s, " vni: %d,", ladj->vni);
521  s = format (s, " remote-RLOC: %U,", format_ip_address, &ladj->remote_rloc);
522 
524  {
525  s = format (s, " %U\n",
528  s = format (s, " %U\n",
531  }
532  else
533  {
534  s = format (s, " LISP L3 sub-interface index: %d,",
535  ladj->lisp_l3_sub_index);
536  s = format (s, " LISP tunnel index: %d", ladj->tunnel_index);
537  }
538 
539 
540  return (s);
541 }
542 
543 static clib_error_t *
545  unformat_input_t * input, vlib_cli_command_t * cmd)
546 {
547  lisp_gpe_adjacency_t *ladj;
548  index_t index;
549 
550  if (pool_elts (lisp_adj_pool) == 0)
551  vlib_cli_output (vm, "No lisp-gpe Adjacencies");
552 
553  if (unformat (input, "%d", &index))
554  {
558  }
559  else
560  {
561  /* *INDENT-OFF* */
563  {
564  vlib_cli_output (vm, "[%d] %U\n",
565  ladj - lisp_adj_pool,
568  }
569  /* *INDENT-ON* */
570  }
571 
572  return 0;
573 }
574 
575 /* *INDENT-OFF* */
577 {
578  .path = "show gpe adjacency",
579  .function = lisp_gpe_adjacency_show,
580 };
581 /* *INDENT-ON* */
582 
583 #define LISP_ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS (256)
584 #define LISP_ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE (1<<20)
585 
586 static clib_error_t *
588 {
590  "Adjacency Neighbour table",
593 
595  return (NULL);
596 }
597 
599 /*
600  * fd.io coding-style-patch-verification: ON
601  *
602  * Local Variables:
603  * eval: (c-set-style "gnu")
604  * End:
605  */
load_balance.h
ADJ_FLAG_MIDCHAIN_NO_COUNT
@ ADJ_FLAG_MIDCHAIN_NO_COUNT
Definition: adj.h:217
lisp_gpe_adjacency_from_fib_node
static lisp_gpe_adjacency_t * lisp_gpe_adjacency_from_fib_node(const fib_node_t *node)
Get a pointer to a tunnel from a pointer to a FIB node.
Definition: lisp_gpe_adjacency.c:418
lisp_types.h
lisp_gpe_adj_module_init
static clib_error_t * lisp_gpe_adj_module_init(vlib_main_t *vm)
Definition: lisp_gpe_adjacency.c:587
lisp_gpe_adj_proto_from_vnet_link_type
static lisp_gpe_next_protocol_e lisp_gpe_adj_proto_from_vnet_link_type(vnet_link_t linkt)
Definition: lisp_gpe_adjacency.c:173
ip_address
Definition: ip_types.h:79
bihash_24_8.h
lisp_gpe_adjacency_t_::remote_rloc
ip_address_t remote_rloc
remote RLOC.
Definition: lisp_gpe_adjacency.h:53
adj_midchain.h
fib_entry.h
get_src_and_dst_eids_from_buffer
void get_src_and_dst_eids_from_buffer(lisp_cp_main_t *lcm, vlib_buffer_t *b, gid_address_t *src, gid_address_t *dst, u16 type)
Definition: control.c:3261
lisp_stats_key_t
Definition: lisp_gpe.h:94
LISP_ADJ_SET_KEY
#define LISP_ADJ_SET_KEY(_key, _itf, _nh)
Definition: lisp_gpe_adjacency.c:48
lisp_cp_main_t::flags
u32 flags
Definition: control.h:163
fib_node_back_walk_rc_t
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
lisp_adj_find
static index_t lisp_adj_find(const ip_address_t *addr, u32 sw_if_index)
Definition: lisp_gpe_adjacency.c:55
lisp_gpe_tunnel_find_or_create_and_lock
index_t lisp_gpe_tunnel_find_or_create_and_lock(const locator_pair_t *pair, u32 rloc_fib_index)
Definition: lisp_gpe_tunnel.c:148
lisp_gpe_update_adjacency
void lisp_gpe_update_adjacency(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
The LISP-GPE interface registered function to update, i.e.
Definition: lisp_gpe_adjacency.c:296
control.h
VNET_LINK_ETHERNET
@ VNET_LINK_ETHERNET
Definition: interface.h:350
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
bihash_template.h
lisp_gpe_next_protocol_e
lisp_gpe_next_protocol_e
Definition: lisp_gpe_packet.h:132
lisp_gpe_adjacency_t_::locks
u32 locks
The number of locks/reference counts on the adjacency.
Definition: lisp_gpe_adjacency.h:63
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
adj_walk_rc_t
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
fib_node_vft_t_
A FIB graph nodes virtual function table.
Definition: fib_node.h:288
vni
u32 vni
Definition: flow_types.api:160
ip46_address_is_ip4
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
Definition: ip46_address.h:55
lisp_gpe_fixup
static void lisp_gpe_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b, const void *data)
Definition: lisp_gpe_adjacency.c:277
vlib_cli_command_t::path
char * path
Definition: cli.h:96
LISP_GPE_NEXT_PROTO_NSH
@ LISP_GPE_NEXT_PROTO_NSH
Definition: lisp_gpe_packet.h:137
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
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
LISP_GPE_NEXT_PROTO_ETHERNET
@ LISP_GPE_NEXT_PROTO_ETHERNET
Definition: lisp_gpe_packet.h:136
lisp_gpe_sub_interface.h
LISP sub-interfaces.
lisp_gpe_sub_interface_t_::sw_if_index
u32 sw_if_index
The SW if index assigned to this sub-interface.
Definition: lisp_gpe_sub_interface.h:75
unformat_input_t
struct _unformat_input_t unformat_input_t
ip_adjacency_t_::ia_link
vnet_link_t ia_link
link/ether-type 1 bytes
Definition: adj.h:343
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
LISP_AFI_IP6
@ LISP_AFI_IP6
Definition: lisp_types.h:185
lisp_gpe_adj_get_fib_chain_type
fib_forward_chain_type_t lisp_gpe_adj_get_fib_chain_type(const lisp_gpe_adjacency_t *ladj)
Definition: lisp_gpe_adjacency.c:99
format_lisp_gpe_sub_interface
u8 * format_lisp_gpe_sub_interface(u8 *s, va_list *ap)
Definition: lisp_gpe_sub_interface.c:219
adj_nbr_midchain_stack_on_fib_entry
void adj_nbr_midchain_stack_on_fib_entry(adj_index_t ai, fib_node_index_t fei, fib_forward_chain_type_t fct)
[re]stack a midchain.
Definition: adj_midchain.c:335
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
LISP_GPE_ADJ_FORMAT_FLAG_DETAIL
@ LISP_GPE_ADJ_FORMAT_FLAG_DETAIL
Definition: lisp_gpe_adjacency.h:123
LISP_ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS
#define LISP_ADJ_NBR_DEFAULT_HASH_NUM_BUCKETS
Definition: lisp_gpe_adjacency.c:583
key
typedef key
Definition: ipsec_types.api:91
lisp_adj_remove
static void lisp_adj_remove(const ip_address_t *addr, u32 sw_if_index)
Definition: lisp_gpe_adjacency.c:83
FIB_NODE_TYPE_LISP_ADJ
@ FIB_NODE_TYPE_LISP_ADJ
Definition: fib_node.h:41
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
vnet_lisp_gpe_get_main
static lisp_gpe_main_t * vnet_lisp_gpe_get_main()
Definition: lisp_gpe.h:184
adj_flags_t
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
lisp_gpe_adjacency_format_flags_t
enum lisp_gpe_adjacency_format_flags_t_ lisp_gpe_adjacency_format_flags_t
Flags for displaying the adjacency.
FIB_FORW_CHAIN_TYPE_UNICAST_IP4
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:108
is_v4_packet
#define is_v4_packet(_h)
Definition: lisp_gpe_adjacency.c:191
i16
signed short i16
Definition: types.h:46
STRUCT_OFFSET_OF
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:73
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
lisp_gpe_adjacency_show
static clib_error_t * lisp_gpe_adjacency_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: lisp_gpe_adjacency.c:544
ip_addr_version
#define ip_addr_version(_a)
Definition: ip_types.h:93
LISP_GPE_NEXT_PROTO_IP6
@ LISP_GPE_NEXT_PROTO_IP6
Definition: lisp_gpe_packet.h:135
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
fib_entry_child_add
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: fib_entry.c:555
lisp_gpe_adjacency_t_::fib_node
fib_node_t fib_node
The LISP adj is a part of the FIB control plane graph.
Definition: lisp_gpe_adjacency.h:48
lisp_gpe_adjacency_last_lock_gone
static void lisp_gpe_adjacency_last_lock_gone(lisp_gpe_adjacency_t *ladj)
Definition: lisp_gpe_adjacency.c:426
clib_bihash_init
void clib_bihash_init(clib_bihash *h, char *name, u32 nbuckets, uword memory_size)
initialize a bounded index extensible hash table
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
lisp_cp_main_t::fwd_entry_by_mapping_index
u32 * fwd_entry_by_mapping_index
Definition: control.h:197
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
LISP_GPE_ADJ_FORMAT_FLAG_NONE
@ LISP_GPE_ADJ_FORMAT_FLAG_NONE
Definition: lisp_gpe_adjacency.h:122
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_lisp_cp_get_main
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:305
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:187
hash_get
#define hash_get(h, key)
Definition: hash.h:249
locator_pair::rmt_loc
ip_address_t rmt_loc
Definition: lisp_types.h:330
lisp_adj_pool
static lisp_gpe_adjacency_t * lisp_adj_pool
Memory pool of all adjacencies.
Definition: lisp_gpe_adjacency.c:36
lisp_cp_main_t::mapping_index_by_gid
gid_dictionary_t mapping_index_by_gid
Definition: control.h:169
lisp_gpe_tunnel_t_::fib_entry_index
fib_node_index_t fib_entry_index
the FIB entry through which the remote rloc is reachable s
Definition: lisp_gpe_tunnel.h:63
lisp_gpe_adjacency_t_::fib_entry_child_index
u32 fib_entry_child_index
This adjacency is a child of the FIB entry to reach the RLOC.
Definition: lisp_gpe_adjacency.h:87
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
show_lisp_gpe_tunnel_command
static vlib_cli_command_t show_lisp_gpe_tunnel_command
(constructor) VLIB_CLI_COMMAND (show_lisp_gpe_tunnel_command)
Definition: lisp_gpe_adjacency.c:576
lisp_gpe_adjacency_get_fib_node
static fib_node_t * lisp_gpe_adjacency_get_fib_node(fib_node_index_t index)
Definition: lisp_gpe_adjacency.c:487
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
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
locator_pair::lcl_loc
ip_address_t lcl_loc
Definition: lisp_types.h:329
lisp_gpe_adjacency_unlock
void lisp_gpe_adjacency_unlock(index_t lai)
Definition: lisp_gpe_adjacency.c:450
lisp_adj_insert
static void lisp_adj_insert(const ip_address_t *addr, u32 sw_if_index, index_t ai)
Definition: lisp_gpe_adjacency.c:72
lisp_afi_from_vnet_link_type
static lisp_afi_e lisp_afi_from_vnet_link_type(vnet_link_t link)
Definition: lisp_gpe_adjacency.c:194
BVT
BVT(clib_bihash)
The table of adjacencies indexed by the rewrite string.
Definition: l2_fib.c:1065
lisp_cp_main_t
Definition: control.h:161
lisp_gpe_tunnel_get
const lisp_gpe_tunnel_t * lisp_gpe_tunnel_get(index_t lgti)
Definition: lisp_gpe_tunnel.c:210
lisp_gpe_build_rewrite
u8 * lisp_gpe_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Definition: lisp_gpe_adjacency.c:333
lisp_gpe_adjacency_last_fib_lock_gone
static void lisp_gpe_adjacency_last_fib_lock_gone(fib_node_t *node)
Definition: lisp_gpe_adjacency.c:496
lisp_gpe_adj_stack_one
static void lisp_gpe_adj_stack_one(lisp_gpe_adjacency_t *ladj, adj_index_t ai)
Stack the tunnel's midchain on the IP forwarding chain of the via.
Definition: lisp_gpe_adjacency.c:132
lisp_gpe_sub_interface_get
const lisp_gpe_sub_interface_t * lisp_gpe_sub_interface_get(index_t l3si)
Definition: lisp_gpe_sub_interface.c:213
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
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.
udp_inlines.h
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
lisp_gpe_adjacency_t_::sw_if_index
u32 sw_if_index
The SW IF index of the sub-interface this adjacency uses.
Definition: lisp_gpe_adjacency.h:74
ip_address_set
void ip_address_set(ip_address_t *dst, const void *src, ip_address_family_t af)
Definition: ip_types.c:207
lisp_gpe_main::lisp_stats_index_by_key
uword * lisp_stats_index_by_key
Definition: lisp_gpe.h:164
ALWAYS_ASSERT
#define ALWAYS_ASSERT(truth)
Definition: error_bootstrap.h:89
ip_adjacency_t_
IP unicast adjacency.
Definition: adj.h:235
fib_node_register_type
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
Definition: fib_node.c:60
LISP_AFI_MAC
@ LISP_AFI_MAC
Definition: lisp_types.h:187
FIB_NODE_BACK_WALK_CONTINUE
@ FIB_NODE_BACK_WALK_CONTINUE
Definition: fib_node.h:259
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
lisp_gpe_tunnel.h
Common utility functions for IPv4, IPv6 and L2 LISP-GPE tunnels.
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
locator_pair
Definition: lisp_types.h:326
gid_dictionary_sd_lookup
u32 gid_dictionary_sd_lookup(gid_dictionary_t *db, gid_address_t *dst, gid_address_t *src)
Definition: gid_dictionary.c:443
data
u8 data[128]
Definition: ipsec_types.api:95
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
vnet_main_t
Definition: vnet.h:76
ip_adjacency_t_::sub_type
union ip_adjacency_t_::@144 sub_type
index
u32 index
Definition: flow_types.api:221
lisp_gpe_adjacency_get
const lisp_gpe_adjacency_t * lisp_gpe_adjacency_get(index_t lai)
Definition: lisp_gpe_adjacency.c:465
adj_nbr_midchain_update_rewrite
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
Definition: adj_midchain.c:213
lisp_afi_e
lisp_afi_e
Definition: lisp_types.h:181
ip46_address_to_ip_address
static void ip46_address_to_ip_address(const ip46_address_t *a, ip_address_t *b)
Definition: lisp_gpe_adjacency.c:115
lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.h:119
lisp_adj_db
static lisp_adj_db
Hash table of all adjacencies.
Definition: lisp_gpe_adjacency.c:46
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
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
LISP_GPE_NEXT_PROTO_IP4
@ LISP_GPE_NEXT_PROTO_IP4
Definition: lisp_gpe_packet.h:134
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
af
vl_api_address_family_t af
Definition: ip.api:619
lisp_gpe_header_t
LISP-GPE header.
Definition: lisp_gpe_packet.h:100
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
si
vnet_sw_interface_t * si
Definition: interface_output.c:418
ip_udp_fixup_one
static void ip_udp_fixup_one(vlib_main_t *vm, vlib_buffer_t *b0, u8 is_ip4)
Definition: udp_inlines.h:46
lisp_gpe_adjacency_t_
A LISP GPE Adjacency.
Definition: lisp_gpe_adjacency.h:43
LISP_AFI_IP
@ LISP_AFI_IP
Definition: lisp_types.h:184
lisp_gpe_adj_stack
static void lisp_gpe_adj_stack(lisp_gpe_adjacency_t *ladj)
Definition: lisp_gpe_adjacency.c:158
LISP_AFI_NO_ADDR
@ LISP_AFI_NO_ADDR
Definition: lisp_types.h:183
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
clib_bihash_add_del
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
AF_IP6
@ AF_IP6
Definition: ip_types.h:24
lisp_gpe_adjacency_find_or_create_and_lock
index_t lisp_gpe_adjacency_find_or_create_and_lock(const locator_pair_t *pair, u32 overlay_table_id, u32 vni)
Definition: lisp_gpe_adjacency.c:342
ip6_header_t
Definition: ip6_packet.h:294
lisp_gpe_sub_interface_find_or_create_and_lock
index_t lisp_gpe_sub_interface_find_or_create_and_lock(const ip_address_t *lrloc, u32 overlay_table_id, u32 vni)
Definition: lisp_gpe_sub_interface.c:120
lisp_gpe_tunnel_build_rewrite
u8 * lisp_gpe_tunnel_build_rewrite(const lisp_gpe_tunnel_t *lgt, const lisp_gpe_adjacency_t *ladj, lisp_gpe_next_protocol_e payload_proto)
Compute IP-UDP-GPE sub-tunnel encap/rewrite header.
Definition: lisp_gpe_tunnel.c:46
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
LISP_ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE
#define LISP_ADJ_NBR_DEFAULT_HASH_MEMORY_SIZE
Definition: lisp_gpe_adjacency.c:584
lisp_gpe_adjacency_back_walk
static fib_node_back_walk_rc_t lisp_gpe_adjacency_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
LISP GPE tunnel back walk.
Definition: lisp_gpe_adjacency.c:478
lisp_gpe_adjacency_t_::flags
u8 flags
LISP header fields in HOST byte order.
Definition: lisp_gpe_adjacency.h:92
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
lisp_gpe_sub_interface_t_
A LISP L3 sub-interface.
Definition: lisp_gpe_sub_interface.h:52
vnet_link_t
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
lisp_gpe_adjacency.h
Common utility functions for IPv4, IPv6 and L2 LISP-GPE adjacencys.
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
lisp_gpe_sub_interface_unlock
void lisp_gpe_sub_interface_unlock(index_t l3si)
Definition: lisp_gpe_sub_interface.c:187
clib_error_t
Definition: clib_error.h:21
a
a
Definition: bitmap.h:525
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
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
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
lisp_gpe_tunnel_t_
A LISP GPE Tunnel.
Definition: lisp_gpe_tunnel.h:48
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
lisp_gpe_tunnel_unlock
void lisp_gpe_tunnel_unlock(index_t lgti)
Definition: lisp_gpe_tunnel.c:194
format_gid_address
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:187
ADJ_WALK_RC_CONTINUE
@ ADJ_WALK_RC_CONTINUE
Definition: adj_types.h:44
ip_adjacency_t_::nbr
struct ip_adjacency_t_::@144::@145 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
fib_node_back_walk_ctx_t_
Context passed between object during a back walk.
Definition: fib_node.h:214
fib_node_vft_t_::fnv_get
fib_node_get_t fnv_get
Definition: fib_node.h:289
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
gid_address_t
struct _gid_address_t gid_address_t
lisp_gpe_adjacency_t_::tunnel_index
u32 tunnel_index
The index of the LISP GPE tunnel that provides the transport in the underlay.
Definition: lisp_gpe_adjacency.h:80
format_lisp_gpe_adjacency
u8 * format_lisp_gpe_adjacency(u8 *s, va_list *args)
Definition: lisp_gpe_adjacency.c:508
lisp_gpe_main::counters
vlib_combined_counter_main_t counters
Definition: lisp_gpe.h:165
FIB_FORW_CHAIN_TYPE_UNICAST_IP6
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:112
format_lisp_gpe_tunnel
u8 * format_lisp_gpe_tunnel(u8 *s, va_list *args)
Format LISP-GPE tunnel.
Definition: lisp_gpe_tunnel.c:217
lisp_gpe_adj_walk_cb
static adj_walk_rc_t lisp_gpe_adj_walk_cb(adj_index_t ai, void *ctx)
Call back when restacking all adjacencies on a GRE interface.
Definition: lisp_gpe_adjacency.c:148
fib_entry_child_remove
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:566
lisp_gpe_tuennel_vft
const static fib_node_vft_t lisp_gpe_tuennel_vft
Definition: lisp_gpe_adjacency.c:501
vlib_cli_command_t
Definition: cli.h:92
lisp_gpe_adjacency_get_i
static lisp_gpe_adjacency_t * lisp_gpe_adjacency_get_i(index_t lai)
Definition: lisp_gpe_adjacency.c:93
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
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
di
void di(unformat_input_t *i)
Definition: unformat.c:163
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
ADJ_FLAG_MIDCHAIN_IP_STACK
@ ADJ_FLAG_MIDCHAIN_IP_STACK
Definition: adj.h:218
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
lisp_gpe_adjacency_t_::lisp_l3_sub_index
u32 lisp_l3_sub_index
The index of the LISP L3 subinterface.
Definition: lisp_gpe_adjacency.h:68
lisp_gpe_increment_stats_counters
static void lisp_gpe_increment_stats_counters(lisp_cp_main_t *lcm, const ip_adjacency_t *adj, vlib_buffer_t *b)
Definition: lisp_gpe_adjacency.c:210
vlib_increment_combined_counter
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
lisp_gpe_adjacency_t_::vni
u32 vni
The VNI.
Definition: lisp_gpe_adjacency.h:58
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105