Ticket #287: nginx-1.13.6.2-listen-transparent.patch
| File nginx-1.13.6.2-listen-transparent.patch, 9.3 KB (added by , 8 years ago) |
|---|
-
bundle/nginx-1.13.6/src/core/ngx_connection.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/core/ngx_connection.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/core/ngx_connection.c
old new 501 501 } 502 502 #endif 503 503 504 #if (NGX_HAVE_TRANSPARENT_PROXY && __linux) 505 /* Don't need to set on FreeBSD or OSX */ 506 507 if (ls[i].transparent && !ngx_test_config) { 508 509 int transparent = 1; 510 511 switch (ls[i].sockaddr->sa_family) { 512 513 case AF_INET: 514 515 if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT, 516 (const void *) &transparent, sizeof(int)) == -1) 517 { 518 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, 519 "setsockopt(IP_TRANSPARENT) %V failed", 520 &ls[i].addr_text); 521 return NGX_ERROR; 522 } 523 524 break; 525 526 #if (NGX_HAVE_INET6) 527 528 case AF_INET6: 529 530 if (setsockopt(s, IPPROTO_IPV6, IPV6_TRANSPARENT, 531 (const void *) &transparent, sizeof(int)) == -1) 532 { 533 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, 534 "setsockopt(IPV6_TRANSPARENT) %V failed", 535 &ls[i].addr_text); 536 return NGX_ERROR; 537 } 538 539 break; 540 541 #endif /* NGX_HAVE_INET6 */ 542 543 } 544 } 545 #endif /* NGX_HAVE_TRANSPARENT_PROXY */ 546 504 547 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) 505 548 506 549 if (ls[i].sockaddr->sa_family == AF_INET6) { -
bundle/nginx-1.13.6/src/core/ngx_connection.h
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/core/ngx_connection.h ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/core/ngx_connection.h
old new 71 71 #endif 72 72 unsigned reuseport:1; 73 73 unsigned add_reuseport:1; 74 75 #if (NGX_HAVE_TRANSPARENT_PROXY) 76 unsigned transparent:1; 77 #endif 74 78 unsigned keepalive:2; 75 79 76 80 unsigned deferred_accept:1; -
bundle/nginx-1.13.6/src/event/ngx_event_accept.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/event/ngx_event_accept.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/event/ngx_event_accept.c
old new 232 232 c->local_sockaddr = ls->sockaddr; 233 233 c->local_socklen = ls->socklen; 234 234 235 #if (NGX_HAVE_TRANSPARENT_PROXY) 236 if (ls->transparent) { 237 c->local_sockaddr = NULL; 238 c->local_socklen = 0; 239 } 240 #endif 241 235 242 #if (NGX_HAVE_UNIX_DOMAIN) 236 243 if (c->sockaddr->sa_family == AF_UNIX) { 237 244 c->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; -
bundle/nginx-1.13.6/src/http/ngx_http.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/http/ngx_http.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/http/ngx_http.c
old new 1776 1776 ls->reuseport = addr->opt.reuseport; 1777 1777 #endif 1778 1778 1779 #if (NGX_HAVE_TRANSPARENT_PROXY) 1780 ls->transparent = addr->opt.transparent; 1781 #endif 1782 1779 1783 return ls; 1780 1784 } 1781 1785 -
bundle/nginx-1.13.6/src/http/ngx_http_core_module.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/http/ngx_http_core_module.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/http/ngx_http_core_module.c
old new 3952 3952 continue; 3953 3953 } 3954 3954 3955 if (ngx_strcmp(value[n].data, "transparent") == 0) { 3956 #if (NGX_HAVE_TRANSPARENT_PROXY) 3957 lsopt.transparent = 1; 3958 continue; 3959 #else 3960 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3961 "transparent is not supported " 3962 "on this platform"); 3963 return NGX_CONF_ERROR; 3964 #endif 3965 } 3966 3955 3967 if (ngx_strcmp(value[n].data, "ssl") == 0) { 3956 3968 #if (NGX_HTTP_SSL) 3957 3969 lsopt.ssl = 1; -
bundle/nginx-1.13.6/src/http/ngx_http_core_module.h
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/http/ngx_http_core_module.h ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/http/ngx_http_core_module.h
old new 79 79 #endif 80 80 unsigned deferred_accept:1; 81 81 unsigned reuseport:1; 82 #if (NGX_HAVE_TRANSPARENT_PROXY) 83 unsigned transparent:1; 84 #endif 82 85 unsigned so_keepalive:2; 83 86 unsigned proxy_protocol:1; 84 87 -
bundle/nginx-1.13.6/src/http/ngx_http_request.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/http/ngx_http_request.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/http/ngx_http_request.c
old new 226 226 227 227 port = c->listening->servers; 228 228 229 if (port->naddrs > 1) { 229 if (port->naddrs > 1 230 #if (NGX_HAVE_TRANSPARENT_PROXY) 231 || c->listening->transparent 232 #endif 233 ) { 230 234 231 235 /* 232 236 * there are several addresses on this port and one of them -
bundle/nginx-1.13.6/src/stream/ngx_stream.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/stream/ngx_stream.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/stream/ngx_stream.c
old new 513 513 #if (NGX_HAVE_REUSEPORT) 514 514 ls->reuseport = addr[i].opt.reuseport; 515 515 #endif 516 #if (NGX_HAVE_TRANSPARENT_PROXY) 517 ls->transparent = addr[i].opt.transparent; 518 #endif 516 519 517 520 stport = ngx_palloc(cf->pool, sizeof(ngx_stream_port_t)); 518 521 if (stport == NULL) { -
bundle/nginx-1.13.6/src/stream/ngx_stream_core_module.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/stream/ngx_stream_core_module.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/stream/ngx_stream_core_module.c
old new 732 732 continue; 733 733 } 734 734 735 if (ngx_strcmp(value[i].data, "transparent") == 0) { 736 #if (NGX_HAVE_TRANSPARENT_PROXY) 737 ls->transparent = 1; 738 continue; 739 #else 740 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 741 "transparent is not supported " 742 "on this platform"); 743 return NGX_CONF_ERROR; 744 #endif 745 } 746 735 747 if (ngx_strcmp(value[i].data, "ssl") == 0) { 736 748 #if (NGX_STREAM_SSL) 737 749 ls->ssl = 1; -
bundle/nginx-1.13.6/src/stream/ngx_stream.h
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/stream/ngx_stream.h ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/stream/ngx_stream.h
old new 55 55 unsigned ipv6only:1; 56 56 #endif 57 57 unsigned reuseport:1; 58 #if (NGX_HAVE_TRANSPARENT_PROXY) 59 unsigned transparent:1; 60 #endif 58 61 unsigned so_keepalive:2; 59 62 unsigned proxy_protocol:1; 60 63 #if (NGX_HAVE_KEEPALIVE_TUNABLE) -
bundle/nginx-1.13.6/src/stream/ngx_stream_handler.c
diff -ru ../openresty-1.13.6.2-patched/bundle/nginx-1.13.6/src/stream/ngx_stream_handler.c ../openresty-1.13.6.2-modified/bundle/nginx-1.13.6/src/stream/ngx_stream_handler.c
old new 42 42 43 43 port = c->listening->servers; 44 44 45 if (port->naddrs > 1) { 45 if (port->naddrs > 1 46 #if (NGX_HAVE_TRANSPARENT_PROXY) 47 || c->listening->transparent 48 #endif 49 ) { 46 50 47 51 /* 48 52 * There are several addresses on this port and one of them
