blob: f64d3deb860669097db70a69ceeb327ca8326d22 [file] [log] [blame]
Neale Rannsdfd39542020-11-09 10:09:42 +00001.. _hacking:
2
3Get Hacking
4-----------
5
6The code's directory structure is trivial, FIB, mFIB, adj have their
7own directories.
8
9for the most part, for all the FIB object types mentioned in this
10documentation there is a corresponding .h and .c file. As with any VPP
11component/sub-system a 'public' header file is any file that can be
12included by another sub-system and/or plugin. These must be specified
13in the build-system, so go look there. Public header files are always
14a good entry point to start reading.
15
16FIB
17^^^
18
19There is no direct [VPP's binary] API access to FIB, but FIB does
20expose types that can be used on the API by FIB and by other
21subsystems (e.g. :ref:`barnacles`). These types are specified in
22fib.api and the encoding and decoding thereof in fib_api.[ch].
23
24Most operations on a FIB entry happen as a result of an operation on a
25FIB table; an entry does not exist in isolation. The APIs in
26fib_table.h are well doxygen documented you should be able to figure
27out what they do. Use this as a starting point to explore how entries
28are created and deleted and how the source priority scheme works.
29
30FIB sources are defined in fib_source.h. Each source behaviour has its
31own file fib_entry_src_*.c These define the virtual functions that
32determine how the source behaves when actions on the FIB occur. For
33example, what the entry must do when its covering prefix's forwarding
34is updated.
35
36When creating new paths/path-lists the main action required is to
37resolve them; see fib_path*_resolve, and once resolved to have them
38contribute a DPO for forwarding or for the uRPF list; see
39fib_*_contribute_forwarding and fib_*_contribute_urpf respectively.
40
41The data-structures that used for entry lookup are protocol
42specific, they are implemented in separate files; ip4_fib.[ch],
43ip6_fib.[ch] and mpls_fib.[ch].
44
45FIB extranet support is implemented in fib_attached_export.[ch].
46FIB tracking is implemented in fib_entry_track.[ch].
47FIB [back]walk is implemented in fib_walk.[ch].
48
49Adjacency
50^^^^^^^^^
51
52Not much to say here, each adjacency type has it own file; use the
53force, read the source.
54
55
56Testing
57^^^^^^^
58
59the majority of FIB coverage comes from the C Unit tests in
60fib_test.c. I strongly encourage you to add code here. It's a much
61easier development cycle to fire up GDB, run VPP and iterate with
62'test fib', than it is work in the python UT. You still need to write
63python UT, don't get me wrong, it's just easier to do the FIB dev
64using C UT.
65
66
67
68Enjoy!