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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
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.
22 #ifndef __ADJ_MIDCHAIN_H__
23 #define __ADJ_MIDCHAIN_H__
25 #include <vnet/adj/adj.h>
29 * Convert an existing neighbour adjacency into a midchain
32 * The index of the neighbour adjacency.
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).
38 * Context data set by the caller that is provided as an argument in the
42 * Flags controlling the adjacency behaviour
47 extern void adj_nbr_midchain_update_rewrite(adj_index_t adj_index,
48 adj_midchain_fixup_t fixup,
49 const void *fixup_data,
55 * [re]stack a midchain. 'Stacking' is the act of forming parent-child
56 * relationships in the data-plane graph. Do NOT use this function to
57 * stack on a DPO type that might form a loop.
60 * The index of the midchain to stack
63 * The parent DPO to stack onto (i.e. become a child of).
65 extern void adj_nbr_midchain_stack(adj_index_t adj_index,
70 * [re]stack a midchain. 'Stacking' is the act of forming parent-child
71 * relationships in the data-plane graph. Since function performs recursive
75 * The index of the midchain to stack
78 * The FIB entry to stack on
81 * The chain type to use from the fib entry fowarding
83 extern void adj_nbr_midchain_stack_on_fib_entry(adj_index_t adj_index,
85 fib_forward_chain_type_t fct);
89 * unstack a midchain. This will break the chain between the midchain and
90 * the next graph section. This is a implemented as stack-on-drop
93 * The index of the midchain to stack
95 extern void adj_nbr_midchain_unstack(adj_index_t adj_index);
98 * @brief descend the FIB graph looking for loops
101 * The adj index to traverse
103 * @param entry_indicies)
104 * A pointer to a vector of FIB entries already visited.
106 extern int adj_ndr_midchain_recursive_loop_detect(adj_index_t ai,
107 fib_node_index_t **entry_indicies);
111 * Module initialisation
113 extern void adj_midchain_module_init(void);
117 * Format a midchain adjacency
119 extern u8* format_adj_midchain(u8* s, va_list *ap);
123 * create/attach a midchain delegate and stack it on the prefix passed
124 * @param ai - the index of the adjacency to stack
125 * @param fib_index - The FIB index of the prefix on which to stack
126 * @param pfx - The prefix on which to stack
128 extern void adj_midchain_delegate_stack(adj_index_t ai,
130 const fib_prefix_t *pfx);
133 * @brief restack a midchain delegate
135 extern void adj_midchain_delegate_restack(adj_index_t ai);
138 * @brief unstack a midchain delegate (this stacks it on a drop)
140 extern void adj_midchain_delegate_unstack(adj_index_t ai);