flockd process is controlled by systemd.
$ systemctl status flockd # systemctl start flockd # systemctl stop flockd
flockd is a single process that is split into separate components.
The system component manages the other components and presents a unified API to the outside world.
The system component monitors external signals and updates the other components as required. Example external signals would be the addition of an IP address to an interface, or the addition of a route to the Linux Kernel.
The system component provides the configuration and operations API.
The RIB component receives route updates from other components and from the Linux Kernel. The RIB component selects the best update for each route and redistributes it to other components and to the Linux Kernel. This redistribution can be controlled by configuration. By default the RIB will send the best route to the Linux Kernel and will accept any routes from the Linux Kernel that are not sourced by
The OSPFv2 component runs the OSPFv2 protocol. This component gets interface state information and connected IP subnet information from the System Component. This component gets external state information by connecting to OSPFv2 neighbors via Linux Kernel raw IP sockets. This information is combined and each best route is derived and sent to the RIB component.
The BGPv4 component runs the BGPv4 protocol. This component gets IP route information from the RIB component and external state information by connecting to BGP neighbors via Linux Kernel TCP sockets. This information is combined and each best route is derived and sent to the RIB component.
The Static component manages the configuration of IPv4/IPv6 static routes. Static routes have a default administrative distance of 1 and therefore are preferred over dynamic routes by default. However, Static component allows you to specific a non-default administrative distance and thereby allowing a static route to be used as a backup route to a dynamic route. The configured static routes can be either recursive or non-recursive by specifying an explicit outgoing interface.
The routing suite runs in a single process and each component runs in its own thread. One way to view the active threads is via the Linux
/proc virtual file system. The System, RIBv4, RIBv6, OSPFv2 and BGPv4 components are allocated a thread each. If a component is not enabled, it will not have any threads allocated.
The BGPv4 master thread travels with a BGP thread pool. The BGP thread pool will have a thread for each logical CPU core on the router.
flock@flocknet:~$ grep Name /proc/`pidof flockd`/task/*/status /proc/409/task/409/status:Name: flockd /proc/409/task/432/status:Name: OSPFv2 Master /proc/409/task/433/status:Name: BGPv4 /proc/409/task/434/status:Name: RIBv4 Master /proc/409/task/435/status:Name: RIBv6 Master /proc/409/task/440/status:Name: BGPv4 /proc/409/task/441/status:Name: BGPv4 /proc/409/task/442/status:Name: BGPv4 /proc/409/task/443/status:Name: BGPv4 flock@flocknet:~$
In the example above:
The entire routing suite is running in a single process (process id
The thread with thread id
The thread with thread id
433is the BGP Master thread. The threads with id's
443belong to the BGP thread pool. There are 4 threads in the BGP thread pool as the router has 4 logical CPU's.
flock@flocknet:~$ cat /proc/cpuinfo | grep -c processor 4 flock@flocknet:~$
Logging can be viewed using
flockd logs since router was booted.
# journalctl -u flockd --boot -- Logs begin at Fri 2020-01-10 14:01:47 GMT, end at Mon 2020-06-29 09:38:44 BST. -- Jun 29 08:49:36 r61 flockd: [INFO flockd] START: PID=455, Compile Mode=Release, Log Level="info" ...
flockd logs since a certain time.
# journalctl -u flockd --since "2020-06-26 17:19:20" -- Logs begin at Fri 2020-01-10 14:01:47 GMT, end at Mon 2020-06-29 09:40:55 BST. -- Jun 26 17:19:20 r61 flockd: [INFO flockd::bgp::bgp_neigh] 126.96.36.199/Some(BgpId(188.8.131.52)) BgpAsn2(70) Outgoing FSM state change OpenConfirm -> Established ...
Monitor for the latest
# journalctl -u flockd --follow -- Logs begin at Fri 2020-01-10 14:01:47 GMT. -- Jun 29 09:44:34 r61 flockd: [INFO flockd::bgp::bgp_neigh] 184.108.40.206/Some(BgpId(220.127.116.11)) BgpAsn2(60) Incoming FSM state change OpenConfirm -> Established ...
Log levels can be set using the RUST_LOG environment variable.