/* * Copyright (c) 2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include /** * A description of the need to import routes from the export table */ typedef struct fib_ae_import_t_ { /** * The entry in the export table that this importer * is importing covereds from */ fib_node_index_t faei_export_entry; /** * The attached entry in the import table */ fib_node_index_t faei_import_entry; /** * the sibling index on the cover */ u32 faei_export_sibling; /** * The index of the exporter tracker. Not set if the * export entry is not valid for export */ fib_node_index_t faei_exporter; /** * A vector/list of imported entry indicies */ fib_node_index_t *faei_importeds; /** * The FIB index and prefix we are tracking */ fib_node_index_t faei_export_fib; fib_prefix_t faei_prefix; /** * The FIB index we are importing into */ fib_node_index_t faei_import_fib; } fib_ae_import_t; /** * A description of the need to export routes to one or more export tables */ typedef struct fib_ae_export_t_ { /** * The vector/list of import tracker indicies */ fib_node_index_t *faee_importers; /** * THe connected entry this export is acting on behalf of */ fib_node_index_t faee_ei; /** * Reference counting locks */ u32 faee_locks; } fib_ae_export_t; /* * memory pools for the importers and exporters */ static fib_ae_import_t *fib_ae_import_pool; static fib_ae_export_t *fib_ae_export_pool; static fib_ae_export_t * fib_entry_ae_add_or_lock (fib_node_index_t connected) { fib_entry_delegate_t *fed; fib_ae_export_t *export; fib_entry_t *entry; entry = fib_entry_get(connected); fed = fib_entry_delegate_find(entry, FIB_ENTRY_DELEGATE_ATTACHED_EXPORT); if (NULL == fed) { fed = fib_entry_delegate_find_or_add(entry, FIB_ENTRY_DELEGATE_ATTACHED_EXPORT); pool_get(fib_ae_export_pool, export); clib_memset(export, 0, sizeof(*export)); fed->fd_index = (export - fib_ae_export_pool); export->faee_ei = connected; } else { export = pool_elt_at_index(fib_ae_export_pool, fed->fd_index); } export->faee_locks++; return (export); } static void fib_entry_import_remove (fib_ae_import_t *import, fib_node_index_t entry_index) { u32 index; /* * find the index in the vector of the entry we are removing */ index = vec_search(import->faei_importeds, entry_index); if (index < vec_len(import->faei_importeds)) { /* * this is an entry that was previously imported */ fib_table_entry_special_remove(import->faei_import_fib, fib_entry_get_prefix(entry_index), FIB_SOURCE_AE); fib_entry_unlock(entry_index); vec_del1(import->faei_importeds, index); } } static void fib_entry_import_add (fib_ae_import_t *import, fib_node_index_t entry_index) { fib_node_index_t *existing; fib_prefix_t prefix; /* * ensure we only add the exported entry once, since * sourcing prefixes in the table is reference counted */ vec_foreach(existing, import->faei_importeds) { if (*existing == entry_index) { return; } } /* * this is the first time this export entry has been imported * Add it to the import FIB and to the list of importeds. * make a copy of the prefix in case the underlying entry reallocs. */ fib_prefix_copy(&prefix, fib_entry_get_prefix(entry_index)); /* * don't import entries that have the same prefix the import entry */ if (0 != fib_prefix_cmp(&prefix, &import->faei_prefix)) { const dpo_id_t *dpo; dpo = fib_entry_contribute_ip_forwarding(entry_index); if (dpo_id_is_valid(dpo) && !dpo_is_drop(dpo)) { fib_table_entry_special_dpo_add(import->faei_import_fib, &prefix, FIB_SOURCE_AE, (fib_entry_get_flags(entry_index) | FIB_ENTRY_FLAG_EXCLUSIVE), load_balance_get_bucket(dpo->dpoi_index, 0));
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# To specify directories to find sources, build/