pfctl: Fix global state initialization

Close #4653.
This commit is contained in:
Sebastian Huber 2022-05-11 13:43:14 +02:00
parent d1b5468caa
commit e00ca96b98
4 changed files with 12 additions and 2 deletions

View File

@ -1351,10 +1351,17 @@ get_socket_domain(void)
return (sdom); return (sdom);
} }
#ifdef __rtems__
static int pfctl_s = -1;
#endif /* __rtems__ */
int int
get_query_socket(void) get_query_socket(void)
{ {
#ifndef __rtems__
static int s = -1; static int s = -1;
#else /* __rtems__ */
#define s pfctl_s
#endif /* __rtems__ */
if (s == -1) { if (s == -1) {
if ((s = socket(get_socket_domain(), SOCK_DGRAM, 0)) == -1) if ((s = socket(get_socket_domain(), SOCK_DGRAM, 0)) == -1)
@ -1362,6 +1369,9 @@ get_query_socket(void)
} }
return (s); return (s);
#ifdef __rtems__
#undef s
#endif /* __rtems__ */
} }
/* /*

View File

@ -35,6 +35,7 @@
#define parseport _bsd_pfctl_parseport #define parseport _bsd_pfctl_parseport
#define pfctl_cmdline_symset _bsd_pfctl_pfctl_cmdline_symset #define pfctl_cmdline_symset _bsd_pfctl_pfctl_cmdline_symset
#define pfctl_load_anchors _bsd_pfctl_pfctl_load_anchors #define pfctl_load_anchors _bsd_pfctl_pfctl_load_anchors
#define pfctl_s _bsd_pfctl_s
#define pfctlychar _bsd_pfctl_pfctlychar #define pfctlychar _bsd_pfctl_pfctlychar
#define pfctlydebug _bsd_pfctl_pfctlydebug #define pfctlydebug _bsd_pfctl_pfctlydebug
#define pfctlyerrflag _bsd_pfctl_pfctlyerrflag #define pfctlyerrflag _bsd_pfctl_pfctlyerrflag

View File

@ -4,8 +4,6 @@
/* pfctl_altq.c */ /* pfctl_altq.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char r2sbuf[][16]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char r2sbuf[][16]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int idx); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int idx);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct gen_sc lssc);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct gen_sc rtsc);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data if_map); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data if_map);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data qid_map); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data qid_map);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data queue_map); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data queue_map);

View File

@ -4,3 +4,4 @@
/* pfctl_parser.c */ /* pfctl_parser.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data isgroup_map); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct hsearch_data isgroup_map);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct node_host *iftab); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct node_host *iftab);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int pfctl_s);