Break 'try 256 dco devices' loop on EPERM
PATCH 1/1 Break 'try 256 dco devices' loop on EPERM
If we get a permission denied error on one DCO device, trying 255 more times will not succeed, and just fill the log file with errors.
Also, remove the msg() call there because it was at debug level (needed --verb 4 to be seen), didn't see the correct errno, and the sitnl code already prints the error.
--- src/openvpn/tun.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/openvpn/tun.c +7 -2
@@ -1883,13 +1883,18 @@ open_tun_dco_generic(const char *dev, const char *dev_type, {openvpn_snprintf (dynamic_name,sizeof (dynamic_name),"%s%d" , dev, i); -if (open_tun_dco (tt, ctx, dynamic_name) ==0 ) +int ret =open_tun_dco (tt, ctx, dynamic_name); +if (ret ==0 ) { dynamic_opened = true;msg (M_INFO ,"DCO device %s opened" , dynamic_name);break ; } -msg (D_READ_WRITE |M_ERRNO ,"Tried opening %s (failed)" , dynamic_name); +/* "permission denied" won't succeed if we try 256 times */ +if (ret == -EPERM ) + { +break ; + } }if (!dynamic_opened) {
Signature · 1 line
2.25.1
PATCH v2 1/1 Break 'try 256 dco devices' loop on EPERM
If we get a permission denied error on one DCO device, trying 255 more times will not succeed, and just fill the log file with errors.
Also, remove the msg() call there because it was at debug level (needed --verb 4 to be seen), didn't see the correct errno, and the sitnl code already prints the error.
v2: use "else if"
--- src/openvpn/tun.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/openvpn/tun.c +7 -2
@@ -1883,13 +1883,18 @@ open_tun_dco_generic(const char *dev, const char *dev_type, {openvpn_snprintf (dynamic_name,sizeof (dynamic_name),"%s%d" , dev, i); -if (open_tun_dco (tt, ctx, dynamic_name) ==0 ) +int ret =open_tun_dco (tt, ctx, dynamic_name); +if (ret ==0 ) { dynamic_opened = true;msg (M_INFO ,"DCO device %s opened" , dynamic_name);break ; } -msg (D_READ_WRITE |M_ERRNO ,"Tried opening %s (failed)" , dynamic_name); +/* "permission denied" won't succeed if we try 256 times */ +else if (ret == -EPERM ) + { +break ; + } }if (!dynamic_opened) {
Signature · 1 line
2.25.1
Hi,
Quoted 10 lines · Gert Doering
If we get a permission denied error on one DCO device, trying 255 more times will not succeed, and just fill the log file with errors.
Also, remove the
msg()call there because it was at debug level (needed --verb 4 to be seen), didn't see the correct errno, and the sitnl code already prints the error.v2: use "else if"
Signed-off-by Gert Doering <[email protected]...>
Signature · 1 line
Antonio Quartulli
Of course I have tested this, very scientifically, like "do two runs with and without sufficient permissions on a DCO-enabled system" :-)
Patch has been applied to the master branch.
commit 78c02dd12bcfe7c4b4e96ea534b39ade9ee2c4d6
Author: Gert Doering Date: Thu Aug 4 10:25:02 2022 +0200
Break 'try 256 dco devices' loop on EPERM
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg24799.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering