Skip to contentSkip to conversation

networking: use OPENVPN_ETH_ALEN instead of ETH_ALEN

PATCH In review Antonio Quartulli 2 participants 2 messages Feb 23, 2022 – Mar 17, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 networking: use OPENVPN_ETH_ALEN instead of ETH_ALEN

With the introduction of SITNL two occurrences of ETH_ALEN were introduced in the code. This define exists on Linux in the linux/if_ether.h header, however the latter is included in linux/if_tun.h which may or may not exist (depending on how old your system is).

If the system lacks if_tun.h then the compilation fails because ETH_ALEN cannot be found.

For this reason, swap ETH_ALEN with OPENVPN_ETH_ALEN which is already used in other places of the code.

---
Changes from v1:
* include proto.h where OPENVPN_ETH_ALEN is used

---
 src/openvpn/lladdr.c           | 3 ++-
 src/openvpn/networking_sitnl.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
src/openvpn/lladdr.c +2 -1
index 3ddbebb3..ee677187 100644
@@ -13,6 +13,7 @@
 #include "misc.h"
 #include "run_command.h"
 #include "lladdr.h"
+#include "proto.h"
 
 int
 set_lladdr(openvpn_net_ctx_t *ctx, const char *ifname, const char *lladdr,
@@ -26,7 +27,7 @@ set_lladdr(openvpn_net_ctx_t *ctx, const char *ifname, const char *lladdr,
     }
 
 #if defined(TARGET_LINUX)
-    uint8_t addr[ETH_ALEN];
+    uint8_t addr[OPENVPN_ETH_ALEN];
 
     sscanf(lladdr, MAC_FMT, MAC_SCAN_ARG(addr));
     r = (net_addr_ll_set(ctx, ifname, addr) == 0);
src/openvpn/networking_sitnl.c +2 -1
index 959c897f..515a30d6 100644
@@ -32,6 +32,7 @@
 #include "buffer.h"
 #include "misc.h"
 #include "networking.h"
+#include "proto.h"
 
 #include <errno.h>
 #include <string.h>
@@ -748,7 +749,7 @@ net_addr_ll_set(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
     req.i.ifi_family = AF_PACKET;
     req.i.ifi_index = ifindex;
 
-    SITNL_ADDATTR(&req.n, sizeof(req), IFLA_ADDRESS, addr, ETH_ALEN);
+    SITNL_ADDATTR(&req.n, sizeof(req), IFLA_ADDRESS, addr, OPENVPN_ETH_ALEN);
 
     msg(M_INFO, "%s: lladdr " MAC_FMT " for %s", __func__, MAC_PRINT_ARG(addr),
         iface);
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#1 lore raw

Change makes sense, brings no behavioural change.

Your patch has been applied to the master and release/2.5 branch.

commit 8d487b4cc5b896cff5277adef6dd491b5918381f (master) commit 445cc852727a59f7338e59f0e594714d2b722beb (HEAD -> release/2.5)

Author: Antonio Quartulli
Date:   Wed Feb 23 09:06:28 2022 +0100
     networking: use OPENVPN_ETH_ALEN instead of ETH_ALEN

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg23882.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering