Skip to content

Commit 2011865

Browse files
author
Kanaga Shanmugam
committed
In ovs-ofctl dump-ports, skip Custom statistics if present.
1 parent 0b3fab9 commit 2011865

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ovs/openflow.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ func parseEach(in []byte, prefix []byte, fn func(b []byte) error) error {
425425
// which must be ignored. A banner appears containing "(OF1.x)" which we
426426
// detect here to discover if the last line should be discarded.
427427
hasDuration := bytes.Contains(scanner.Bytes(), []byte("(OF1."))
428+
// Detect if CUSTOM Statistics is present, to skip additional lines
429+
hasCustomStats := bytes.Contains(in, []byte("CUSTOM"))
428430

429431
// Scan every two lines to retrieve information needed to unmarshal
430432
// a single PortStats struct.
@@ -438,9 +440,20 @@ func parseEach(in []byte, prefix []byte, fn func(b []byte) error) error {
438440
}
439441
b = append(b, scanner.Bytes()...)
440442

441-
// Discard the third line of information if applicable.
442-
if hasDuration && !scanner.Scan() {
443-
return io.ErrUnexpectedEOF
443+
if hasDuration {
444+
// Discard the third line of information if applicable.
445+
if !scanner.Scan() {
446+
return io.ErrUnexpectedEOF
447+
}
448+
//Discard 4th & 5th lines if Custom stats are present
449+
if hasCustomStats {
450+
if !scanner.Scan() {
451+
return io.ErrUnexpectedEOF
452+
}
453+
if !scanner.Scan() {
454+
return io.ErrUnexpectedEOF
455+
}
456+
}
444457
}
445458

446459
if err := fn(b); err != nil {

0 commit comments

Comments
 (0)