summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch')
-rw-r--r--meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch343
1 files changed, 343 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch b/meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch
new file mode 100644
index 0000000000..3cff6bbcfa
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc-2.10.1/glibc-check_pf.patch
@@ -0,0 +1,343 @@
1From libc-ports-return-550-listarch-libc-ports=sources dot redhat dot com at sourceware dot org Tue Oct 31 17:37:21 2006
2Return-Path: <libc-ports-return-550-listarch-libc-ports=sources dot redhat dot com at sourceware dot org>
3Delivered-To: listarch-libc-ports at sources dot redhat dot com
4Received: (qmail 17273 invoked by alias); 31 Oct 2006 17:37:20 -0000
5Received: (qmail 17262 invoked by uid 22791); 31 Oct 2006 17:37:19 -0000
6X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,TW_CP
7X-Spam-Check-By: sourceware.org
8Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Tue, 31 Oct 2006 17:37:11 +0000
9Received: from drow by nevyn.them.org with local (Exim 4.54) id 1GexXw-0007Dj-30; Tue, 31 Oct 2006 12:37:08 -0500
10Date: Tue, 31 Oct 2006 12:37:08 -0500
11From: Daniel Jacobowitz <drow at false dot org>
12To: Mike Frysinger <vapier at gentoo dot org>
13Cc: libc-ports at sourceware dot org, Philip Balister <philip dot balister at gmail dot com>
14Subject: Re: Problem with glibc-2.5 on ARM
15Message-ID: <20061031173708.GJ20468@nevyn.them.org>
16References: <499146270610241149ibe030e0nd9d6b177a95b346e@mail.gmail.com> <499146270610241254u7cadf63ej2edf05cedbc5266f@mail.gmail.com> <20061024195837.GA20181@nevyn.them.org> <200610291954.27022.vapier@gentoo.org>
17MIME-Version: 1.0
18Content-Type: text/plain; charset=us-ascii
19Content-Disposition: inline
20In-Reply-To: <200610291954 dot 27022 dot vapier at gentoo dot org>
21User-Agent: Mutt/1.5.13 (2006-08-11)
22X-IsSubscribed: yes
23Mailing-List: contact libc-ports-help at sourceware dot org; run by ezmlm
24Precedence: bulk
25List-Subscribe: <mailto:libc-ports-subscribe at sourceware dot org>
26List-Post: <mailto:libc-ports at sourceware dot org>
27List-Help: <mailto:libc-ports-help at sourceware dot org>, <http://sourceware dot org/lists dot html#faqs>
28Sender: libc-ports-owner at sourceware dot org
29Delivered-To: mailing list libc-ports at sourceware dot org
30
31On Sun, Oct 29, 2006 at 07:54:25PM -0500, Mike Frysinger wrote:
32> On Tuesday 24 October 2006 15:58, Daniel Jacobowitz wrote:
33> > ARM is going to need a slightly different version of that file, I
34> > guess.
35>
36> would declaring req with attribute packed not help ?
37> -mike
38
39Nope. "struct rtgenmsg" would still have size 4.
40
41Philip, are you still at all interested in this for the old ABI?
42I don't have time to test this patch right now, but I think it
43will work.
44
45--
46Daniel Jacobowitz
47CodeSourcery
48
492006-10-31 Daniel Jacobowitz <dan@codesourcery.com>
50
51 * sysdeps/unix/sysv/linux/arm/check_pf.c: New file.
52 * sysdeps/unix/sysv/linux/arm/eabi/check_pf.c: New file.
53
54Index: sysdeps/unix/sysv/linux/arm/check_pf.c
55===================================================================
56RCS file: sysdeps/unix/sysv/linux/arm/check_pf.c
57diff -N sysdeps/unix/sysv/linux/arm/check_pf.c
58--- /dev/null 1 Jan 1970 00:00:00 -0000
59+++ sysdeps/unix/sysv/linux/arm/check_pf.c 31 Oct 2006 17:29:58 -0000
60@@ -0,0 +1,274 @@
61+/* Determine protocol families for which interfaces exist. ARM Linux version.
62+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
63+ This file is part of the GNU C Library.
64+
65+ The GNU C Library is free software; you can redistribute it and/or
66+ modify it under the terms of the GNU Lesser General Public
67+ License as published by the Free Software Foundation; either
68+ version 2.1 of the License, or (at your option) any later version.
69+
70+ The GNU C Library is distributed in the hope that it will be useful,
71+ but WITHOUT ANY WARRANTY; without even the implied warranty of
72+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73+ Lesser General Public License for more details.
74+
75+ You should have received a copy of the GNU Lesser General Public
76+ License along with the GNU C Library; if not, write to the Free
77+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
78+ 02111-1307 USA. */
79+
80+#include <assert.h>
81+#include <errno.h>
82+#include <ifaddrs.h>
83+#include <netdb.h>
84+#include <stddef.h>
85+#include <string.h>
86+#include <time.h>
87+#include <unistd.h>
88+#include <sys/socket.h>
89+
90+#include <asm/types.h>
91+#include <linux/netlink.h>
92+#include <linux/rtnetlink.h>
93+
94+#include <not-cancel.h>
95+#include <kernel-features.h>
96+
97+
98+#ifndef IFA_F_TEMPORARY
99+# define IFA_F_TEMPORARY IFA_F_SECONDARY
100+#endif
101+#ifndef IFA_F_HOMEADDRESS
102+# define IFA_F_HOMEADDRESS 0
103+#endif
104+
105+
106+static int
107+make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
108+ struct in6addrinfo **in6ai, size_t *in6ailen)
109+{
110+ struct req
111+ {
112+ struct nlmsghdr nlh;
113+ struct rtgenmsg g;
114+ } req;
115+ struct sockaddr_nl nladdr;
116+
117+ /* struct rtgenmsg consists of a single byte but the ARM ABI rounds
118+ it up to a word. Clear the padding explicitly here. */
119+ assert (sizeof (req.g) == 4);
120+ memset (&req.g, '\0', sizeof (req.g));
121+
122+ req.nlh.nlmsg_len = sizeof (req);
123+ req.nlh.nlmsg_type = RTM_GETADDR;
124+ req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
125+ req.nlh.nlmsg_pid = 0;
126+ req.nlh.nlmsg_seq = time (NULL);
127+ req.g.rtgen_family = AF_UNSPEC;
128+
129+ memset (&nladdr, '\0', sizeof (nladdr));
130+ nladdr.nl_family = AF_NETLINK;
131+
132+ if (TEMP_FAILURE_RETRY (__sendto (fd, (void *) &req, sizeof (req), 0,
133+ (struct sockaddr *) &nladdr,
134+ sizeof (nladdr))) < 0)
135+ return -1;
136+
137+ *seen_ipv4 = false;
138+ *seen_ipv6 = false;
139+
140+ bool done = false;
141+ char buf[4096];
142+ struct iovec iov = { buf, sizeof (buf) };
143+ struct in6ailist
144+ {
145+ struct in6addrinfo info;
146+ struct in6ailist *next;
147+ } *in6ailist = NULL;
148+ size_t in6ailistlen = 0;
149+
150+ do
151+ {
152+ struct msghdr msg =
153+ {
154+ (void *) &nladdr, sizeof (nladdr),
155+ &iov, 1,
156+ NULL, 0,
157+ 0
158+ };
159+
160+ ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
161+ if (read_len < 0)
162+ return -1;
163+
164+ if (msg.msg_flags & MSG_TRUNC)
165+ return -1;
166+
167+ struct nlmsghdr *nlmh;
168+ for (nlmh = (struct nlmsghdr *) buf;
169+ NLMSG_OK (nlmh, (size_t) read_len);
170+ nlmh = (struct nlmsghdr *) NLMSG_NEXT (nlmh, read_len))
171+ {
172+ if (nladdr.nl_pid != 0 || (pid_t) nlmh->nlmsg_pid != pid
173+ || nlmh->nlmsg_seq != req.nlh.nlmsg_seq)
174+ continue;
175+
176+ if (nlmh->nlmsg_type == RTM_NEWADDR)
177+ {
178+ struct ifaddrmsg *ifam = (struct ifaddrmsg *) NLMSG_DATA (nlmh);
179+
180+ switch (ifam->ifa_family)
181+ {
182+ case AF_INET:
183+ *seen_ipv4 = true;
184+ break;
185+ case AF_INET6:
186+ *seen_ipv6 = true;
187+
188+ if (ifam->ifa_flags & (IFA_F_DEPRECATED
189+ | IFA_F_TEMPORARY
190+ | IFA_F_HOMEADDRESS))
191+ {
192+ struct rtattr *rta = IFA_RTA (ifam);
193+ size_t len = (nlmh->nlmsg_len
194+ - NLMSG_LENGTH (sizeof (*ifam)));
195+ void *local = NULL;
196+ void *address = NULL;
197+ while (RTA_OK (rta, len))
198+ {
199+ switch (rta->rta_type)
200+ {
201+ case IFA_LOCAL:
202+ local = RTA_DATA (rta);
203+ break;
204+
205+ case IFA_ADDRESS:
206+ address = RTA_DATA (rta);
207+ break;
208+ }
209+
210+ rta = RTA_NEXT (rta, len);
211+ }
212+
213+ struct in6ailist *newp = alloca (sizeof (*newp));
214+ newp->info.flags = (((ifam->ifa_flags & IFA_F_DEPRECATED)
215+ ? in6ai_deprecated : 0)
216+ | ((ifam->ifa_flags
217+ & IFA_F_TEMPORARY)
218+ ? in6ai_temporary : 0)
219+ | ((ifam->ifa_flags
220+ & IFA_F_HOMEADDRESS)
221+ ? in6ai_homeaddress : 0));
222+ memcpy (newp->info.addr, address ?: local,
223+ sizeof (newp->info.addr));
224+ newp->next = in6ailist;
225+ in6ailist = newp;
226+ ++in6ailistlen;
227+ }
228+ break;
229+ default:
230+ /* Ignore. */
231+ break;
232+ }
233+ }
234+ else if (nlmh->nlmsg_type == NLMSG_DONE)
235+ /* We found the end, leave the loop. */
236+ done = true;
237+ }
238+ }
239+ while (! done);
240+
241+ close_not_cancel_no_status (fd);
242+
243+ if (in6ailist != NULL)
244+ {
245+ *in6ai = malloc (in6ailistlen * sizeof (**in6ai));
246+ if (*in6ai == NULL)
247+ return -1;
248+
249+ *in6ailen = in6ailistlen;
250+
251+ do
252+ {
253+ (*in6ai)[--in6ailistlen] = in6ailist->info;
254+ in6ailist = in6ailist->next;
255+ }
256+ while (in6ailist != NULL);
257+ }
258+
259+ return 0;
260+}
261+
262+
263+/* We don't know if we have NETLINK support compiled in in our
264+ Kernel. */
265+#if __ASSUME_NETLINK_SUPPORT == 0
266+/* Define in ifaddrs.h. */
267+extern int __no_netlink_support attribute_hidden;
268+#else
269+# define __no_netlink_support 0
270+#endif
271+
272+
273+void
274+attribute_hidden
275+__check_pf (bool *seen_ipv4, bool *seen_ipv6,
276+ struct in6addrinfo **in6ai, size_t *in6ailen)
277+{
278+ *in6ai = NULL;
279+ *in6ailen = 0;
280+
281+ if (! __no_netlink_support)
282+ {
283+ int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
284+
285+ struct sockaddr_nl nladdr;
286+ memset (&nladdr, '\0', sizeof (nladdr));
287+ nladdr.nl_family = AF_NETLINK;
288+
289+ socklen_t addr_len = sizeof (nladdr);
290+
291+ if (fd >= 0
292+ && __bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
293+ && __getsockname (fd, (struct sockaddr *) &nladdr, &addr_len) == 0
294+ && make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6,
295+ in6ai, in6ailen) == 0)
296+ /* It worked. */
297+ return;
298+
299+ if (fd >= 0)
300+ __close (fd);
301+
302+#if __ASSUME_NETLINK_SUPPORT == 0
303+ /* Remember that there is no netlink support. */
304+ __no_netlink_support = 1;
305+#else
306+ /* We cannot determine what interfaces are available. Be
307+ pessimistic. */
308+ *seen_ipv4 = true;
309+ *seen_ipv6 = true;
310+#endif
311+ }
312+
313+#if __ASSUME_NETLINK_SUPPORT == 0
314+ /* No netlink. Get the interface list via getifaddrs. */
315+ struct ifaddrs *ifa = NULL;
316+ if (getifaddrs (&ifa) != 0)
317+ {
318+ /* We cannot determine what interfaces are available. Be
319+ pessimistic. */
320+ *seen_ipv4 = true;
321+ *seen_ipv6 = true;
322+ return;
323+ }
324+
325+ struct ifaddrs *runp;
326+ for (runp = ifa; runp != NULL; runp = runp->ifa_next)
327+ if (runp->ifa_addr->sa_family == PF_INET)
328+ *seen_ipv4 = true;
329+ else if (runp->ifa_addr->sa_family == PF_INET6)
330+ *seen_ipv6 = true;
331+
332+ (void) freeifaddrs (ifa);
333+#endif
334+}
335Index: sysdeps/unix/sysv/linux/arm/eabi/check_pf.c
336===================================================================
337RCS file: sysdeps/unix/sysv/linux/arm/eabi/check_pf.c
338diff -N sysdeps/unix/sysv/linux/arm/eabi/check_pf.c
339--- /dev/null 1 Jan 1970 00:00:00 -0000
340+++ sysdeps/unix/sysv/linux/arm/eabi/check_pf.c 31 Oct 2006 17:29:58 -0000
341@@ -0,0 +1 @@
342+#include <sysdeps/unix/sysv/linux/check_pf.c>
343