summaryrefslogtreecommitdiffstats
path: root/doc/developer/fpm.rst
blob: 98498691330f88880174420db5f6acc1f7d31ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
FPM
===

FPM stands for Forwarding Plane Manager and it's a module for use with Zebra.

The encapsulation header for the messages exchanged with the FPM is
defined by the file :file:`fpm/fpm.h` in the frr tree. The routes
themselves are encoded in Netlink or protobuf format, with Netlink
being the default.

Netlink is standard format for encoding messages to talk with kernel space
in Linux and it is also the name of the socket type used by it.
The FPM netlink usage differs from Linux's in:

- Linux netlink sockets use datagrams in a multicast fashion, FPM uses
  as a stream and it is unicast.
- FPM netlink messages might have more or less information than a normal
  Linux netlink socket message (example: RTM_NEWROUTE might add an extra
  route attribute to signalize VxLAN encapsulation).

Protobuf is one of a number of new serialization formats wherein the
message schema is expressed in a purpose-built language. Code for
encoding/decoding to/from the wire format is generated from the
schema. Protobuf messages can be extended easily while maintaining
backward-compatibility with older code. Protobuf has the following
advantages over Netlink:

- Code for serialization/deserialization is generated automatically. This
  reduces the likelihood of bugs, allows third-party programs to be integrated
  quickly, and makes it easy to add fields.
- The message format is not tied to an OS (Linux), and can be evolved
  independently.

.. note::

   Currently there are two FPM modules in ``zebra``:

   * ``fpm``
   * ``dplane_fpm_nl``

fpm
^^^

The first FPM implementation that was built using hooks in ``zebra`` route
handling functions. It uses its own netlink/protobuf encoding functions to
translate ``zebra`` route data structures into formatted binary data.


dplane_fpm_nl
^^^^^^^^^^^^^

The newer FPM implementation that was built using ``zebra``'s data plane
framework as a plugin. It only supports netlink and it shares ``zebra``'s
netlink functions to translate route event snapshots into formatted binary
data.


Protocol Specification
----------------------

FPM (in any mode) uses a TCP connection to talk with external applications.
It operates as TCP client and uses the CLI configured address/port to connect
to the FPM server (defaults to port ``2620``).

FPM frames all data with a header to help the external reader figure how
many bytes it has to read in order to read the full message (this helps
simulates datagrams like in the original netlink Linux kernel usage).

Frame header:

::

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +---------------+---------------+-------------------------------+
   | Version       | Message type  | Message length                |
   +---------------+---------------+-------------------------------+
   | Data...                                                       |
   +---------------------------------------------------------------+


Version
^^^^^^^

Currently there is only one version, so it should be always ``1``.


Message Type
^^^^^^^^^^^^

Defines what underlining protocol we are using: netlink (``1``) or protobuf (``2``).


Message Length
^^^^^^^^^^^^^^

Amount of data in this frame in network byte order.


Data
^^^^

The netlink or protobuf message payload.