This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Cleanup / New Helpers / Detailed Examples and usage guides. (#9)
- Moved the bindata generated `Assets` api for public (non-lib-internal) use. - event.Trace->Argv is now a `call.Function` instead of a naked interface{} - Added `call.Function.Arguments()` accessor method. - Moved cmd/loadBPFargs helper function into cmd/loader.go - Removed `event.TraceEvent.WithTopology` (now covered by `WithContainerLookup` - `event.TraceEvent.WithContainerLookup` is now used as a callback for resolving pid-namespace->container resolution - Added `kernel.Probe.DetectAndSetOffsets()` helpers for auto-discovering proper struct member offsets using the running kernel. - kernel.Probe.InitProbe() now has optional configuration options * WithOffsetDetection() - struct task_struct member offset detection * WithDefaultFilter() - sets up default kernel filters for the BPF - Moved `hub.Hub` under the Topology API (pkg/topology) - Moved `hub.Job` under the Topology API (pkg/topology) - the Hub API no longer uses its own `hub.Observer`, this is derived from the `Observer` it was created with. - A metric buttload of documentation additions along with some pretty verbose examples.
- Loading branch information
Showing
45 changed files
with
1,874 additions
and
1,078 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
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,47 @@ | ||
package cmd | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/criticalstack/swoll/pkg/kernel/assets" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// loadBPFargs will attempt to find the BPF object file via the commandline, | ||
// If the argument is empty (default), we check the local environment, and if | ||
// that fails, we attempt to load the go-bindata generated asset. | ||
func loadBPFargs(cmd *cobra.Command, args []string) ([]byte, error) { | ||
var ( | ||
bpf []byte | ||
err error | ||
) | ||
|
||
// first check to see if the bpf object was defined at the commandline | ||
bpfFile, err = cmd.Flags().GetString("bpf") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if bpfFile == "" { | ||
// not found on the command-line, now try environment | ||
bpfFile = os.Getenv("SWOLL_BPFOBJECT") | ||
} | ||
|
||
if bpfFile != "" { | ||
// attempt to read the bpf object file if defined | ||
bpf, err = ioutil.ReadFile(bpfFile) | ||
if err != nil && !os.IsNotExist(err) { | ||
// only error if the error is *NOT* of type "file not found" | ||
return nil, err | ||
} | ||
} | ||
|
||
if len(bpf) == 0 { | ||
// we've tried all sorts of ways to load this file, by default | ||
// it attempts to use the go-bindata generated asset resource. | ||
bpf = assets.LoadBPF() | ||
} | ||
|
||
return bpf, err | ||
} |
Oops, something went wrong.