wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
* [PATCH] centos 6 compatibility
@ 2019-03-03 13:30 namiltd
  2019-03-27 14:48 ` Mieczysław Nalewaj
  0 siblings, 1 reply; 3+ messages in thread
From: namiltd @ 2019-03-03 13:30 UTC (permalink / raw)
  To: wireguard

---
 src/crypto/zinc/blake2s/blake2s.c | 17 +++++++++++++++++
 src/socket.c                      |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index b881db0..60b7763 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -19,9 +19,16 @@
 #include <linux/init.h>
 #include <linux/bug.h>
 #include <asm/unaligned.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
+#if GCC_VERSION > 40407
 typedef union {
 	struct {
+#else
+typedef struct {
+#endif
 		u8 digest_length;
 		u8 key_length;
 		u8 fanout;
@@ -33,8 +40,10 @@ typedef union {
 		u8 inner_length;
 		u8 salt[8];
 		u8 personal[8];
+#if GCC_VERSION > 40407
 	};
 	__le32 words[8];
+#endif
 } __packed blake2s_param;
 
 static const u32 blake2s_iv[8] = {
@@ -74,9 +83,17 @@ static inline void blake2s_init_param(struct blake2s_state *state,
 {
 	int i;
 
+#if GCC_VERSION <= 40407
+	const __le32 *words;
+	words = (const __le32 *)param;
+#endif
 	memset(state, 0, sizeof(*state));
 	for (i = 0; i < 8; ++i)
+#if GCC_VERSION > 40407
 		state->h[i] = blake2s_iv[i] ^ le32_to_cpu(param->words[i]);
+#else
+		state->h[i] = blake2s_iv[i] ^ le32_to_cpu(words[i]);
+#endif
 }
 
 void blake2s_init(struct blake2s_state *state, const size_t outlen)
diff --git a/src/socket.c b/src/socket.c
index 652d798..dfc98d3 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -16,6 +16,9 @@
 #include <linux/inetdevice.h>
 #include <net/udp_tunnel.h>
 #include <net/ipv6.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
 static int send4(struct wg_device *wg, struct sk_buff *skb,
 		 struct endpoint *endpoint, u8 ds, struct dst_cache *cache)
@@ -363,7 +366,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
 	struct socket *new4 = NULL, *new6 = NULL;
 	struct udp_port_cfg port4 = {
 		.family = AF_INET,
+#if GCC_VERSION > 40407
 		.local_ip.s_addr = htonl(INADDR_ANY),
+#endif
 		.local_udp_port = htons(port),
 		.use_udp_checksums = true
 	};
@@ -371,7 +376,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
 	int retries = 0;
 	struct udp_port_cfg port6 = {
 		.family = AF_INET6,
+#if GCC_VERSION > 40407
 		.local_ip6 = IN6ADDR_ANY_INIT,
+#endif
 		.use_udp6_tx_checksums = true,
 		.use_udp6_rx_checksums = true,
 		.ipv6_v6only = true
-- 
2.18.0.windows.1

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] centos 6 compatibility
  2019-03-03 13:30 [PATCH] centos 6 compatibility namiltd
@ 2019-03-27 14:48 ` Mieczysław Nalewaj
  2019-03-29 14:36   ` Mieczysław Nalewaj
  0 siblings, 1 reply; 3+ messages in thread
From: Mieczysław Nalewaj @ 2019-03-27 14:48 UTC (permalink / raw)
  To: wireguard


[-- Attachment #1.1: Type: text/plain, Size: 2824 bytes --]

Is there any chance to add this code?

W dniu 2019-03-03 o 14:30, namiltd@poczta.onet.pl pisze:
> ---
> src/crypto/zinc/blake2s/blake2s.c | 17 +++++++++++++++++
> src/socket.c                      |  7 +++++++
> 2 files changed, 24 insertions(+)
>
> diff --git a/src/crypto/zinc/blake2s/blake2s.c
> b/src/crypto/zinc/blake2s/blake2s.c
> index b881db0..60b7763 100644
> --- a/src/crypto/zinc/blake2s/blake2s.c
> +++ b/src/crypto/zinc/blake2s/blake2s.c
> @@ -19,9 +19,16 @@
> #include <linux/init.h>
> #include <linux/bug.h>
> #include <asm/unaligned.h>
> +#define GCC_VERSION (__GNUC__ * 10000 \
> +            + __GNUC_MINOR__ * 100 \
> +            + __GNUC_PATCHLEVEL__)
>
> +#if GCC_VERSION > 40407
> typedef union {
>     struct {
> +#else
> +typedef struct {
> +#endif
>         u8 digest_length;
>         u8 key_length;
>         u8 fanout;
> @@ -33,8 +40,10 @@ typedef union {
>         u8 inner_length;
>         u8 salt[8];
>         u8 personal[8];
> +#if GCC_VERSION > 40407
>     };
>     __le32 words[8];
> +#endif
> } __packed blake2s_param;
>
> static const u32 blake2s_iv[8] = {
> @@ -74,9 +83,17 @@ static inline void blake2s_init_param(struct
> blake2s_state *state,
> {
>     int i;
>
> +#if GCC_VERSION <= 40407
> +    const __le32 *words;
> +    words = (const __le32 *)param;
> +#endif
>     memset(state, 0, sizeof(*state));
>     for (i = 0; i < 8; ++i)
> +#if GCC_VERSION > 40407
>         state->h[i] = blake2s_iv[i] ^ le32_to_cpu(param->words[i]);
> +#else
> +        state->h[i] = blake2s_iv[i] ^ le32_to_cpu(words[i]);
> +#endif
> }
>
> void blake2s_init(struct blake2s_state *state, const size_t outlen)
> diff --git a/src/socket.c b/src/socket.c
> index 652d798..dfc98d3 100644
> --- a/src/socket.c
> +++ b/src/socket.c
> @@ -16,6 +16,9 @@
> #include <linux/inetdevice.h>
> #include <net/udp_tunnel.h>
> #include <net/ipv6.h>
> +#define GCC_VERSION (__GNUC__ * 10000 \
> +            + __GNUC_MINOR__ * 100 \
> +            + __GNUC_PATCHLEVEL__)
>
> static int send4(struct wg_device *wg, struct sk_buff *skb,
>          struct endpoint *endpoint, u8 ds, struct dst_cache *cache)
> @@ -363,7 +366,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
>     struct socket *new4 = NULL, *new6 = NULL;
>     struct udp_port_cfg port4 = {
>         .family = AF_INET,
> +#if GCC_VERSION > 40407
>         .local_ip.s_addr = htonl(INADDR_ANY),
> +#endif
>         .local_udp_port = htons(port),
>         .use_udp_checksums = true
>     };
> @@ -371,7 +376,9 @@ int wg_socket_init(struct wg_device *wg, u16 port)
>     int retries = 0;
>     struct udp_port_cfg port6 = {
>         .family = AF_INET6,
> +#if GCC_VERSION > 40407
>         .local_ip6 = IN6ADDR_ANY_INIT,
> +#endif
>         .use_udp6_tx_checksums = true,
>         .use_udp6_rx_checksums = true,
>         .ipv6_v6only = true



[-- Attachment #1.2: Type: text/html, Size: 4954 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] centos 6 compatibility
  2019-03-27 14:48 ` Mieczysław Nalewaj
@ 2019-03-29 14:36   ` Mieczysław Nalewaj
  0 siblings, 0 replies; 3+ messages in thread
From: Mieczysław Nalewaj @ 2019-03-29 14:36 UTC (permalink / raw)
  To: wireguard


[-- Attachment #1.1: Type: text/plain, Size: 420 bytes --]

New, improved version of patch for WireGuard Centos6 compatibility.

W dniu 2019-03-27 o 15:48, Mieczysław Nalewaj pisze:
> Is there any chance to add this code?
>
> W dniu 2019-03-03 o 14:30, namiltd@poczta.onet.pl pisze:
>> ---
>> src/crypto/zinc/blake2s/blake2s.c | 17 +++++++++++++++++
>> src/socket.c                      |  7 +++++++
>> 2 files changed, 24 insertions(+)
>> ....
>>        .ipv6_v6only = true
>
>


[-- Attachment #1.2: Type: text/html, Size: 1882 bytes --]

[-- Attachment #2: wireguard.diff --]
[-- Type: text/plain, Size: 1125 bytes --]

diff -ruN master/src/socket.c master-centos6/src/socket.c
--- master/src/socket.c	2019-03-29 15:10:20.000000000 +0100
+++ master-centos6/src/socket.c	2019-03-29 15:10:31.000000000 +0100
@@ -16,6 +16,9 @@
 #include <linux/inetdevice.h>
 #include <net/udp_tunnel.h>
 #include <net/ipv6.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
 static int send4(struct wg_device *wg, struct sk_buff *skb,
 		 struct endpoint *endpoint, u8 ds, struct dst_cache *cache)
@@ -363,7 +366,11 @@
 	struct socket *new4 = NULL, *new6 = NULL;
 	struct udp_port_cfg port4 = {
 		.family = AF_INET,
+#if GCC_VERSION == 40407
+		{.local_ip.s_addr = htonl(INADDR_ANY)},
+#else
 		.local_ip.s_addr = htonl(INADDR_ANY),
+#endif
 		.local_udp_port = htons(port),
 		.use_udp_checksums = true
 	};
@@ -371,7 +378,11 @@
 	int retries = 0;
 	struct udp_port_cfg port6 = {
 		.family = AF_INET6,
+#if GCC_VERSION == 40407
+		{.local_ip6 = IN6ADDR_ANY_INIT},
+#else
 		.local_ip6 = IN6ADDR_ANY_INIT,
+#endif
 		.use_udp6_tx_checksums = true,
 		.use_udp6_rx_checksums = true,
 		.ipv6_v6only = true

[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-06 11:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-03 13:30 [PATCH] centos 6 compatibility namiltd
2019-03-27 14:48 ` Mieczysław Nalewaj
2019-03-29 14:36   ` Mieczysław Nalewaj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).