Skip to content

Commit 91fd961

Browse files
schwabecron2
authored andcommitted
Change type of option flag from unsigned int to uint64_t
We currently use all 32 bits of the unsigned int for option classes. While we can probably can retire 2-3 of the existing options, at some point we will hit the limit again. Instead of fully rewriting this logic to use a different approach or structure, changing the type from unsigned int to uint64_t seem to be a lot less intrusive approach. Change-Id: I8ca07e2bbb5de229204191d61e90f084a58969af Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Frank Lichtenheld <frank@lichtenheld.com> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1583 Message-Id: <20260325124338.123477-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36266.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent 5933af1 commit 91fd961

14 files changed

Lines changed: 77 additions & 77 deletions

File tree

src/openvpn/init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ do_deferred_options_part2(struct context *c)
23392339
}
23402340

23412341
bool
2342-
do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
2342+
do_up(struct context *c, bool pulled_options, uint64_t option_types_found)
23432343
{
23442344
int error_flags = 0;
23452345
if (!c->c2.do_up_ran)
@@ -2474,7 +2474,7 @@ do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
24742474
}
24752475

24762476
bool
2477-
do_update(struct context *c, unsigned int option_types_found)
2477+
do_update(struct context *c, uint64_t option_types_found)
24782478
{
24792479
/* Not necessary since to receive the update the openvpn
24802480
* instance must be up and running but just in case
@@ -2588,7 +2588,7 @@ do_deferred_p2p_ncp(struct context *c)
25882588
}
25892589

25902590
bool
2591-
do_deferred_options(struct context *c, const unsigned int found, const bool is_update)
2591+
do_deferred_options(struct context *c, const uint64_t found, const bool is_update)
25922592
{
25932593
if (found & OPT_P_MESSAGES)
25942594
{
@@ -4209,7 +4209,7 @@ open_plugins(struct context *c, const bool import_options, int init_point)
42094209
int i;
42104210
for (i = 0; i < config.n; ++i)
42114211
{
4212-
unsigned int option_types_found = 0;
4212+
uint64_t option_types_found = 0;
42134213
if (config.list[i] && config.list[i]->value)
42144214
{
42154215
options_string_import(

src/openvpn/init.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void do_test_crypto(struct context *o);
7575

7676
void context_gc_free(struct context *c);
7777

78-
bool do_up(struct context *c, bool pulled_options, unsigned int option_types_found);
78+
bool do_up(struct context *c, bool pulled_options, uint64_t option_types_found);
7979

8080
/**
8181
* @brief A simplified version of the do_up() function. This function is called
@@ -87,7 +87,7 @@ bool do_up(struct context *c, bool pulled_options, unsigned int option_types_fou
8787
* @return true on success.
8888
* @return false on error.
8989
*/
90-
bool do_update(struct context *c, unsigned int option_types_found);
90+
bool do_update(struct context *c, uint64_t option_types_found);
9191

9292
unsigned int pull_permission_mask(const struct context *c);
9393

@@ -99,7 +99,7 @@ void reset_coarse_timers(struct context *c);
9999
* Handle non-tun-related pulled options.
100100
* Set `is_update` param to true to skip NCP check.
101101
*/
102-
bool do_deferred_options(struct context *c, const unsigned int found, const bool is_update);
102+
bool do_deferred_options(struct context *c, const uint64_t found, const bool is_update);
103103

104104
void inherit_context_child(struct context *dest, const struct context *src,
105105
struct link_socket *sock);

src/openvpn/multi.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ multi_set_virtual_addr_env(struct multi_instance *mi)
16191619
*/
16201620
static void
16211621
multi_client_connect_post(struct multi_context *m, struct multi_instance *mi, const char *dc_file,
1622-
unsigned int *option_types_found)
1622+
uint64_t *option_types_found)
16231623
{
16241624
/* Did script generate a dynamic config file? */
16251625
if (platform_test_file(dc_file))
@@ -1645,7 +1645,7 @@ multi_client_connect_post(struct multi_context *m, struct multi_instance *mi, co
16451645
*/
16461646
static void
16471647
multi_client_connect_post_plugin(struct multi_context *m, struct multi_instance *mi,
1648-
const struct plugin_return *pr, unsigned int *option_types_found)
1648+
const struct plugin_return *pr, uint64_t *option_types_found)
16491649
{
16501650
struct plugin_return config;
16511651

@@ -1684,7 +1684,7 @@ multi_client_connect_post_plugin(struct multi_context *m, struct multi_instance
16841684
*/
16851685
enum client_connect_return
16861686
multi_client_connect_mda(struct multi_context *m, struct multi_instance *mi, bool deferred,
1687-
unsigned int *option_types_found)
1687+
uint64_t *option_types_found)
16881688
{
16891689
/* We never return CC_RET_DEFERRED */
16901690
ASSERT(!deferred);
@@ -2055,7 +2055,7 @@ ccs_gen_config_file(struct multi_instance *mi)
20552055

20562056
static enum client_connect_return
20572057
multi_client_connect_call_plugin_v1(struct multi_context *m, struct multi_instance *mi,
2058-
bool deferred, unsigned int *option_types_found)
2058+
bool deferred, uint64_t *option_types_found)
20592059
{
20602060
enum client_connect_return ret = CC_RET_SKIPPED;
20612061
#ifdef ENABLE_PLUGIN
@@ -2145,7 +2145,7 @@ multi_client_connect_call_plugin_v1(struct multi_context *m, struct multi_instan
21452145

21462146
static enum client_connect_return
21472147
multi_client_connect_call_plugin_v2(struct multi_context *m, struct multi_instance *mi,
2148-
bool deferred, unsigned int *option_types_found)
2148+
bool deferred, uint64_t *option_types_found)
21492149
{
21502150
enum client_connect_return ret = CC_RET_SKIPPED;
21512151
#ifdef ENABLE_PLUGIN
@@ -2194,7 +2194,7 @@ multi_client_connect_call_plugin_v2(struct multi_context *m, struct multi_instan
21942194

21952195
static enum client_connect_return
21962196
multi_client_connect_script_deferred(struct multi_context *m, struct multi_instance *mi,
2197-
unsigned int *option_types_found)
2197+
uint64_t *option_types_found)
21982198
{
21992199
ASSERT(mi);
22002200
ASSERT(option_types_found);
@@ -2235,7 +2235,7 @@ multi_client_connect_script_deferred(struct multi_context *m, struct multi_insta
22352235
*/
22362236
static enum client_connect_return
22372237
multi_client_connect_call_script(struct multi_context *m, struct multi_instance *mi, bool deferred,
2238-
unsigned int *option_types_found)
2238+
uint64_t *option_types_found)
22392239
{
22402240
if (deferred)
22412241
{
@@ -2339,7 +2339,7 @@ multi_client_generate_tls_keys(struct context *c)
23392339

23402340
static void
23412341
multi_client_connect_late_setup(struct multi_context *m, struct multi_instance *mi,
2342-
const unsigned int option_types_found)
2342+
const uint64_t option_types_found)
23432343
{
23442344
ASSERT(m);
23452345
ASSERT(mi);
@@ -2497,7 +2497,7 @@ multi_client_connect_early_setup(struct multi_context *m, struct multi_instance
24972497
*/
24982498
static enum client_connect_return
24992499
multi_client_connect_compress_migrate(struct multi_context *m, struct multi_instance *mi,
2500-
bool deferred, unsigned int *option_types_found)
2500+
bool deferred, uint64_t *option_types_found)
25012501
{
25022502
#ifdef USE_COMP
25032503
struct options *o = &mi->context.options;
@@ -2529,7 +2529,7 @@ multi_client_connect_compress_migrate(struct multi_context *m, struct multi_inst
25292529
*/
25302530
static enum client_connect_return
25312531
multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *mi, bool deferred,
2532-
unsigned int *option_types_found)
2532+
uint64_t *option_types_found)
25332533
{
25342534
/* Since we never return a CC_RET_DEFERRED, this indicates a serious
25352535
* problem */
@@ -2580,7 +2580,7 @@ multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *
25802580

25812581
typedef enum client_connect_return (*multi_client_connect_handler)(
25822582
struct multi_context *m, struct multi_instance *mi, bool from_deferred,
2583-
unsigned int *option_types_found);
2583+
uint64_t *option_types_found);
25842584

25852585
static const multi_client_connect_handler client_connect_handlers[] = {
25862586
multi_client_connect_compress_migrate,
@@ -2678,7 +2678,7 @@ multi_connection_established(struct multi_context *m, struct multi_instance *mi)
26782678
bool from_deferred = (mi->context.c2.tls_multi->multi_state != CAS_PENDING);
26792679

26802680
int *cur_handler_index = &mi->client_connect_defer_state.cur_handler_index;
2681-
unsigned int *option_types_found = &mi->client_connect_defer_state.option_types_found;
2681+
uint64_t *option_types_found = &mi->client_connect_defer_state.option_types_found;
26822682

26832683
/* We are called for the first time */
26842684
if (!from_deferred)

src/openvpn/multi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct client_connect_defer_state
7373
int cur_handler_index;
7474
/* Remember which option classes where processed for delayed option
7575
* handling. */
76-
unsigned int option_types_found;
76+
uint64_t option_types_found;
7777

7878
/**
7979
* The temporary file name that contains the return status of the

src/openvpn/options.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,8 +4972,8 @@ atou(const char *str)
49724972
}
49734973

49744974
static bool
4975-
verify_permission(const char *name, const char *file, int line, const unsigned int type,
4976-
const unsigned int allowed, unsigned int *found, const msglvl_t msglevel,
4975+
verify_permission(const char *name, const char *file, int line, const uint64_t type,
4976+
const uint64_t allowed, uint64_t *found, const msglvl_t msglevel,
49774977
struct options *options, bool is_inline)
49784978
{
49794979
if (!(type & allowed))
@@ -5065,7 +5065,7 @@ msglevel_forward_compatible(struct options *options, const msglvl_t msglevel)
50655065
void
50665066
remove_option(struct context *c, struct options *options, char *p[], bool is_inline,
50675067
const char *file, int line, const msglvl_t msglevel,
5068-
const unsigned int permission_mask, unsigned int *option_types_found,
5068+
const uint64_t permission_mask, uint64_t *option_types_found,
50695069
struct env_set *es)
50705070
{
50715071
msglvl_t msglevel_fc = msglevel_forward_compatible(options, msglevel);
@@ -5385,7 +5385,7 @@ check_dns_option(struct options *options, char *p[], const msglvl_t msglevel, bo
53855385
void
53865386
update_option(struct context *c, struct options *options, char *p[], bool is_inline,
53875387
const char *file, int line, const int level, const msglvl_t msglevel,
5388-
const unsigned int permission_mask, unsigned int *option_types_found,
5388+
const uint64_t permission_mask, uint64_t *option_types_found,
53895389
struct env_set *es)
53905390
{
53915391
const bool pull_mode = BOOL_CAST(permission_mask & OPT_P_PULL_MODE);
@@ -5574,8 +5574,8 @@ key_is_external(const struct options *options)
55745574

55755575
void
55765576
add_option(struct options *options, char *p[], bool is_inline, const char *file, int line,
5577-
const int level, const msglvl_t msglevel, const unsigned int permission_mask,
5578-
unsigned int *option_types_found, struct env_set *es)
5577+
const int level, const msglvl_t msglevel, const uint64_t permission_mask,
5578+
uint64_t *option_types_found, struct env_set *es)
55795579
{
55805580
struct gc_arena gc = gc_new();
55815581
const bool pull_mode = BOOL_CAST(permission_mask & OPT_P_PULL_MODE);

src/openvpn/options.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ struct options
553553
bool client;
554554
bool pull; /* client pull of config options from server */
555555
int push_continuation;
556-
unsigned int push_option_types_found;
557-
unsigned int push_update_options_found; /* tracks which option types have been reset in current PUSH_UPDATE sequence */
556+
uint64_t push_option_types_found;
557+
uint64_t push_update_options_found; /* tracks which option types have been reset in current PUSH_UPDATE sequence */
558558
const char *auth_user_pass_file;
559559
bool auth_user_pass_file_inline;
560560
struct options_pre_connect *pre_connect;
@@ -808,7 +808,7 @@ struct pull_filter_list
808808

809809
void add_option(struct options *options, char *p[], bool is_inline, const char *file,
810810
int line, const int level, const msglvl_t msglevel,
811-
const unsigned int permission_mask, unsigned int *option_types_found,
811+
const uint64_t permission_mask, uint64_t *option_types_found,
812812
struct env_set *es);
813813

814814
/**
@@ -833,7 +833,7 @@ void add_option(struct options *options, char *p[], bool is_inline, const char *
833833
*/
834834
void remove_option(struct context *c, struct options *options, char *p[], bool is_inline,
835835
const char *file, int line, const msglvl_t msglevel,
836-
const unsigned int permission_mask, unsigned int *option_types_found,
836+
const uint64_t permission_mask, uint64_t *option_types_found,
837837
struct env_set *es);
838838

839839
/**
@@ -858,21 +858,21 @@ void remove_option(struct context *c, struct options *options, char *p[], bool i
858858
*/
859859
void update_option(struct context *c, struct options *options, char *p[], bool is_inline,
860860
const char *file, int line, const int level, const msglvl_t msglevel,
861-
const unsigned int permission_mask, unsigned int *option_types_found,
861+
const uint64_t permission_mask, uint64_t *option_types_found,
862862
struct env_set *es);
863863

864864
void parse_argv(struct options *options, const int argc, char *argv[], const msglvl_t msglevel,
865-
const unsigned int permission_mask, unsigned int *option_types_found,
865+
const uint64_t permission_mask, uint64_t *option_types_found,
866866
struct env_set *es);
867867

868868
void read_config_file(struct options *options, const char *file, int level, const char *top_file,
869869
const int top_line, const msglvl_t msglevel,
870-
const unsigned int permission_mask, unsigned int *option_types_found,
870+
const uint64_t permission_mask, uint64_t *option_types_found,
871871
struct env_set *es);
872872

873873
void read_config_string(const char *prefix, struct options *options, const char *config,
874-
const msglvl_t msglevel, const unsigned int permission_mask,
875-
unsigned int *option_types_found, struct env_set *es);
874+
const msglvl_t msglevel, const uint64_t permission_mask,
875+
uint64_t *option_types_found, struct env_set *es);
876876

877877
void notnull(const char *arg, const char *description);
878878

@@ -933,13 +933,13 @@ bool options_postprocess_pull(struct options *o, struct env_set *es);
933933
void pre_connect_restore(struct options *o, struct gc_arena *gc);
934934

935935
bool apply_push_options(struct context *c, struct options *options, struct buffer *buf,
936-
unsigned int permission_mask, unsigned int *option_types_found,
936+
uint64_t permission_mask, uint64_t *option_types_found,
937937
struct env_set *es, bool is_update);
938938

939939
void options_detach(struct options *o);
940940

941941
void options_server_import(struct options *o, const char *filename, msglvl_t msglevel,
942-
unsigned int permission_mask, unsigned int *option_types_found,
942+
uint64_t permission_mask, uint64_t *option_types_found,
943943
struct env_set *es);
944944

945945
void pre_pull_default(struct options *o);
@@ -972,7 +972,7 @@ bool auth_retry_set(const msglvl_t msglevel, const char *option);
972972
const char *auth_retry_print(void);
973973

974974
void options_string_import(struct options *options, const char *config, const msglvl_t msglevel,
975-
const unsigned int permission_mask, unsigned int *option_types_found,
975+
const uint64_t permission_mask, uint64_t *option_types_found,
976976
struct env_set *es);
977977

978978
bool key_is_external(const struct options *options);

src/openvpn/options_parse.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ check_inline_file_via_buf(struct buffer *multiline, char *p[], struct gc_arena *
346346
void
347347
read_config_file(struct options *options, const char *file, int level, const char *top_file,
348348
const int top_line, const msglvl_t msglevel,
349-
const unsigned int permission_mask, unsigned int *option_types_found,
349+
const uint64_t permission_mask, uint64_t *option_types_found,
350350
struct env_set *es)
351351
{
352352
const int max_recursive_levels = 10;
@@ -419,8 +419,8 @@ read_config_file(struct options *options, const char *file, int level, const cha
419419

420420
void
421421
read_config_string(const char *prefix, struct options *options, const char *config,
422-
const msglvl_t msglevel, const unsigned int permission_mask,
423-
unsigned int *option_types_found, struct env_set *es)
422+
const msglvl_t msglevel, const uint64_t permission_mask,
423+
uint64_t *option_types_found, struct env_set *es)
424424
{
425425
char line[OPTION_LINE_SIZE];
426426
struct buffer multiline;
@@ -448,7 +448,7 @@ read_config_string(const char *prefix, struct options *options, const char *conf
448448

449449
void
450450
parse_argv(struct options *options, const int argc, char *argv[], const msglvl_t msglevel,
451-
const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es)
451+
const uint64_t permission_mask, uint64_t *option_types_found, struct env_set *es)
452452
{
453453
/* usage message */
454454
if (argc <= 1)
@@ -510,7 +510,7 @@ parse_argv(struct options *options, const int argc, char *argv[], const msglvl_t
510510

511511
bool
512512
apply_push_options(struct context *c, struct options *options, struct buffer *buf,
513-
unsigned int permission_mask, unsigned int *option_types_found,
513+
uint64_t permission_mask, uint64_t *option_types_found,
514514
struct env_set *es, bool is_update)
515515
{
516516
char line[OPTION_PARM_SIZE];
@@ -523,7 +523,7 @@ apply_push_options(struct context *c, struct options *options, struct buffer *bu
523523
char *p[MAX_PARMS + 1];
524524
CLEAR(p);
525525
++line_num;
526-
unsigned int push_update_option_flags = 0;
526+
uint64_t push_update_option_flags = 0;
527527
int i = 0;
528528

529529
/* skip leading spaces matching the behaviour of parse_line */
@@ -578,7 +578,7 @@ apply_push_options(struct context *c, struct options *options, struct buffer *bu
578578

579579
void
580580
options_server_import(struct options *o, const char *filename, msglvl_t msglevel,
581-
unsigned int permission_mask, unsigned int *option_types_found,
581+
const uint64_t permission_mask, uint64_t *option_types_found,
582582
struct env_set *es)
583583
{
584584
msg(D_PUSH, "OPTIONS IMPORT: reading client specific options from: %s", filename);
@@ -588,7 +588,7 @@ options_server_import(struct options *o, const char *filename, msglvl_t msglevel
588588

589589
void
590590
options_string_import(struct options *options, const char *config, const msglvl_t msglevel,
591-
const unsigned int permission_mask, unsigned int *option_types_found,
591+
const uint64_t permission_mask, uint64_t *option_types_found,
592592
struct env_set *es)
593593
{
594594
read_config_string("[CONFIG-STRING]", options, config, msglevel, permission_mask,

src/openvpn/options_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static const char *updatable_options[] = { "block-ipv6", "block-outside-dns",
203203
"tun-mtu", "keepalive" };
204204

205205
bool
206-
check_push_update_option_flags(char *line, int *i, unsigned int *flags)
206+
check_push_update_option_flags(char *line, int *i, uint64_t *flags)
207207
{
208208
*flags = 0;
209209
bool opt_is_updatable = false;

src/openvpn/options_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ bool apply_pull_filter(const struct options *o, char *line);
106106
* - The `line` parameter is empty or `NULL`.
107107
* - The `?` flag is absent and the option is not updatable.
108108
*/
109-
bool check_push_update_option_flags(char *line, int *i, unsigned int *flags);
109+
bool check_push_update_option_flags(char *line, int *i, uint64_t *flags);
110110

111111
#endif /* ifndef OPTIONS_UTIL_H_ */

0 commit comments

Comments
 (0)