Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDN-4168: Cleanup ipsec state only when ipsec is not full mode #2611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:

[Service]
Type=oneshot
ExecStartPre=rm -f /etc/ipsec.d/cno.conf
ExecStart=systemctl enable --now ipsec.service

[Install]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
[Service]
Type=oneshot
ExecStartPre=rm -f /etc/ipsec.d/cno.conf
ExecStart=systemctl enable --now ipsec.service
[Install]
Expand Down
45 changes: 15 additions & 30 deletions bindata/network/ovn-kubernetes/common/ipsec-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,38 +239,23 @@ 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

# Use /etc/ipsec.d/cno.conf file to write our own default IPsec connection parameters.
# The /etc/ipsec.d/openshift.conf file can not be used because it is managed by openvswitch.
touch /etc/ipsec.d/cno.conf
if ! grep -q "narrowing=yes" /etc/ipsec.d/cno.conf; then
cat <<EOF > /etc/ipsec.d/cno.conf
# Default IPsec connection parameters rendered by network operator.
# The narrowing=yes is needed to narrow down the proposals exchanged
# by two peers to a mutually acceptable set, otherwise it sometimes
# have traffic hit between peer nodes.
conn %default
narrowing=yes
EOF
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

# 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"

# Workaround for https://github.com/libreswan/libreswan/issues/373
ulimit -n 1024

Expand Down Expand Up @@ -407,7 +392,7 @@ spec:
# When east-west ipsec is not disabled, then do not flush xfrm states and
# policies in order to maintain traffic flows during container restart.
ipsecflush() {
if [ "$(kubectl get networks.operator.openshift.io cluster -ojsonpath='{.spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig.mode}')" != "Full" ] || \
if [ "$(kubectl get networks.operator.openshift.io cluster -ojsonpath='{.spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig.mode}')" != "Full" ] && \
[ "$(kubectl get networks.operator.openshift.io cluster -ojsonpath='{.spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig}')" != "{}" ]; then
ip x s flush
ip x p flush
Expand Down