Skip to content

Commit 4fc465e

Browse files
committed
fix: ignore missing /proc/net/tcp6 and /proc/net/udp6 on IPv6-disabled systems
Signed-off-by: Shouhei <shouhei.yamaguchi.be@gmail.com>
1 parent 0951079 commit 4fc465e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/portutil/procnet/procnet_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package procnet
1818

1919
import (
2020
"bufio"
21+
"errors"
2122
"fmt"
2223
"os"
2324
)
@@ -52,6 +53,10 @@ func ReadStatsFileData(protocol string) ([]string, error) {
5253

5354
fp, err := os.Open(fileAddress)
5455
if err != nil {
56+
// IPv6-disabled environments do not have these files.
57+
if (fileAddress == netTCP6Stats || fileAddress == netUDP6Stats) && errors.Is(err, os.ErrNotExist) {
58+
return nil, nil
59+
}
5560
return nil, err
5661
}
5762
defer fp.Close()

0 commit comments

Comments
 (0)