]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: fix attribute length for wireguard (#10380)
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 13 Oct 2018 08:28:49 +0000 (10:28 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 13 Oct 2018 08:28:49 +0000 (17:28 +0900)
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 <Jason@zx2c4.com>
src/libsystemd/sd-netlink/netlink-types.c
src/network/netdev/wireguard.c

index b50a8c8303b7569153cdae7cdaca38d4b0c1e8f7..1e5b6a9dbbeb087af86e26f79607e0d4d5837864 100644 (file)
@@ -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 },
 };
index b81ddbde8f06c4f6741a725e5a3adb0320a9e0e7..fabff3b72e446ee2bbb2bfe804bc1b035f02df27 100644 (file)
@@ -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;