networkctl: Add support to display qdisc

./networkctl status ens38                                                                                                                                                                ─╯
● 4: ens38
             Link File: /usr/lib/systemd/network/99-default.link
          Network File: /usr/lib/systemd/network/10-ens38.network
                  Type: ether
                 State: routable (configured)
     Alternative Names: enp2s6
                  Path: pci-0000:02:06.0
                Driver: e1000
                Vendor: Intel Corporation
                 Model: 82545EM Gigabit Ethernet Controller (Copper) (PRO/1000 MT Single Port Adapter)
            HW Address: 00:0c:29:d2:42:7c (VMware, Inc.)
                   MTU: 1500 (min: 46, max: 16110)
                 QDisc: fq_codel        <============================
  Queue Length (Tx/Rx): 1/1
      Auto negotiation: yes
                 Speed: 1Gbps
                Duplex: full
                  Port: tp
               Address: 192.168.5.123
                        fe80::20c:29ff:fed2:427c
This commit is contained in:
Susant Sahani 2020-03-13 10:54:35 +01:00
parent 8394952777
commit e810df37e4

View file

@ -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,