The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / dhcpcd / 0001-fix-in6_pktinfo-build-issue-on-linux.patch
1 [PATCH] fix in6_pktinfo build issue on Linux
2
3 From http://roy.marples.name/projects/dhcpcd/vpatch?from=e05490e2d12d03b1&to=c32714545158ca83
4
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.
11
12 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
13 --
14
15 Index: common.c
16 ==================================================================
17 --- a/common.c
18 +++ b/common.c
19 @@ -23,15 +23,10 @@
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
22   * SUCH DAMAGE.
23   */
24  
25 -/* Needed define to get at getline for glibc and FreeBSD */
26 -#ifndef _GNU_SOURCE
27 -#  define _GNU_SOURCE
28 -#endif
29 -
30  #ifdef __APPLE__
31  #  include <mach/mach_time.h>
32  #  include <mach/kern_return.h>
33  #endif
34  
35
36 Index: configure
37 ==================================================================
38 --- a/configure
39 +++ b/configure
40 @@ -358,27 +358,25 @@
41         echo "There is no fork"
42         echo "CPPFLAGS+=        -DTHERE_IS_NO_FORK" >>$CONFIG_MK
43  fi
44  
45  case "$OS" in
46 -kfreebsd*)
47 +freebsd*|kfreebsd*)
48         echo "CPPFLAGS+=        -D_GNU_SOURCE" >>$CONFIG_MK
49         echo "DHCPCD_SRCS+=     if-bsd.c" >>$CONFIG_MK
50         ;;
51  linux*)
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
59 -       # glibc-2.20
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
67         ;;
68  qnx*)
69         echo "CPPFLAGS+=        -D__EXT" >>$CONFIG_MK
70         echo "DHCPCD_SRCS+=     if-bsd.c" >>$CONFIG_MK
71         ;;
72 @@ -592,11 +590,10 @@
73  fi
74  
75  if [ -z "$GETLINE" ]; then
76         printf "Testing for getline ... "
77         cat <<EOF >_getline.c
78 -#define _GNU_SOURCE
79  #include <stdio.h>
80  int main(void) {
81         char *buf = NULL;
82         size_t n = 0;
83         getline(&buf, &n, stdin);
84
85 Index: dhcp6.c
86 ==================================================================
87 --- a/dhcp6.c
88 +++ b/dhcp6.c
89 @@ -1149,11 +1149,11 @@
90                 return -1;
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));
98  
99         if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
100                 logger(ifp->ctx, LOG_ERR,
101                     "%s: %s: sendmsg: %m", ifp->name, __func__);
102
103 Index: eloop.c
104 ==================================================================
105 --- a/eloop.c
106 +++ b/eloop.c
107 @@ -23,13 +23,10 @@
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
110   * SUCH DAMAGE.
111   */
112  
113 -/* Needed for ppoll(2) */
114 -#define _GNU_SOURCE
115 -
116  #include <sys/time.h>
117  
118  #include <errno.h>
119  #include <limits.h>
120  #include <signal.h>
121
122 Index: ipv6.h
123 ==================================================================
124 --- a/ipv6.h
125 +++ b/ipv6.h
126 @@ -27,18 +27,12 @@
127  
128  #ifndef IPV6_H
129  #define IPV6_H
130  
131  #include <sys/uio.h>
132 -
133  #include <netinet/in.h>
134  
135 -#if defined(__linux__) && defined(__GLIBC__)
136 -#  define _LINUX_IN6_H
137 -#  include <linux/ipv6.h>
138 -#endif
139 -
140  #include "config.h"
141  #include "dhcpcd.h"
142  
143  #define ALLROUTERS "ff02::2"
144  
145 Index: ipv6nd.c
146 ==================================================================
147 --- a/ipv6nd.c
148 +++ b/ipv6nd.c
149 @@ -293,11 +293,11 @@
150                 return;
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));
158  
159         logger(ifp->ctx, LOG_DEBUG,
160             "%s: sending Router Solicitation", ifp->name);
161         if (sendmsg(ctx->nd_fd, &ctx->sndhdr, 0) == -1) {
162