diff auto/unix @ 6980:dbb0c854e308

Set UDP datagram source address (ticket #1239). Previously, the source IP address of a response UDP datagram could differ from the original datagram destination address. This could happen if the server UDP socket is bound to a wildcard address and the network interface chosen to output the response packet has a different default address than the destination address of the original packet. For example, if two addresses from the same network are configured on an interface. Now source address is set explicitly if a response is sent for a server UDP socket bound to a wildcard address.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 11 Apr 2017 16:41:53 +0300
parents a6d116645c51
children c1524829af3d
line wrap: on
line diff
--- a/auto/unix
+++ b/auto/unix
@@ -394,6 +394,19 @@ ngx_feature_test="setsockopt(0, IPPROTO_
 . auto/feature
 
 
+# BSD way to set IPv4 datagram source address
+
+ngx_feature="IP_SENDSRCADDR"
+ngx_feature_name="NGX_HAVE_IP_SENDSRCADDR"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/socket.h>
+                  #include <netinet/in.h>"
+ngx_feature_path=
+ngx_feature_libs=
+ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_SENDSRCADDR, NULL, 0)"
+. auto/feature
+
+
 # Linux way to get IPv4 datagram destination address
 
 ngx_feature="IP_PKTINFO"