FD.io VPP  v18.07-rc0-415-g6c78436
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 
46 
48  rpaths);
49 
50  vec_foreach(rpath, rpaths)
51  {
52  if (NULL != rpath->frp_label_stack)
53  {
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  */
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  {
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  {
122  };
123  /*
124  * resolve the remaining extensions
125  */
127  }
128 }
129 
130 static void
132  const fib_entry_t *entry,
134  dpo_proto_t proto,
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 {
150 }
151 
152 const static fib_entry_src_vft_t api_src_vft = {
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 {
167  fib_entry_src_register(FIB_SOURCE_API, &api_src_vft);
168  fib_entry_src_register(FIB_SOURCE_CLI, &api_src_vft);
172  fib_entry_src_register(FIB_SOURCE_SR, &api_src_vft);
173 }
fib_entry_src_init_t fesv_init
An entry in a FIB table.
Definition: fib_entry.h:453
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 *rpath)
A representation of a path as described by a route producer.
Definition: fib_types.h:455
Virtual function table each FIB entry source will register.
#define NULL
Definition: clib.h:55
Information related to the source of a FIB entry.
Definition: fib_entry.h:345
An MPLS extension that maintains the path&#39;s outgoing labels,.
Definition: fib_path_ext.h:31
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)
From the CLI.
Definition: fib_entry.h:74
static void fib_entry_src_api_deinit(fib_entry_src_t *src)
Source deinitialisation Function.
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)
A high priority source a plugin can use.
Definition: fib_entry.h:62
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
Definition: fib_entry.h:270
static void fib_entry_src_api_remove(fib_entry_src_t *src)
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)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:168
IPv6 ND (seen in the link-local tables)
Definition: fib_entry.h:98
void fib_path_ext_list_flush(fib_path_ext_list_t *list)
Definition: fib_path_ext.c:446
fib_node_index_t fib_path_list_create(fib_path_list_flags_t flags, const fib_route_path_t *rpaths)
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
Definition: fib_types.h:510
fib_path_list_flags_t fib_entry_src_flags_2_path_list_flags(fib_entry_flag_t eflags)
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:426
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:344
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)
enum fib_entry_flag_t_ fib_entry_flag_t
void fib_entry_src_register(fib_source_t source, const fib_entry_src_vft_t *vft)
Definition: fib_entry_src.c:56
From the control plane API.
Definition: fib_entry.h:70
fib_node_index_t fes_pl
The path-list created by the source.
Definition: fib_entry.h:354
SRv6 and SR-MPLS.
Definition: fib_entry.h:58
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:31
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)
void fib_path_ext_list_resolve(fib_path_ext_list_t *list, fib_node_index_t path_list_index)
Definition: fib_path_ext.c:414
DHCP.
Definition: fib_entry.h:90
void fib_entry_src_api_register(void)
static void fib_entry_src_api_init(fib_entry_src_t *src)
Source initialisation Function.
#define vec_foreach(var, vec)
Vector iterator.
fib_path_ext_list_t fes_path_exts
A vector of path extensions.
Definition: fib_entry.h:349
enum fib_path_list_flags_t_ fib_path_list_flags_t
u32 flags
Definition: vhost-user.h:77
A low (below routing) priority source a plugin can use.
Definition: fib_entry.h:78
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)
IPv6 Proxy ND.
Definition: fib_entry.h:94
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:370