Skip to contentSkip to conversation

Use OPENVPN_ETH_P_* so that <netinet/if_ether.h> is unecessary

PATCH In review Felix Janda 3 participants 3 messages May 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use OPENVPN_ETH_P_* so that <netinet/if_ether.h> is unecessary

Fixes compilation error on linux with musl libc because of conflicting ethhdr declarations in <netinet/if_ether.h> and <linux/if_ether.h> which is included from <linux/if_tun.h>

---
 configure.ac          | 2 +-
 src/openvpn/syshead.h | 4 ----
 src/openvpn/tun.c     | 4 ++--
 3 files changed, 3 insertions(+), 7 deletions(-)
configure.ac +1 -1
index 9132468..5dccfbb 100644
@@ -461,7 +461,7 @@ SOCKET_INCLUDES="
 "
 
 AC_CHECK_HEADERS(
-	[net/if.h netinet/ip.h netinet/if_ether.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
+	[net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
 	,
 	,
 	[[${SOCKET_INCLUDES}]]
src/openvpn/syshead.h +0 -4
index b898bf2..cf29131 100644
@@ -214,10 +214,6 @@
 
 #if defined(TARGET_LINUX) || defined (TARGET_ANDROID)
 
-#if defined(HAVE_NETINET_IF_ETHER_H)
-#include <netinet/if_ether.h>
-#endif
-
 #ifdef HAVE_LINUX_IF_TUN_H
 #include <linux/if_tun.h>
 #endif
src/openvpn/tun.c +2 -2
index 11a6d71..ce3ed85 100644
@@ -1856,9 +1856,9 @@ write_tun (struct tuntap* tt, uint8_t *buf, int len)
       pi.flags = 0;
 
       if(iph->version == 6)
-	pi.proto = htons(ETH_P_IPV6);
+	pi.proto = htons(OPENVPN_ETH_P_IPV6);
       else
-	pi.proto = htons(ETH_P_IP);
+	pi.proto = htons(OPENVPN_ETH_P_IPV4);
 
       vect[0].iov_len = sizeof(pi);
       vect[0].iov_base = &pi;
Signature · 1 line
2.3.6
#1 lore raw
Quoted 46 lines · Felix Janda

Fixes compilation error on linux with musl libc because of conflicting ethhdr declarations in <netinet/if_ether.h> and <linux/if_ether.h> which is included from <linux/if_tun.h>

---
  configure.ac          | 2 +-
  src/openvpn/syshead.h | 4 ----
  src/openvpn/tun.c     | 4 ++--
  3 files changed, 3 insertions(+), 7 deletions(-)
configure.ac +1 -1
index 9132468..5dccfbb 100644
@@ -461,7 +461,7 @@ SOCKET_INCLUDES="
  "
 
  AC_CHECK_HEADERS(
-	[net/if.h netinet/ip.h netinet/if_ether.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
+	[net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
  	,
  	,
  	[[${SOCKET_INCLUDES}]]
src/openvpn/syshead.h +0 -4
index b898bf2..cf29131 100644
@@ -214,10 +214,6 @@
 
  #if defined(TARGET_LINUX) || defined (TARGET_ANDROID)
 
-#if defined(HAVE_NETINET_IF_ETHER_H)
-#include <netinet/if_ether.h>
-#endif
-
  #ifdef HAVE_LINUX_IF_TUN_H
  #include <linux/if_tun.h>
  #endif
src/openvpn/tun.c +0 -0
index 11a6d71..ce3ed85 100644
@@ -1856,9 +1856,9 @@ write_tun (struct tuntap* tt, uint8_t *buf, int len)
        pi.flags = 0;

src/openvpn/tun.c write_tun (struct tuntap* tt, uint8_t *buf, int len) · line 1864

Quoted 10 lines
src/openvpn/tun.c +2 -2
 
        if(iph->version == 6)
-	pi.proto = htons(ETH_P_IPV6);
+	pi.proto = htons(OPENVPN_ETH_P_IPV6);
        else
-	pi.proto = htons(ETH_P_IP);
+	pi.proto = htons(OPENVPN_ETH_P_IPV4);
 
        vect[0].iov_len = sizeof(pi);
        vect[0].iov_base = &pi;

Fewer dependencies, fewer lines of code, same functionality. Looks good to me. Compiled fine on Linux 3.13 and 3.16.

ACK

-Steffan

#2 lore raw
In reply to Felix Janda

Your patch has been applied to the master and release/2.3 branches.

commit ddb1f20a9ddbb94956c9f7b1115c89543d9b411a (master) commit e9739fbf587e1b0516fa47b9576cc8be8b514d21 (release/2.3)

Author: Felix Janda
Date:   Sat May 16 15:59:50 2015 +0200
     Use OPENVPN_ETH_P_* so that <netinet/if_ether.h> is unecessary

     Signed-off-by: Felix Janda <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/9690
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering