diff options
author | Guocai He <guocai.he.cn@windriver.com> | 2025-08-26 16:42:02 +0800 |
---|---|---|
committer | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-09-06 16:27:30 +0200 |
commit | 12824411988d10737a840a97336e1ba7c8e4f525 (patch) | |
tree | fd2ec59414e5a5ac927070ebbbcb3d40422b6a58 | |
parent | afb55dd3301d0e256a26b495b63be4d6416830a9 (diff) | |
download | meta-openembedded-12824411988d10737a840a97336e1ba7c8e4f525.tar.gz |
libnet: backport patch to remove configure time SOCK_PACKET check
Backport [1] to fix the do_configure error like below:
checking for packet socket (PF_PACKET)... ./pf_packet-test:
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
[1] https://github.com/libnet/libnet/commit/19979c4541ddcc817c64ea911a309ee71a8cc250
Signed-off-by: Qi Chen <Qi.Chen@windriver.com>
Signed-off-by: Guocai He <guocai.he.cn@windriver.com>
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
-rw-r--r-- | meta-oe/recipes-connectivity/libnet/libnet/0001-Remove-support-for-SOCK_PACKET-sockets.patch | 251 | ||||
-rw-r--r-- | meta-oe/recipes-connectivity/libnet/libnet_1.2-rc3.bb | 1 |
2 files changed, 252 insertions, 0 deletions
diff --git a/meta-oe/recipes-connectivity/libnet/libnet/0001-Remove-support-for-SOCK_PACKET-sockets.patch b/meta-oe/recipes-connectivity/libnet/libnet/0001-Remove-support-for-SOCK_PACKET-sockets.patch new file mode 100644 index 0000000000..2fc7ecd180 --- /dev/null +++ b/meta-oe/recipes-connectivity/libnet/libnet/0001-Remove-support-for-SOCK_PACKET-sockets.patch | |||
@@ -0,0 +1,251 @@ | |||
1 | From dd77c43a9773edb895bfe9074315e83a19cac471 Mon Sep 17 00:00:00 2001 | ||
2 | From: Guocai He <guocai.he.cn@windriver.com> | ||
3 | Date: Tue, 26 Aug 2025 06:15:41 +0000 | ||
4 | Subject: [PATCH] Remove support for SOCK_PACKET sockets | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | The current code has a build-time check to verify that PF_PACKET sockets | ||
10 | are supported on Linux systems and if not, fallback on SOCK_PACKET sockets. | ||
11 | |||
12 | The test implementation relies on FTM (Feature Test Macros) to detect | ||
13 | glibc and its version to include correct headers. | ||
14 | But, some libc such as the musl libc do not have such macros, making the | ||
15 | test program compilation fail and libnet fallback on SOCK_PACKET. | ||
16 | |||
17 | Since PF_PACKET support is present in kernel for more than 20 years now, | ||
18 | the simplest solution and safe choice is to just drop support for | ||
19 | SOCK_PACKET and assume PF_PACKET is always available on any Linux system. | ||
20 | |||
21 | Signed-off-by: Hervé Boisse <admin@netgeek.ovh> | ||
22 | |||
23 | Upstream-Status: Backport [19979c4541ddcc817c64ea911a309ee71a8cc250] | ||
24 | |||
25 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
26 | Signed-off-by: Guocai He <guocai.he.cn@windriver.com> | ||
27 | --- | ||
28 | acinclude.m4 | 87 ----------------------------------------- | ||
29 | configure.ac | 3 -- | ||
30 | src/libnet_link_linux.c | 19 +-------- | ||
31 | win32/config.h | 1 - | ||
32 | 4 files changed, 1 insertion(+), 109 deletions(-) | ||
33 | |||
34 | diff --git a/acinclude.m4 b/acinclude.m4 | ||
35 | index 064b582..f8ab967 100644 | ||
36 | --- a/acinclude.m4 | ||
37 | +++ b/acinclude.m4 | ||
38 | @@ -25,93 +25,6 @@ AC_DEFUN([AC_LIBNET_LINUX_PROCFS], | ||
39 | [Define if you have the Linux /proc filesystem.]) | ||
40 | fi]) | ||
41 | |||
42 | -dnl | ||
43 | -dnl Checks to see if this linux kernel has a working PF_PACKET | ||
44 | -dnl | ||
45 | -dnl usage: | ||
46 | -dnl | ||
47 | -dnl AC_LIBNET_CHECK_PF_PACKET | ||
48 | -dnl | ||
49 | -dnl results: | ||
50 | -dnl | ||
51 | -dnl HAVE_PACKET_SOCKET (DEFINED) | ||
52 | -dnl | ||
53 | - | ||
54 | -AC_DEFUN([AC_LIBNET_CHECK_PF_PACKET], | ||
55 | -[ | ||
56 | - AC_MSG_CHECKING(for packet socket (PF_PACKET)) | ||
57 | - AC_CACHE_VAL(libnet_cv_have_packet_socket, | ||
58 | - | ||
59 | - [ | ||
60 | - cat > pf_packet-test.c << EOF | ||
61 | -#include <stdio.h> | ||
62 | -#include <errno.h> | ||
63 | -#include <stdlib.h> | ||
64 | -#include <netinet/in.h> | ||
65 | -#include <sys/socket.h> | ||
66 | -#include <features.h> /* for the glibc version number */ | ||
67 | -#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1 | ||
68 | -#include <netpacket/packet.h> | ||
69 | -#include <net/ethernet.h> /* the L2 protocols */ | ||
70 | -#else | ||
71 | -#include <asm/types.h> | ||
72 | -#include <linux/if_packet.h> | ||
73 | -#include <linux/if_ether.h> /* The L2 protocols */ | ||
74 | -#endif | ||
75 | - | ||
76 | -#ifndef SOL_PACKET | ||
77 | -#define SOL_PACKET 263 | ||
78 | -#endif /* SOL_PACKET */ | ||
79 | - | ||
80 | -int | ||
81 | -main(int argc, char **argv) | ||
82 | -{ | ||
83 | - int fd; | ||
84 | - | ||
85 | - fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); | ||
86 | - if (fd == -1) | ||
87 | - { | ||
88 | - if (errno == EPERM) | ||
89 | - { | ||
90 | - /* user's UID != 0 */ | ||
91 | - printf("probably"); | ||
92 | - exit (EXIT_FAILURE); | ||
93 | - } | ||
94 | - printf("no"); | ||
95 | - exit (EXIT_FAILURE); | ||
96 | - } | ||
97 | - printf("yes"); | ||
98 | - exit (EXIT_SUCCESS); | ||
99 | -} | ||
100 | -EOF | ||
101 | - ${CC-cc} -o pf_packet-test $CFLAGS pf_packet-test.c >/dev/null 2>&1 | ||
102 | - | ||
103 | - # Oopz 4.3 BSD doesn't have this. Sorry. | ||
104 | - if test ! -x ./pf_packet-test ; then | ||
105 | - libnet_cv_have_packet_socket=choked | ||
106 | - else | ||
107 | - libnet_cv_have_packet_socket=`./pf_packet-test`; | ||
108 | - fi | ||
109 | - if test $libnet_cv_have_packet_socket = choked; then | ||
110 | - AC_MSG_RESULT(test program compile choked... assuming no) | ||
111 | - elif test $libnet_cv_have_packet_socket = yes; then | ||
112 | - AC_MSG_RESULT(yes) | ||
113 | - elif test $libnet_cv_have_packet_socket = probably; then | ||
114 | - AC_MSG_RESULT(test program got EPERM... assuming yes) | ||
115 | - elif test $libnet_cv_have_packet_socket = no; then | ||
116 | - AC_MSG_RESULT(no) | ||
117 | - fi | ||
118 | - | ||
119 | - rm -f pf_packet-test* core core.pf_packet-test | ||
120 | - | ||
121 | - ]) | ||
122 | - | ||
123 | - if test $libnet_cv_have_packet_socket = yes -o $libnet_cv_have_packet_socket = probably; then | ||
124 | - AC_DEFINE(HAVE_PACKET_SOCKET, 1, | ||
125 | - [Define if we're running on a Linux system with PF_PACKET sockets.]) | ||
126 | - fi | ||
127 | -]) | ||
128 | - | ||
129 | dnl | ||
130 | dnl Looks for a previous libnet version and attempts to determine which verion | ||
131 | dnl it is. Version 0.8 was the first version that actually knew internally | ||
132 | diff --git a/configure.ac b/configure.ac | ||
133 | index 4751f62..ad002b9 100644 | ||
134 | --- a/configure.ac | ||
135 | +++ b/configure.ac | ||
136 | @@ -51,7 +51,6 @@ AC_LIBNET_ENDIAN_CHECK | ||
137 | dnl AC_LBL_LIBRARY_NET | ||
138 | |||
139 | AC_SUBST(ENDIANESS) | ||
140 | -AC_SUBST(HAVE_PACKET_SOCKET) | ||
141 | AC_SUBST(ADDITIONAL_LIBS) | ||
142 | AC_SUBST(LIBNET_CONFIG_DEFINES) | ||
143 | AC_SUBST(LIBNET_CONFIG_LIBS) | ||
144 | @@ -87,7 +86,6 @@ if test -n "${with_link_layer}"; then | ||
145 | snoop) AC_LIBOBJ([libnet_link_snoop]) ;; | ||
146 | dlpi) AC_LIBOBJ([libnet_link_dlpi]) ;; | ||
147 | linux) AC_LIBOBJ([libnet_link_linux]) | ||
148 | - AC_LIBNET_CHECK_PF_PACKET | ||
149 | AC_LIBNET_LINUX_PROCFS ;; | ||
150 | none) AC_LIBOBJ([libnet_link_none]) ;; | ||
151 | *) AC_MSG_ERROR([Invalid link type "${with_link_layer}"]) ;; | ||
152 | @@ -115,7 +113,6 @@ elif test "${ac_cv_header_sys_dlpi_h}" = "yes" ; then | ||
153 | elif test "${ac_cv_header_linux_socket_h}" = "yes" ; then | ||
154 | AC_LIBOBJ([libnet_link_linux]) | ||
155 | AC_MSG_RESULT(found link layer linux) | ||
156 | - AC_LIBNET_CHECK_PF_PACKET | ||
157 | AC_LIBNET_LINUX_PROCFS | ||
158 | elif test "${cross_compiling}" != "yes" -a -c /dev/bpf0 ; then # check again in case not readable | ||
159 | AC_LIBOBJ([libnet_link_bpf]) | ||
160 | diff --git a/src/libnet_link_linux.c b/src/libnet_link_linux.c | ||
161 | index 3c6df3c..1dd2a42 100644 | ||
162 | --- a/src/libnet_link_linux.c | ||
163 | +++ b/src/libnet_link_linux.c | ||
164 | @@ -33,13 +33,11 @@ | ||
165 | #include <netinet/if_ether.h> | ||
166 | #include <net/if_arp.h> | ||
167 | |||
168 | -#if (HAVE_PACKET_SOCKET) | ||
169 | #ifndef SOL_PACKET | ||
170 | #define SOL_PACKET 263 | ||
171 | #endif /* SOL_PACKET */ | ||
172 | #include <netpacket/packet.h> | ||
173 | #include <net/ethernet.h> /* the L2 protocols */ | ||
174 | -#endif /* HAVE_PACKET_SOCKET */ | ||
175 | |||
176 | #include "../include/libnet.h" | ||
177 | |||
178 | @@ -69,11 +67,8 @@ libnet_open_link(libnet_t *l) | ||
179 | return (-1); | ||
180 | } | ||
181 | |||
182 | -#if (HAVE_PACKET_SOCKET) | ||
183 | l->fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); | ||
184 | -#else | ||
185 | - l->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); | ||
186 | -#endif | ||
187 | + | ||
188 | if (l->fd == -1) | ||
189 | { | ||
190 | if (errno == EPERM) { | ||
191 | @@ -177,7 +172,6 @@ libnet_close_link(libnet_t *l) | ||
192 | } | ||
193 | |||
194 | |||
195 | -#if (HAVE_PACKET_SOCKET) | ||
196 | static int | ||
197 | get_iface_index(int fd, const char *device) | ||
198 | { | ||
199 | @@ -194,18 +188,12 @@ get_iface_index(int fd, const char *device) | ||
200 | |||
201 | return ifr.ifr_ifindex; | ||
202 | } | ||
203 | -#endif | ||
204 | - | ||
205 | |||
206 | int | ||
207 | libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size) | ||
208 | { | ||
209 | int c; | ||
210 | -#if (HAVE_PACKET_SOCKET) | ||
211 | struct sockaddr_ll sa; | ||
212 | -#else | ||
213 | - struct sockaddr sa; | ||
214 | -#endif | ||
215 | |||
216 | if (l == NULL) | ||
217 | { | ||
218 | @@ -213,7 +201,6 @@ libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size) | ||
219 | } | ||
220 | |||
221 | memset(&sa, 0, sizeof (sa)); | ||
222 | -#if (HAVE_PACKET_SOCKET) | ||
223 | sa.sll_family = AF_PACKET; | ||
224 | sa.sll_ifindex = get_iface_index(l->fd, l->device); | ||
225 | if (sa.sll_ifindex == -1) | ||
226 | @@ -221,10 +208,6 @@ libnet_write_link(libnet_t *l, const uint8_t *packet, uint32_t size) | ||
227 | return (-1); | ||
228 | } | ||
229 | sa.sll_protocol = htons(ETH_P_ALL); | ||
230 | -#else | ||
231 | - strncpy(sa.sa_data, l->device, sizeof (sa.sa_data) - 1); | ||
232 | - sa.sa_data[sizeof (sa.sa_data) - 1] = 0; | ||
233 | -#endif | ||
234 | |||
235 | c = sendto(l->fd, packet, size, 0, | ||
236 | (struct sockaddr *)&sa, sizeof (sa)); | ||
237 | diff --git a/win32/config.h b/win32/config.h | ||
238 | index 926f12f..12e1ee7 100644 | ||
239 | --- a/win32/config.h | ||
240 | +++ b/win32/config.h | ||
241 | @@ -11,7 +11,6 @@ | ||
242 | #undef HAVE_HPUX11 | ||
243 | #undef HAVE_SOCKADDR_SA_LEN | ||
244 | #undef HAVE_DLPI | ||
245 | -#undef HAVE_PACKET_SOCKET | ||
246 | #undef HAVE_STRUCT_IP_CSUM | ||
247 | #undef HAVE_LIB_PCAP | ||
248 | #undef STUPID_SOLARIS_CHECKSUM_BUG | ||
249 | -- | ||
250 | 2.35.5 | ||
251 | |||
diff --git a/meta-oe/recipes-connectivity/libnet/libnet_1.2-rc3.bb b/meta-oe/recipes-connectivity/libnet/libnet_1.2-rc3.bb index 785abf66d6..5e35fc3391 100644 --- a/meta-oe/recipes-connectivity/libnet/libnet_1.2-rc3.bb +++ b/meta-oe/recipes-connectivity/libnet/libnet_1.2-rc3.bb | |||
@@ -10,6 +10,7 @@ PROVIDES = "libnet-1.2rc2" | |||
10 | 10 | ||
11 | SRC_URI = "${SOURCEFORGE_MIRROR}/libnet-dev/${BPN}-${PV}.tar.gz \ | 11 | SRC_URI = "${SOURCEFORGE_MIRROR}/libnet-dev/${BPN}-${PV}.tar.gz \ |
12 | file://0001-Support-musl-libc-remove-support-for-glibc-2.1.patch \ | 12 | file://0001-Support-musl-libc-remove-support-for-glibc-2.1.patch \ |
13 | file://0001-Remove-support-for-SOCK_PACKET-sockets.patch \ | ||
13 | " | 14 | " |
14 | 15 | ||
15 | SRC_URI[md5sum] = "f051e6e5bdecddb90f77c701c2ca1804" | 16 | SRC_URI[md5sum] = "f051e6e5bdecddb90f77c701c2ca1804" |