Skip to content

Commit

Permalink
Merge pull request #78 from Atul-source/map_name_without_path
Browse files Browse the repository at this point in the history
Implemented map name without having full path in map name
  • Loading branch information
sanfern authored Jul 28, 2022
2 parents b0ae0b5 + ac2cee5 commit 5257289
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 164 deletions.
9 changes: 5 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Config struct {
HttpClientTimeout time.Duration
MaxNFReStartCount int
Environment string

BpfMapDefaultPath string
// Flag to enable chaining with root program
BpfChainingEnabled bool

Expand Down Expand Up @@ -117,21 +117,22 @@ func ReadConfig(configPath string) (*Config, error) {
ShutdownTimeout: LoadConfigDuration(confReader, "l3afd", "shutdown-timeout"),
SwaggerApiEnabled: LoadOptionalConfigBool(confReader, "l3afd", "swagger-api-enabled", false),
Environment: LoadOptionalConfigString(confReader, "l3afd", "environment", ENV_PROD),
BpfMapDefaultPath: LoadOptionalConfigString(confReader, "l3afd", "BpfMapDefaultPath", "/sys/fs/bpf"),
AdmindHost: LoadConfigString(confReader, "admind", "host"),
AdmindUsername: LoadConfigString(confReader, "admind", "username"),
AdmindApiKey: LoadConfigString(confReader, "admind", "api-key"),
AdmindGroupID: LoadConfigInt(confReader, "admind", "group-id"),
AdmindApiEnabled: LoadOptionalConfigBool(confReader, "admind", "api-enabled", true),
XDPRootProgramName: LoadOptionalConfigString(confReader, "xdp-root-program", "name", "xdp_root"),
XDPRootProgramArtifact: LoadOptionalConfigString(confReader, "xdp-root-program", "artifact", "l3af_xdp_root.tar.gz"),
XDPRootProgramMapName: LoadOptionalConfigString(confReader, "xdp-root-program", "ingress-map-name", "/sys/fs/bpf/xdp_root_array"),
XDPRootProgramMapName: LoadOptionalConfigString(confReader, "xdp-root-program", "ingress-map-name", "xdp_root_array"),
XDPRootProgramCommand: LoadOptionalConfigString(confReader, "xdp-root-program", "command", "xdp_root"),
XDPRootProgramVersion: LoadOptionalConfigString(confReader, "xdp-root-program", "version", "1.01"),
XDPRootProgramUserProgramDaemon: LoadOptionalConfigBool(confReader, "xdp-root-program", "user-program-daemon", false),
TCRootProgramName: LoadOptionalConfigString(confReader, "tc-root-program", "name", "tc_root"),
TCRootProgramArtifact: LoadOptionalConfigString(confReader, "tc-root-program", "artifact", "l3af_tc_root.tar.gz"),
TCRootProgramIngressMapName: LoadOptionalConfigString(confReader, "tc-root-program", "ingress-map-name", "/sys/fs/bpf/tc/globals/tc_ingress_root_array"),
TCRootProgramEgressMapName: LoadOptionalConfigString(confReader, "tc-root-program", "egress-map-name", "/sys/fs/bpf/tc/globals/tc_egress_root_array"),
TCRootProgramIngressMapName: LoadOptionalConfigString(confReader, "tc-root-program", "ingress-map-name", "tc/globals/tc_ingress_root_array"),
TCRootProgramEgressMapName: LoadOptionalConfigString(confReader, "tc-root-program", "egress-map-name", "tc/globals/tc_egress_root_array"),
TCRootProgramCommand: LoadOptionalConfigString(confReader, "tc-root-program", "command", "tc_root"),
TCRootProgramVersion: LoadOptionalConfigString(confReader, "tc-root-program", "version", "1.0"),
TCRootProgramUserProgramDaemon: LoadOptionalConfigBool(confReader, "tc-root-program", "user-program-daemon", false),
Expand Down
7 changes: 5 additions & 2 deletions config/l3afd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ bpf-chaining-enabled: true
swagger-api-enabled: false
# PROD | DEV
environment: PROD
#BpfMapDefaultPath is base path for storing maps
BpfMapDefaultPath: /sys/fs/bpf


[kf-repo]
url:
Expand Down Expand Up @@ -42,8 +45,8 @@ is-user-program: false
[tc-root-program]
name: tc_root
artifact: l3af_tc_root.tar.gz
ingress-map-name: /sys/fs/bpf/tc/globals/tc_ingress_root_array
egress-map-name: /sys/fs/bpf/tc/globals/tc_egress_root_array
ingress-map-name: tc/globals/tc_ingress_root_array
egress-map-name: tc/globals/tc_egress_root_array
command: tc_root
version: 1.0
is-user-program: false
Expand Down
4 changes: 2 additions & 2 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The payload will look more like this standard JSON:
"seq_id": 1,
"artifact": "l3af_ratelimiting.tar.gz",
"ebpf_package_repo_url": "https://l3af.io"
"map_name": "/sys/fs/bpf/xdp_rl_ingress_next_prog",
"map_name": "xdp_rl_ingress_next_prog",
"cmd_start": "ratelimiting",
"version": "latest",
"user_program_daemon": true,
Expand Down Expand Up @@ -49,7 +49,7 @@ The payload will look more like this standard JSON:
| seq_id | number | `1` | Position of the eBPF program in the chain. Count starts at 1. |
| artifact | string | `"l3af_ratelimiting.tar.gz"` | Userspace eBPF program binary and kernel eBPF byte code in tar.gz format |
| ebpf_package_repo_url | string | `"https://l3af.io/"` | eBPF package repository URL. If it is not provided default URL is used.| |
| map_name | string | `"/sys/fs/bpf/ep1_next_prog_array"` | Chaining program map in the file system with path. This should match the eBPF program code. |
| map_name | string | `"ep1_next_prog_array"` | Chaining program map to pin to. This should match the eBPF program code. |
| cmd_start | string | `"ratelimiting"` | The command used to start the eBPF program. Usually the userspace eBPF program binary name. |
| cmd_stop | string | | The command used stop the eBPF program |
| cmd_status | string | | The command used to get the status of the eBPF program |
Expand Down
Loading

0 comments on commit 5257289

Please sign in to comment.