From 83949527774ead2765bd563a1828c4fb8d151073 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Fri, 13 Mar 2020 10:54:02 +0100 Subject: [PATCH 1/2] sd-netlink: Add IFLA_QDISC --- src/libsystemd/sd-netlink/netlink-types.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index 720e48e227c..8644cc7488c 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -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], From e810df37e4ea6d653ecf5fe402b3d35907b60b40 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Fri, 13 Mar 2020 10:54:35 +0100 Subject: [PATCH 2/2] networkctl: Add support to display qdisc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ./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 --- src/network/networkctl.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 880917a8442..70adf4c73bb 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -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,