Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto/os/features9
-rw-r--r--src/core/ngx_connection.c36
-rw-r--r--src/core/ngx_connection.h3
-rw-r--r--src/http/ngx_http.c4
-rw-r--r--src/http/ngx_http_core_module.c19
-rw-r--r--src/http/ngx_http_core_module.h3
6 files changed, 74 insertions, 0 deletions
diff --git a/auto/os/features b/auto/os/features
index 3d490255f..ecd8e7fb4 100644
--- a/auto/os/features
+++ b/auto/os/features
@@ -295,6 +295,15 @@ if [ $ngx_found != yes ]; then
fi
fi
+ngx_feature="SO_SETFIB"
+ngx_feature_name="NGX_HAVE_SETFIB"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/socket.h>"
+ngx_feature_path=
+ngx_feature_libs=
+ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_SETFIB, NULL, 4)"
+. auto/feature
+
if [ $NGX_FILE_AIO = YES ]; then
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 4a90b6120..c495edd52 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -74,6 +74,10 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
ls->rcvbuf = -1;
ls->sndbuf = -1;
+#if (NGX_HAVE_SETFIB)
+ ls->setfib = -1;
+#endif
+
return ls;
}
@@ -179,6 +183,25 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
ls[i].sndbuf = -1;
}
+#if 0
+ /* SO_SETFIB is currently a set only option */
+
+#if (NGX_HAVE_SETFIB)
+
+ if (getsockopt(ls[i].setfib, SOL_SOCKET, SO_SETFIB,
+ (void *) &ls[i].setfib, &olen)
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
+ "getsockopt(SO_SETFIB) %V failed, ignored",
+ &ls[i].addr_text);
+
+ ls[i].setfib = -1;
+ }
+
+#endif
+#endif
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
ngx_memzero(&af, sizeof(struct accept_filter_arg));
@@ -473,6 +496,19 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
}
}
+#if (NGX_HAVE_SETFIB)
+ if (ls[i].setfib != -1) {
+ if (setsockopt(ls[i].fd, SOL_SOCKET, SO_SETFIB,
+ (const void *) &ls[i].setfib, sizeof(int))
+ == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
+ "setsockopt(SO_SETFIB, %d) %V failed, ignored",
+ ls[i].setfib, &ls[i].addr_text);
+ }
+ }
+#endif
+
#if 0
if (1) {
int tcp_nodelay = 1;
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 1810daca0..3837fd255 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -69,6 +69,9 @@ struct ngx_listening_s {
char *accept_filter;
#endif
#endif
+#if (NGX_HAVE_SETFIB)
+ int setfib;
+#endif
};
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 84867887d..9f9294ce5 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1720,6 +1720,10 @@ ngx_http_add_listening(ngx_conf_t *cf, ngx_http_conf_addr_t *addr)
ls->ipv6only = addr->opt.ipv6only;
#endif
+#if (NGX_HAVE_SETFIB)
+ ls->setfib = addr->opt.setfib;
+#endif
+
return ls;
}
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 1654510be..0296d00bf 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -2992,6 +2992,9 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
lsopt.backlog = NGX_LISTEN_BACKLOG;
lsopt.rcvbuf = -1;
lsopt.sndbuf = -1;
+#if (NGX_HAVE_SETFIB)
+ lsopt.setfib = -1;
+#endif
lsopt.wildcard = 1;
(void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
@@ -3410,6 +3413,9 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
lsopt.backlog = NGX_LISTEN_BACKLOG;
lsopt.rcvbuf = -1;
lsopt.sndbuf = -1;
+#if (NGX_HAVE_SETFIB)
+ lsopt.setfib = -1;
+#endif
lsopt.wildcard = u.wildcard;
(void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
@@ -3430,6 +3436,19 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
continue;
}
+#if (NGX_HAVE_SETFIB)
+ if (ngx_strncmp(value[n].data, "setfib=", 7) == 0) {
+ lsopt.setfib = ngx_atoi(value[n].data + 7, value[n].len - 7);
+
+ if (lsopt.setfib == NGX_ERROR || lsopt.setfib == 0) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid setfib \"%V\"", &value[n]);
+ return NGX_CONF_ERROR;
+ }
+
+ continue;
+ }
+#endif
if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {
lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);
lsopt.set = 1;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 2f49202c3..82c120845 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -71,6 +71,9 @@ typedef struct {
int backlog;
int rcvbuf;
int sndbuf;
+#if (NGX_HAVE_SETFIB)
+ int setfib;
+#endif
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
char *accept_filter;