Skip to content

Commit

Permalink
dhclient: T6667: Added workaround for communication with FRR
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zdc committed Aug 21, 2024
1 parent 2277371 commit 10224cf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
Original file line number Diff line number Diff line change
Expand Up @@ -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 configured 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 configure 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
Expand All @@ -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 $@\""
Expand Down

0 comments on commit 10224cf

Please sign in to comment.