summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/strace/strace/0001-Avoid-relying-on-presence-of-ipx.h.patch
blob: e791b4130da962f7696617ebb6d9d773cf191f22 (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
From 197f712ea96c12dcabc9fe98889a425d61ad6a60 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Wed, 3 Nov 2021 00:48:59 +0100
Subject: [PATCH] Avoid relying on presence of ipx.h

After Linux has broken UAPI in commit v5.15-rc1~157^2~207, it is well
possible that neither kernel nor libc (such as musl, for example)
provide IPX-related header.  Avoid relying on its presence
in the strace's code and conditionalise the relevant checks in the tests.

* configure.ac (AC_CHECK_HEADERS): Add linux/ipx.h.
* src/net.c: Remove <netipx/ipx.h>/<linux/ipx.h> includes.
* src/sockaddr.c: Likewise.
(IPX_NODE_LEN): New macro constant.
(struct sockaddr_ipx): New type definition.
* src/xlat/sock_ipx_options.in (IPX_TYPE): Provide a fallback value.
* tests/net-sockaddr.c [!HAVE_LINUX_IPX_H]: Do not include
<linux/ipx.h>.
[!HAVE_LINUX_IPX_H && HAVE_NETIPX_IPX_H]: Include <netipx/ipx.h>.
[!(HAVE_LINUX_IPX_H || defined HAVE_NETIPX_IPX_H)]: Do not define
check_ipx.
[!(HAVE_LINUX_IPX_H || defined HAVE_NETIPX_IPX_H)] (main): Do not call
check_ipx.

Closes: https://github.com/strace/strace/issues/201

Upstream-Status: Backport [commit cca828197c0e1 branch esyr/5.15]

[bva: changed context to apply to a released strace 5.14 tarball]
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>

---
 configure.ac                 |  1 +
 src/net.c                    |  5 -----
 src/sockaddr.c               | 16 ++++++++++------
 src/xlat/sock_ipx_options.in |  2 +-
 tests/net-sockaddr.c         | 10 +++++++++-
 5 files changed, 21 insertions(+), 13 deletions(-)

Index: strace-5.14/configure.ac
===================================================================
--- strace-5.14.orig/configure.ac
+++ strace-5.14/configure.ac
@@ -423,6 +423,7 @@
 	elf.h
 	gcov.h
 	iconv.h
+	linux/ipx.h
 	mqueue.h
 	netinet/sctp.h
 	netipx/ipx.h
Index: strace-5.14/src/net.c
===================================================================
--- strace-5.14.orig/src/net.c
+++ strace-5.14/src/net.c
@@ -28,11 +28,6 @@
 #include <arpa/inet.h>
 #include <net/if.h>
 #include <asm/types.h>
-#ifdef HAVE_NETIPX_IPX_H
-# include <netipx/ipx.h>
-#else
-# include <linux/ipx.h>
-#endif
 
 #include <linux/ip_vs.h>
 #include "netlink.h"
Index: strace-5.14/src/sockaddr.c
===================================================================
--- strace-5.14.orig/src/sockaddr.c
+++ strace-5.14/src/sockaddr.c
@@ -24,12 +24,6 @@
 #include <linux/if_ether.h>
 #include <linux/x25.h>
 
-#ifdef HAVE_NETIPX_IPX_H
-# include <netipx/ipx.h>
-#else
-# include <linux/ipx.h>
-#endif
-
 #include "xlat/addrfams.h"
 #include "xlat/arp_hardware_types.h"
 #include "xlat/ethernet_protocols.h"
@@ -45,6 +39,16 @@
 const size_t arp_hardware_types_size = ARRAY_SIZE(arp_hardware_types) - 1;
 const size_t ethernet_protocols_size = ARRAY_SIZE(ethernet_protocols) - 1;
 
+#define IPX_NODE_LEN	6
+struct sockaddr_ipx {
+	uint16_t sipx_family;
+	uint16_t sipx_port;
+	uint32_t sipx_network;
+	unsigned char sipx_node[IPX_NODE_LEN];
+	uint8_t sipx_type;
+	unsigned char sipx_zero;
+};
+
 static void
 print_sockaddr_data_un(struct tcb *tcp, const void *const buf, const int addrlen)
 {
Index: strace-5.14/src/xlat/sock_ipx_options.in
===================================================================
--- strace-5.14.orig/src/xlat/sock_ipx_options.in
+++ strace-5.14/src/xlat/sock_ipx_options.in
@@ -1 +1 @@
-IPX_TYPE
+IPX_TYPE	1
Index: strace-5.14/tests/net-sockaddr.c
===================================================================
--- strace-5.14.orig/tests/net-sockaddr.c
+++ strace-5.14/tests/net-sockaddr.c
@@ -24,7 +24,11 @@
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
 #include <linux/x25.h>
-#include <linux/ipx.h>
+#if defined HAVE_LINUX_IPX_H
+# include <linux/ipx.h>
+#elif defined HAVE_NETIPX_IPX_H
+# include <netipx/ipx.h>
+#endif
 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
 # include <bluetooth/bluetooth.h>
 # include <bluetooth/hci.h>
@@ -269,6 +273,7 @@
 	printf("connect(-1, %p, %u) = %d EBADF (%m)\n", in6, len, ret);
 }
 
+#if defined HAVE_LINUX_IPX_H || defined HAVE_NETIPX_IPX_H
 static void
 check_ipx(void)
 {
@@ -295,6 +300,7 @@
 	       c_ipx.sipx_node[4], c_ipx.sipx_node[5],
 	       c_ipx.sipx_type, len, ret);
 }
+#endif /* HAVE_LINUX_IPX_H || defined HAVE_NETIPX_IPX_H */
 
 /* for a bit more compact AX.25 address definitions */
 #define AX25_ADDR(c_, s_) \
@@ -773,7 +779,9 @@
 	check_un();
 	check_in();
 	check_in6();
+#if defined HAVE_LINUX_IPX_H || defined HAVE_NETIPX_IPX_H
 	check_ipx();
+#endif
 	check_ax25();
 	check_x25();
 	check_nl();