summaryrefslogtreecommitdiff
path: root/package/openpowerlink/0004-veth-avoid-kernel-header-issue-with-musl.patch
blob: a85b94e15c08aae55ba6955dee48751e95cfebf2 (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
From 9cd93aeecbca62db278f2fe4a2c0a2f6fd04924b Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@gmail.com>
Date: Wed, 25 May 2016 13:26:49 +0200
Subject: [PATCH] veth: avoid kernel header issue with musl

The Virtual Ethernet driver doesn't build when the musl libc is used on the
system. As stated in the musl wiki [1], the userspace and kernel headers are
mixed leading to a "clash" with the definitions provided by musl.

Remove netinet/if_ether.h userspace header and replace ETHER_ADDR_LEN by
ETH_ALEN [2] and ETHERMTU by ETH_DATA_LEN [3] in veth-linuxuser.c.

Fixes:
http://autobuild.buildroot.org/results/2ca/2ca04bb046263e479e7597867b56469893d3c11d/build-end.log

Upsteam status: pending
https://github.com/OpenAutomationTechnologies/openPOWERLINK_V2/pull/120

[1] http://wiki.musl-libc.org/wiki/FAQ#Q:_why_am_i_getting_.22error:_redefinition_of_struct_ethhdr.2Ftcphdr.2Fetc.22_.3F
[2] https://git.musl-libc.org/cgit/musl/tree/include/net/ethernet.h?h=v1.1.14#n35
[3] https://git.musl-libc.org/cgit/musl/tree/include/net/ethernet.h?h=v1.1.14#n48

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
 stack/src/kernel/veth/veth-linuxuser.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/stack/src/kernel/veth/veth-linuxuser.c b/stack/src/kernel/veth/veth-linuxuser.c
index d70566c..ddcf950 100644
--- a/stack/src/kernel/veth/veth-linuxuser.c
+++ b/stack/src/kernel/veth/veth-linuxuser.c
@@ -61,7 +61,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <arpa/inet.h>
 #include <linux/if.h>
 #include <linux/if_tun.h>
-#include <netinet/if_ether.h>
 
 //============================================================================//
 //            G L O B A L   D E F I N I T I O N S                             //
@@ -248,7 +247,7 @@ static void getMacAdrs(UINT8* pMac_p)
 
     close(sock);
 
-    OPLK_MEMCPY(pMac_p, &ifr.ifr_hwaddr.sa_data[0], ETHER_ADDR_LEN);
+    OPLK_MEMCPY(pMac_p, &ifr.ifr_hwaddr.sa_data[0], ETH_ALEN);
 }
 
 //------------------------------------------------------------------------------
@@ -272,9 +271,9 @@ static tOplkError veth_receiveFrame(tFrameInfo* pFrameInfo_p,
 
     // replace the MAC address of the POWERLINK Ethernet interface with virtual
     // Ethernet MAC address before forwarding it into the virtual Ethernet interface
-    if (OPLK_MEMCMP(pFrameInfo_p->frame.pBuffer->aDstMac, vethInstance_l.macAdrs, ETHER_ADDR_LEN) == 0)
+    if (OPLK_MEMCMP(pFrameInfo_p->frame.pBuffer->aDstMac, vethInstance_l.macAdrs, ETH_ALEN) == 0)
     {
-        OPLK_MEMCPY(pFrameInfo_p->frame.pBuffer->aDstMac, vethInstance_l.tapMacAdrs, ETHER_ADDR_LEN);
+        OPLK_MEMCPY(pFrameInfo_p->frame.pBuffer->aDstMac, vethInstance_l.tapMacAdrs, ETH_ALEN);
     }
 
     nwrite = write(vethInstance_l.fd, pFrameInfo_p->frame.pBuffer, pFrameInfo_p->frameSize);
@@ -302,7 +301,7 @@ to be used as a thread which does a blocking read in a while loop.
 //------------------------------------------------------------------------------
 static void* vethRecvThread(void* pArg_p)
 {
-    UINT8               buffer[ETHERMTU];
+    UINT8               buffer[ETH_DATA_LEN];
     UINT                nread;
     tFrameInfo          frameInfo;
     tOplkError          ret = kErrorOk;
@@ -331,7 +330,7 @@ static void* vethRecvThread(void* pArg_p)
                 break;
 
             default:    // data from tun/tap ready for read
-                nread = read(pInstance->fd, buffer, ETHERMTU);
+                nread = read(pInstance->fd, buffer, ETH_DATA_LEN);
                 if (nread > 0)
                 {
                     DEBUG_LVL_VETH_TRACE("VETH:Read %d bytes from the tap interface\n", nread);
@@ -340,7 +339,7 @@ static void* vethRecvThread(void* pArg_p)
                     DEBUG_LVL_VETH_TRACE("DST MAC: %02X:%02X:%02x:%02X:%02X:%02x\n",
                                           buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
                     // replace src MAC address with MAC address of virtual Ethernet interface
-                    OPLK_MEMCPY(&buffer[6], pInstance->macAdrs, ETHER_ADDR_LEN);
+                    OPLK_MEMCPY(&buffer[6], pInstance->macAdrs, ETH_ALEN);
 
                     frameInfo.frame.pBuffer = (tPlkFrame *)buffer;
                     frameInfo.frameSize = nread;
-- 
2.5.5