Ticket #287: nginx-1.12.1-ip_transparent.patch

File nginx-1.12.1-ip_transparent.patch, 3.0 KB (added by stintel@…, 9 years ago)

Updated patch that applies cleanly against nginx 1.12.1

  • src/core/ngx_connection.c

    a b ngx_open_listening_sockets(ngx_cycle_t *  
    497497            }
    498498#endif
    499499
     500#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     501
     502            if (ls[i].transparent) {
     503                int  transparent;
     504
     505                transparent = (ls[i].transparent == 1);
     506
     507                if (setsockopt(s, SOL_IP, IP_TRANSPARENT,
     508                               (const void *) &transparent, sizeof(int))
     509                    == -1)
     510                {
     511                    ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
     512                                  "setsockopt(IP_TRANSPARENT) for %V failed, "
     513                                  "ignored",
     514                                  &ls[i].addr_text);
     515                }
     516            }
     517#endif
     518
    500519#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
    501520
    502521            if (ls[i].sockaddr->sa_family == AF_INET6) {
  • src/core/ngx_connection.h

    a b struct ngx_listening_s {  
    8787    int                 fastopen;
    8888#endif
    8989
     90#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     91    unsigned            transparent:1;
     92#endif
     93
    9094};
    9195
    9296
  • src/http/ngx_http.c

    a b ngx_http_add_listening(ngx_conf_t *cf, n  
    17451745    ls->sndbuf = addr->opt.sndbuf;
    17461746
    17471747    ls->keepalive = addr->opt.so_keepalive;
     1748
     1749#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     1750    ls->transparent = addr->opt.transparent;
     1751#endif
     1752
    17481753#if (NGX_HAVE_KEEPALIVE_TUNABLE)
    17491754    ls->keepidle = addr->opt.tcp_keepidle;
    17501755    ls->keepintvl = addr->opt.tcp_keepintvl;
  • src/http/ngx_http_core_module.c

    a b ngx_http_core_listen(ngx_conf_t *cf, ngx  
    41014101            continue;
    41024102        }
    41034103
     4104        if (ngx_strcmp(value[n].data, "transparent") == 0) {
     4105#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     4106            lsopt.transparent = 1;
     4107#else
     4108            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
     4109                               "transparent mode is not supported "
     4110                               "on this platform, ignored",
     4111                               &value[n]);
     4112#endif
     4113            continue;
     4114        }
     4115
    41044116        if (ngx_strncmp(value[n].data, "ipv6only=o", 10) == 0) {
    41054117#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
    41064118            struct sockaddr  *sa;
  • src/http/ngx_http_core_module.h

    a b typedef struct {  
    8181    unsigned                   reuseport:1;
    8282    unsigned                   so_keepalive:2;
    8383    unsigned                   proxy_protocol:1;
     84#if (NGX_HAVE_TRANSPARENT && defined IP_TRANSPARENT)
     85    unsigned                   transparent:1;
     86#endif
    8487
    8588    int                        backlog;
    8689    int                        rcvbuf;
  • auto/unix

    a b if [ $ngx_found = no ]; then  
    300300fi
    301301
    302302
     303ngx_feature="IP_TRANSPARENT"
     304ngx_feature_name="NGX_HAVE_TRANSPARENT"
     305ngx_feature_run=no
     306ngx_feature_incs="#include <sys/socket.h>
     307                  #include <netinet/in.h>"
     308ngx_feature_path=
     309ngx_feature_libs=
     310ngx_feature_test="setsockopt(0, SOL_IP, IP_TRANSPARENT, NULL, 0)"
     311. auto/feature
     312
     313
    303314ngx_feature="SO_SETFIB"
    304315ngx_feature_name="NGX_HAVE_SETFIB"
    305316ngx_feature_run=no