platform/wireguard: fix WGPEER_A_LAST_HANDSHAKE_TIME to use int64 typed timespec structure

The netlink API changed for WireGuard. Adjust for that.

https://git.zx2c4.com/WireGuard/commit/?id=c870c7af53f44a37814dfc76ceb8ad88e290fcd8
This commit is contained in:
Thomas Haller 2019-03-01 09:32:45 +01:00
parent 7451a6a649
commit 4e399d82ac
2 changed files with 18 additions and 3 deletions

View file

@ -2019,8 +2019,10 @@ _wireguard_update_from_peers_nla (CList *peers,
if (tb[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL])
peer_c->data.persistent_keepalive_interval = nla_get_u16 (tb[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]);
if (tb[WGPEER_A_LAST_HANDSHAKE_TIME])
nla_memcpy (&peer_c->data.last_handshake_time, tb[WGPEER_A_LAST_HANDSHAKE_TIME], sizeof (peer_c->data.last_handshake_time));
if (tb[WGPEER_A_LAST_HANDSHAKE_TIME]) {
if (nla_len (tb[WGPEER_A_LAST_HANDSHAKE_TIME]) >= sizeof (peer_c->data.last_handshake_time))
nla_memcpy (&peer_c->data.last_handshake_time, tb[WGPEER_A_LAST_HANDSHAKE_TIME], sizeof (peer_c->data.last_handshake_time));
}
if (tb[WGPEER_A_RX_BYTES])
peer_c->data.rx_bytes = nla_get_u64 (tb[WGPEER_A_RX_BYTES]);
if (tb[WGPEER_A_TX_BYTES])

View file

@ -31,6 +31,18 @@ struct udev_device;
/*****************************************************************************/
/* "struct __kernel_timespec" uses "long long", but we use gint64. In practice,
* these are the same types. */
G_STATIC_ASSERT (sizeof (long long) == sizeof (gint64));
typedef struct {
/* like "struct __kernel_timespec". */
gint64 tv_sec;
gint64 tv_nsec;
} NMPTimespec64;
/*****************************************************************************/
typedef union {
struct sockaddr sa;
struct sockaddr_in in;
@ -72,7 +84,8 @@ typedef struct {
typedef struct _NMPWireGuardPeer {
NMSockAddrUnion endpoint;
struct timespec last_handshake_time;
NMPTimespec64 last_handshake_time;
guint64 rx_bytes;
guint64 tx_bytes;