浏览代码

fastd: fix musl compatibility

Prefer linux/if_ether.h over netinet/if_ether.h if available since the
musl libc if_ether.h header does not allow mixing with kernel headers,
it will result in a struct ethhdr redefinition error.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Matthias Schiffer 9 年前
父节点
当前提交
c38ba76698
共有 2 个文件被更改,包括 68 次插入1 次删除
  1. 1
    1
      net/fastd/Makefile
  2. 67
    0
      net/fastd/patches/100-musl-compat.patch

+ 1
- 1
net/fastd/Makefile 查看文件

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=fastd
11 11
 PKG_VERSION:=17
12
-PKG_RELEASE:=1
12
+PKG_RELEASE:=2
13 13
 
14 14
 PKG_MAINTAINER:=Matthias Schiffer <mschiffer@universe-factory.net>
15 15
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz

+ 67
- 0
net/fastd/patches/100-musl-compat.patch 查看文件

@@ -0,0 +1,67 @@
1
+--- a/cmake/checks.cmake
2
++++ b/cmake/checks.cmake
3
+@@ -54,9 +54,13 @@ if(NOT DARWIN)
4
+ endif(NOT DARWIN)
5
+ 
6
+ 
7
++set(CMAKE_EXTRA_INCLUDE_FILES "linux/if_ether.h")
8
++check_type_size("struct ethhdr" SIZEOF_ETHHDR)
9
++string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_LINUX_ETHHDR)
10
++
11
+ set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h")
12
+ check_type_size("struct ethhdr" SIZEOF_ETHHDR)
13
+-string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR)
14
++string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_NETINET_ETHHDR)
15
+ 
16
+ 
17
+ set(CMAKE_REQUIRED_INCLUDES "sys/types.h")
18
+--- a/src/compat.h
19
++++ b/src/compat.h
20
+@@ -45,7 +45,12 @@
21
+ #include <net/if.h>
22
+ #include <net/if_arp.h>
23
+ #include <netinet/in.h>
24
++
25
++#if defined(HAVE_LINUX_ETHHDR)
26
++#include <linux/if_ether.h>
27
++#elif defined(HAVE_NETINET_ETHHDR)
28
+ #include <netinet/if_ether.h>
29
++#endif
30
+ 
31
+ #ifndef ETH_ALEN
32
+ /** The length of a MAC address */
33
+@@ -55,9 +60,8 @@
34
+ #ifndef ETH_HLEN
35
+ /** The length of the standard ethernet header */
36
+ #define ETH_HLEN 14
37
+-#endif
38
+ 
39
+-#ifndef HAVE_ETHHDR
40
++#if !defined(HAVE_LINUX_ETHHDR) && !defined(HAVE_NETINET_ETHHDR)
41
+ /** An ethernet header */
42
+ struct ethhdr {
43
+ 	uint8_t h_dest[ETH_ALEN];			/**< The destination MAC address field */
44
+@@ -65,6 +69,7 @@ struct ethhdr {
45
+ 	uint16_t h_proto;				/**< The EtherType/length field */
46
+ } __attribute__((packed));
47
+ #endif
48
++#endif
49
+ 
50
+ #if defined(USE_FREEBIND) && !defined(IP_FREEBIND)
51
+ /** Compatiblity define for systems supporting, but not defining IP_FREEBIND */
52
+--- a/src/fastd_config.h.in
53
++++ b/src/fastd_config.h.in
54
+@@ -35,8 +35,11 @@
55
+ /** Defined if the platform supports the AI_ADDRCONFIG flag to getaddrinfo() */
56
+ #cmakedefine HAVE_AI_ADDRCONFIG
57
+ 
58
+-/** Defined if the platform defines the \e ethhdr struct */
59
+-#cmakedefine HAVE_ETHHDR
60
++/** Defined if the platform defines the \e ethhdr struct through linux/if_ether.h */
61
++#cmakedefine HAVE_LINUX_ETHHDR
62
++
63
++/** Defined if the platform defines the \e ethhdr struct through netinet/if_ether.h */
64
++#cmakedefine HAVE_NETINET_ETHHDR
65
+ 
66
+ /** Defined if the platform defines get_current_dir_name() */
67
+ #cmakedefine HAVE_GET_CURRENT_DIR_NAME