[Openvpn-devel,XS] Change in openvpn[master]: Minor fix on ifconfig parameter warning

Message ID f9f0326682ea7ae7af91dce81f369af384d58051-HTML@gerrit.openvpn.net
State Deferred
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: Minor fix on ifconfig parameter warning | expand

Commit Message

cron2 (Code Review) Sept. 6, 2024, 3:44 p.m. UTC
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/+/736?usp=email

to review the following change.


Change subject: Minor fix on ifconfig parameter warning
......................................................................

Minor fix on ifconfig parameter warning

Handle the case of tun device and subnet topology in
ifconfig_sanity_check(). Emit a warning if the second parameter of
ifconfig doesn't look like a netmask.

Change-Id: I2f55eabd0e950edc3fbcd08b257257cf9ed9c8d8
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
---
M src/openvpn/tun.c
1 file changed, 5 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/736/1

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index ce3d882..875f558 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -510,20 +510,21 @@ 
 {
     struct gc_arena gc = gc_new();
     const bool looks_like_netmask = ((addr & 0xFF000000) == 0xFF000000);
-    if (tun)
+    if (tun && (topology == TOP_NET30 || topology == TOP_P2P))
     {
-        if (looks_like_netmask && (topology == TOP_NET30 || topology == TOP_P2P))
+        if (looks_like_netmask)
         {
             msg(M_WARN, "WARNING: Since you are using --dev tun with a point-to-point topology, the second argument to --ifconfig must be an IP address.  You are using something (%s) that looks more like a netmask. %s",
                 print_in_addr_t(addr, 0, &gc),
                 ifconfig_warn_how_to_silence);
         }
     }
-    else /* tap */
+    else /* tap or tun with subnet topology */
     {
         if (!looks_like_netmask)
         {
-            msg(M_WARN, "WARNING: Since you are using --dev tap, the second argument to --ifconfig must be a netmask, for example something like 255.255.255.0. %s",
+            msg(M_WARN, "WARNING: Since you are using --dev %s, the second argument to --ifconfig must be a netmask, for example something like 255.255.255.0. %s",
+                tun ? "tun with a subnet topology" : "tap",
                 ifconfig_warn_how_to_silence);
         }
     }