Skip to content

Commit

Permalink
networkd: fix attribute length for wireguard (#10380)
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 7d0b26a)
(cherry picked from commit f116178)
  • Loading branch information
zx2c4 authored and keszybz committed Oct 29, 2018
1 parent 4e4a85d commit 7db3fe0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libsystemd/sd-netlink/netlink-types.c
Expand Up @@ -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 },
};
Expand Down
2 changes: 1 addition & 1 deletion src/network/netdev/wireguard.c
Expand Up @@ -122,7 +122,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;

Expand Down

0 comments on commit 7db3fe0

Please sign in to comment.