netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Changli Gao <xiaosuo@gmail.com>
To: shemminger@vyatta.com
Cc: netdev@vger.kernel.org, kuznet@ms2.inr.ac.ru,
	Changli Gao <xiaosuo@gmail.com>
Subject: [PATCH] iproute2: use IFLA_TXQLEN when it is available
Date: Thu, 12 May 2011 10:47:31 +0800	[thread overview]
Message-ID: <1305168451-14491-1-git-send-email-xiaosuo@gmail.com> (raw)

Use IFLA_TXQLEN when it is available, to avoid additional system calls.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 ip/ipaddress.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index a1f78b9..59afafd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -285,8 +285,16 @@ int print_linkinfo(const struct sockaddr_nl *who,
 	if (tb[IFLA_OPERSTATE])
 		print_operstate(fp, *(__u8 *)RTA_DATA(tb[IFLA_OPERSTATE]));
 		
-	if (filter.showqueue)
-		print_queuelen(fp, (char*)RTA_DATA(tb[IFLA_IFNAME]));
+	if (filter.showqueue) {
+		if (tb[IFLA_TXQLEN]) {
+			__u32 txqlen = *(__u32 *)RTA_DATA(tb[IFLA_TXQLEN]);
+
+			if (txqlen)
+				fprintf(fp, "qlen %u", txqlen);
+		} else {
+			print_queuelen(fp, (char*)RTA_DATA(tb[IFLA_IFNAME]));
+		}
+	}
 
 	if (!filter.family || filter.family == AF_PACKET) {
 		SPRINT_BUF(b1);

             reply	other threads:[~2011-05-12  2:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12  2:47 Changli Gao [this message]
2011-05-12  3:28 ` [PATCH] iproute2: use IFLA_TXQLEN when it is available Eric Dumazet
2011-05-12  4:40   ` Eric Dumazet
2011-05-12 15:57     ` Stephen Hemminger

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=1305168451-14491-1-git-send-email-xiaosuo@gmail.com \
    --to=xiaosuo@gmail.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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;
as well as URLs for NNTP newsgroup(s).