Run external script after accepting BGP update or withdraw

Vincent Bernat bernat at luffy.cx
Sun Jul 20 09:19:08 CEST 2014


 ❦ 20 juillet 2014 10:05 +0300, Stanislav Datskevich <sdatskevich at gmail.com> :

> Hi Vincent, Alex,
> I'm not a C programmer, so, could you please explain why fork() is the
> problem? I see this feature work this way:
> 1. Place "run external command" statement into "if" statement inside
> the filter or function, so it will be ran only on the specific
> updates/withdraws.
> 2. When update/withdraw message is arrived, BIRD runs external
> command, passes message details to it as environment variables and
> forks it. After fork BIRD is not blocked by child execution, so it
> will not be a performance impact.

When a lot of updates are happening, you'll have to do a lot of
fork/exec which will put pressure on the system, slowing it down. If you
are worried about using stdin instead of arguments or environment
variables, that's not really more complex.

Instead of having a script which does:

echo $1 $2 >> /var/log/something

You do:

while read a b; do
 echo $a $b >> /var/log/something
done

Moreover, this allows bidirectional communication. Your script can send
routes to be advertised.

At least, it should make your life easier by handling one route at a
time without locking. In the first example, parallel execution of such a
script would lead to a mangled log file.
-- 
Make sure comments and code agree.
            - The Elements of Programming Style (Kernighan & Plauger)



More information about the Bird-users mailing list