From d69b62de4439a103fe3c8fbb9dbd25e1758d48b3 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Wed, 18 Mar 2020 13:42:27 +0100 Subject: [PATCH] networkctl: Add support to display IPv6 addrgenmode --- src/network/networkctl.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 7db2142ef24..772e6a95c22 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -127,6 +127,7 @@ typedef struct LinkInfo { uint32_t max_mtu; uint32_t tx_queues; uint32_t rx_queues; + uint8_t addr_gen_mode; char *qdisc; char **alternative_names; @@ -188,6 +189,7 @@ typedef struct LinkInfo { bool has_ethtool_link_info:1; bool has_wlan_link_info:1; bool has_tunnel_ipv4:1; + bool has_ipv6_address_generation_mode:1; bool needs_freeing:1; } LinkInfo; @@ -397,6 +399,19 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b (void) sd_netlink_message_read_u32(m, IFLA_MASTER, &info->master); + r = sd_netlink_message_enter_container(m, IFLA_AF_SPEC); + if (r >= 0) { + r = sd_netlink_message_enter_container(m, AF_INET6); + if (r >= 0) { + r = sd_netlink_message_read_u8(m, IFLA_INET6_ADDR_GEN_MODE, &info->addr_gen_mode); + if (r >= 0) + info->has_ipv6_address_generation_mode = true; + + (void) sd_netlink_message_exit_container(m); + } + (void) sd_netlink_message_exit_container(m); + } + /* fill kind info */ (void) decode_netdev(m, info); @@ -1418,6 +1433,24 @@ static int link_status_one( return table_log_add_error(r); } + if (info->has_ipv6_address_generation_mode) { + static const struct { + const char *mode; + } mode_table[] = { + { "eui64" }, + { "none" }, + { "stable-privacy" }, + { "random" }, + }; + + r = table_add_many(table, + TABLE_EMPTY, + TABLE_STRING, "IPv6 Address Generation Mode:", + TABLE_STRING, mode_table[info->addr_gen_mode]); + if (r < 0) + return table_log_add_error(r); + } + if (streq_ptr(info->netdev_kind, "bridge")) { r = table_add_many(table, TABLE_EMPTY,