Skip to content

sapi/fpm: adding listen.rtable option for OpenBSD. #11890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sapi/fpm/fpm/fpm_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ static const struct ini_value_parser_s ini_fpm_pool_options[] = {
{ "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
#ifdef SO_SETFIB
{ "listen.setfib", &fpm_conf_set_integer, WPO(listen_setfib) },
#endif
#ifdef SO_RTABLE
{ "listen.rtable", &fpm_conf_set_integer, WPO(listen_rtable) },
#endif
{ "process.priority", &fpm_conf_set_integer, WPO(process_priority) },
{ "process.dumpable", &fpm_conf_set_boolean, WPO(process_dumpable) },
Expand Down Expand Up @@ -627,6 +630,9 @@ static void *fpm_worker_pool_config_alloc(void)
#ifdef SO_SETFIB
wp->config->listen_setfib = -1;
#endif
#ifdef SO_RTABLE
wp->config->listen_rtable = -1;
#endif

if (!fpm_worker_all_pools) {
fpm_worker_all_pools = wp;
Expand Down Expand Up @@ -1764,6 +1770,9 @@ static void fpm_conf_dump(void)
zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients));
#ifdef SO_SETFIB
zlog(ZLOG_NOTICE, "\tlisten.setfib = %d", wp->config->listen_setfib);
#endif
#ifdef SO_RTABLE
zlog(ZLOG_NOTICE, "\tlisten.rtable = %d", wp->config->listen_rtable);
#endif
if (wp->config->process_priority == 64) {
zlog(ZLOG_NOTICE, "\tprocess.priority = undefined");
Expand Down
3 changes: 3 additions & 0 deletions sapi/fpm/fpm/fpm_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ struct fpm_worker_pool_config_s {
#ifdef SO_SETFIB
int listen_setfib;
#endif
#ifdef SO_RTABLE
int listen_rtable;
#endif
};

struct ini_value_parser_s {
Expand Down
7 changes: 7 additions & 0 deletions sapi/fpm/fpm/fpm_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
}
}
#endif
#ifdef SO_RTABLE
if (-1 < wp->config->listen_rtable) {
if (0 > setsockopt(sock, SOL_SOCKET, SO_RTABLE, &wp->config->listen_rtable, sizeof(wp->config->listen_rtable))) {
zlog(ZLOG_WARNING, "failed to change socket SO_RTABLE attribute");
}
}
#endif

return sock;
}
Expand Down
4 changes: 4 additions & 0 deletions sapi/fpm/www.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ listen = 127.0.0.1:9000
; Default Value: -1
;listen.setfib = 1

; Set the associated the route table. OpenBSD only
; Default Value: -1
;listen.rtable = 1

; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
Expand Down