1 [PATCH] fix in6_pktinfo build issue on Linux
3 From http://roy.marples.name/projects/dhcpcd/vpatch?from=e05490e2d12d03b1&to=c32714545158ca83
5 Give up on _BSD_SOURCE and use _GNU_SOURCE for Linux. This is requires for
6 newer Linux headers as there is no easy way to get at the in6_pktinfo
7 structure, so we have to fallback to the glibc variant which requires
8 _GNU_SOURCE being set. This does have the advantage of no longer sprinkling
9 _GNU_SOURCE around and no longer having to cast ipi.ipi_ifindex but may
10 break compile on older Linux.
12 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
16 ==================================================================
20 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 -/* Needed define to get at getline for glibc and FreeBSD */
31 # include <mach/mach_time.h>
32 # include <mach/kern_return.h>
37 ==================================================================
41 echo "There is no fork"
42 echo "CPPFLAGS+= -DTHERE_IS_NO_FORK" >>$CONFIG_MK
48 echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
49 echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
52 - echo "CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=700" >>$CONFIG_MK
53 + echo "CPPFLAGS+= -D_GNU_SOURCE" >>$CONFIG_MK
54 # Large File Support, should be fine for 32-bit systems.
55 # But if this is the case, why is it not set by default?
56 echo "CPPFLAGS+= -D_FILE_OFFSET_BITS=64" >>$CONFIG_MK
57 echo "CPPFLAGS+= -D_LARGEFILE_SOURCE" >>$CONFIG_MK
58 echo "CPPFLAGS+= -D_LARGEFILE64_SOURCE" >>$CONFIG_MK
60 - echo "CPPFLAGS+= -D_DEFAULT_SOURCE" >>$CONFIG_MK
61 echo "DHCPCD_SRCS+= if-linux.c" >>$CONFIG_MK
62 # for RTM_NEWADDR and friends
63 - echo "#include <asm/types.h> /* fix broken headers */" >>$CONFIG_H
64 - echo "#include <linux/rtnetlink.h>" >>$CONFIG_H
65 + echo "#include <asm/types.h> /* fix broken headers */" >>$CONFIG_H
66 + echo "#include <linux/rtnetlink.h>" >>$CONFIG_H
69 echo "CPPFLAGS+= -D__EXT" >>$CONFIG_MK
70 echo "DHCPCD_SRCS+= if-bsd.c" >>$CONFIG_MK
75 if [ -z "$GETLINE" ]; then
76 printf "Testing for getline ... "
83 getline(&buf, &n, stdin);
86 ==================================================================
89 @@ -1149,11 +1149,11 @@
91 cm->cmsg_level = IPPROTO_IPV6;
92 cm->cmsg_type = IPV6_PKTINFO;
93 cm->cmsg_len = CMSG_LEN(sizeof(pi));
94 memset(&pi, 0, sizeof(pi));
95 - pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
96 + pi.ipi6_ifindex = ifp->index;
97 memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
99 if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
100 logger(ifp->ctx, LOG_ERR,
101 "%s: %s: sendmsg: %m", ifp->name, __func__);
104 ==================================================================
108 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
109 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
113 -/* Needed for ppoll(2) */
116 #include <sys/time.h>
123 ==================================================================
133 #include <netinet/in.h>
135 -#if defined(__linux__) && defined(__GLIBC__)
136 -# define _LINUX_IN6_H
137 -# include <linux/ipv6.h>
143 #define ALLROUTERS "ff02::2"
146 ==================================================================
149 @@ -293,11 +293,11 @@
151 cm->cmsg_level = IPPROTO_IPV6;
152 cm->cmsg_type = IPV6_PKTINFO;
153 cm->cmsg_len = CMSG_LEN(sizeof(pi));
154 memset(&pi, 0, sizeof(pi));
155 - pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
156 + pi.ipi6_ifindex = ifp->index;
157 memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
159 logger(ifp->ctx, LOG_DEBUG,
160 "%s: sending Router Solicitation", ifp->name);
161 if (sendmsg(ctx->nd_fd, &ctx->sndhdr, 0) == -1) {