mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 01:55:22 +03:00
Merge pull request #15104 from ssahani/networkctl-qdisc
networkctl: Add support to display qdisc
This commit is contained in:
commit
9790ca75fc
@ -543,9 +543,7 @@ static const NLType rtnl_link_types[] = {
|
||||
[IFLA_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 },
|
||||
[IFLA_MTU] = { .type = NETLINK_TYPE_U32 },
|
||||
[IFLA_LINK] = { .type = NETLINK_TYPE_U32 },
|
||||
/*
|
||||
[IFLA_QDISC],
|
||||
*/
|
||||
[IFLA_QDISC] = { .type = NETLINK_TYPE_STRING },
|
||||
[IFLA_STATS] = { .size = sizeof(struct rtnl_link_stats) },
|
||||
/*
|
||||
[IFLA_COST],
|
||||
|
@ -125,6 +125,7 @@ typedef struct LinkInfo {
|
||||
uint32_t max_mtu;
|
||||
uint32_t tx_queues;
|
||||
uint32_t rx_queues;
|
||||
char *qdisc;
|
||||
char **alternative_names;
|
||||
|
||||
union {
|
||||
@ -179,6 +180,7 @@ static const LinkInfo* link_info_array_free(LinkInfo *array) {
|
||||
for (unsigned i = 0; array && array[i].needs_freeing; i++) {
|
||||
sd_device_unref(array[i].sd_device);
|
||||
free(array[i].ssid);
|
||||
free(array[i].qdisc);
|
||||
strv_free(array[i].alternative_names);
|
||||
}
|
||||
|
||||
@ -249,7 +251,7 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
|
||||
|
||||
static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, bool matched_patterns[]) {
|
||||
_cleanup_strv_free_ char **altnames = NULL;
|
||||
const char *name;
|
||||
const char *name, *qdisc;
|
||||
int ifindex, r;
|
||||
uint16_t type;
|
||||
|
||||
@ -333,6 +335,13 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
|
||||
else if (sd_netlink_message_read(m, IFLA_STATS, sizeof info->stats, &info->stats) >= 0)
|
||||
info->has_stats = true;
|
||||
|
||||
r = sd_netlink_message_read_string(m, IFLA_QDISC, &qdisc);
|
||||
if (r >= 0) {
|
||||
info->qdisc = strdup(qdisc);
|
||||
if (!info->qdisc)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
/* fill kind info */
|
||||
(void) decode_netdev(m, info);
|
||||
|
||||
@ -1336,6 +1345,15 @@ static int link_status_one(
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (info->qdisc) {
|
||||
r = table_add_many(table,
|
||||
TABLE_EMPTY,
|
||||
TABLE_STRING, "QDisc:",
|
||||
TABLE_STRING, info->qdisc);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
if (streq_ptr(info->netdev_kind, "bridge")) {
|
||||
r = table_add_many(table,
|
||||
TABLE_EMPTY,
|
||||
|
Loading…
Reference in New Issue
Block a user