FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
ip6_mfib.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  * @brief The IPv4 Multicast-FIB
17  *
18  * FIXME
19  *
20  * This IPv4 FIB is used by the protocol independent FIB. So directly using
21  * this APIs in client code is not encouraged. However, this IPv4 FIB can be
22  * used if all the client wants is an IPv4 prefix data-base
23  */
24 
25 #ifndef __IP6_MFIB_H__
26 #define __IP6_MFIB_H__
27 
28 #include <vlib/vlib.h>
29 #include <vnet/ip/ip.h>
30 
31 #include <vnet/mfib/mfib_table.h>
32 
34  const ip6_address_t *src,
35  const ip6_address_t *grp,
36  u32 len);
38  const ip6_address_t *grp,
39  const ip6_address_t *src,
40  u32 len);
41 
43  const ip6_address_t *grp,
44  const ip6_address_t *src,
45  u32 len);
46 
48  const ip6_address_t *grp,
49  const ip6_address_t *src,
50  u32 len,
51  fib_node_index_t fib_entry_index);
52 extern void ip6_mfib_table_destroy(ip6_mfib_t *fib);
53 
54 /**
55  * @brief
56  * Add/remove the interface from the accepting list of the special MFIB entries
57  */
58 extern void ip6_mfib_interface_enable_disable(u32 sw_if_index,
59  int is_enable);
60 
61 /**
62  * @brief Get the FIB at the given index
63  */
64 static inline ip6_mfib_t *
66 {
67  return (&(pool_elt_at_index(ip6_main.mfibs, index)->v6));
68 }
69 
70 /**
71  * @brief Get or create an IPv4 fib.
72  *
73  * Get or create an IPv4 fib with the provided table ID.
74  *
75  * @param table_id
76  * When set to \c ~0, an arbitrary and unused fib ID is picked
77  * and can be retrieved with \c ret->table_id.
78  * Otherwise, the fib ID to be used to retrieve or create the desired fib.
79  * @returns A pointer to the retrieved or created fib.
80  *
81  */
83  mfib_source_t src);
85 
86 
87 static inline
89 {
90  ip6_main_t * im = &ip6_main;
91  uword * p;
92 
93  p = hash_get (im->mfib_index_by_table_id, table_id);
94  if (!p)
95  return ~0;
96 
97  return p[0];
98 }
99 
101 
102 /**
103  * @brief Data-plane lookup function
104  */
106  const ip6_address_t *src,
107  const ip6_address_t *grp);
108 
109 /**
110  * @brief Walk the IP6 mfib table.
111  *
112  * @param mfib the table to walk
113  * @param fn The function to invoke on each entry visited
114  * @param ctx A context passed in the visit function
115  */
116 extern void ip6_mfib_table_walk (ip6_mfib_t *mfib,
118  void *ctx);
119 
120 /**
121  * @brief format (display) ipv6 MFIB mempry usage
122  */
123 extern u8 *format_ip6_mfib_table_memory(u8 * s, va_list * args);
124 
125 #endif
126 
void ip6_mfib_table_entry_insert(ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len, fib_node_index_t fib_entry_index)
Definition: ip6_mfib.c:429
void ip6_mfib_table_entry_remove(ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:452
u32 ip6_mfib_table_create_and_lock(mfib_source_t src)
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
u8 * format_ip6_mfib_table_memory(u8 *s, va_list *args)
format (display) ipv6 MFIB mempry usage
Definition: ip6_mfib.c:476
void ip6_mfib_table_destroy(ip6_mfib_t *fib)
Definition: ip6_mfib.c:218
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:461
uword * mfib_index_by_table_id
Hash table mapping table id to multicast fib index.
Definition: ip6.h:190
fib_node_index_t ip6_mfib_table_lookup2(const ip6_mfib_t *mfib, const ip6_address_t *src, const ip6_address_t *grp)
Data-plane lookup function.
Definition: ip6_mfib.c:411
void ip6_mfib_table_walk(ip6_mfib_t *mfib, mfib_table_walk_fn_t fn, void *ctx)
Walk the IP6 mfib table.
Definition: ip6_mfib.c:560
void ip6_mfib_interface_enable_disable(u32 sw_if_index, int is_enable)
Add/remove the interface from the accepting list of the special MFIB entries.
Definition: ip6_mfib.c:260
Definition: ip6.h:79
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:2750
long ctx[MAX_CONNS]
Definition: main.c:126
static u32 ip6_mfib_index_from_table_id(u32 table_id)
Definition: ip6_mfib.h:88
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:170
fib_node_index_t ip6_mfib_table_lookup(const ip6_mfib_t *fib, const ip6_address_t *src, const ip6_address_t *grp, u32 len)
The IPv4 Multicast-FIB.
Definition: ip6_mfib.c:386
u64 uword
Definition: types.h:112
u32 ip6_mfib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_mfib.c:315
unsigned char u8
Definition: types.h:56
int(* mfib_table_walk_fn_t)(fib_node_index_t fei, void *ctx)
Call back function when walking entries in a FIB table.
Definition: mfib_table.h:416
static ip6_mfib_t * ip6_mfib_get(u32 index)
Get the FIB at the given index.
Definition: ip6_mfib.h:65
u32 ip6_mfib_table_find_or_create_and_lock(u32 table_id, mfib_source_t src)
Get or create an IPv4 fib.
Definition: ip6_mfib.c:301
fib_node_index_t ip6_mfib_table_lookup_exact_match(const ip6_mfib_t *fib, const ip6_address_t *grp, const ip6_address_t *src, u32 len)
Definition: ip6_mfib.c:359