Skip to content

Commit 7533304

Browse files
authored
Merge pull request F-Stack#292 from jinhao2/master
fstack only support IP_BINDANY, not support IP_TRANSPARENT.
2 parents 5f03949 + 98d67ca commit 7533304

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

app/nginx-1.11.10/src/event/ngx_event_connect.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -360,25 +360,28 @@ ngx_event_connect_set_transparent(ngx_peer_connection_t *pc, ngx_socket_t s)
360360

361361
case AF_INET:
362362

363-
#if defined(IP_TRANSPARENT)
364-
365-
if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT,
366-
(const void *) &value, sizeof(int)) == -1)
367-
{
368-
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
369-
"setsockopt(IP_TRANSPARENT) failed");
370-
return NGX_ERROR;
371-
}
372-
373-
#elif defined(IP_BINDANY)
374-
375-
if (setsockopt(s, IPPROTO_IP, IP_BINDANY,
376-
(const void *) &value, sizeof(int)) == -1)
363+
#if defined(NGX_HAVE_FSTACK)
364+
/****
365+
FreeBSD define IP_BINDANY in freebsd/netinet/in.h
366+
Fstack should only support IP_BINDANY.
367+
****/
368+
#define IP_BINDANY 24
369+
if (setsockopt(s, IPPROTO_IP, IP_BINDANY,
370+
(const void *) &value, sizeof(int)) == -1)
377371
{
378372
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
379-
"setsockopt(IP_BINDANY) failed");
373+
"setsockopt(IP_BINDANY) failed");
380374
return NGX_ERROR;
381375
}
376+
377+
#elif defined(IP_TRANSPARENT)
378+
if (setsockopt(s, IPPROTO_IP, IP_TRANSPARENT,
379+
(const void *) &value, sizeof(int)) == -1)
380+
{
381+
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
382+
"setsockopt(IP_TRANSPARENT) failed");
383+
return NGX_ERROR;
384+
}
382385

383386
#endif
384387

0 commit comments

Comments
 (0)