busybox: fix issues with the ip command on mips64
[openwrt/openwrt.git] / package / utils / busybox / patches / 030-ip-fix-problem-on-mips64-n64-big-endian-musl-systems.patch
1 From: Szabolcs Nagy <nsz@port70.net>
2 Date: Sun, 24 Apr 2016 17:39:02 +0200
3 Subject: [PATCH] ip: fix problem on mips64 n64 big endian musl systems
4
5 Use designated initializers for struct msghdr.
6 The struct layout is non-portable and musl libc does not match what busybox expects.
7
8 Signed-off-by: Szabolcs Nagy <nsz@port70.net>
9 Tested-by: Waldemar Brodkorb <wbx@openadk.org>
10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 ---
12
13 --- a/networking/libiproute/libnetlink.c
14 +++ b/networking/libiproute/libnetlink.c
15 @@ -71,11 +71,15 @@ int FAST_FUNC rtnl_dump_request(struct r
16 struct nlmsghdr nlh;
17 struct sockaddr_nl nladdr;
18 struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } };
19 + /* Use designated initializers, struct layout is non-portable */
20 struct msghdr msg = {
21 - (void*)&nladdr, sizeof(nladdr),
22 - iov, 2,
23 - NULL, 0,
24 - 0
25 + .msg_name = (void*)&nladdr,
26 + .msg_namelen = sizeof(nladdr),
27 + .msg_iov = iov,
28 + .msg_iovlen = 2,
29 + .msg_control = NULL,
30 + .msg_controllen = 0,
31 + .msg_flags = 0
32 };
33
34 memset(&nladdr, 0, sizeof(nladdr));
35 @@ -104,12 +108,15 @@ static int rtnl_dump_filter(struct rtnl_
36 while (1) {
37 int status;
38 struct nlmsghdr *h;
39 -
40 + /* Use designated initializers, struct layout is non-portable */
41 struct msghdr msg = {
42 - (void*)&nladdr, sizeof(nladdr),
43 - &iov, 1,
44 - NULL, 0,
45 - 0
46 + .msg_name = (void*)&nladdr,
47 + .msg_namelen = sizeof(nladdr),
48 + .msg_iov = &iov,
49 + .msg_iovlen = 1,
50 + .msg_control = NULL,
51 + .msg_controllen = 0,
52 + .msg_flags = 0
53 };
54
55 status = recvmsg(rth->fd, &msg, 0);
56 @@ -211,11 +218,15 @@ int FAST_FUNC rtnl_talk(struct rtnl_hand
57 struct sockaddr_nl nladdr;
58 struct iovec iov = { (void*)n, n->nlmsg_len };
59 char *buf = xmalloc(8*1024); /* avoid big stack buffer */
60 + /* Use designated initializers, struct layout is non-portable */
61 struct msghdr msg = {
62 - (void*)&nladdr, sizeof(nladdr),
63 - &iov, 1,
64 - NULL, 0,
65 - 0
66 + .msg_name = (void*)&nladdr,
67 + .msg_namelen = sizeof(nladdr),
68 + .msg_iov = &iov,
69 + .msg_iovlen = 1,
70 + .msg_control = NULL,
71 + .msg_controllen = 0,
72 + .msg_flags = 0
73 };
74
75 memset(&nladdr, 0, sizeof(nladdr));