Skip to content

Commit 1d30162

Browse files
Gavrilov Iliadavem330
authored andcommitted
net: pktgen: Fix interface flags printing
Device flags are displayed incorrectly: 1) The comparison (i == F_FLOW_SEQ) is always false, because F_FLOW_SEQ is equal to (1 << FLOW_SEQ_SHIFT) == 2048, and the maximum value of the 'i' variable is (NR_PKT_FLAG - 1) == 17. It should be compared with FLOW_SEQ_SHIFT. 2) Similarly to the F_IPSEC flag. 3) Also add spaces to the print end of the string literal "spi:%u" to prevent the output from merging with the flag that follows. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 99c6d3d ("pktgen: Remove brute-force printing of flags") Signed-off-by: Gavrilov Ilia <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f6c7b42 commit 1d30162

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

net/core/pktgen.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,19 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
669669
seq_puts(seq, " Flags: ");
670670

671671
for (i = 0; i < NR_PKT_FLAGS; i++) {
672-
if (i == F_FLOW_SEQ)
672+
if (i == FLOW_SEQ_SHIFT)
673673
if (!pkt_dev->cflows)
674674
continue;
675675

676-
if (pkt_dev->flags & (1 << i))
676+
if (pkt_dev->flags & (1 << i)) {
677677
seq_printf(seq, "%s ", pkt_flag_names[i]);
678-
else if (i == F_FLOW_SEQ)
679-
seq_puts(seq, "FLOW_RND ");
680-
681678
#ifdef CONFIG_XFRM
682-
if (i == F_IPSEC && pkt_dev->spi)
683-
seq_printf(seq, "spi:%u", pkt_dev->spi);
679+
if (i == IPSEC_SHIFT && pkt_dev->spi)
680+
seq_printf(seq, "spi:%u ", pkt_dev->spi);
684681
#endif
682+
} else if (i == FLOW_SEQ_SHIFT) {
683+
seq_puts(seq, "FLOW_RND ");
684+
}
685685
}
686686

687687
seq_puts(seq, "\n");

0 commit comments

Comments
 (0)