FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
fib_entry_src_api.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 #include <vnet/fib/fib_entry.h>
17 #include <vnet/fib/fib_entry_src.h>
18 #include <vnet/fib/fib_path_list.h>
19 #include <vnet/fib/fib_path_ext.h>
20 
21 /**
22  * Source initialisation Function
23  */
24 static void
26 {
27 }
28 
29 /**
30  * Source deinitialisation Function
31  */
32 static void
34 {
35 }
36 
37 static void
39  const fib_entry_t *entry,
40  fib_path_list_flags_t pl_flags,
41  const fib_route_path_t *rpaths)
42 {
43  const fib_route_path_t *rpath;
44 
45  fib_path_ext_list_flush(&src->fes_path_exts);
46 
47  src->fes_pl = fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED | pl_flags),
48  rpaths);
49 
50  vec_foreach(rpath, rpaths)
51  {
52  if (NULL != rpath->frp_label_stack)
53  {
54  fib_path_ext_list_push_back(&src->fes_path_exts,
55  src->fes_pl,
57  rpath);
58  }
59  }
60 }
61 
62 static void
64  const fib_entry_t *entry,
65  fib_path_list_flags_t pl_flags,
66  const fib_route_path_t *rpaths)
67 {
68  const fib_route_path_t *rpath;
69 
70  if (FIB_NODE_INDEX_INVALID == src->fes_pl)
71  {
72  src->fes_pl =
73  fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED | pl_flags), rpaths);
74  }
75  else
76  {
77  src->fes_pl =
79  (FIB_PATH_LIST_FLAG_SHARED | pl_flags),
80  rpaths);
81  }
82 
83  /*
84  * re-resolve all the path-extensions with the new path-list
85  */
86  fib_path_ext_list_resolve(&src->fes_path_exts, src->fes_pl);
87 
88  /*
89  * if the path has a label we need to add a path extension
90  */
91  vec_foreach(rpath, rpaths)
92  {
93  if (NULL != rpath->frp_label_stack)
94  {
95  fib_path_ext_list_insert(&src->fes_path_exts,
96  src->fes_pl,
98  rpath);
99  }
100  }
101 }
102 
103 static void
105  fib_path_list_flags_t pl_flags,
106  const fib_route_path_t *rpaths)
107 {
108  const fib_route_path_t *rpath;
109 
110  if (FIB_NODE_INDEX_INVALID != src->fes_pl)
111  {
112  src->fes_pl =
114  (FIB_PATH_LIST_FLAG_SHARED | pl_flags),
115  rpaths);
116  /*
117  * remove the path-extension for the path
118  */
119  vec_foreach(rpath, rpaths)
120  {
121  fib_path_ext_list_remove(&src->fes_path_exts, FIB_PATH_EXT_MPLS, rpath);
122  };
123  /*
124  * resolve the remaining extensions
125  */
126  fib_path_ext_list_resolve(&src->fes_path_exts, src->fes_pl);
127  }
128 }
129 
130 static void
132  const fib_entry_t *entry,
135  const dpo_id_t *dpo)
136 {
137  if (FIB_ENTRY_FLAG_NONE != flags)
138  {
140  proto,
142  dpo);
143  }
144 }
145 
146 static void
148 {
149  src->fes_pl = FIB_NODE_INDEX_INVALID;
150 }
151 
154  .fesv_deinit = fib_entry_src_api_deinit,
155  .fesv_add = fib_entry_src_api_add,
156  .fesv_remove = fib_entry_src_api_remove,
157  .fesv_path_add = fib_entry_src_api_path_add,
158  .fesv_path_swap = fib_entry_src_api_path_swap,
159  .fesv_path_remove = fib_entry_src_api_path_remove,
160 };
161 
162 void
164 {
166 }
fib_entry_src_api_remove
static void fib_entry_src_api_remove(fib_entry_src_t *src)
Definition: fib_entry_src_api.c:147
fib_entry.h
fib_entry_src_api_path_swap
static void fib_entry_src_api_path_swap(fib_entry_src_t *src, const fib_entry_t *entry, fib_path_list_flags_t pl_flags, const fib_route_path_t *rpaths)
Definition: fib_entry_src_api.c:38
fib_entry_t_
An entry in a FIB table.
Definition: fib_entry.h:305
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
fib_entry_src_t_
Information related to the source of a FIB entry.
Definition: fib_entry.h:197
FIB_NODE_INDEX_INVALID
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
fib_entry_src_api_add
static void fib_entry_src_api_add(fib_entry_src_t *src, const fib_entry_t *entry, fib_entry_flag_t flags, dpo_proto_t proto, const dpo_id_t *dpo)
Definition: fib_entry_src_api.c:131
fib_path_ext_list_flush
void fib_path_ext_list_flush(fib_path_ext_list_t *list)
Definition: fib_path_ext.c:448
fib_path_list_flags_t
enum fib_path_list_flags_t_ fib_path_list_flags_t
fib_route_path_t_::frp_label_stack
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
Definition: fib_types.h:560
fib_entry_src.h
fib_entry_src_vft_t_
Virtual function table each FIB entry source will register.
Definition: fib_entry_src.h:195
fib_entry_flag_t
enum fib_entry_flag_t_ fib_entry_flag_t
fib_path_ext_list_remove
void fib_path_ext_list_remove(fib_path_ext_list_t *list, fib_path_ext_type_t ext_type, const fib_route_path_t *rpath)
Definition: fib_path_ext.c:428
FIB_PATH_LIST_FLAG_SHARED
@ FIB_PATH_LIST_FLAG_SHARED
Definition: fib_path_list.h:81
fib_entry_src_api_deinit
static void fib_entry_src_api_deinit(fib_entry_src_t *src)
Source deinitialisation Function.
Definition: fib_entry_src_api.c:33
FIB_ENTRY_FLAG_NONE
@ FIB_ENTRY_FLAG_NONE
Definition: fib_entry.h:112
api_src_vft
const static fib_entry_src_vft_t api_src_vft
Definition: fib_entry_src_api.c:152
src
vl_api_address_t src
Definition: gre.api:54
fib_entry_src_api_path_add
static void fib_entry_src_api_path_add(fib_entry_src_t *src, const fib_entry_t *entry, fib_path_list_flags_t pl_flags, const fib_route_path_t *rpaths)
Definition: fib_entry_src_api.c:63
fib_path_ext_list_resolve
void fib_path_ext_list_resolve(fib_path_ext_list_t *list, fib_node_index_t path_list_index)
Definition: fib_path_ext.c:416
FIB_SOURCE_BH_API
@ FIB_SOURCE_BH_API
add paths with [mpls] path extensions
Definition: fib_source.h:208
FIB_PATH_EXT_MPLS
@ FIB_PATH_EXT_MPLS
An MPLS extension that maintains the path's outgoing labels,.
Definition: fib_path_ext.h:31
fib_path_list_create_special
fib_node_index_t fib_path_list_create_special(dpo_proto_t nh_proto, fib_path_list_flags_t flags, const dpo_id_t *dpo)
Definition: fib_path_list.c:774
fib_path_list.h
fib_path_list_copy_and_path_remove
fib_node_index_t fib_path_list_copy_and_path_remove(fib_node_index_t orig_path_list_index, fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
Definition: fib_path_list.c:1086
fib_entry_src_api_path_remove
static void fib_entry_src_api_path_remove(fib_entry_src_t *src, fib_path_list_flags_t pl_flags, const fib_route_path_t *rpaths)
Definition: fib_entry_src_api.c:104
fib_entry_src_api_init
static void fib_entry_src_api_init(fib_entry_src_t *src)
Source initialisation Function.
Definition: fib_entry_src_api.c:25
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
fib_entry_src_vft_t_::fesv_init
fib_entry_src_init_t fesv_init
Definition: fib_entry_src.h:196
fib_path_ext_list_push_back
fib_path_ext_t * fib_path_ext_list_push_back(fib_path_ext_list_t *list, fib_node_index_t path_list_index, fib_path_ext_type_t ext_type, const fib_route_path_t *rpath)
Definition: fib_path_ext.c:346
fib_path_ext_list_insert
fib_path_ext_t * fib_path_ext_list_insert(fib_path_ext_list_t *list, fib_node_index_t path_list_index, fib_path_ext_type_t ext_type, const fib_route_path_t *rpath)
Definition: fib_path_ext.c:372
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
fib_entry_src_behaviour_register
void fib_entry_src_behaviour_register(fib_source_behaviour_t bh, const fib_entry_src_vft_t *vft)
Definition: fib_entry_src.c:61
fib_path_ext.h
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
fib_path_list_copy_and_path_add
fib_node_index_t fib_path_list_copy_and_path_add(fib_node_index_t orig_path_list_index, fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
Definition: fib_path_list.c:907
fib_entry_src_api_register
void fib_entry_src_api_register(void)
Definition: fib_entry_src_api.c:163
fib_path_list_create
fib_node_index_t fib_path_list_create(fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
Definition: fib_path_list.c:682
fib_entry_src_flags_2_path_list_flags
fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(fib_entry_flag_t eflags)
Definition: fib_entry_src.c:1532
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105