From patchwork Sat Dec 12 11:09:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitrii Shcherbakov X-Patchwork-Id: 556008 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0A98F1401E7 for ; Sat, 12 Dec 2015 22:16:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=yandex.com header.i=@yandex.com header.b=ursQGy72; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbbLLLQO (ORCPT ); Sat, 12 Dec 2015 06:16:14 -0500 Received: from forward10j.cmail.yandex.net ([5.255.227.111]:48122 "EHLO forward10j.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752753AbbLLLQM (ORCPT ); Sat, 12 Dec 2015 06:16:12 -0500 X-Greylist: delayed 390 seconds by postgrey-1.27 at vger.kernel.org; Sat, 12 Dec 2015 06:16:12 EST Received: from web5j.yandex.ru (web5j.yandex.ru [IPv6:2a02:6b8:0:1619::305]) by forward10j.cmail.yandex.net (Yandex) with ESMTP id 067DE20F8D; Sat, 12 Dec 2015 14:09:40 +0300 (MSK) Received: from 127.0.0.1 (localhost [127.0.0.1]) by web5j.yandex.ru (Yandex) with ESMTP id 6430F268186F; Sat, 12 Dec 2015 14:09:40 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1449918580; bh=io+i6YGoaTOaxUmzn2WsDPHSUsLdmkitZfIEGVJQZo0=; h=From:To:Cc:Subject:Date; b=ursQGy72ljrqB7jbCOCsPehg5bXLiXTJnUKaPXv8qBUzVEU9TyqIH0rviASKBOzfc GvnPCBi1LI/OR1IvddpINufv+Kj1IJp4/2DieyaLipT/W0AjfkAUSnjkazgIe5ybgh FChdNy2g7Szs2mAppwNqL/MWKyvuK2vGU3jmf9AU= Received: by web5j.yandex.ru with HTTP; Sat, 12 Dec 2015 14:09:39 +0300 From: Dmitrii Shcherbakov Envelope-From: fw-dmitrii@yandex.ru To: netdev@vger.kernel.org Cc: jbrouer Subject: [PATCH][iproute2] tc/q_htb.c: Fix the MPU value output in 'tc -d class show dev ' command MIME-Version: 1.0 Message-Id: <5917221449918579@web5j.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sat, 12 Dec 2015 14:09:39 +0300 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hello, I noticed a quite an old change which I have a few questions about so maybe somebody could help me out. There are a few lines of code in tc/q_htb.c which were committed originally back in 2004 and have not changed since related to MPU (Minimum Packet Unit). I asked Stephen - this is probably the code that pre-dated git so I am not sure exactly who to ask: commit a166d246d84e7d0ba784e210515708006e16a366 Author: osdl.net!shemminger Date: Fri Jul 30 20:26:15 2004 +0000 mpu support @@ -243,10 +264,16 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) fprintf(f, "ceil %s ", sprint_rate(hopt->ceil.rate, b1)); cbuffer = ((double)hopt->ceil.rate*tc_core_tick2usec(hopt->cbuffer))/1000000; if (show_details) { - fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1), - 1<rate.cell_log, sprint_size(hopt->rate.mpu, b2)); - fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1), - 1<ceil.cell_log, sprint_size(hopt->ceil.mpu, b2)); + fprintf(f, "burst %s/%u mpu %s overhead %s ", + sprint_size(buffer, b1), + 1<rate.cell_log, + sprint_size(hopt->rate.mpu&0xFF, b2), + sprint_size((hopt->rate.mpu>>8)&0xFF, b3)); + fprintf(f, "cburst %s/%u mpu %s overhead %s ", + sprint_size(cbuffer, b1), + 1<ceil.cell_log, + sprint_size(hopt->ceil.mpu&0xFF, b2), + sprint_size((hopt->ceil.mpu>>8)&0xFF, b3)); I noticed that there is a separate configurable value called 'overhead' in q_htb.c now which does not have anything to do with 'overhead = hopt->rate.mpu>>8)&0xFF' that is being printed out in the above lines: static void explain(void) { ... " overhead per-packet size overhead used in rate computations\n" ... In the code fragment from the commit (for some reason I don't understand) 'rate.mpu' is sliced into two parts called 'mpu' and 'overhead'. So, basically, to retrieve the original MPU value from the output of `tc -d class show dev ` I need to do the following: real_mpu = mpu + overhead<<8. I also have a hard time understanding whether it is possible to have a condition where rate.mpu and ceil.mpu have different values - the outputs I have seen always showed the same values for both and I do not see anything in the code that sets them to different values (if so, maybe the duplicate output should be removed). As a reference, here is a link for a line in tc/q_tbf.c for the same functionality (show_details) that does not have anything like that for the MPU value: https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/tc/q_tbf.c#n279 |fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1),| Please take a look at my patch if you have time for it as this would simplify testing in the project I work on and make the output of the command less ambiguous for other people who may use HTB. Thank you, Dmitrii Shcherbakov From 26c62f17e1d6ebca9f236000806a63363ab70640 Mon Sep 17 00:00:00 2001 From: Dmitrii Shcherbakov Date: Sat, 12 Dec 2015 02:04:09 +0300 Subject: [PATCH] tc/q_htb.c: Fix the MPU value output in 'tc -d class show dev ' command This patch removes slicing of 'rate.mpu' into two parts called 'mpu' and 'overhead' alleviating the need to perform calculations to get the original MPU value after it is configured as follows: real_mpu = mpu + overhead<<8. Signed-off-by: Dmitrii Shcherbakov --- tc/q_htb.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tc/q_htb.c b/tc/q_htb.c index 7075a4c..f810329 100644 --- a/tc/q_htb.c +++ b/tc/q_htb.c @@ -274,7 +274,6 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) SPRINT_BUF(b1); SPRINT_BUF(b2); SPRINT_BUF(b3); - SPRINT_BUF(b4); if (opt == NULL) return 0; @@ -311,18 +310,16 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) cbuffer = tc_calc_xmitsize(ceil64, hopt->cbuffer); linklayer = (hopt->rate.linklayer & TC_LINKLAYER_MASK); if (linklayer > TC_LINKLAYER_ETHERNET || show_details) - fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, b4)); + fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, b3)); if (show_details) { - fprintf(f, "burst %s/%u mpu %s overhead %s ", + fprintf(f, "burst %s/%u mpu %s ", sprint_size(buffer, b1), 1<rate.cell_log, - sprint_size(hopt->rate.mpu&0xFF, b2), - sprint_size((hopt->rate.mpu>>8)&0xFF, b3)); - fprintf(f, "cburst %s/%u mpu %s overhead %s ", + sprint_size(hopt->rate.mpu, b2)); + fprintf(f, "cburst %s/%u mpu %s ", sprint_size(cbuffer, b1), 1<ceil.cell_log, - sprint_size(hopt->ceil.mpu&0xFF, b2), - sprint_size((hopt->ceil.mpu>>8)&0xFF, b3)); + sprint_size(hopt->ceil.mpu, b2)); fprintf(f, "level %d ", (int)hopt->level); } else { fprintf(f, "burst %s ", sprint_size(buffer, b1));