Browse code

dco linux: avoid redefining ovpn enums (2.6)

Starting with Linux kernel version 6.16, a couple of ovpn-related enum
definitions were introduced in the `include/uapi/linux/if_link.h`
header. Redefining them in openvpn when they are already present in the
system headers can lead to conflicts or build issues.

This commit ensures that enum redefinitions are avoided by conditionally
using the existing definitions from the system header when available.

This is the port to release/2.6 based on commit
1d3c2b67a73a0aa011c13e62f876d24e49d41df0.

Change-Id: I41c5dfc7489352a9534ff6b1585a5a81e0623ab1
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Message-Id: <20250801130302.372311-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32470.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Frank Lichtenheld authored on 2025/08/01 22:03:02
Showing 2 changed files
... ...
@@ -26,11 +26,13 @@
26 26
 
27 27
 #include "event.h"
28 28
 
29
-#include "ovpn_dco_linux.h"
30
-
31 29
 #include <netlink/socket.h>
32 30
 #include <netlink/netlink.h>
33 31
 
32
+/* include last since we need to behave differently if the kernel headers
33
+ * are from 6.16+ */
34
+#include "ovpn_dco_linux.h"
35
+
34 36
 typedef enum ovpn_key_slot dco_key_slot_t;
35 37
 typedef enum ovpn_cipher_alg dco_cipher_t;
36 38
 
... ...
@@ -237,14 +237,17 @@ enum ovpn_netlink_packet_attrs {
237 237
 	OVPN_PACKET_ATTR_MAX = __OVPN_PACKET_ATTR_AFTER_LAST - 1,
238 238
 };
239 239
 
240
+#ifndef IFLA_OVPN_MAX
241
+
240 242
 enum ovpn_ifla_attrs {
241 243
 	IFLA_OVPN_UNSPEC = 0,
242 244
 	IFLA_OVPN_MODE,
243 245
 
244
-	__IFLA_OVPN_AFTER_LAST,
245
-	IFLA_OVPN_MAX = __IFLA_OVPN_AFTER_LAST - 1,
246
+	__IFLA_OVPN_MAX,
246 247
 };
247 248
 
249
+#define IFLA_OVPN_MAX (__IFLA_OVPN_MAX - 1)
250
+
248 251
 enum ovpn_mode {
249 252
 	__OVPN_MODE_FIRST = 0,
250 253
 	OVPN_MODE_P2P = __OVPN_MODE_FIRST,
... ...
@@ -253,4 +256,6 @@ enum ovpn_mode {
253 253
 	__OVPN_MODE_AFTER_LAST,
254 254
 };
255 255
 
256
+#endif /* ifndef IFLA_OVPN_MAX */
257
+
256 258
 #endif /* _UAPI_LINUX_OVPN_DCO_H_ */