Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 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 | * Midchain Adjacency sub-type. These adjs represent an L3 peer on a |
| 17 | * tunnel interface. The tunnel's adjacency is thus not the end of the chain, |
| 18 | * and needs to stack on/link to another chain (or portion of the graph) to |
| 19 | * reach the tunnel's destination. |
| 20 | */ |
| 21 | |
| 22 | #ifndef __ADJ_MIDCHAIN_H__ |
| 23 | #define __ADJ_MIDCHAIN_H__ |
| 24 | |
| 25 | #include <vnet/adj/adj.h> |
| 26 | |
| 27 | /** |
| 28 | * @brief |
| 29 | * Convert an existing neighbour adjacency into a midchain |
| 30 | * |
| 31 | * @param adj_index |
| 32 | * The index of the neighbour adjacency. |
| 33 | * |
Neale Ranns | db14f5a | 2018-01-29 10:43:33 -0800 | [diff] [blame] | 34 | * @param fixup |
| 35 | * The function that will be invoked at paket switch time to 'fixup' |
| 36 | * the rewrite applied with necessary per-packet info (i.e. length, checksums). |
| 37 | * @param fixup_data |
| 38 | * Context data set by the caller that is provided as an argument in the |
| 39 | * fixup function. |
| 40 | * |
| 41 | * @param flags |
| 42 | * Flags controlling the adjacency behaviour |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 43 | * |
| 44 | * @param rewrite |
| 45 | * The rewrite. |
| 46 | */ |
| 47 | extern void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 48 | adj_midchain_fixup_t fixup, |
Neale Ranns | db14f5a | 2018-01-29 10:43:33 -0800 | [diff] [blame] | 49 | const void *fixup_data, |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 50 | adj_flags_t flags, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 51 | u8 *rewrite); |
| 52 | |
| 53 | /** |
| 54 | * @brief |
Neale Ranns | 4ec36c5 | 2020-03-31 09:21:29 -0400 | [diff] [blame] | 55 | * Return the adjacency's next node to its default value |
| 56 | * |
| 57 | * @param adj_index |
| 58 | * The index of the neighbour adjacency. |
| 59 | */ |
| 60 | extern void adj_nbr_midchain_reset_next_node(adj_index_t adj_index); |
| 61 | |
| 62 | /** |
| 63 | * @brief |
| 64 | * Update the VLIB node to which packets are sent post processing |
| 65 | * |
| 66 | * @param adj_index |
| 67 | * The index of the neighbour adjacency. |
| 68 | * |
| 69 | * @param node node-index to send to |
| 70 | */ |
| 71 | extern void adj_nbr_midchain_update_next_node(adj_index_t adj_index, |
| 72 | u32 node_index); |
| 73 | |
| 74 | /** |
| 75 | * @brief |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 76 | * [re]stack a midchain. 'Stacking' is the act of forming parent-child |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 77 | * relationships in the data-plane graph. Do NOT use this function to |
| 78 | * stack on a DPO type that might form a loop. |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 79 | * |
| 80 | * @param adj_index |
| 81 | * The index of the midchain to stack |
| 82 | * |
| 83 | * @param dpo |
| 84 | * The parent DPO to stack onto (i.e. become a child of). |
| 85 | */ |
| 86 | extern void adj_nbr_midchain_stack(adj_index_t adj_index, |
| 87 | const dpo_id_t *dpo); |
| 88 | |
| 89 | /** |
| 90 | * @brief |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 91 | * [re]stack a midchain. 'Stacking' is the act of forming parent-child |
| 92 | * relationships in the data-plane graph. Since function performs recursive |
| 93 | * loop detection. |
| 94 | * |
| 95 | * @param adj_index |
| 96 | * The index of the midchain to stack |
| 97 | * |
| 98 | * @param fei |
| 99 | * The FIB entry to stack on |
| 100 | * |
| 101 | * @param fct |
Nathan Skrzypczak | 2c77ae4 | 2021-09-29 15:36:51 +0200 | [diff] [blame] | 102 | * The chain type to use from the fib entry forwarding |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 103 | */ |
| 104 | extern void adj_nbr_midchain_stack_on_fib_entry(adj_index_t adj_index, |
| 105 | fib_node_index_t fei, |
| 106 | fib_forward_chain_type_t fct); |
| 107 | |
| 108 | /** |
| 109 | * @brief |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 110 | * unstack a midchain. This will break the chain between the midchain and |
| 111 | * the next graph section. This is a implemented as stack-on-drop |
| 112 | * |
| 113 | * @param adj_index |
| 114 | * The index of the midchain to stack |
| 115 | */ |
| 116 | extern void adj_nbr_midchain_unstack(adj_index_t adj_index); |
| 117 | |
| 118 | /** |
Neale Ranns | 521a8d7 | 2018-12-06 13:46:49 +0000 | [diff] [blame] | 119 | * @brief descend the FIB graph looking for loops |
| 120 | * |
| 121 | * @param ai |
| 122 | * The adj index to traverse |
| 123 | * |
| 124 | * @param entry_indicies) |
| 125 | * A pointer to a vector of FIB entries already visited. |
| 126 | */ |
| 127 | extern int adj_ndr_midchain_recursive_loop_detect(adj_index_t ai, |
| 128 | fib_node_index_t **entry_indicies); |
| 129 | |
| 130 | /** |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 131 | * @brief |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 132 | * Module initialisation |
| 133 | */ |
| 134 | extern void adj_midchain_module_init(void); |
| 135 | |
| 136 | /** |
| 137 | * @brief |
| 138 | * Format a midchain adjacency |
| 139 | */ |
| 140 | extern u8* format_adj_midchain(u8* s, va_list *ap); |
| 141 | |
Neale Ranns | 4c3ba81 | 2019-03-26 07:02:58 +0000 | [diff] [blame] | 142 | /** |
| 143 | * @brief |
| 144 | * create/attach a midchain delegate and stack it on the prefix passed |
| 145 | * @param ai - the index of the adjacency to stack |
| 146 | * @param fib_index - The FIB index of the prefix on which to stack |
| 147 | * @param pfx - The prefix on which to stack |
| 148 | */ |
| 149 | extern void adj_midchain_delegate_stack(adj_index_t ai, |
| 150 | u32 fib_index, |
| 151 | const fib_prefix_t *pfx); |
| 152 | |
| 153 | /** |
| 154 | * @brief restack a midchain delegate |
| 155 | */ |
| 156 | extern void adj_midchain_delegate_restack(adj_index_t ai); |
| 157 | |
| 158 | /** |
| 159 | * @brief unstack a midchain delegate (this stacks it on a drop) |
| 160 | */ |
| 161 | extern void adj_midchain_delegate_unstack(adj_index_t ai); |
| 162 | |
Neale Ranns | 4ec36c5 | 2020-03-31 09:21:29 -0400 | [diff] [blame] | 163 | extern u8 adj_is_midchain (adj_index_t ai); |
| 164 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 165 | #endif |