FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
ip6_fib.h
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 #ifndef __IP6_FIB_H__
17 #define __IP6_FIB_H__
18 
19 #include <vlib/vlib.h>
20 #include <vnet/ip/format.h>
21 #include <vnet/fib/fib_entry.h>
22 #include <vnet/fib/fib_table.h>
23 #include <vnet/ip/lookup.h>
24 #include <vnet/dpo/load_balance.h>
25 
27  const ip6_address_t *addr,
28  u32 len);
30  const ip6_address_t *addr,
31  u32 len);
32 
33 extern void ip6_fib_table_entry_remove(u32 fib_index,
34  const ip6_address_t *addr,
35  u32 len);
36 
37 extern void ip6_fib_table_entry_insert(u32 fib_index,
38  const ip6_address_t *addr,
39  u32 len,
40  fib_node_index_t fib_entry_index);
41 extern void ip6_fib_table_destroy(u32 fib_index);
42 
43 extern void ip6_fib_table_fwding_dpo_update(u32 fib_index,
44  const ip6_address_t *addr,
45  u32 len,
46  const dpo_id_t *dpo);
47 
48 extern void ip6_fib_table_fwding_dpo_remove(u32 fib_index,
49  const ip6_address_t *addr,
50  u32 len,
51  const dpo_id_t *dpo);
52 
54  u32 sw_if_index,
55  const ip6_address_t * dst);
57  u32 fib_index,
58  const ip6_address_t * dst);
59 
60 /**
61  * @biref return the DPO that the LB stacks on.
62  */
65  vlib_buffer_t * b,
66  ip6_header_t * i)
67 {
68  if (vnet_buffer (b)->ip.adj_index[VLIB_RX] == ~0)
69  {
70  const dpo_id_t *dpo;
71  index_t lbi;
72 
74  im,
75  vnet_buffer (b)->sw_if_index[VLIB_RX],
76  &i->src_address);
77 
79 
80  if (dpo_is_adj(dpo))
81  {
82  vnet_buffer (b)->ip.adj_index[VLIB_RX] = dpo->dpoi_index;
83  }
84  }
85  return vnet_buffer (b)->ip.adj_index[VLIB_RX];
86 }
87 
88 /**
89  * \brief Get or create an IPv6 fib.
90  *
91  * Get or create an IPv4 fib with the provided table ID.
92  *
93  * \param im
94  * ip4_main pointer.
95  * \param table_id
96  * When set to \c ~0, an arbitrary and unused fib ID is picked
97  * and can be retrieved with \c ret->table_id.
98  * Otherwise, the fib ID to be used to retrieve or create the desired fib.
99  * \returns A pointer to the retrieved or created fib.
100  *
101  */
104 
105 static inline ip6_fib_t *
107 {
109  return (&pool_elt_at_index (ip6_main.fibs, index)->v6);
110 }
111 
112 static inline
114 {
115  ip6_main_t * im = &ip6_main;
116  uword * p;
117 
118  p = hash_get (im->fib_index_by_table_id, table_id);
119  if (!p)
120  return ~0;
121 
122  return p[0];
123 }
124 
126 
128 
129 #endif
130 
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
Definition: ip6_fib.h:106
int dpo_is_adj(const dpo_id_t *dpo)
Return TRUE is the DPO is any type of adjacency.
Definition: dpo.c:237
Definitions for all things IP (v4|v6) unicast and multicast lookup related.
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:41
u32 ip6_fib_table_fwding_lookup_with_if_index(ip6_main_t *im, u32 sw_if_index, const ip6_address_t *dst)
Definition: ip6_fib.c:430
void ip6_fib_table_fwding_dpo_update(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:459
u32 ip6_fib_table_find_or_create_and_lock(u32 table_id)
Get or create an IPv6 fib.
Definition: ip6_fib.c:134
ip6_address_t src_address
Definition: ip6_packet.h:337
#define always_inline
Definition: clib.h:84
u32 ip6_fib_table_create_and_lock(void)
Definition: ip6_fib.c:148
static u32 ip6_src_lookup_for_packet(ip6_main_t *im, vlib_buffer_t *b, ip6_header_t *i)
return the DPO that the LB stacks on.
Definition: ip6_fib.h:64
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
#define hash_get(h, key)
Definition: hash.h:248
void ip6_fib_table_entry_insert(u32 fib_index, const ip6_address_t *addr, u32 len, fib_node_index_t fib_entry_index)
Definition: ip6_fib.c:362
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
fib_node_index_t ip6_fib_table_lookup_exact_match(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:292
void ip6_fib_table_destroy(u32 fib_index)
Definition: ip6_fib.c:154
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
Definition: load_balance.h:194
static u32 ip6_fib_index_from_table_id(u32 table_id)
Definition: ip6_fib.h:113
flow_hash_config_t ip6_fib_table_get_flow_hash_config(u32 fib_index)
Definition: ip6_fib.c:439
u32 ip6_fib_table_fwding_lookup(ip6_main_t *im, u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.c:392
uword * fib_index_by_table_id
Definition: ip6.h:151
Definition: ip6.h:66
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
void ip6_fib_table_entry_remove(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:331
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:361
ip6_main_t ip6_main
Definition: ip6_forward.c:2828
static load_balance_t * load_balance_get(index_t lbi)
Definition: load_balance.h:185
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:160
u64 uword
Definition: types.h:112
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:445
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:154
fib_node_index_t ip6_fib_table_lookup(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:246
void ip6_fib_table_fwding_dpo_remove(u32 fib_index, const ip6_address_t *addr, u32 len, const dpo_id_t *dpo)
Definition: ip6_fib.c:489
vhost_vring_addr_t addr
Definition: vhost-user.h:81
struct fib_table_t_ * fibs
Definition: ip6.h:138
Definition: defs.h:46