Ticket #287: nginx-ip_transparent.patch

File nginx-ip_transparent.patch, 4.0 KB (added by Stijn Tintel, 13 years ago)
  • src/core/ngx_connection.c

    old new ngx_open_listening_sockets(ngx_cycle_t *  
    334334                return NGX_ERROR;
    335335            }
    336336
     337#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     338
     339            if (ls[i].transparent) {
     340                int  transparent;
     341
     342                transparent = (ls[i].transparent == 1);
     343
     344                if (setsockopt(s, SOL_IP, IP_TRANSPARENT,
     345                               (const void *) &transparent, sizeof(int))
     346                    == -1)
     347                {
     348                    ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
     349                                  "setsockopt(IP_TRANSPARENT) for %V failed, "
     350                                  "ignored",
     351                                  &ls[i].addr_text);
     352                }
     353            }
     354#endif
     355
    337356#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
    338357
    339358            if (ls[i].sockaddr->sa_family == AF_INET6 && ls[i].ipv6only) {
  • src/core/ngx_connection.h

    old new struct ngx_listening_s {  
    6262    unsigned            nonblocking:1;
    6363    unsigned            shared:1;    /* shared between threads or processes */
    6464    unsigned            addr_ntop:1;
     65#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     66    unsigned            transparent:1;
     67#endif
    6568
    6669#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
    6770    unsigned            ipv6only:2;
  • src/http/ngx_http.c

    old new ngx_http_add_listening(ngx_conf_t *cf, n  
    17691769    ls->sndbuf = addr->opt.sndbuf;
    17701770
    17711771    ls->keepalive = addr->opt.so_keepalive;
     1772
     1773#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     1774    ls->transparent = addr->opt.transparent;
     1775#endif
     1776
    17721777#if (NGX_HAVE_KEEPALIVE_TUNABLE)
    17731778    ls->keepidle = addr->opt.tcp_keepidle;
    17741779    ls->keepintvl = addr->opt.tcp_keepintvl;
  • src/http/ngx_http_core_module.c

    old new ngx_http_core_listen(ngx_conf_t *cf, ngx  
    39753975            continue;
    39763976        }
    39773977
     3978        if (ngx_strcmp(value[n].data, "transparent") == 0) {
     3979#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     3980            lsopt.transparent = 1;
     3981#else
     3982            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
     3983                               "transparent mode is not supported "
     3984                               "on this platform, ignored",
     3985                               &value[n]);
     3986#endif
     3987            continue;
     3988        }
     3989
    39783990        if (ngx_strncmp(value[n].data, "ipv6only=o", 10) == 0) {
    39793991#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
    39803992            struct sockaddr  *sa;
  • src/http/ngx_http_core_module.h

    old new typedef struct {  
    7272    unsigned                   default_server:1;
    7373    unsigned                   bind:1;
    7474    unsigned                   wildcard:1;
     75#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     76    unsigned                   transparent:1;
     77#endif
    7578#if (NGX_HTTP_SSL)
    7679    unsigned                   ssl:1;
    7780#endif
  • nginx-1.2.6

    old new if [ $ngx_found != yes ]; then  
    298298fi
    299299
    300300
     301ngx_feature="IP_TRANSPARENT"
     302ngx_feature_name="NGX_HAVE_TRANSPARENT"
     303ngx_feature_run=no
     304ngx_feature_incs="#include <sys/socket.h>
     305                  #include <netinet/in.h>"
     306ngx_feature_path=
     307ngx_feature_libs=
     308ngx_feature_test="setsockopt(0, SOL_IP, IP_TRANSPARENT, NULL, 0)"
     309. auto/feature
     310
     311
    301312ngx_feature="SO_SETFIB"
    302313ngx_feature_name="NGX_HAVE_SETFIB"
    303314ngx_feature_run=no