From: "cron2 (Code Review)" Date: Mon, 5 May 2025 10:15:40 +0000 References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <23aaea636e1bfdd2f701287c36a10e10d86f87dc-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="s9zTq7re7JU="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Add information-gathering about DNS resolvers configured to t_client.... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --s9zTq7re7JU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/961?usp=3Demail to review the following change. Change subject: Add information-gathering about DNS resolvers configured to= t_client.sh(.in) ...................................................................... Add information-gathering about DNS resolvers configured to t_client.sh(.in) With the patchsets to add DNS configuration on Unix+MacOS systems, and the addition of test stanzas to excercise and verify the OS specific "dns-updown" script, it becomes important to trace test failures ("did it not ping because the DNS was not installed, or did something else fail?") and also verify that DNS config is properly restored at the end of each test. Linux is probed with "resolvectl status", if available, and "cat resolv.conf" if not. MacOS uses scutil --dns. All other platforms use "cat resolv.conf" for now (because even if "a tool to maintain DNS config" is available, in the end resolv.conf is always where the final config lands). Include a bit of restructuring to handle linux iproute2 testing in the "Linux" branch, and make the control flow more amenable to having a second case / esac block. Change-Id: I9cae7314203424e4a604073c5445559260172477 Signed-off-by: Gert Doering --- M tests/t_client.sh.in 1 file changed, 41 insertions(+), 23 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/61/961/1 diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in index 1ccadeb..7a271b6 100755 --- a/tests/t_client.sh.in +++ b/tests/t_client.sh.in @@ -166,53 +166,71 @@ # this is higly system dependent... get_ifconfig_route() { - # linux / iproute2? (-> if configure got a path) - if [ -n "@IPROUTE@" ] - then - echo "-- linux iproute2 --" - @IPROUTE@ addr show | grep -v valid_lft - @IPROUTE@ route show - @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-= 9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e 's/ (rtt|rttvar= ) [0-9]+ms//g' - return - fi - - # try uname - case `uname -s` in + UNAME=3D`uname -s` + case $UNAME in Linux) - echo "-- linux / ifconfig --" - LANG=3DC @IFCONFIG@ -a |egrep "( addr:|encap:)" - LANG=3DC @NETSTAT@ -rn -4 -6 - return - ;; + # linux / iproute2? (-> if configure got a path) + if [ -n "@IPROUTE@" ] + then + echo "-- linux iproute2 --" + @IPROUTE@ addr show | grep -v valid_lft + @IPROUTE@ route show + @IPROUTE@ -o -6 route show | grep -v ' cache' | sed -E -e = 's/ expires [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e = 's/ (rtt|rttvar) [0-9]+ms//g' + else + echo "-- linux / ifconfig --" + LANG=3DC @IFCONFIG@ -a |egrep "( addr:|encap:)" + LANG=3DC @NETSTAT@ -rn -4 -6 + fi + ;; FreeBSD|NetBSD|Darwin) echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --" @IFCONFIG@ -a | egrep "(flags=3D|inet)" @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }' - return ;; OpenBSD) echo "-- OpenBSD --" @IFCONFIG@ -a | egrep "(flags=3D|inet)" | \ sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//' @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }' - return ;; SunOS) echo "-- Solaris --" @IFCONFIG@ -a | egrep "(flags=3D|inet)" @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }' - return ;; AIX) echo "-- AIX --" @IFCONFIG@ -a | egrep "(flags=3D|inet)" @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }' - return ;; + *) + echo "get_ifconfig_route(): no idea how to get info on your OS = (`uname -s`). FAIL." >&2 + exit 20 + ;; esac - echo "get_ifconfig_route(): no idea how to get info on your OS. FAIL.= " >&2 - exit 20 + # another round of per-platform information gathering, for DNS info + # for most of the platforms "cat /etc/resolv.conf" is good enough + # except Linux and MacOS + case $UNAME in + Linux) + if [ -x /usr/bin/resolvectl ] ; then + echo "-- linux resolvectl --" + resolvectl status + else + echo "-- linux resolv.conf --" + cat /etc/resolv.conf + fi + ;; + Darwin) + echo "-- MacOS scutil --dns" + scutil --dns + ;; + *) + echo "-- resolv.conf --" + cat /etc/resolv.conf + ;; + esac } # ---------------------------------------------------------- -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/961?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: I9cae7314203424e4a604073c5445559260172477 Gerrit-Change-Number: 961 Gerrit-PatchSet: 1 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --s9zTq7re7JU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

cron2 would like plaisthos and flichtenheld to review t= his change.

Vi= ew Change

Add information-gathering about DNS resolvers configured to t=
_client.sh(.in)

With the patchsets to add DNS configuration on Unix+= MacOS systems, and
the addition of test stanzas to excercise and verify = the OS specific
"dns-updown" script, it becomes important to t= race test failures
("did it not ping because the DNS was not instal= led, or did something
else fail?") and also verify that DNS config = is properly restored at
the end of each test.

Linux is probed wit= h "resolvectl status", if available, and
"cat resolv.conf= " if not. MacOS uses scutil --dns.

All other platforms use &qu= ot;cat resolv.conf" for now (because even if
"a tool to mainta= in DNS config" is available, in the end resolv.conf
is always where= the final config lands).

Include a bit of restructuring to handle l= inux iproute2 testing in the
"Linux" branch, and make the cont= rol flow more amenable to having a
second case / esac block.

Chan= ge-Id: I9cae7314203424e4a604073c5445559260172477
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M tests/t_client.sh.in
1 file cha= nged, 41 insertions(+), 23 deletions(-)

git pull ssh://gerrit.ope=
nvpn.net:29418/openvpn refs/changes/61/961/1
diff --git a/tests/t_c=
lient.sh.in b/tests/t_client.sh.in
index 1ccadeb..7a271b6 1= 00755
--- a/tests/t_client.sh.in
+++ b/test= s/t_client.sh.in
@@ -166,53 +166,71 @@
# t= his is higly system dependent...
get_ifconfig_route()
{
- # l= inux / iproute2? (-> if configure got a path)
- if [ -n "@IPROUTE@" ]
- then

- echo "-- linux iproute2 --"- @IPROUTE@ addr show | gre= p -v valid_lft
- @IPROU= TE@ route show
- @IPROU= TE@ -o -6 route show | grep -v ' cache' | sed -E -e 's/ expires= [0-9]*sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e= 's/ (rtt|rttvar) [0-9]+ms//g'
- return
-
<= span style=3D"color: hsl(0, 100%, 40%);">- # try uname
- case `uname -s` in
+ UNAME=3D`uname -s`
+ case $UNAME in
Linux)
- echo &q= uot;-- linux / ifconfig --"
- LANG=3DC @IFCONFIG@ -a |egrep "( addr:|encap:)"
- LANG=3DC @NETSTAT@ = -rn -4 -6
- return
- ;;
+ # linux / iproute2? (-&g= t; if configure got a path)
+ if [ -n "@IPROUTE@" ]
+ then
+ echo "-- linux iproute2= --"
+ = @IPROUTE@ addr show | grep -v valid_lft
+ @IPROUTE@ route show+ @IPROUTE@ -o= -6 route show | grep -v ' cache' | sed -E -e 's/ expires [0-9]= *sec//' -e 's/ (mtu|hoplimit|cwnd|ssthresh) [0-9]+//g' -e '= s/ (rtt|rttvar) [0-9]+ms//g'
+ else
+ echo "-- linux / ifconfig --"
+ LANG=3DC @IFCONFIG@ -a |egr= ep "( addr:|encap:)"
+ LANG=3DC @NETSTAT@ -rn -4 -6
+ fi
+ ;;
FreeBSD|NetBSD|Da= rwin)
echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --= "
@IFCONFIG@ -a | egrep "(flags=3D|inet)&quo= t;
@NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2= ,$3,$NF }'
- ret= urn
;;
OpenBSD)
= echo "-- OpenBSD --"
@IFCONFIG@ -a | egrep = "(flags=3D|inet)" | \
sed -e 's/pltime [0-= 9]*//' -e 's/vltime [0-9]*//'
@NETSTAT@ -r= n | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
- return
;; SunOS)
echo "-- Solaris --"=
@IFCONFIG@ -a | egrep "(flags=3D|inet)"
= @NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'=
- return
= ;;
AIX)
echo "-- AIX= --"
@IFCONFIG@ -a | egrep "(flags=3D|inet)&= quot;
@NETSTAT@ -rn | awk '$3 !~ /^UHL/ { print $1= ,$2,$3,$6 }'
- r= eturn
;;
+ *)
= + echo "get_ifconfig_route(): no idea how to get info on you= r OS (`uname -s`). FAIL." >&2
+ exit 20
+ ;;
esac

- echo "ge= t_ifconfig_route(): no idea how to get info on your OS. FAIL." >&a= mp;2
- exit 20
+ # another round of pe= r-platform information gathering, for DNS info
+ # for most of the platforms "cat /etc/r= esolv.conf" is good enough
+ # except Linux and MacOS
+ case $UNAME in
+ Linux)
+ if [ -x /usr/bin/resolvectl ] ; then
+ echo "-- linux re= solvectl --"
+ = resolvectl status
+ else
+ echo "-- linux resolv.conf --"+ cat /etc/reso= lv.conf
+ = fi
+ ;;
+ Darwin)
+ echo "-- MacOS s= cutil --dns"

+ = scutil --dns
+ = *)
+ = echo "-- resolv.conf --"
+ cat /etc/resolv.conf
+ ;;
+ esac
}

# ----------------------------------------------------------

To view, visit change 961. To unsubscribe, or = for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9cae7314203424e4a604073c544= 5559260172477
Gerrit-Change-Number: 961
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <gert@...1296...>
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: newchange
--s9zTq7re7JU=--