FD.io VPP  v16.09
Vector Packet Processing
lookup.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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  * ip/ip_lookup.h: ip (4 or 6) lookup structures, adjacencies, ...
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 /**
41  * @file
42  * Definitions for all things IP (v4|v6) unicast and multicast lookup related.
43  *
44  * - Adjacency definitions and registration.
45  * - Callbacks on route add.
46  * - Callbacks on interface address change.
47  */
48 
49 #ifndef included_ip_lookup_h
50 #define included_ip_lookup_h
51 
52 #include <vnet/vnet.h>
53 #include <vlib/buffer.h>
54 #include <vnet/ip/ip4_packet.h>
55 #include <vnet/ip/ip6_packet.h>
56 
57 /** @brief Common (IP4/IP6) next index stored in adjacency. */
58 typedef enum {
59  /** Packet does not match any route in table. */
61 
62  /** Adjacency to drop this packet. */
64  /** Adjacency to punt this packet. */
66 
67  /** This packet is for one of our own IP addresses. */
69 
70  /** This packet matches an "interface route" and packets
71  need to be passed to ARP to find rewrite string for
72  this destination. */
74 
75  /** This packet is to be rewritten and forwarded to the next
76  processing node. This is typically the output interface but
77  might be another node for further output processing. */
79 
80  /** This packet needs to be classified */
82 
83  /** This packet needs to go to MAP - RFC7596, RFC7597 */
85 
86  /** This packet needs to go to MAP with Translation - RFC7599 */
88 
89  /** This packets needs to go to indirect next hop */
91 
92  /** This packets needs to go to ICMP error */
94 
97 
98 typedef enum {
101 
102 typedef enum {
103  /** Hop-by-hop header handling */
109 
110 #define IP4_LOOKUP_NEXT_NODES { \
111  [IP_LOOKUP_NEXT_MISS] = "ip4-miss", \
112  [IP_LOOKUP_NEXT_DROP] = "ip4-drop", \
113  [IP_LOOKUP_NEXT_PUNT] = "ip4-punt", \
114  [IP_LOOKUP_NEXT_LOCAL] = "ip4-local", \
115  [IP_LOOKUP_NEXT_ARP] = "ip4-arp", \
116  [IP_LOOKUP_NEXT_REWRITE] = "ip4-rewrite-transit", \
117  [IP_LOOKUP_NEXT_CLASSIFY] = "ip4-classify", \
118  [IP_LOOKUP_NEXT_MAP] = "ip4-map", \
119  [IP_LOOKUP_NEXT_MAP_T] = "ip4-map-t", \
120  [IP_LOOKUP_NEXT_INDIRECT] = "ip4-indirect", \
121  [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error", \
122 }
123 
124 #define IP6_LOOKUP_NEXT_NODES { \
125  [IP_LOOKUP_NEXT_MISS] = "ip6-miss", \
126  [IP_LOOKUP_NEXT_DROP] = "ip6-drop", \
127  [IP_LOOKUP_NEXT_PUNT] = "ip6-punt", \
128  [IP_LOOKUP_NEXT_LOCAL] = "ip6-local", \
129  [IP_LOOKUP_NEXT_ARP] = "ip6-discover-neighbor", \
130  [IP_LOOKUP_NEXT_REWRITE] = "ip6-rewrite", \
131  [IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify", \
132  [IP_LOOKUP_NEXT_MAP] = "ip6-map", \
133  [IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t", \
134  [IP_LOOKUP_NEXT_INDIRECT] = "ip6-indirect", \
135  [IP_LOOKUP_NEXT_ICMP_ERROR] = "ip6-icmp-error", \
136  [IP6_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop", \
137  [IP6_LOOKUP_NEXT_ADD_HOP_BY_HOP] = "ip6-add-hop-by-hop", \
138  [IP6_LOOKUP_NEXT_POP_HOP_BY_HOP] = "ip6-pop-hop-by-hop", \
139 }
140 
141 /** Flow hash configuration */
142 #define IP_FLOW_HASH_SRC_ADDR (1<<0)
143 #define IP_FLOW_HASH_DST_ADDR (1<<1)
144 #define IP_FLOW_HASH_PROTO (1<<2)
145 #define IP_FLOW_HASH_SRC_PORT (1<<3)
146 #define IP_FLOW_HASH_DST_PORT (1<<4)
147 #define IP_FLOW_HASH_REVERSE_SRC_DST (1<<5)
148 
149 /** Default: 5-tuple without the "reverse" bit */
150 #define IP_FLOW_HASH_DEFAULT (0x1F)
151 
152 #define foreach_flow_hash_bit \
153 _(src, IP_FLOW_HASH_SRC_ADDR) \
154 _(dst, IP_FLOW_HASH_DST_ADDR) \
155 _(sport, IP_FLOW_HASH_SRC_PORT) \
156 _(dport, IP_FLOW_HASH_DST_PORT) \
157 _(proto, IP_FLOW_HASH_PROTO) \
158 _(reverse, IP_FLOW_HASH_REVERSE_SRC_DST)
159 
160 #define IP_ADJACENCY_OPAQUE_SZ 16
161 /** @brief IP unicast adjacency.
162  @note cache aligned.
163 */
164 typedef struct {
165  CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
166  /** Handle for this adjacency in adjacency heap. */
168 
169  STRUCT_MARK(signature_start);
170 
171  /** Interface address index for this local/arp adjacency. */
173 
174  /** Number of adjecencies in block. Greater than 1 means multipath;
175  otherwise equal to 1. */
177 
178  /** Next hop after ip4-lookup. */
179  union {
180  ip_lookup_next_t lookup_next_index : 16;
182  };
183 
184  /** Force re-lookup in a different FIB. ~0 => normal behavior */
187 
188  /** Highest possible perf subgraph arc interposition, e.g. for ip6 ioam */
190 
191  union {
192  /** IP_LOOKUP_NEXT_ARP only */
193  struct {
194  ip46_address_t next_hop;
195  } arp;
196  /** IP_LOOKUP_NEXT_CLASSIFY only */
197  struct {
199  } classify;
200  /** IP_LOOKUP_NEXT_INDIRECT only */
201  struct {
202  ip46_address_t next_hop;
203  } indirect;
205  };
206 
207  /** @brief Special format function for this adjacency.
208  * Specifically good for cases which use the entire rewrite
209  * for their own purposes. Can easily reduce to a u16 or a u8 if/when
210  * the first cache line reads "full" on the free space gas gauge.
211  */
213  STRUCT_MARK(signature_end);
214 
215  /** Number of FIB entries sharing this adjacency */
217  /** Use this adjacency instead */
219 
220  CLIB_CACHE_LINE_ALIGN_MARK(cacheline1);
221 
222  /** Rewrite in second/third cache lines */
225 
226 static inline uword
228 {
229  uword signature = 0xfeedfaceULL;
230 
231  /* Skip heap handle, sum everything up to but not including share_count */
232  signature = hash_memory
233  (STRUCT_MARK_PTR(adj, signature_start),
234  STRUCT_OFFSET_OF(ip_adjacency_t, signature_end)
235  - STRUCT_OFFSET_OF(ip_adjacency_t, signature_start),
236  signature);
237 
238  /* and the rewrite */
239  signature = hash_memory (&adj->rewrite_header, VLIB_BUFFER_PRE_DATA_SIZE,
240  signature);
241  return signature;
242 }
243 
244 static inline int
246 {
247  if (memcmp (STRUCT_MARK_PTR(a1, signature_start),
248  STRUCT_MARK_PTR(a2, signature_start),
249  STRUCT_OFFSET_OF(ip_adjacency_t, signature_end)
250  - STRUCT_OFFSET_OF(ip_adjacency_t, signature_start)))
251  return 0;
252  if (memcmp (&a1->rewrite_header, &a2->rewrite_header,
254  return 0;
255  return 1;
256 }
257 
258 /* Index into adjacency table. */
260 
261 typedef struct {
262  /* Directly connected next-hop adjacency index. */
264 
265  /* Path weight for this adjacency. */
268 
269 typedef struct {
270  /* Adjacency index of first index in block. */
272 
273  /* Power of 2 size of adjacency block. */
275 
276  /* Number of prefixes that point to this adjacency. */
278 
279  /* Normalized next hops are used as hash keys: they are sorted by weight
280  and weights are chosen so they add up to 1 << log2_n_adj_in_block (with
281  zero-weighted next hops being deleted).
282  Unnormalized next hops are saved so that control plane has a record of exactly
283  what the RIB told it. */
284  struct {
285  /* Number of hops in the multipath. */
287 
288  /* Offset into next hop heap for this block. */
290 
291  /* Heap handle used to for example free block when we're done with it. */
293  } normalized_next_hops, unnormalized_next_hops;
295 
296 /* IP multicast adjacency. */
297 typedef struct {
298  /* Handle for this adjacency in adjacency heap. */
300 
301  /* Number of adjecencies in block. */
303 
304  /* Rewrite string. */
305  vnet_declare_rewrite (64 - 2*sizeof(u32));
307 
308 typedef struct {
309  /* ip4-multicast-rewrite next index. */
311 
313 
314  u8 rewrite_string[64 - 1*sizeof(u32) - 1*sizeof(u8)];
316 
317 typedef struct {
319 
321 
322  /* Negative rewrite string index; >= 0 sw_if_index.
323  Sorted. Used to hash. */
325 
328 
329 typedef struct {
330  /* Key for mhash; in fact, just a byte offset into mhash key vector. */
332 
333  /* Interface which has this address. */
335 
336  /* Adjacency for neighbor probe (ARP) for this interface address. */
338 
339  /* Address (prefix) length for this interface. */
341 
342  /* Will be used for something eventually. Primary vs. secondary? */
344 
345  /* Next and previous pointers for doubly linked list of
346  addresses per software interface. */
350 
351 typedef enum {
358 
359 struct ip_lookup_main_t;
360 
361 typedef void (* ip_add_del_adjacency_callback_t) (struct ip_lookup_main_t * lm,
362  u32 adj_index,
363  ip_adjacency_t * adj,
364  u32 is_del);
365 
366 typedef struct {
368 
371 
372 /**
373  * This structure is used to dynamically register a custom adjacency
374  * for ip lookup.
375  * Typically used with
376  * VNET_IP4_REGISTER_ADJACENCY or
377  * VNET_IP6_REGISTER_ADJACENCY macros.
378  */
379 typedef struct ip_adj_register_struct {
380  /** Name of the node for this registered adjacency. */
381  char *node_name;
382 
383  /** Formatting function for the adjacency.
384  * Variadic arguments given to the function are:
385  * - struct ip_lookup_main_t *
386  * - ip_adjacency_t *adj
387  */
389 
390  /**
391  * When the adjacency is registered, the ip-lookup next index will
392  * be written where this pointer points.
393  */
395 
398 
399 typedef struct ip_lookup_main_t {
400  /** Adjacency heap. */
402 
403  /** Adjacency packet/byte counters indexed by adjacency index. */
405 
406  /** Heap of (next hop, weight) blocks. Sorted by next hop. */
408 
409  /** Indexed by heap_handle from ip_adjacency_t. */
411 
412  /** Adjacency by signature hash */
414 
415  /** Temporary vectors for looking up next hops in hash. */
418 
419  /** Hash table mapping normalized next hops and weights
420  to multipath adjacency index. */
422 
425 
426  /** If average error per adjacency is less than this threshold adjacency block
427  size is accepted. */
429 
430  /** Adjacency index for routing table misses, local punts, and drops. */
432 
433  /** Miss adjacency is always first in adjacency table. */
434 #define IP_LOOKUP_MISS_ADJ_INDEX 0
435 
437 
438  /** Pool of addresses that are assigned to interfaces. */
440 
441  /** Hash table mapping address to index in interface address pool. */
443 
444  /** Head of doubly linked list of interface addresses for each software interface.
445  ~0 means this interface has no address. */
447 
448  /** First table index to use for this interface, ~0 => none */
450 
451  /** rx/tx interface/feature configuration. */
453 
454  /** Number of bytes in a fib result. Must be at least
455  sizeof (uword). First word is always adjacency index. */
457 
459 
460  /** 1 for ip6; 0 for ip4. */
462 
463  /** Either format_ip4_address_and_length or format_ip6_address_and_length. */
465 
466  /** Special adjacency format functions */
468 
469  /** Table mapping ip protocol to ip[46]-local node next index. */
471 
472  /** IP_BUILTIN_PROTOCOL_{TCP,UDP,ICMP,OTHER} by protocol in IP header. */
474 
475  /** Registered adjacencies */
478 
481  u32 adj_index)
482 {
483  ip_adjacency_t * adj;
484 
485  adj = vec_elt_at_index (lm->adjacency_heap, adj_index);
486 
487  ASSERT (adj->heap_handle != ~0);
488 
489  return adj;
490 }
491 
492 #define ip_prefetch_adjacency(lm,adj_index,type) \
493 do { \
494  ip_adjacency_t * _adj = (lm)->adjacency_heap + (adj_index); \
495  CLIB_PREFETCH (_adj, sizeof (_adj[0]), type); \
496 } while (0)
497 
498 /* Adds a next node to ip4 or ip6 lookup node which can be then used in adjacencies.
499  * @param vlib_main pointer
500  * @param lm ip4_main.lookup_main or ip6_main.lookup_main
501  * @param reg registration structure
502  * @param next_node_index Returned index to be used in adjacencies.
503  * @return 0 on success. -1 on failure.
504  */
505 int ip_register_adjacency(vlib_main_t *vm, u8 is_ip4,
506  ip_adj_register_t *reg);
507 
508 /*
509  * Construction helpers to add IP adjacency at init.
510  */
511 #define VNET_IP_REGISTER_ADJACENCY(ip,x,...) \
512  __VA_ARGS__ ip_adj_register_t ip##adj_##x; \
513 static void __vnet_##ip##_register_adjacency_##x (void) \
514  __attribute__((__constructor__)) ; \
515 static void __vnet_##ip##_register_adjacency_##x (void) \
516 { \
517  ip_lookup_main_t *lm = &ip##_main.lookup_main; \
518  ip##adj_##x.next = lm->registered_adjacencies; \
519  lm->registered_adjacencies = &ip##adj_##x; \
520 } \
521 __VA_ARGS__ ip_adj_register_t ip##adj_##x
522 
523 #define VNET_IP4_REGISTER_ADJACENCY(x,...) \
524  VNET_IP_REGISTER_ADJACENCY(ip4, x, __VA_ARGS__)
525 
526 #define VNET_IP6_REGISTER_ADJACENCY(x,...) \
527  VNET_IP_REGISTER_ADJACENCY(ip6, x, __VA_ARGS__)
528 
529 static inline void
532 {
534 }
535 
536 always_inline void
538 {
539  ip_adjacency_t * adj;
540  uword i;
541  adj = ip_get_adjacency (lm, adj_index);
542  for (i = 0; i < vec_len (lm->add_del_adjacency_callbacks); i++)
543  lm->add_del_adjacency_callbacks[i] (lm, adj_index, adj, is_del);
544 }
545 
546 /* Create new block of given number of contiguous adjacencies. */
549  ip_adjacency_t * adj,
550  u32 n_adj,
551  u32 * adj_index_result);
552 
553 void ip_del_adjacency (ip_lookup_main_t * lm, u32 adj_index);
554 void
556  u32 adj_index,
557  ip_adjacency_t * copy_adj);
558 
559 static inline int
561 {
562  if (!vec_len(lm->multipath_adjacencies))
563  return 0;
564 
565  if (vec_len(lm->multipath_adjacencies) < adj_index - 1)
566  return 0;
567 
568 
569  return (lm->multipath_adjacencies[adj_index].adj_index == adj_index &&
570  lm->multipath_adjacencies[adj_index].n_adj_in_block > 0);
571 }
572 
573 void
576 
577 u32
579  u32 is_del,
580  u32 old_mp_adj_index,
581  u32 next_hop_adj_index,
582  u32 next_hop_weight,
583  u32 * new_mp_adj_index);
584 
585 clib_error_t *
587  u32 sw_if_index,
588  void * address,
589  u32 address_length,
590  u32 is_del,
591  u32 * result_index);
592 
595 {
596  uword * p = mhash_get (&lm->address_to_if_address_index, addr_fib);
597  return p ? pool_elt_at_index (lm->if_address_pool, p[0]) : 0;
598 }
599 
600 always_inline void *
603 
606 {
607  ip_adjacency_t * adj;
608  u32 if_address_index;
609 
610  adj = ip_get_adjacency (lm, vnet_buffer (b)->ip.adj_index[VLIB_TX]);
611 
614  if_address_index = adj->if_address_index;
615  if_address_index = (if_address_index == ~0 ?
617  : if_address_index);
618 
619  return (if_address_index != ~0)?pool_elt_at_index (lm->if_address_pool, if_address_index):NULL;
620 }
621 
622 #define foreach_ip_interface_address(lm,a,sw_if_index,loop,body) \
623 do { \
624  vnet_main_t *_vnm = vnet_get_main(); \
625  u32 _sw_if_index = sw_if_index; \
626  vnet_sw_interface_t *_swif; \
627  _swif = vnet_get_sw_interface (_vnm, _sw_if_index); \
628  \
629  /* \
630  * Loop => honor unnumbered interface addressing. \
631  */ \
632  if (loop && _swif->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED) \
633  _sw_if_index = _swif->unnumbered_sw_if_index; \
634  u32 _ia = \
635  (vec_len((lm)->if_address_pool_index_by_sw_if_index) \
636  > (_sw_if_index)) \
637  ? vec_elt ((lm)->if_address_pool_index_by_sw_if_index, \
638  (_sw_if_index)) : (u32)~0; \
639  ip_interface_address_t * _a; \
640  while (_ia != ~0) \
641  { \
642  _a = pool_elt_at_index ((lm)->if_address_pool, _ia); \
643  _ia = _a->next_this_sw_interface; \
644  (a) = _a; \
645  body; \
646  } \
647 } while (0)
648 
649 void ip_lookup_init (ip_lookup_main_t * lm, u32 ip_lookup_node_index);
652 
653 #endif /* included_ip_lookup_h */
uword * multipath_adjacency_by_next_hops
Hash table mapping normalized next hops and weights to multipath adjacency index. ...
Definition: lookup.h:421
static void ip_call_add_del_adjacency_callbacks(ip_lookup_main_t *lm, u32 adj_index, u32 is_del)
Definition: lookup.h:537
uword * adjacency_by_id_vector
Definition: lookup.h:326
format_function_t * format_fib_result
Definition: lookup.h:458
ip_lookup_next_t
Common (IP4/IP6) next index stored in adjacency.
Definition: lookup.h:58
Definition: mhash.h:46
static ip_interface_address_t * ip_interface_address_for_packet(ip_lookup_main_t *lm, vlib_buffer_t *b, u32 sw_if_index)
Definition: lookup.h:605
char * node_name
Name of the node for this registered adjacency.
Definition: lookup.h:381
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
Definition: cache.h:68
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
u32 * config_index_by_sw_if_index
Definition: lookup.h:369
u32 local_adj_index
Definition: lookup.h:431
ip_add_del_adjacency_callback_t * add_del_adjacency_callbacks
Definition: lookup.h:436
ip_adjacency_t * adjacency_heap
Adjacency heap.
Definition: lookup.h:401
u16 saved_lookup_next_index
Highest possible perf subgraph arc interposition, e.g.
Definition: lookup.h:189
ip_multicast_rewrite_t * rewrite_heap
Definition: lookup.h:318
clib_error_t * ip_interface_address_add_del(ip_lookup_main_t *lm, u32 sw_if_index, void *address, u32 address_length, u32 is_del, u32 *result_index)
Definition: lookup.c:764
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
Definition: lookup.h:439
#define STRUCT_MARK_PTR(v, f)
Definition: clib.h:68
u16 n_adj
Number of adjecencies in block.
Definition: lookup.h:176
format_function_t * fn
Formatting function for the adjacency.
Definition: lookup.h:388
ip_lookup_next_t lookup_next_index
Definition: lookup.h:180
IP unicast adjacency.
Definition: lookup.h:164
static int ip_adjacency_is_multipath(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:560
u32 miss_adj_index
Adjacency index for routing table misses, local punts, and drops.
Definition: lookup.h:431
#define NULL
Definition: clib.h:55
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
Definition: lookup.h:452
void ip_update_adjacency(ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *copy_adj)
Definition: lookup.c:263
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
u32 share_count
Number of FIB entries sharing this adjacency.
Definition: lookup.h:216
u32 special_adjacency_format_function_index
Special format function for this adjacency.
Definition: lookup.h:212
#define STRUCT_MARK(mark)
Definition: clib.h:67
u32 * next_index
When the adjacency is registered, the ip-lookup next index will be written where this pointer points...
Definition: lookup.h:394
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
static int vnet_ip_adjacency_share_compare(ip_adjacency_t *a1, ip_adjacency_t *a2)
Definition: lookup.h:245
u16 table_index
Definition: lookup.h:198
void(* ip_add_del_adjacency_callback_t)(struct ip_lookup_main_t *lm, u32 adj_index, ip_adjacency_t *adj, u32 is_del)
Definition: lookup.h:361
u32 neighbor_probe_adj_index
Definition: lookup.h:337
mhash_t address_to_if_address_index
Hash table mapping address to index in interface address pool.
Definition: lookup.h:442
This structure is used to dynamically register a custom adjacency for ip lookup.
Definition: lookup.h:379
Adjacency to drop this packet.
Definition: lookup.h:63
ip6_lookup_next_t
Definition: lookup.h:102
u32 next_adj_with_signature
Use this adjacency instead.
Definition: lookup.h:218
This packets needs to go to ICMP error.
Definition: lookup.h:93
u32 vnet_register_special_adjacency_format_function(ip_lookup_main_t *lm, format_function_t *fp)
Definition: lookup.c:1013
#define always_inline
Definition: clib.h:84
Hop-by-hop header handling.
Definition: lookup.h:104
u32 * adjacency_remap_table
Definition: lookup.h:423
uword * adj_index_by_signature
Adjacency by signature hash.
Definition: lookup.h:413
int i32
Definition: types.h:81
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Adjacency to punt this packet.
Definition: lookup.h:65
u16 mcast_group_index
Definition: lookup.h:186
This packet is for one of our own IP addresses.
Definition: lookup.h:68
#define VLIB_BUFFER_PRE_DATA_SIZE
Definition: buffer.h:52
int ip_register_adjacency(vlib_main_t *vm, u8 is_ip4, ip_adj_register_t *reg)
Definition: lookup.c:137
static uword vnet_ip_adjacency_signature(ip_adjacency_t *adj)
Definition: lookup.h:227
struct ip_lookup_main_t ip_lookup_main_t
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
u32 * classify_table_index_by_sw_if_index
First table index to use for this interface, ~0 => none.
Definition: lookup.h:449
This packet needs to go to MAP - RFC7596, RFC7597.
Definition: lookup.h:84
struct ip_adj_register_struct * next
Definition: lookup.h:396
u8 local_next_by_ip_protocol[256]
Table mapping ip protocol to ip[46]-local node next index.
Definition: lookup.h:470
This packet needs to be classified.
Definition: lookup.h:81
u32 ip_multipath_adjacency_add_del_next_hop(ip_lookup_main_t *lm, u32 is_del, u32 old_mp_adj_index, u32 next_hop_adj_index, u32 next_hop_weight, u32 *new_mp_adj_index)
Definition: lookup.c:524
ip_adj_register_t * registered_adjacencies
Registered adjacencies.
Definition: lookup.h:476
u32 drop_adj_index
Definition: lookup.h:431
static ip_interface_address_t * ip_get_interface_address(ip_lookup_main_t *lm, void *addr_fib)
Definition: lookup.h:594
static uword * mhash_get(mhash_t *h, void *key)
Definition: mhash.h:110
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *adj, u32 n_adj, u32 *adj_index_result)
Definition: lookup.c:167
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: lookup.h:73
vlib_combined_counter_main_t adjacency_counters
Adjacency packet/byte counters indexed by adjacency index.
Definition: lookup.h:404
u8 builtin_protocol_by_ip_protocol[256]
IP_BUILTIN_PROTOCOL_{TCP,UDP,ICMP,OTHER} by protocol in IP header.
Definition: lookup.h:473
u32 ip_adjacency_index_t
Definition: lookup.h:259
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
Definition: lookup.h:446
static void ip_register_add_del_adjacency_callback(ip_lookup_main_t *lm, ip_add_del_adjacency_callback_t cb)
Definition: lookup.h:530
#define ASSERT(truth)
ip_multipath_next_hop_t * next_hop_hash_lookup_key
Temporary vectors for looking up next hops in hash.
Definition: lookup.h:416
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:335
uword hash_memory(void *p, word n_bytes, uword state)
Definition: hash.c:214
u32 fib_result_n_words
Definition: lookup.h:456
u32 n_adjacency_remaps
Definition: lookup.h:424
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
u64 uword
Definition: types.h:112
#define vec_elt(v, i)
Get vector value at index i.
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
ip_config_main_t tx_config_main
Definition: lookup.h:452
#define vnet_declare_rewrite(total_bytes)
Definition: rewrite.h:84
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
format_function_t ** special_adjacency_format_functions
Special adjacency format functions.
Definition: lookup.h:467
ip46_address_t next_hop
Definition: lookup.h:194
unsigned char u8
Definition: types.h:56
void ip_multipath_adjacency_free(ip_lookup_main_t *lm, ip_multipath_adjacency_t *a)
Definition: lookup.c:706
u32 heap_handle
Handle for this adjacency in adjacency heap.
Definition: lookup.h:167
u32 is_ip6
1 for ip6; 0 for ip4.
Definition: lookup.h:461
Packet does not match any route in table.
Definition: lookup.h:60
#define IP_ADJACENCY_OPAQUE_SZ
Definition: lookup.h:160
static void * mhash_key_to_mem(mhash_t *h, uword key)
Definition: mhash.h:90
A collection of combined counters.
Definition: counter.h:212
short i16
Definition: types.h:46
ip_multipath_next_hop_t * next_hop_heap
Heap of (next hop, weight) blocks.
Definition: lookup.h:407
ip_multipath_adjacency_t * multipath_adjacencies
Indexed by heap_handle from ip_adjacency_t.
Definition: lookup.h:410
This packets needs to go to indirect next hop.
Definition: lookup.h:90
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:78
u32 if_address_index
Interface address index for this local/arp adjacency.
Definition: lookup.h:172
ip_local_next_t
Definition: lookup.h:351
i16 explicit_fib_index
Force re-lookup in a different FIB.
Definition: lookup.h:185
ip_multipath_next_hop_t * next_hop_hash_lookup_key_normalized
Definition: lookup.h:417
void ip_lookup_init(ip_lookup_main_t *lm, u32 ip_lookup_node_index)
Definition: lookup.c:870
ip4_lookup_next_t
Definition: lookup.h:98
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:601
This packet needs to go to MAP with Translation - RFC7599.
Definition: lookup.h:87
vlib buffer structure definition and a few select access methods.
vnet_config_main_t config_main
Definition: lookup.h:367
void ip_del_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.c:314
f64 multipath_next_hop_error_tolerance
If average error per adjacency is less than this threshold adjacency block size is accepted...
Definition: lookup.h:428
u32 fib_result_n_bytes
Number of bytes in a fib result.
Definition: lookup.h:456
ip_multicast_rewrite_string_t * rewrite_strings
Definition: lookup.h:320
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:480
format_function_t * format_address_and_length
Either format_ip4_address_and_length or format_ip6_address_and_length.
Definition: lookup.h:464
struct ip_adj_register_struct ip_adj_register_t
This structure is used to dynamically register a custom adjacency for ip lookup.
u16 lookup_next_index_as_int
Definition: lookup.h:181