blob: 63d1be0ef9aeef7b3788fb496e96b79b9d4f764e [file] [log] [blame]
Neale Ranns1f50bf82019-07-16 15:28:52 +00001/*
2 * Copyright (c) 2019 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#ifndef __FIB_TRACKER_H__
17#define __FIB_TRACKER_H__
18
19#include <vnet/fib/fib_entry.h>
20
21/**
22 * Trackers are used on FIB entries by objects that which to track the
23 * changing state of the entry. For example a tunnel would track its
24 * destination address to be informed of reachability changes.
25 *
26 * The benefit of this aproach is that each time a new client tracks the
27 * entry it doesn't RR source it. When an entry is sourced all its children
28 * are updated. Thus, new clients tracking an entry is O(n^2). With the
29 * tracker as indirection, the entry is sourced only once.
30 */
31
32/**
33 * Track a FIB entry
34 * @param fib_index The FIB the entry is in
35 * @param prefix The Prefix of the entry to track
36 * @param child_type The type of object that is tracking this entry
37 * @param child_index The pool index of the object tracking
38 * @param sigbling [RETURNED] The sibling index of the child on the tracker
39 * @return The index of the FIB entry
40 */
41extern fib_node_index_t fib_entry_track(u32 fib_index,
42 const fib_prefix_t *prefix,
43 fib_node_type_t child_type,
44 index_t child_index,
45 u32 *sibling);
46
47/**
48 * Stop tracking a FIB entry
49 * @param fei FIB entry index (as returned from the track API above)
50 * @param sibling Sibling index (as returned from the track API above)
51 */
52extern void fib_entry_untrack(fib_node_index_t fei,
53 u32 sibling);
54
55extern void fib_entry_track_module_init(void);
56
57#endif