summaryrefslogtreecommitdiffstats
path: root/package/dhcpcd/0001-fix-in6_pktinfo-build-issue-on-linux.patch
blob: 69919d6e375c5b41276002585ff0675155c6542a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[PATCH] fix in6_pktinfo build issue on Linux

From http://roy.marples.name/projects/dhcpcd/vpatch?from=e05490e2d12d03b1&to=c32714545158ca83

Give up on _BSD_SOURCE and use _GNU_SOURCE for Linux. This is requires for
newer Linux headers as there is no easy way to get at the in6_pktinfo
structure, so we have to fallback to the glibc variant which requires
_GNU_SOURCE being set.  This does have the advantage of no longer sprinkling
_GNU_SOURCE around and no longer having to cast ipi.ipi_ifindex but may
break compile on older Linux.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
--

Index: common.c
==================================================================
--- a/common.c
+++ b/common.c
@@ -23,15 +23,10 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
-/* Needed define to get at getline for glibc and FreeBSD */
-#ifndef _GNU_SOURCE
-#  define _GNU_SOURCE
-#endif
-
 #ifdef __APPLE__
 #  include <mach/mach_time.h>
 #  include <mach/kern_return.h>
 #endif
 

Index: configure
==================================================================
--- a/configure
+++ b/configure
@@ -358,27 +358,25 @@
 	echo "There is no fork"
 	echo "CPPFLAGS+=	-DTHERE_IS_NO_FORK" >>$CONFIG_MK
 fi
 
 case "$OS" in
-kfreebsd*)
+freebsd*|kfreebsd*)
 	echo "CPPFLAGS+=	-D_GNU_SOURCE" >>$CONFIG_MK
 	echo "DHCPCD_SRCS+=	if-bsd.c" >>$CONFIG_MK
 	;;
 linux*)
-	echo "CPPFLAGS+=	-D_BSD_SOURCE -D_XOPEN_SOURCE=700" >>$CONFIG_MK
+	echo "CPPFLAGS+=	-D_GNU_SOURCE" >>$CONFIG_MK
 	# Large File Support, should be fine for 32-bit systems.
 	# But if this is the case, why is it not set by default?
 	echo "CPPFLAGS+=	-D_FILE_OFFSET_BITS=64" >>$CONFIG_MK
 	echo "CPPFLAGS+=	-D_LARGEFILE_SOURCE" >>$CONFIG_MK
 	echo "CPPFLAGS+=	-D_LARGEFILE64_SOURCE" >>$CONFIG_MK
-	# glibc-2.20
-	echo "CPPFLAGS+=	-D_DEFAULT_SOURCE" >>$CONFIG_MK
 	echo "DHCPCD_SRCS+=	if-linux.c" >>$CONFIG_MK
 	# for RTM_NEWADDR and friends
-	echo "#include <asm/types.h> /* fix broken headers */" >>$CONFIG_H
-	echo "#include <linux/rtnetlink.h>" >>$CONFIG_H
+	echo "#include		<asm/types.h> /* fix broken headers */" >>$CONFIG_H
+	echo "#include		<linux/rtnetlink.h>" >>$CONFIG_H
 	;;
 qnx*)
 	echo "CPPFLAGS+=	-D__EXT" >>$CONFIG_MK
 	echo "DHCPCD_SRCS+=	if-bsd.c" >>$CONFIG_MK
 	;;
@@ -592,11 +590,10 @@
 fi
 
 if [ -z "$GETLINE" ]; then
 	printf "Testing for getline ... "
 	cat <<EOF >_getline.c
-#define _GNU_SOURCE
 #include <stdio.h>
 int main(void) {
 	char *buf = NULL;
 	size_t n = 0;
 	getline(&buf, &n, stdin);

Index: dhcp6.c
==================================================================
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -1149,11 +1149,11 @@
 		return -1;
 	cm->cmsg_level = IPPROTO_IPV6;
 	cm->cmsg_type = IPV6_PKTINFO;
 	cm->cmsg_len = CMSG_LEN(sizeof(pi));
 	memset(&pi, 0, sizeof(pi));
-	pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
+	pi.ipi6_ifindex = ifp->index;
 	memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
 	if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
 		logger(ifp->ctx, LOG_ERR,
 		    "%s: %s: sendmsg: %m", ifp->name, __func__);

Index: eloop.c
==================================================================
--- a/eloop.c
+++ b/eloop.c
@@ -23,13 +23,10 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
-/* Needed for ppoll(2) */
-#define _GNU_SOURCE
-
 #include <sys/time.h>
 
 #include <errno.h>
 #include <limits.h>
 #include <signal.h>

Index: ipv6.h
==================================================================
--- a/ipv6.h
+++ b/ipv6.h
@@ -27,18 +27,12 @@
 
 #ifndef IPV6_H
 #define IPV6_H
 
 #include <sys/uio.h>
-
 #include <netinet/in.h>
 
-#if defined(__linux__) && defined(__GLIBC__)
-#  define _LINUX_IN6_H
-#  include <linux/ipv6.h>
-#endif
-
 #include "config.h"
 #include "dhcpcd.h"
 
 #define ALLROUTERS "ff02::2"
 
Index: ipv6nd.c
==================================================================
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -293,11 +293,11 @@
 		return;
 	cm->cmsg_level = IPPROTO_IPV6;
 	cm->cmsg_type = IPV6_PKTINFO;
 	cm->cmsg_len = CMSG_LEN(sizeof(pi));
 	memset(&pi, 0, sizeof(pi));
-	pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
+	pi.ipi6_ifindex = ifp->index;
 	memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
 	logger(ifp->ctx, LOG_DEBUG,
 	    "%s: sending Router Solicitation", ifp->name);
 	if (sendmsg(ctx->nd_fd, &ctx->sndhdr, 0) == -1) {

OpenPOWER on IntegriCloud