Bug 229136

Summary: net/frr: Implementing FRR VRFs in the startup script
Product: Ports & Packages Reporter: Alexey <pautina>
Component: Individual Port(s)Assignee: Olivier Cochard <olivier>
Status: New ---    
Severity: Affects Many People CC: olivier, pi
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Alexey 2018-06-19 07:24:35 UTC
OSPF supports several instances and they work fine. But to run the second or more instances need to manually run ospfd with key -n 1.
For example:

run default instance:

#cat /etc/rc.conf |grep frr
frr_daemons="zebra ospfd"
#/usr/local/etc/rc.d/frr start

run ospd with instance 1:

/usr/local/sbin/ospfd -d -n 1

run ospd with instance 1:

/usr/local/sbin/ospfd -d -n 2222.

And so on.

This is well described in this commit:
Comment 1 Alexey 2018-09-21 22:28:21 UTC
On frr add documentation about OSPF instance
Comment 2 Olivier Cochard freebsd_committer 2018-10-18 04:28:19 UTC
FRR's RC script is quiet complex with all the daemons to manage.
If you've got an idea to add multiple OSPF instances to this mess: your ideas are welcome!
Comment 3 Alexey 2020-04-15 13:45:11 UTC
(In reply to Olivier Cochard from comment #2)
I thought for a long time how to organize this and recently through experiments I have achieved some results. My ideas lead to the likeness of VRF in FreeBSD, not only for ospfd, but and for other daimons (staticd, bgpd ..).

First thing we need to implement my idea is to add the line net.fibs=16 to the /boot/loader.conf file (or write this option in the kernel config and recompile the kernel).

The following action is to add to the start script add the option frr_fib="1,2,3, .. 15"

Next, in the start script, need while cycle that start all copies of daemons in your FIB using the set fib utility with the option -N 1 ... -N 15

In addition, we need to create a directory for the configurations of each FIB table:

To connect VRF, we need to add a key for vtysh -N and id FIB.

Information from man frr-zebra:

       -N, --pathspace pathspace
              Insert pathspace into all default paths, changing the defaults


              ´.´ and ´/´ characters will not be accepted in pathspace, but
              the empty string will be accepted.

              Note that this only changes the respective defaults, it has no
              effect on the respective path if the -f, -i, -z or –vty_socket
              options are used.

              The purpose of this option is to easily group all file system
              related bits together for running multiple fully-separate
              “logical routers” on a system, particularly with Linux network
              namespaces.  Groups of daemons running with distinct pathspace
              values will be completely unaware of each other and not interact
              in any way.

              This option does not do any system setup (like network
              namespaces.) This must be done by the user, for example by

              ip netns exec namespace <daemon> -N namespace

Below are the logs of my experiments:

[root@nas5 /home/pautina]# setfib 1 /usr/local/sbin/staticd -d -N 1
[root@nas5 /usr/local/etc]# ps -aux |grep frr
frr     1624    0,0  0,0 70336  8952  -  Is   23:50     0:00,01 /usr/local/sbin/zebra -d
frr     1728    0,0  0,0 97684  9320  -  Is   00:02     0:00,01 /usr/local/sbin/zebra -d -N 1
frr     1734    0,0  0,0 42192  7592  -  Is   00:03     0:00,00 /usr/local/sbin/staticd -d -N 1
root    1743    0,0  0,0 11308  2600  0  R+   00:05     0:00,00 grep frr
[root@nas5 /home/pautina]# vtysh -N 1

Hello, this is FRRouting (version 7.3).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

nas1.istec.net.ua# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

S>* [1/0] unreachable (blackhole), 00:00:06
S>* [1/0] unreachable (blackhole), 00:00:06
C>* [0/1] is directly connected, igb0, 00:00:10
nas1.istec.net.ua# wr
Note: this version of vtysh never writes vtysh.conf
Building Configuration...
Configuration saved to /usr/local/etc/frr/1/zebra.conf
Configuration saved to /usr/local/etc/frr/1/staticd.conf
[root@nas5 /home/pautina]# netstat -rn -F1
Routing tables (fib: 1)

Destination        Gateway            Flags     Netif Expire          UG1B        lo0          UG1B        lo0          link#5             UH          lo0   00:25:90:62:e8:bc  US         igb0
[root@nas5 /home/pautina]# netstat -rn -F0
Routing tables

Destination        Gateway            Flags     Netif Expire
default        UGS        igb0          link#5             UH          lo0   link#1             U          igb0     link#1             UHS         lo0
[root@nas5 /home/pautina]#

If you are interested in my idea - please help to implement this functionality through rc.d script frr