-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to disable BPF programs.
If the page size for an enhanced event is 0, then don't attempt to load that BPF program. This is helpful for BPF programs that generate massive amounts of events (like disk events).
- Loading branch information
Showing
7 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
Copyright 2019 Gravitational, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package bpf | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gravitational/teleport/lib/defaults" | ||
"github.com/gravitational/teleport/lib/utils" | ||
|
||
"gopkg.in/check.v1" | ||
) | ||
|
||
type CommonSuite struct{} | ||
|
||
var _ = fmt.Printf | ||
var _ = check.Suite(&CommonSuite{}) | ||
|
||
func (s *CommonSuite) SetUpSuite(c *check.C) { | ||
utils.InitLoggerForTests() | ||
} | ||
func (s *CommonSuite) TearDownSuite(c *check.C) {} | ||
func (s *CommonSuite) SetUpTest(c *check.C) {} | ||
func (s *CommonSuite) TearDownTest(c *check.C) {} | ||
|
||
// TestCheckAndSetDefaults makes sure defaults are set when the user does not | ||
// provide values for the page sizes and hard coded values (like zero or a | ||
// specific page size) are respected when given. | ||
func (s *CommonSuite) TestCheckAndSetDefaults(c *check.C) { | ||
var perfBufferPageCount = defaults.PerfBufferPageCount | ||
var openPerfBufferPageCount = defaults.OpenPerfBufferPageCount | ||
var zeroPageCount = 0 | ||
|
||
var tests = []struct { | ||
inConfig *Config | ||
outConfig *Config | ||
}{ | ||
// Empty values get defaults. | ||
{ | ||
inConfig: &Config{ | ||
CommandBufferSize: nil, | ||
DiskBufferSize: nil, | ||
NetworkBufferSize: nil, | ||
}, | ||
outConfig: &Config{ | ||
CommandBufferSize: &perfBufferPageCount, | ||
DiskBufferSize: &openPerfBufferPageCount, | ||
NetworkBufferSize: &perfBufferPageCount, | ||
}, | ||
}, | ||
// Values are not wiped out with defaults. | ||
{ | ||
inConfig: &Config{ | ||
CommandBufferSize: &zeroPageCount, | ||
DiskBufferSize: &zeroPageCount, | ||
NetworkBufferSize: &perfBufferPageCount, | ||
}, | ||
outConfig: &Config{ | ||
CommandBufferSize: &zeroPageCount, | ||
DiskBufferSize: &zeroPageCount, | ||
NetworkBufferSize: &perfBufferPageCount, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
err := tt.inConfig.CheckAndSetDefaults() | ||
c.Assert(err, check.IsNil) | ||
c.Assert(*tt.inConfig.CommandBufferSize, check.Equals, *tt.outConfig.CommandBufferSize) | ||
c.Assert(*tt.inConfig.DiskBufferSize, check.Equals, *tt.outConfig.DiskBufferSize) | ||
c.Assert(*tt.inConfig.NetworkBufferSize, check.Equals, *tt.outConfig.NetworkBufferSize) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters