summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2024-08-21 21:55:17 +0300
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-09-26 13:23:35 +0000
commitdddc6a7ea25f3514faaa562af0f3cefed4b6048b (patch)
tree02b31b76f258912e0931d443fd7254d1ee35c1ce
parent6450c7d964352503c99347bdf1d6bd5c673b37bd (diff)
downloadvyos-1x-dddc6a7ea25f3514faaa562af0f3cefed4b6048b.tar.gz
vyos-1x-dddc6a7ea25f3514faaa562af0f3cefed4b6048b.zip
dhclient: T6667: Added workaround for communication with FRRmergify/bp/sagitta/pr-4002
To increase the chance for dhclient to configure routes in FRR, added a workaround. Now 10 attempts are performed with 1 second delay and only after this dhclient gives up. (cherry picked from commit da64a7246e9b12d5bd84287517cfbfa59e364c28)
-rw-r--r--src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
index 5d879471d..2a1c5a7b2 100644
--- a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
+++ b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
@@ -72,6 +72,22 @@ function delroute () {
fi
}
+# try to communicate with vtysh
+function vtysh_conf () {
+ # perform 10 attempts with 1 second delay for retries
+ for i in {1..10} ; do
+ if vtysh -c "conf t" -c "$1" ; then
+ logmsg info "Command was executed successfully via vtysh: \"$1\""
+ return 0
+ else
+ logmsg info "Failed to send command to vtysh, retrying in 1 second"
+ sleep 1
+ fi
+ done
+ logmsg error "Failed to execute command via vtysh after 10 attempts: \"$1\""
+ return 1
+}
+
# replace ip command with this wrapper
function ip () {
# pass comand to system `ip` if this is not related to routes change
@@ -84,7 +100,7 @@ function ip () {
delroute ${@:4}
iptovtysh $@
logmsg info "Sending command to vtysh"
- vtysh -c "conf t" -c "$VTYSH_CMD"
+ vtysh_conf "$VTYSH_CMD"
else
# add ip route to kernel
logmsg info "Modifying routes in kernel: \"/usr/sbin/ip $@\""