Bug 210882

Summary: [PATCH] ipfw sched show output mangled after r270424
Product: Base System Reporter: Guido Falsi <madpilot>
Component: binAssignee: Andrey V. Elsukov <ae>
Status: Closed FIXED    
Severity: Affects Some People CC: ae, madpilot, melifaro, pi, re
Priority: --- Keywords: needs-qa, patch, regression
Version: CURRENTFlags: madpilot: mfc-stable11?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
ipfw-sched-show-patch
none
header fix none

Description Guido Falsi freebsd_committer freebsd_triage 2016-07-06 23:14:43 UTC
Created attachment 172183 [details]
ipfw-sched-show-patch

I noticed the output of "ipfw sched show" became garbled in recent head, for example:

00001: 460.000 Kbit/s    0 ms burst 5120 
 sched 1 type QFQ flags 0x0 0 buckets 1 active
   Children flowsets: 16 15 14 13 12 11 
BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp
  0 ip           0.0.0.0/0             0.0.0.0/0     309679 166803112  0    0 181
00002:   7.424 Mbit/s    0 ms burst 10240 
 sched 2 type QFQ flags 0x0 0 buckets 1 active
   Children flowsets: 26 25 24 23 22 21 
  0 ip           0.0.0.0/0             0.0.0.0/0     309679 166803112  0    0 181  0 ip           0.0.0.0/0             0.0.0.0/0     411158 519899222  0    0   0
00003: 350.000 Kbit/s    0 ms burst 5120 
 sched 3 type QFQ flags 0x0 0 buckets 1 active
   Children flowsets: 31 
  0 ip           0.0.0.0/0             0.0.0.0/0     309679 166803112  0    0 181  0 ip           0.0.0.0/0             0.0.0.0/0     411158 519899222  0    0   0  0 ip           0.0.0.0/0             0.0.0.0/0     8465 12575050 34 50524   8


The script keeps appending things to the buffer after printing them. Attached patch adds a buffer flush after printing it.

BTW there is also a change in output due to the toPrint check just above my change. It used to print the header after each scheduler. I'm going to test a patch for this issue too and attach it here if I get something working.

CCing melifaro as he's the author of the commit which caused the regression.
Comment 1 Guido Falsi freebsd_committer freebsd_triage 2016-07-07 00:02:19 UTC
Created attachment 172184 [details]
header fix

I hacked up this fix for the header problem.

It restates previous behaviour for the headers, AFAIK.

Please note that this patch does not include the fix in the previous one, bot patches need to be applied IMHO, but also work separately.

Thanks.
Comment 2 Guido Falsi freebsd_committer freebsd_triage 2016-07-08 07:51:58 UTC
Since 11-STABLE has been branched, this fix, if accepted, should also be merged there.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-07-11 12:45:44 UTC
A commit references this bug:

Author: ae
Date: Mon Jul 11 12:44:59 UTC 2016
New revision: 302561
URL: https://svnweb.freebsd.org/changeset/base/302561

Log:
  Flush buffer after output. This fixes adding new data to already
  printed flows.

  PR:		210882
  MFC after:	3 days

Changes:
  head/sbin/ipfw/dummynet.c
Comment 4 Andrey V. Elsukov freebsd_committer freebsd_triage 2016-07-11 12:58:24 UTC
I am not sure what you mean about the change in output due to the toPrint check. It looks like the logic is still the same.
Comment 5 Guido Falsi freebsd_committer freebsd_triage 2016-07-11 20:34:36 UTC
(In reply to Andrey V. Elsukov from comment #4)
> I am not sure what you mean about the change in output due to the toPrint
> check. It looks like the logic is still the same.

I'm going by memory, I must admit that looking at the code I cannot see a reason why the output should be different, so I could well be mistaken.

Please allow me a few days (I'm away from home for a few days) to perform a test, if I find myself wrong I'll notify you here.

Thanks!
Comment 6 Guido Falsi freebsd_committer freebsd_triage 2016-07-11 20:53:09 UTC
Looking at some old logs I found online the difference I'm observing is the header line:

BKT Prot ___Source IP/port____ ____Dest. IP/port____ Tot_pkt/bytes Pkt/Byte Drp

gets printer only after the first sched (or queue if listing queues) while in old logs (but for reasons not clear to me by looking at the code) used to appear after each sche(or pipe) description, before the flows list.

I'm trying to get the old behaviour from a 10.3 jail I have on my laptop, just to check I'm not wrong.
Comment 7 commit-hook freebsd_committer freebsd_triage 2016-07-18 04:17:51 UTC
A commit references this bug:

Author: ae
Date: Mon Jul 18 04:16:54 UTC 2016
New revision: 302979
URL: https://svnweb.freebsd.org/changeset/base/302979

Log:
  MFC r302561,302565:
    Flush buffer after output. This fixes adding new data to already
    printed flows.

    PR:		210882
  Approved by:	re (kib)

Changes:
_U  stable/11/
  stable/11/sbin/ipfw/dummynet.c
  stable/11/sbin/ipfw/ipfw2.h
Comment 8 Glen Barber freebsd_committer freebsd_triage 2016-08-08 16:34:08 UTC
Presumably fixed.