mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
networkctl: show permanent mac address if it is not used now
This commit is contained in:
parent
4bb7cc8287
commit
caa8538a22
@ -134,6 +134,7 @@ typedef struct LinkInfo {
|
||||
int ifindex;
|
||||
unsigned short iftype;
|
||||
struct ether_addr mac_address;
|
||||
struct ether_addr permanent_mac_address;
|
||||
uint32_t mtu;
|
||||
uint32_t min_mtu;
|
||||
uint32_t max_mtu;
|
||||
@ -173,6 +174,7 @@ typedef struct LinkInfo {
|
||||
struct ether_addr bssid;
|
||||
|
||||
bool has_mac_address:1;
|
||||
bool has_permanent_mac_address:1;
|
||||
bool has_tx_queues:1;
|
||||
bool has_rx_queues:1;
|
||||
bool has_stats64:1;
|
||||
@ -318,6 +320,12 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns) {
|
||||
sd_netlink_message_read_ether_addr(m, IFLA_ADDRESS, &info->mac_address) >= 0 &&
|
||||
memcmp(&info->mac_address, ÐER_ADDR_NULL, sizeof(struct ether_addr)) != 0;
|
||||
|
||||
_cleanup_close_ int fd = -1;
|
||||
info->has_permanent_mac_address =
|
||||
ethtool_get_permanent_macaddr(&fd, info->name, &info->permanent_mac_address) >= 0 &&
|
||||
memcmp(&info->permanent_mac_address, ÐER_ADDR_NULL, sizeof(struct ether_addr)) != 0 &&
|
||||
memcmp(&info->permanent_mac_address, &info->mac_address, sizeof(struct ether_addr)) != 0;
|
||||
|
||||
(void) sd_netlink_message_read_u32(m, IFLA_MTU, &info->mtu);
|
||||
(void) sd_netlink_message_read_u32(m, IFLA_MIN_MTU, &info->min_mtu);
|
||||
(void) sd_netlink_message_read_u32(m, IFLA_MAX_MTU, &info->max_mtu);
|
||||
@ -1228,6 +1236,26 @@ static int link_status_one(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (info->has_permanent_mac_address) {
|
||||
_cleanup_free_ char *description = NULL;
|
||||
char ea[ETHER_ADDR_TO_STRING_MAX];
|
||||
|
||||
(void) ieee_oui(hwdb, &info->permanent_mac_address, &description);
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "HW Permanent Address:");
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = table_add_cell_stringf(table, NULL, "%s%s%s%s",
|
||||
ether_addr_to_string(&info->permanent_mac_address, ea),
|
||||
description ? " (" : "",
|
||||
strempty(description),
|
||||
description ? ")" : "");
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (info->mtu > 0) {
|
||||
char min_str[DECIMAL_STR_MAX(uint32_t)], max_str[DECIMAL_STR_MAX(uint32_t)];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user