From: Jason A. Donenfeld Date: Sat, 13 Oct 2018 08:28:49 +0000 (+0200) Subject: networkd: fix attribute length for wireguard (#10380) X-Git-Tag: v240~560 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7d0b26a027118ca063780421cb31c74e9d2664ee;p=thirdparty%2Fsystemd.git networkd: fix attribute length for wireguard (#10380) This is actually a u16, not a u32, so the kernel complains: kernel: netlink: 'systemd-network': attribute type 5 has an invalid length This is due to: if (nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) { pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n", current->comm, type); } Presumably this has been working fine in functionality on little-endian systems, but nobody bothered to try on big-endian systems. Signed-off-by: Jason A. Donenfeld --- diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index b50a8c8303b..1e5b6a9dbbe 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -685,7 +685,7 @@ static const NLType genl_wireguard_peer_types[] = { [WGPEER_A_PUBLIC_KEY] = { .size = WG_KEY_LEN }, [WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, [WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN }, - [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U32 }, + [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 }, [WGPEER_A_ENDPOINT] = { /* either size of sockaddr_in or sockaddr_in6 depending on address family */ }, [WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system }, }; diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c index b81ddbde8f0..fabff3b72e4 100644 --- a/src/network/netdev/wireguard.c +++ b/src/network/netdev/wireguard.c @@ -107,7 +107,7 @@ static int set_wireguard_interface(NetDev *netdev) { if (r < 0) break; - r = sd_netlink_message_append_u32(message, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, peer->persistent_keepalive_interval); + r = sd_netlink_message_append_u16(message, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, peer->persistent_keepalive_interval); if (r < 0) break;