Skip to content

Commit

Permalink
Restart IPsec service only when needed
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Jan 2, 2025
1 parent 9f6ad67 commit d1e9d2c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
[Service]
Type=oneshot
ExecStartPre=rm -f /etc/ipsec.d/cno.conf
ExecStart=systemctl enable --now ipsec.service
ExecStartPost=/usr/local/bin/ipsec-connect-wait.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
[Service]
Type=oneshot
ExecStartPre=rm -f /etc/ipsec.d/cno.conf
ExecStart=systemctl enable --now ipsec.service
ExecStartPost=/usr/local/bin/ipsec-connect-wait.sh
Expand Down
31 changes: 15 additions & 16 deletions bindata/network/ovn-kubernetes/common/ipsec-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,22 @@ spec:
defaultcpinclude="include \/etc\/crypto-policies\/back-ends\/libreswan.config"
if ! grep -q "# ${defaultcpinclude}" /etc/ipsec.conf; then
sed -i "/${defaultcpinclude}/s/^/# /" /etc/ipsec.conf
fi
# since pluto is on the host, we need to restart it after changing connection
# parameters.
chroot /proc/1/root ipsec restart
# since pluto is on the host, we need to restart it after changing connection
# parameters.
chroot /proc/1/root ipsec restart
counter=0
until [ -r /run/pluto/pluto.ctl ]; do
counter=$((counter+1))
sleep 1
if [ $counter -gt 300 ];
then
echo "ipsec has not started after $counter seconds"
exit 1
fi
done
echo "ipsec service is restarted"
counter=0
until [ -r /run/pluto/pluto.ctl ]; do
counter=$((counter+1))
sleep 1
if [ $counter -gt 300 ];
then
echo "ipsec has not started after $counter seconds"
exit 1
fi
done
echo "ipsec service is restarted"
fi
# Workaround for https://github.com/libreswan/libreswan/issues/373
ulimit -n 1024
Expand Down

0 comments on commit d1e9d2c

Please sign in to comment.