Exa-Networks / exabgp

The BGP swiss army knife of networking
Other
2.1k stars 447 forks source link

Exabgpcli with multiple configuration files with different named pipes #1214

Open JamesTuMarines opened 5 months ago

JamesTuMarines commented 5 months ago

Hi Team,

I run exabgp with two different configuration files but both configuration files use different named pipes.

When I run the command "exabgpcli show neighbor summary" to see the status of all the neighbors, it randomly sends the command to different pipes so I can only get half of the result I want.

Is there a way that I can control which pipe that exabgpcli sends to?

Thank you.

Exabgp Version

[root@localhost ~]# exabgpcli version exabgp 4.2.21

PIPE Files created like this

/bin/bash -c "/usr/bin/mkfifo -m 0777 /var/run/exabgp_clean.cmd"
/bin/bash -c "/usr/bin/mkfifo -m 0777 /var/run/exabgp_clean.{in,out}"
/bin/bash -c "/usr/bin/mkfifo -m 0777 /var/run/exabgp_rtbh.cmd"
/bin/bash -c "/usr/bin/mkfifo -m 0777 /var/run/exabgp_rtbh.{in,out}"

Configuration File 1 exabgp_clean.conf

process announce-routes {
run /usr/bin/socat stdout pipe:/var/run/exabgp_clean.cmd;
encoder json;
}

template {
    neighbor clean {
        router-id 172.31.250.119;  
        local-as 65000;   # local AS number
        peer-as 65000;   # remote AS number
        group-updates false;
        family {
                ipv4 flow;
                ipv4 unicast;
        }               # 啟用的AFI
        api {
                processes [ announce-routes ];
        }
    }
}

neighbor 172.31.250.118{
        local-address 172.31.250.119;
        inherit clean;
}

Configuration File 2 exabgp_rtbh.conf


process announce-routes {
run /usr/bin/socat stdout pipe:/var/run/exabgp_rtbh.cmd;
encoder json;
}

template {
    neighbor rtbh {
        router-id 172.31.250.143;   
        local-as 65000;   # local AS number
        peer-as 65000;   # remote AS number
        group-updates false;
        family {
                ipv4 flow;
                ipv4 unicast;
        }               # 啟用的AFI
        api {
                processes [ announce-routes ];
        }
    }
}

neighbor 172.31.250.142{
        local-address 172.31.250.143;
        inherit rtbh;
}```
thomas-mangin commented 5 months ago

The PIPE location can be controlled by env name if I recall how I did it correctly (and if it does not now it could). This name could be passed via another env variable and changed by the forking version of ExaBGP. This would be a feature and is not available ATM.

JamesTuMarines commented 5 months ago

Hi @thomas-mangin,

Thank you for the hint. I created two env files and set the different exabgp.api.pipename for two configuration files.

cat exabgp_rtbh.env
[exabgp.api]
pipename = 'exabgp_rtbh'
cat exabgp_clean.env
[exabgp.api]
pipename = 'exabgp_clean'

Run exabgp like this.

exabgp -e /root/exabgp_rtbh.env /root/exabgp_rtbh.conf
exabgp -e /root/exabgp_clean.env /root/exabgp_clean.conf

Run the API like this. I wrote a script to run the command about 500 times and no random output anymore. I think the problem is solved now.

env exabgp.api.pipename=exabgp_rtbh exabgpcli show neighbor summary
env exabgp.api.pipename=exabgp_clean exabgpcli show neighbor summary

However, if I tried to run exabgpcli with --env and it shows timeout. Did I run the API in the wrong way?

exabgpcli --env exabgp_rtbh.env show nei sum
command: show neighbor summary
could not send command to ExaBGP (command timeout)

Thank you.

thomas-mangin commented 5 months ago

What I suggested requires code change. What you suggested should have worked for me. Please use ./sbin/exabgp env -d to check if the settings are correctly loaded.

JamesTuMarines commented 5 months ago

Hi @thomas-mangin

I tried the command and it shows this.

09:56:26 | 5783 | configuration | one of the arguments passed as configuration is not a file (env)

Is what I should expect?

Thank you.

thomas-mangin commented 5 months ago

The command I gave you is for master, for 4.2, it may be -di - and no need for env ?

JamesTuMarines commented 5 months ago

Oh, I see I understand what you mean.

The output is like this.

[root@localhost ~]# exabgp --di --env /root/exabgp_clean.env

[exabgp.api]
pipename = 'exabgp_clean'