Skip to contentSkip to conversation

Change in openvpn[master]: options: Move < 0 check for keepalive settings earlier

Openvpn-devel flichtenheld (Code Review) 1 participant 2 messages Aug 22, 2025 – Feb 12 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1755879913000.Ic9ac18f730e6035126ccf1cf19799548e5fd9316@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1155?usp=email

to review the following change.

Change subject: options: Move < 0 check for keepalive settings earlier
......................................................................

options: Move < 0 check for keepalive settings earlier

Use the atoi_constrained function.

Change-Id Ic9ac18f730e6035126ccf1cf19799548e5fd9316

---
M src/openvpn/helper.c
M src/openvpn/options.c

2 files changed, 3 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1155/1

src/openvpn/helper.c +1 -5
index b2ecb1e..b262e8d 100644
@@ -552,14 +552,10 @@
         /*
          * Sanity checks.
          */
-        if (o->keepalive_ping <= 0 || o->keepalive_timeout <= 0)
-        {
-            msg(M_USAGE, "--keepalive parameters must be > 0");
-        }
         if (o->keepalive_ping * 2 > o->keepalive_timeout)
         {
             msg(M_USAGE,
-                "the second parameter to --keepalive (restart timeout=%d) must be at least twice the value of the first parameter (ping interval=%d).  A ratio of 1:5 or 1:6 would be even better.  Recommended setting is --keepalive 10 60.",
+                "The second parameter to --keepalive (restart timeout=%d) must be at least twice the value of the first parameter (ping interval=%d).  A ratio of 1:5 or 1:6 would be even better.  Recommended setting is --keepalive 10 60.",
                 o->keepalive_timeout, o->keepalive_ping);
         }
         if (o->ping_send_timeout || o->ping_rec_timeout)
src/openvpn/options.c +2 -2
index 87c0895..97bf957 100644
@@ -7362,8 +7362,8 @@
     else if (streq(p[0], "keepalive") && p[1] && p[2] && !p[3])
     {
         VERIFY_PERMISSION(OPT_P_GENERAL);
-        options->keepalive_ping = atoi_warn(p[1], msglevel);
-        options->keepalive_timeout = atoi_warn(p[2], msglevel);
+        atoi_constrained(p[1], &options->keepalive_ping, "keepalive ping", 0, 0, msglevel);
+        atoi_constrained(p[2], &options->keepalive_timeout, "keepalive timeout", 0, 0, msglevel);
     }
     else if (streq(p[0], "ping") && p[1] && !p[2])
     {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1155?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9ac18f730e6035126ccf1cf19799548e5fd9316
Gerrit-Change-Number: 1155
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: options: Move <= 0 check for keepalive settings earlier

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1155?usp=email )

Change subject: options: Move <= 0 check for keepalive settings earlier
......................................................................

Patch Set 7:

(1 comment)

This change is ready for review.

Patchset:

PS7:
Moving this out of draft status. I was originally hesitant to put this into the RCs, but it is definitely fine for post-2.7 master

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1155?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9ac18f730e6035126ccf1cf19799548e5fd9316
Gerrit-Change-Number: 1155
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Feb 2026 12:24:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No