Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #19945 to 7.9: Packetbeat process monitor: Ignore missing /proc/net/tcp6 #20014

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ field. You can revert this change by configuring tags for the module and omittin
*Packetbeat*

- Enable setting promiscuous mode automatically. {pull}11366[11366]
- Fix process monitoring when ipv6 is disabled under Linux. {issue}19941[19941] {pull}19945[19945]

*Winlogbeat*

Expand Down
15 changes: 13 additions & 2 deletions packetbeat/procs/procs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"

"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/packetbeat/protos/applayer"
Expand All @@ -51,6 +52,8 @@ var procFiles = map[applayer.Transport]struct {
applayer.TransportTCP: {"/proc/net/tcp", "/proc/net/tcp6"},
}

var warnIPv6Once sync.Once

// GetLocalPortToPIDMapping returns the list of local port numbers and the PID
// that owns them.
func (proc *ProcessesWatcher) GetLocalPortToPIDMapping(transport applayer.Transport) (ports map[endpoint]int, err error) {
Expand All @@ -68,10 +71,18 @@ func (proc *ProcessesWatcher) GetLocalPortToPIDMapping(transport applayer.Transp
logp.Err("GetLocalPortToPIDMapping: parsing '%s': %s", sourceFiles.ipv4, err)
return nil, err
}

ipv6socks, err := socketsFromProc(sourceFiles.ipv6, true)
// Ignore the error when /proc/net/tcp6 doesn't exists (ipv6 disabled).
if err != nil {
logp.Err("GetLocalPortToPIDMapping: parsing '%s': %s", sourceFiles.ipv6, err)
return nil, err
if os.IsNotExist(err) {
warnIPv6Once.Do(func() {
logp.Warn("No IPv6 socket info reported by the kernel. Process monitor won't enrich IPv6 events")
})
} else {
logp.Err("GetLocalPortToPIDMapping: parsing '%s': %s", sourceFiles.ipv6, err)
return nil, err
}
}
socksMap := map[uint64]*socketInfo{}
for _, s := range ipv4socks {
Expand Down