-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bgpd]: Check zebra is ready to connect when starting bgpd (#6478)
Fix #5026 There is a race condition between zebra server accepts connections and bgpd tries to connect. Bgpd has a chance to try to connect before zebra is ready. In this scenario, bgpd will try again after 10 seconds and operate as normal within these 10 seconds. As a consequence, whatever bgpd tries to sent to zebra will be missing in the 10 seconds. To avoid such a scenario, bgpd should start after zebra is ready to accept connections.
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
addr="127.0.0.1" | ||
port=2601 | ||
|
||
function help() | ||
{ | ||
echo "This script aims to ensure zebra is ready to accept connections before starting bgpd" | ||
echo "Usage: $0 [options] [bgpd options]" | ||
echo "Options:" | ||
echo " -a Zebra address" | ||
echo " -o Zebra port" | ||
exit 1 | ||
} | ||
|
||
while getopts ":a:o:h" opt; do | ||
case "${opt}" in | ||
h) help | ||
;; | ||
a) addr=${OPTARG} | ||
;; | ||
o) port=${OPTARG} | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
timeout 5s bash -c -- "until </dev/tcp/${addr}/${port}; do sleep 0.1;done" | ||
if [ "$?" != "0" ]; then | ||
logger -p error "Error: zebra is not ready to accept connections" | ||
fi | ||
|
||
exec /usr/lib/frr/bgpd "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters