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

Check that conntrack events are enabled in the kernel #2112

Merged
merged 1 commit into from
Jan 2, 2017
Merged
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
29 changes: 18 additions & 11 deletions probe/endpoint/conntrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"bytes"
"fmt"
"io"
"os"
"io/ioutil"
"path/filepath"
"strconv"
"sync"
Expand All @@ -18,13 +18,13 @@ import (

const (
// From https://www.kernel.org/doc/Documentation/networking/nf_conntrack-sysctl.txt
// Check a tcp-related file for existence since we need tcp tracking
procFileToCheck = "sys/net/netfilter/nf_conntrack_tcp_timeout_close"
timeWait = "TIME_WAIT"
tcpProto = "tcp"
newType = "[NEW]"
updateType = "[UPDATE]"
destroyType = "[DESTROY]"
eventsPath = "sys/net/netfilter/nf_conntrack_events"

timeWait = "TIME_WAIT"
tcpProto = "tcp"
newType = "[NEW]"
updateType = "[UPDATE]"
destroyType = "[DESTROY]"
)

var (
Expand Down Expand Up @@ -104,9 +104,16 @@ func newConntrackFlowWalker(useConntrack bool, procRoot string, bufferSize int,

// IsConntrackSupported returns true if conntrack is suppported by the kernel
var IsConntrackSupported = func(procRoot string) error {
procFile := filepath.Join(procRoot, procFileToCheck)
_, err := os.Stat(procFile)
return err
// Make sure events are enabled, the conntrack CLI doesn't verify it
f := filepath.Join(procRoot, eventsPath)
contents, err := ioutil.ReadFile(f)
if err != nil {
return err
}
if string(contents) == "0" {
return fmt.Errorf("conntrack events (%s) are disabled", f)
}
return nil
}

func (c *conntrackWalker) loop() {
Expand Down