Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2] ip: drop unnecessary fallback to ioctl for tx queue length
Date: Tue, 28 Jul 2026 14:38:43 -0700	[thread overview]
Message-ID: <20260728213843.794737-1-stephen@networkplumber.org> (raw)

Kernel has been reporting TxQ length with netlink since
the 2.5 so the ioctl path is dead code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ipaddress.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 7e4cb77c..6fa02c77 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -159,30 +159,11 @@ int get_operstate(const char *name)
 
 static void print_queuelen(FILE *f, struct rtattr *tb[IFLA_MAX + 1])
 {
-	int qlen;
+	if (tb[IFLA_TXQLEN]) {
+		__u32 qlen = rta_getattr_u32(tb[IFLA_TXQLEN]);
 
-	if (tb[IFLA_TXQLEN])
-		qlen = rta_getattr_u32(tb[IFLA_TXQLEN]);
-	else {
-		struct ifreq ifr = {};
-		int s = socket(AF_INET, SOCK_STREAM, 0);
-
-		if (s < 0)
-			return;
-
-		strcpy(ifr.ifr_name, rta_getattr_str(tb[IFLA_IFNAME]));
-		if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) {
-			fprintf(stderr,
-				"ioctl(SIOCGIFTXQLEN) failed: %s\n",
-				strerror(errno));
-			close(s);
-			return;
-		}
-		close(s);
-		qlen = ifr.ifr_qlen;
+		print_uint(PRINT_ANY, "txqlen", "qlen %u", qlen);
 	}
-	if (qlen)
-		print_int(PRINT_ANY, "txqlen", "qlen %d", qlen);
 }
 
 static const char *link_modes[] = {
-- 
2.53.0


                 reply	other threads:[~2026-07-28 21:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260728213843.794737-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox