Routing decision based on carp status under freebsd

Manon Goo lists at manon.de
Mon Mar 15 20:46:00 CET 2021


Hello,

I would like announce  routes differently via bgp (longer AS-Path)  
depending on, if carp(4) status is "master" or "backup".  If the carp  
status  is „Master“ Status the shows up as a kernel route to the  
carp(4) address. If carp is in "Backup“ status the route is removed.

**Master Status for carp IP 10.8.15.254**

bird> show route 10.8.15.254/32 all
10.8.15.254/32     dev lo0 [kernel1 00:06:42] * (10)
Type: inherit unicast univ
Kernel.source: 1
Kernel.metric: 0
bird>

**Backup Status for carp IP 10.8.15.254**

bird> show route 10.8.15.254/32 all
Network not in table
bird>


If possible I would like to check in my bgp export filter if I have a  
kernel route to my carp address (10.8.15.254) and if possible  if this  
route is via the loopback dev lo0

Is there any function to lookup a route in bird that could be used in  
the following scenario?

filter bgp_export {
   if ( [ check_if_10.8.15.254/32 is via lo0] ) {
        bgp_local_pref = 120;
        accept;
   } else {
        bgp_path.prepend(65534);
        accept;
   }
}


Kind regards,
Manon




More information about the Bird-users mailing list