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

Update config parameters #120

Merged
merged 6 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
116 changes: 50 additions & 66 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,20 @@ type Config struct {

SwaggerApiEnabled bool

// Admin API endpoint config for registering l3afd.
AdmindHost string
AdmindUsername string
AdmindApiKey string
AdmindGroupID int
AdmindApiEnabled bool

// XDP Root program details.
XDPRootProgramName string
XDPRootProgramArtifact string
XDPRootProgramMapName string
XDPRootProgramCommand string
XDPRootProgramVersion string
XDPRootProgramUserProgramDaemon bool
XDPRootProgramName string
XDPRootProgramArtifact string
XDPRootProgramMapName string
XDPRootProgramCommand string
XDPRootProgramVersion string

// TC Root program details.
TCRootProgramName string
TCRootProgramArtifact string
TCRootProgramIngressMapName string
TCRootProgramEgressMapName string
TCRootProgramCommand string
TCRootProgramVersion string
TCRootProgramUserProgramDaemon bool
TCRootProgramName string
TCRootProgramArtifact string
TCRootProgramIngressMapName string
TCRootProgramEgressMapName string
TCRootProgramCommand string
TCRootProgramVersion string

// ebpf chain details
EBPFChainDebugAddr string
Expand Down Expand Up @@ -101,52 +92,45 @@ func ReadConfig(configPath string) (*Config, error) {
}

return &Config{
PIDFilename: LoadConfigString(confReader, "l3afd", "pid-file"),
DataCenter: LoadConfigString(confReader, "l3afd", "datacenter"),
BPFDir: LoadConfigString(confReader, "l3afd", "bpf-dir"),
BPFLogDir: LoadConfigString(confReader, "l3afd", "bpf-log-dir"),
MinKernelMajorVer: LoadConfigInt(confReader, "l3afd", "kernel-major-version"),
MinKernelMinorVer: LoadConfigInt(confReader, "l3afd", "kernel-minor-version"),
KFRepoURL: LoadConfigString(confReader, "kf-repo", "url"),
HttpClientTimeout: LoadConfigDuration(confReader, "l3afd", "http-client-timeout"),
MaxNFReStartCount: LoadConfigInt(confReader, "l3afd", "max-nf-restart-count"),
BpfChainingEnabled: LoadOptionalConfigBool(confReader, "l3afd", "bpf-chaining-enabled", true),
MetricsAddr: LoadConfigString(confReader, "web", "metrics-addr"),
KFPollInterval: LoadOptionalConfigDuration(confReader, "web", "kf-poll-interval", 30*time.Second),
NMetricSamples: LoadOptionalConfigInt(confReader, "web", "n-metric-samples", 20),
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", "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", "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),
EBPFChainDebugAddr: LoadOptionalConfigString(confReader, "ebpf-chain-debug", "addr", "0.0.0.0:8899"),
EBPFChainDebugEnabled: LoadOptionalConfigBool(confReader, "ebpf-chain-debug", "enabled", false),
L3afConfigsRestAPIAddr: LoadOptionalConfigString(confReader, "l3af-configs", "restapi-addr", "localhost:53000"),
L3afConfigStoreFileName: LoadOptionalConfigString(confReader, "l3af-config-store", "filename", "/etc/l3afd/l3af-config.json"),
MTLSEnabled: LoadOptionalConfigBool(confReader, "mtls", "enabled", true),
MTLSMinVersion: minTLSVersion,
MTLSCertDir: LoadOptionalConfigString(confReader, "mtls", "cert-dir", "/etc/l3afd/certs"),
MTLSCACertFilename: LoadOptionalConfigString(confReader, "mtls", "cacert-filename", "ca.pem"),
MTLSServerCertFilename: LoadOptionalConfigString(confReader, "mtls", "server-cert-filename", "server.crt"),
MTLSServerKeyFilename: LoadOptionalConfigString(confReader, "mtls", "server-key-filename", "server.key"),
MTLSCertExpiryWarningDays: LoadOptionalConfigInt(confReader, "mtls", "cert-expiry-warning-days", 30),
PIDFilename: LoadConfigString(confReader, "l3afd", "pid-file"),
DataCenter: LoadConfigString(confReader, "l3afd", "datacenter"),
BPFDir: LoadConfigString(confReader, "l3afd", "bpf-dir"),
BPFLogDir: LoadConfigString(confReader, "l3afd", "bpf-log-dir"),
MinKernelMajorVer: LoadConfigInt(confReader, "l3afd", "kernel-major-version"),
MinKernelMinorVer: LoadConfigInt(confReader, "l3afd", "kernel-minor-version"),
KFRepoURL: LoadConfigString(confReader, "kf-repo", "url"),
HttpClientTimeout: LoadConfigDuration(confReader, "l3afd", "http-client-timeout"),
MaxNFReStartCount: LoadConfigInt(confReader, "l3afd", "max-nf-restart-count"),
BpfChainingEnabled: LoadOptionalConfigBool(confReader, "l3afd", "bpf-chaining-enabled", true),
MetricsAddr: LoadConfigString(confReader, "web", "metrics-addr"),
KFPollInterval: LoadOptionalConfigDuration(confReader, "web", "kf-poll-interval", 30*time.Second),
NMetricSamples: LoadOptionalConfigInt(confReader, "web", "n-metric-samples", 20),
ShutdownTimeout: LoadConfigDuration(confReader, "l3afd", "shutdown-timeout"),
SwaggerApiEnabled: LoadOptionalConfigBool(confReader, "l3afd", "swagger-api-enabled", false),
Environment: LoadOptionalConfigString(confReader, "l3afd", "environment", ENV_PROD),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to docs this should be required in the config and I agree on specifically defining this PROD vs non

BpfMapDefaultPath: LoadOptionalConfigString(confReader, "l3afd", "BpfMapDefaultPath", "/sys/fs/bpf"),
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", "xdp_root_array"),
XDPRootProgramCommand: LoadOptionalConfigString(confReader, "xdp-root-program", "command", "xdp_root"),
XDPRootProgramVersion: LoadOptionalConfigString(confReader, "xdp-root-program", "version", "1.01"),
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", "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"),
EBPFChainDebugAddr: LoadOptionalConfigString(confReader, "ebpf-chain-debug", "addr", "0.0.0.0:8899"),
EBPFChainDebugEnabled: LoadOptionalConfigBool(confReader, "ebpf-chain-debug", "enabled", false),
L3afConfigsRestAPIAddr: LoadOptionalConfigString(confReader, "l3af-configs", "restapi-addr", "localhost:53000"),
L3afConfigStoreFileName: LoadOptionalConfigString(confReader, "l3af-config-store", "filename", "/etc/l3afd/l3af-config.json"),
MTLSEnabled: LoadOptionalConfigBool(confReader, "mtls", "enabled", true),
MTLSMinVersion: minTLSVersion,
MTLSCertDir: LoadOptionalConfigString(confReader, "mtls", "cert-dir", "/etc/l3afd/certs"),
MTLSCACertFilename: LoadOptionalConfigString(confReader, "mtls", "cacert-filename", "ca.pem"),
MTLSServerCertFilename: LoadOptionalConfigString(confReader, "mtls", "server-cert-filename", "server.crt"),
MTLSServerKeyFilename: LoadOptionalConfigString(confReader, "mtls", "server-key-filename", "server.key"),
MTLSCertExpiryWarningDays: LoadOptionalConfigInt(confReader, "mtls", "cert-expiry-warning-days", 30),
}, nil
}

Expand Down
22 changes: 7 additions & 15 deletions config/l3afd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[l3afd]
pid-file: ./l3afd.pid
datacenter: dummy
datacenter: dc
bpf-dir: /dev/shm
bpf-log-dir:
kernel-major-version: 4
Expand All @@ -14,33 +14,25 @@ bpf-chaining-enabled: true
swagger-api-enabled: false
# PROD | DEV
environment: PROD
#BpfMapDefaultPath is base path for storing maps
# BpfMapDefaultPath is base path for storing maps
BpfMapDefaultPath: /sys/fs/bpf


[kf-repo]
url:
url: http://localhost:8000/

[web]
metrics-addr: 0.0.0.0:8898
kf-poll-interval: 30s
n-metric-samples: 20

[admind]
host:
username:
api-key:
group-id: 0
api-enabled: true


[xdp-root-program]
name: xdp-root
artifact: xdp-root.tar.gz
ingress-map-name: root_array
command: xdp_root
version: 1.01
is-user-program: false
# user-program-daemon: false

[tc-root-program]
name: tc_root
Expand All @@ -49,7 +41,7 @@ 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
# user-program-daemon: false

[ebpf-chain-debug]
addr: 0.0.0.0:8899
Expand All @@ -64,10 +56,10 @@ filename: "/etc/l3afd/l3af-config.json"
[mtls]
enabled: true
# TLS_1_2 or TLS_1_3
min-tls-version:
min-tls-version: TLS_1_3
cert-dir: /etc/l3af/certs
cacert-filename: ca.pem
server-crt-filename: server.crt
server-key-filename: server.key
cert-expiry-warning-days: 30
# how many days before expiry you want warning
cert-expiry-warning-days: 30
2 changes: 1 addition & 1 deletion docs/configdoc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# L3AFD Config Options Documentation

See [l3afd.cfg](https://github.com/l3af-project/l3af-arch/blob/main/dev_environment/cfg/l3afd.cfg) for a full example configuration.
See [l3afd.cfg](https://github.com/l3af-project/l3afd/blob/main/config/l3afd.cfg) for a full example configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets convert this to relative link since it references file in same repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this got missed in your last commit



```
Expand Down
4 changes: 2 additions & 2 deletions kf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func LoadRootProgram(ifaceName string, direction string, progType string, conf *
Artifact: conf.XDPRootProgramArtifact,
MapName: conf.XDPRootProgramMapName,
Version: conf.XDPRootProgramVersion,
UserProgramDaemon: conf.XDPRootProgramUserProgramDaemon,
UserProgramDaemon: false,
CmdStart: conf.XDPRootProgramCommand,
CmdStop: conf.XDPRootProgramCommand,
CmdStatus: "",
Expand All @@ -119,7 +119,7 @@ func LoadRootProgram(ifaceName string, direction string, progType string, conf *
Name: conf.TCRootProgramName,
Artifact: conf.TCRootProgramArtifact,
Version: conf.TCRootProgramVersion,
UserProgramDaemon: conf.TCRootProgramUserProgramDaemon,
UserProgramDaemon: false,
CmdStart: conf.TCRootProgramCommand,
CmdStop: conf.TCRootProgramCommand,
CmdStatus: "",
Expand Down