options: Always define options->management_flags
PATCH 1/1 options: Always define options->management_flags
That makes it possible to remove several preprocessor directives which is a good thing. The cost should be negligible.
--- src/openvpn/manage.h | 41 +++++++++++++++++++------------------- src/openvpn/options.c | 46 +++++++++++++------------------------------ src/openvpn/options.h | 6 ++++-- 3 files changed, 39 insertions(+), 54 deletions(-)
I tried to make options.c less ugly. I didn't get far. But it still might be an incremental improvement.
src/openvpn/manage.h +21 -20
@@ -24,6 +24,27 @@#ifndef MANAGE_H #define MANAGE_H +/* management_open flags */ +#define MF_SERVER (1<<0) +#define MF_QUERY_PASSWORDS (1<<1) +#define MF_HOLD (1<<2) +#define MF_SIGNAL (1<<3) +#define MF_FORGET_DISCONNECT (1<<4) +#define MF_CONNECT_AS_CLIENT (1<<5) +#define MF_CLIENT_AUTH (1<<6) +/* #define MF_CLIENT_PF (1<<7) *REMOVED FEATURE* */ +#define MF_UNIX_SOCK (1<<8) +#define MF_EXTERNAL_KEY (1<<9) +#define MF_EXTERNAL_KEY_NOPADDING (1<<10) +#define MF_EXTERNAL_KEY_PKCS1PAD (1<<11) +#define MF_UP_DOWN (1<<12) +#define MF_QUERY_REMOTE (1<<13) +#define MF_QUERY_PROXY (1<<14) +#define MF_EXTERNAL_CERT (1<<15) +#define MF_EXTERNAL_KEY_PSSPAD (1<<16) +#define MF_EXTERNAL_KEY_DIGEST (1<<17) + +#ifdef ENABLE_MANAGEMENT #include "misc.h"
@@ -321,26 +342,6 @@ struct user_pass;struct management *management_init (void ); -/* management_open flags */ -#define MF_SERVER (1<<0) -#define MF_QUERY_PASSWORDS (1<<1) -#define MF_HOLD (1<<2) -#define MF_SIGNAL (1<<3) -#define MF_FORGET_DISCONNECT (1<<4) -#define MF_CONNECT_AS_CLIENT (1<<5) -#define MF_CLIENT_AUTH (1<<6) -/* #define MF_CLIENT_PF (1<<7) *REMOVED FEATURE* */ -#define MF_UNIX_SOCK (1<<8) -#define MF_EXTERNAL_KEY (1<<9) -#define MF_EXTERNAL_KEY_NOPADDING (1<<10) -#define MF_EXTERNAL_KEY_PKCS1PAD (1<<11) -#define MF_UP_DOWN (1<<12) -#define MF_QUERY_REMOTE (1<<13) -#define MF_QUERY_PROXY (1<<14) -#define MF_EXTERNAL_CERT (1<<15) -#define MF_EXTERNAL_KEY_PSSPAD (1<<16) -#define MF_EXTERNAL_KEY_DIGEST (1<<17) - bool management_open(struct management *man, const char *addr, const char *port,
src/openvpn/options.c +14 -32
159 lines not on this page · raw message
src/openvpn/options.h +4 -2
@@ -438,10 +438,12 @@ struct optionsconst char *management_client_user;const char *management_client_group; -/* Mask of MF_ values of manage.h */ -unsigned int management_flags;const char *management_certificate;#endif +/* Mask of MF_ values of manage.h +* Always available to simplify options.c +*/ +unsigned int management_flags;#ifdef ENABLE_PLUGIN struct plugin_option_list *plugin_list;
Signature · 1 line
2.34.1
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Quoted 22 lines · Arne Schwabe
Am 27.11.22 um 15:25 schrieb Frank Lichtenheld:
Quoted 3 lines
That makes it possible to remove several preprocessor directives which is a good thing. The cost should be negligible.
Acked-by Arne Schwabe <[email protected]...>In general the commit looks good but I would like to improve the comment for the management flags (see below).
Quoted 11 lines
src/openvpn/options.h +0
-2@@ -438,10 +438,12 @@ struct optionsconst char *management_client_user;const char *management_client_group; -/* Mask of MF_ values of manage.h */ -unsigned int management_flags;const char *management_certificate;#endif
Quoted 8 lines
src/openvpn/options.h struct options · line 446
Quoted 4 lines
src/openvpn/options.h +4
-0+/* Mask of MF_ values of manage.h +* Always available to simplify options.c +*/ +unsigned int management_flags;This feels a bit odd as a comment. I would expect this in the commit or something like "even available when management support is not available" but this comment feels a bit too "temporary".
How is this "temporary"? It does not describe the change, it actually states why this is handled specially. Your proposal just drops the justification, then the comment becomes useless IMHO.
Would you prefer "Always available to simplify option verification code"?
Regards,
Signature · 1 line
Frank Lichtenheld
Am 16.12.22 um 14:11 schrieb Frank Lichtenheld:
Quoted 32 lines · Arne Schwabe
Quoted 22 lines
Am 27.11.22 um 15:25 schrieb Frank Lichtenheld:
Quoted 3 lines
That makes it possible to remove several preprocessor directives which is a good thing. The cost should be negligible.
Acked-by Arne Schwabe <[email protected]...>In general the commit looks good but I would like to improve the comment for the management flags (see below).
Quoted 11 lines
src/openvpn/options.h +0
-2@@ -438,10 +438,12 @@ struct optionsconst char *management_client_user;const char *management_client_group; -/* Mask of MF_ values of manage.h */ -unsigned int management_flags;const char *management_certificate;#endif Quoted 8 lines
src/openvpn/options.h struct options · line 446
Quoted 4 lines
src/openvpn/options.h +4
-0+/* Mask of MF_ values of manage.h +* Always available to simplify options.c +*/ +unsigned int management_flags;This feels a bit odd as a comment. I would expect this in the commit or something like "even available when management support is not available" but this comment feels a bit too "temporary".
Quoted 5 lines
How is this "temporary"? It does not describe the change, it actually states why this is handled specially. Your proposal just drops the justification, then the comment becomes useless IMHO.
Would you prefer "Always available to simplify option verification code"?
I feel this because it is always available to avoid ifdefs and therefore to simplify options.c but the information that ifdefs are the alternative is not obvious from the comment or code alone. We have a lot of other variables that are always available but are only used if certain compile options are used. So I feel this comment is temporary because it basically is from the history that here in this case we had ifdefs, so we added here now a comment that there now no longer ifdefs. But in general without the historical context the comment feels odd to me.
Arne
Quoted 39 lines · Arne Schwabe
Am 16.12.22 um 14:11 schrieb Frank Lichtenheld:
Quoted 32 lines · Arne Schwabe
Quoted 22 lines
Am 27.11.22 um 15:25 schrieb Frank Lichtenheld:
Quoted 3 lines
That makes it possible to remove several preprocessor directives which is a good thing. The cost should be negligible.
Acked-by Arne Schwabe <[email protected]...>In general the commit looks good but I would like to improve the comment for the management flags (see below).
Quoted 11 lines
src/openvpn/options.h +0
-2@@ -438,10 +438,12 @@ struct optionsconst char *management_client_user;const char *management_client_group; -/* Mask of MF_ values of manage.h */ -unsigned int management_flags;const char *management_certificate;#endif Quoted 8 lines
src/openvpn/options.h struct options · line 446
Quoted 4 lines
src/openvpn/options.h +4
-0+/* Mask of MF_ values of manage.h +* Always available to simplify options.c +*/ +unsigned int management_flags;This feels a bit odd as a comment. I would expect this in the commit or something like "even available when management support is not available" but this comment feels a bit too "temporary".
Quoted 5 lines
How is this "temporary"? It does not describe the change, it actually states why this is handled specially. Your proposal just drops the justification, then the comment becomes useless IMHO.
Would you prefer "Always available to simplify option verification code"?
Quoted 8 lines
I feel this because it is always available to avoid ifdefs and therefore to simplify
options.cbut the information that ifdefs are the alternative is not obvious from the comment or code alone. We have a lot of other variables that are always available but are only used if certain compile options are used. So I feel this comment is temporary because it basically is from the history that here in this case we had ifdefs, so we added here now a comment that there now no longer ifdefs. But in general without the historical context the comment feels odd to me.
I don't have a strong enough opinion about this to argue more about it. Gert, feel free to take Arne's ack and just remove the additional comment line I added.
Regards,
Signature · 1 line
Frank Lichtenheld
The ACK from Arne is not on the list, but it's in the quote from Frank, so I can say "I have seen it" (and since the discussion went on about a comment line, it's not a fake :-) ). I have removed that comment line per discussion on IRC.
Tested by compiling normally and with --disable-management, and asking for a GHA test run.
Your patch has been applied to the master branch.
commit ff7d7989e007a8c66fba438a257c1b85e8bcca69 (master) commit c8b131e5eb174a2c81a29a0b7eab5110e2e3ca19 (release/2.6)
Author: Frank Lichtenheld Date: Sun Nov 27 15:25:06 2022 +0100
options: Always define options->management_flags
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25554.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering