HAVE_SO_BINDTODEVICE referenced before it has a chance to be defined
name: HAVE_SO_BINDTODEVICE referenced before it has a chance to be defined
Describe the bug
In includes/osdep.h, HAVE_SO_BINDTODEVICE
is referenced on line 152 in the following conditional:
#if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \
defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || \
defined (USE_LPF_SEND) || \
(defined (USE_SOCKET_SEND) && defined (HAVE_SO_BINDTODEVICE))
# define USE_SOCKET_FALLBACK
# define USE_FALLBACK
#endif
However, it might not get defined until line 267, as follows:
#if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
# define HAVE_SO_BINDTODEVICE
#endif
Therefore, if USE_SOCKET_SEND
is defined, it is possible that USE_SOCKET_FALLBACK
and USE_FALLBACK
will not get defined, even though they should, simply because HAVE_SO_BINDTODEVICE
is referenced before it has had a chance to get defined.
To Reproduce
Steps to reproduce the behavior:
- Add a
#pragma message()
line inside the first#if
block mentioned above (e.g., at line 153 of includes/osdep.h) so that the preprocessor will print the message if it enters the block - Compile isc-dhcp on a system which defines
SO_BINDTODEVICE
(e.g., Debian Stretch), while also definingUSE_SOCKETS
(e.g., via the--enable-use-sockets
configure flag) - Note that the message does not print, although it should
Expected behavior
HAVE_SO_BINDTODEVICE
should have an opportunity to be defined before it is referenced
Environment:
- ISC DHCP version: All versions since commit d758ad8c (pre-version 4.0.0)
- OS: Debian Jessie/Stretch, most likely many other Linux flavors
- Which features were compiled in:
USE_SOCKETS
Describe the solution you'd like
Reorder the file includes/osdep.h to ensure HAVE_SO_BINDTODEVICE
has a chance to be defined before it is referenced.