Skip to content

Commit 133e4fb

Browse files
authored
Merge pull request #35 from jayanthvn/release-1.0
Readme from master to release branch
2 parents 0511633 + ee9cd0c commit 133e4fb

File tree

1 file changed

+122
-6
lines changed

1 file changed

+122
-6
lines changed

README.md

Lines changed: 122 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,133 @@
1-
## My Project
1+
# aws-ebpf-sdk-go
22

3-
TODO: Fill this README out!
3+
Golang based SDK for kernel eBPF operations i.e, load/attach/detach eBPF programs and create/delete/update maps. SDK relies on Unix bpf() system calls.
44

5-
Be sure to:
5+
SDK currently supports -
66

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
7+
1. eBPF program types -
8+
a. Traffic Classifiers
9+
b. XDP
10+
c. Kprobes/Kretprobes
11+
d. Tracepoint probes
12+
2. Ring buffer (would need kernel 5.10+)
13+
14+
SDK currently do not support -
15+
16+
1. Map in Map
17+
2. Perf buffer
18+
19+
Contributions welcome!
20+
21+
Note: This is the first version of SDK and interface is subject to change so kindly review the release notes before upgrading.
22+
23+
# Getting started
24+
25+
## How to build SDK?
26+
27+
Run `make buid-linux` - this will build the sdk binary.
28+
29+
## How to build elf file?
30+
31+
```
32+
clang -I../../.. -O2 -target bpf -c <C file> -o <ELF file>
33+
```
34+
35+
## How to use the SDK?
36+
37+
**Note:** SDK expects the BPF File System (/sys/fs/bpf) to be mounted.
38+
39+
In your application,
40+
41+
1. Get the latest SDK -
42+
43+
```
44+
GOPROXY=direct go get github.com/aws/aws-ebpf-sdk-go
45+
```
46+
47+
2. Import the elfparser -
48+
49+
```
50+
goebpfelfparser "github.com/aws/aws-ebpf-sdk-go/pkg/elfparser"
51+
```
52+
53+
3. Load the elf -
54+
55+
```
56+
goebpfelfparser.LoadBpfFile(<ELF file>, <custom pin path>)
57+
```
58+
59+
On a successful load, SDK returns -
60+
61+
1. loaded programs (includes associated maps)
62+
63+
```
64+
This is indexed by the pinpath -
65+
66+
type BpfData struct {
67+
Program ebpf_progs.BpfProgram // Return the program
68+
Maps map[string]ebpf_maps.BpfMap // List of associated maps
69+
}
70+
```
71+
72+
2. All maps in the elf file
73+
```
74+
This is indexed by the map name -
75+
76+
type BpfMap struct {
77+
MapFD uint32
78+
MapID uint32
79+
MapMetaData CreateEBPFMapInput
80+
}
81+
```
82+
83+
Application can specify custom pinpath while loading the elf file.
84+
85+
Maps and Programs pinpath location is not customizable with the current version of SDK and will be installed under the below locations by default -
86+
87+
Program PinPath - "/sys/fs/bpf/globals/aws/programs/"
88+
89+
Map PinPath - "/sys/fs/bpf/globals/aws/maps/"
90+
91+
Map defintion should follow the below definition else the SDK will fail to create the map.
92+
93+
```
94+
struct bpf_map_def_pvt {
95+
__u32 type;
96+
__u32 key_size;
97+
__u32 value_size;
98+
__u32 max_entries;
99+
__u32 map_flags;
100+
__u32 pinning;
101+
__u32 inner_map_fd;
102+
};
103+
```
104+
105+
## How to debug SDK issues?
106+
107+
SDK logs are located here `/var/log/aws-routed-eni/ebpf-sdk.log`.
108+
109+
## How to run unit-test
110+
111+
Run `sudo make unit-test`
112+
113+
Note: you would need to run this on you linux system
114+
115+
## How to run functional tests
116+
117+
Go to -
118+
119+
```
120+
cd test/
121+
make run-test
122+
```
9123

10124
## Security
11125

12126
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
13127

128+
If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the
129+
instructions [here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly](mailto:[email protected]).
130+
14131
## License
15132

16133
This project is licensed under the Apache-2.0 License.
17-

0 commit comments

Comments
 (0)