From: "d12fk (Code Review)" Date: Wed, 9 Jul 2025 08:57:04 +0000 In-Reply-To: References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="dQNAIfpOpc0="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: mac dns: do not run dns-updown in parallel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --dQNAIfpOpc0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1076?usp=3Demail to look at the new patch set (#3). Change subject: mac dns: do not run dns-updown in parallel ...................................................................... mac dns: do not run dns-updown in parallel In case more than one openvpn connection is coming up or going down at the same time, there is potential for breakage, since the operations performed are not atomic. Introduce a locking mechanism, which let's scripts run in sequence, to prevent races between them. Change-Id: I7adfaa08df6a17545cca8264d7230b5e65e49719 Signed-off-by: Heiko Hund --- M distro/dns-scripts/macos-dns-updown.sh 1 file changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/76/1076/3 diff --git a/distro/dns-scripts/macos-dns-updown.sh b/distro/dns-scripts/ma= cos-dns-updown.sh index 282b034..065a725 100644 --- a/distro/dns-scripts/macos-dns-updown.sh +++ b/distro/dns-scripts/macos-dns-updown.sh @@ -26,6 +26,23 @@ # dns_server_1_sni dns.mycorp.in # +lockdir=3D/var/lock +if [ ! -d "${lockdir}" ]; then + /bin/mkdir "${lockdir}" + /bin/chmod 1777 "${lockdir}" +fi + +i=3D1 +lockfile=3D"${lockdir}/openvpn-dns-updown.lock" +while ! /usr/bin/shlock -f $lockfile -p $$; do + if [ $((++i)) -gt 10 ]; then + echo "dns-updown failed, could not acquire lock" + exit 1 + fi + sleep 0.2 +done +trap "/bin/rm -f ${lockfile}" EXIT + [ -z "${dns_vars_file}" ] || . "${dns_vars_file}" itf_dns_key=3D"State:/Network/Service/openvpn-${dev}/DNS" -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1076?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I7adfaa08df6a17545cca8264d7230b5e65e49719 Gerrit-Change-Number: 1076 Gerrit-PatchSet: 3 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --dQNAIfpOpc0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

d12fk uploaded patch set #3 to this change.

View Change

mac dns: do not run dns-updown in parallel

In case more than one = openvpn connection is coming up or going down at
the same time, there is= potential for breakage, since the operations
performed are not atomic.<= br>
Introduce a locking mechanism, which let's scripts run in sequen= ce, to
prevent races between them.

Change-Id: I7adfaa08df6a17545c= ca8264d7230b5e65e49719
Signed-off-by: Heiko Hund <heiko@...2662...>= ;
---
M distro/dns-scripts/macos-dns-updown.sh
1 file changed, 17 = insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:2=
9418/openvpn refs/changes/76/1076/3
diff --git a/distro/dns-scripts=
/macos-dns-updown.sh b/distro/dns-scripts/macos-dns-updown.sh
index 282b034..065a725 100644
--- a/distro/dns-scripts/m= acos-dns-updown.sh
+++ b/distro/dns-scripts/macos-dns-updow= n.sh
@@ -26,6 +26,23 @@
# dns_server_1_s= ni dns.mycorp.in
#

+lockdir=3D/var/lock
+if [ ! -d "${lockdir}" ]; then<= /span>
+ /bin/mkdir "= ;${lockdir}"
+ = /bin/chmod 1777 "${lockdir}"
+fi
+
+i=3D1+lockfile=3D"${lockdir}/o= penvpn-dns-updown.lock"
+while ! /usr/bin/shlock -f $lockfile -p $$; do
+ if [ $((++i)) -gt 10 ]; then=
+ echo "dns-upd= own failed, could not acquire lock"
+ exit 1
+ fi
+don= e
+trap "/bin/rm= -f ${lockfile}" EXIT
+
[ -z "${dns_vars_file}" ] || . "${d= ns_vars_file}"

itf_dns_key=3D"= State:/Network/Service/openvpn-${dev}/DNS"

=

To view, visit change 1076. To unsubscribe, or for help writing mail f= ilters, visit settings.<= /p>

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7adfaa08df6a17545cca8264d72= 30b5e65e49719
Gerrit-Change-Number: 1076
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--dQNAIfpOpc0=--