listen setfib=X

This commit is contained in:
Igor Sysoev 2010-07-05 13:49:16 +00:00
parent 7d9ed15393
commit cec9b84e05
6 changed files with 74 additions and 0 deletions

View file

@ -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

View file

@ -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;

View file

@ -69,6 +69,9 @@ struct ngx_listening_s {
char *accept_filter;
#endif
#endif
#if (NGX_HAVE_SETFIB)
int setfib;
#endif
};

View file

@ -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;
}

View file

@ -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;

View file

@ -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;