From 37324d912f22c755926debde5b7305211c7e7160 Mon Sep 17 00:00:00 2001
From: 10077240
Date: Tue, 23 Oct 2018 15:18:03 +0800
Subject: [PATCH] FreeBSD define IP_BINDANY in freebsd/netinet/in.h Fstack
should only support IP_BINDANY.
---
.../src/event/ngx_event_connect.c | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/app/nginx-1.11.10/src/event/ngx_event_connect.c b/app/nginx-1.11.10/src/event/ngx_event_connect.c
index 64c0ea1e7..bc932a093 100644
--- a/app/nginx-1.11.10/src/event/ngx_event_connect.c
+++ b/app/nginx-1.11.10/src/event/ngx_event_connect.c
@@ -360,25 +360,28 @@ ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s)
case AF_INET:
-#if defined(IP_TRANSPARENT)
-
- if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT,
- (const void *) &value, sizeof(int)) == -1)
+#if defined(NGX_HAVE_FSTACK)
+ /****
+ FreeBSD define IP_BINDANY in freebsd/netinet/in.h
+ Fstack should only support IP_BINDANY.
+ ****/
+ #define IP_BINDANY 24
+ if (setsockopt(s, IPPROTO_IP, IP_BINDANY,
+ (const void *) &value, sizeof(int)) == -1)
{
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
- "setsockopt(IP_TRANSPARENT) failed");
- return NGX_ERROR;
- }
-
-#elif defined(IP_BINDANY)
-
- if (setsockopt(s, IPPROTO_IP, IP_BINDANY,
- (const void *) &value, sizeof(int)) == -1)
- {
- ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
- "setsockopt(IP_BINDANY) failed");
+ "setsockopt(IP_BINDANY) failed");
return NGX_ERROR;
}
+
+#elif defined(IP_TRANSPARENT)
+ if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT,
+ (const void *) &value, sizeof(int)) == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
+ "setsockopt(IP_TRANSPARENT) failed");
+ return NGX_ERROR;
+ }
#endif