Skip to content

Commit

Permalink
Skip warning about rules in legacy iptables.
Browse files Browse the repository at this point in the history
After iptables support nft backend, it will emit the following warning
if there are rules in the legacy iptables. "# Warning: iptables-legacy
tables present, use iptables-legacy to see them". This cause the
header skipping to fail in the following loop.
  • Loading branch information
kuroa-me committed Jun 25, 2023
1 parent fa6abe8 commit 45291ce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ func (ipt *IPTables) Stats(table, chain string) ([][]string, error) {

ipv6 := ipt.proto == ProtocolIPv6

// Skip the warning if exist
if strings.HasPrefix(lines[0], "#") {
lines = lines[1:]
}

rows := [][]string{}
for i, line := range lines {
// Skip over chain name and field header
Expand Down

0 comments on commit 45291ce

Please sign in to comment.