Skip to content

Commit

Permalink
update kf references to ebpf (l3af-project#135)
Browse files Browse the repository at this point in the history
Signed-off-by: sanfern <[email protected]>
  • Loading branch information
sanfern authored Oct 28, 2022
1 parent 0e9c8f5 commit c9908e2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Config struct {
BPFLogDir string
MinKernelMajorVer int
MinKernelMinorVer int
KFRepoURL string
EBPFRepoURL string
HttpClientTimeout time.Duration
MaxNFReStartCount int
Environment string
Expand All @@ -35,9 +35,9 @@ type Config struct {

// stats
// Prometheus endpoint for pull/scrape the metrics.
MetricsAddr string
KFPollInterval time.Duration
NMetricSamples int
MetricsAddr string
EBPFPollInterval time.Duration
NMetricSamples int

ShutdownTimeout time.Duration

Expand Down Expand Up @@ -99,12 +99,12 @@ func ReadConfig(configPath string) (*Config, error) {
BPFLogDir: LoadOptionalConfigString(confReader, "l3afd", "bpf-log-dir", ""),
MinKernelMajorVer: LoadOptionalConfigInt(confReader, "l3afd", "kernel-major-version", 5),
MinKernelMinorVer: LoadOptionalConfigInt(confReader, "l3afd", "kernel-minor-version", 1),
KFRepoURL: LoadConfigString(confReader, "kf-repo", "url"),
EBPFRepoURL: LoadConfigString(confReader, "ebpf-repo", "url"),
HttpClientTimeout: LoadOptionalConfigDuration(confReader, "l3afd", "http-client-timeout", 10*time.Second),
MaxNFReStartCount: LoadOptionalConfigInt(confReader, "l3afd", "max-nf-restart-count", 3),
BpfChainingEnabled: LoadConfigBool(confReader, "l3afd", "bpf-chaining-enabled"),
MetricsAddr: LoadConfigString(confReader, "web", "metrics-addr"),
KFPollInterval: LoadOptionalConfigDuration(confReader, "web", "kf-poll-interval", 30*time.Second),
EBPFPollInterval: LoadOptionalConfigDuration(confReader, "web", "ebpf-poll-interval", 30*time.Second),
NMetricSamples: LoadOptionalConfigInt(confReader, "web", "n-metric-samples", 20),
ShutdownTimeout: LoadOptionalConfigDuration(confReader, "l3afd", "shutdown-timeout", 5*time.Second),
SwaggerApiEnabled: LoadOptionalConfigBool(confReader, "l3afd", "swagger-api-enabled", false),
Expand Down
4 changes: 2 additions & 2 deletions config/l3afd.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ environment: PROD
BpfMapDefaultPath: /sys/fs/bpf


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

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

[xdp-root-program]
Expand Down
12 changes: 6 additions & 6 deletions docs/configdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ environment: PROD
|environment|`"PROD"`|If set to anything other than "PROD", mTLS security will not be checked| Yes |
|BpfMapDefaultPath|`"/sys/fs/bpf"`|The base pin path for eBPF maps| Yes |

## [kf-repo]
## [ebpf-repo]
| FieldName | Default | Description | Required |
| ------------- | ------------- | --------------- |----------|
|url| `"http://localhost:8000/"`|Default repository from which to download eBPF packages| Yes |

## [web]

| FieldName | Default | Description | Required |
| ------------- | ------------- | --------------- |----------|
|metrics-addr|`"0.0.0.0:8898"`|Prometheus endpoint for pulling/scraping the metrics. For more info about Prometheus see [prometheus.io](https://prometheus.io/) | Yes |
|kf-poll-interval|`"30s"`|Periodic interval at which to scrape metrics using Prometheus| No |
|n-metric-samples|`"20"`|Number of Metric Samples| No |
| FieldName | Default | Description | Required |
|--------------------| ------------- | --------------- |----------|
| metrics-addr |`"0.0.0.0:8898"`|Prometheus endpoint for pulling/scraping the metrics. For more info about Prometheus see [prometheus.io](https://prometheus.io/) | Yes |
| ebpf-poll-interval |`"30s"`|Periodic interval at which to scrape metrics using Prometheus| No |
| n-metric-samples |`"20"`|Number of Metric Samples| No |


## [xdp-root-program]
Expand Down
2 changes: 1 addition & 1 deletion kf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (b *BPF) GetArtifacts(conf *config.Config) error {
isDefaultURLUsed := false
RepoURL := b.Program.EPRURL
if len(b.Program.EPRURL) == 0 {
RepoURL = conf.KFRepoURL
RepoURL = conf.EBPFRepoURL
isDefaultURLUsed = true
}

Expand Down
14 changes: 7 additions & 7 deletions kf/bpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func TestBPF_GetArtifacts(t *testing.T) {
}),
},
args: args{conf: &config.Config{BPFDir: "/tmp",
KFRepoURL: "https://l3af.io/"}},
EBPFRepoURL: "https://l3af.io/"}},
wantErr: true,
},
{
Expand All @@ -443,8 +443,8 @@ func TestBPF_GetArtifacts(t *testing.T) {
},
args: args{
conf: &config.Config{
BPFDir: "/tmp",
KFRepoURL: "https://l3af.io/",
BPFDir: "/tmp",
EBPFRepoURL: "https://l3af.io/",
},
},
wantErr: true,
Expand All @@ -461,8 +461,8 @@ func TestBPF_GetArtifacts(t *testing.T) {
},
args: args{
conf: &config.Config{
BPFDir: "/tmp",
KFRepoURL: "https://l3af.io/",
BPFDir: "/tmp",
EBPFRepoURL: "https://l3af.io/",
},
},
wantErr: true,
Expand All @@ -479,8 +479,8 @@ func TestBPF_GetArtifacts(t *testing.T) {
},
args: args{
conf: &config.Config{
BPFDir: "/tmp",
KFRepoURL: "https://l3af.io/",
BPFDir: "/tmp",
EBPFRepoURL: "https://l3af.io/",
},
},
wantErr: true,
Expand Down
6 changes: 3 additions & 3 deletions kf/nfconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TestNFConfigs_Deploy(t *testing.T) {
ingressXDPBpfs: make(map[string]*list.List),
ingressTCBpfs: make(map[string]*list.List),
egressTCBpfs: make(map[string]*list.List),
hostConfig: &config.Config{BPFDir: "/tmp", KFRepoURL: "http://www.example.com"},
hostConfig: &config.Config{BPFDir: "/tmp", EBPFRepoURL: "http://www.example.com"},
processMon: pMon,
metricsMon: mMon,
},
Expand All @@ -307,7 +307,7 @@ func TestNFConfigs_Deploy(t *testing.T) {
ingressXDPBpfs: make(map[string]*list.List),
ingressTCBpfs: make(map[string]*list.List),
egressTCBpfs: make(map[string]*list.List),
hostConfig: &config.Config{BPFDir: "/tmp", KFRepoURL: "http://www.example.com"},
hostConfig: &config.Config{BPFDir: "/tmp", EBPFRepoURL: "http://www.example.com"},
processMon: pMon,
metricsMon: mMon,
},
Expand All @@ -326,7 +326,7 @@ func TestNFConfigs_Deploy(t *testing.T) {
ingressXDPBpfs: make(map[string]*list.List),
ingressTCBpfs: make(map[string]*list.List),
egressTCBpfs: make(map[string]*list.List),
hostConfig: &config.Config{BPFDir: "/tmp", KFRepoURL: "http://www.example.com"},
hostConfig: &config.Config{BPFDir: "/tmp", EBPFRepoURL: "http://www.example.com"},
processMon: pMon,
metricsMon: mMon,
},
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
log.Error().Err(err).Msg("L3afd registration failed")
}

kfConfigs, err := SetupNFConfigs(ctx, conf)
ebpfConfigs, err := SetupNFConfigs(ctx, conf)
if err != nil {
log.Fatal().Err(err).Msg("L3afd failed to start")
}
Expand All @@ -99,17 +99,17 @@ func main() {
}

if t != nil {
if err := kfConfigs.DeployeBPFPrograms(t); err != nil {
if err := ebpfConfigs.DeployeBPFPrograms(t); err != nil {
log.Error().Err(err).Msg("L3afd filed to deploy persistent configs from store")
}
}

if err := handlers.InitConfigs(kfConfigs); err != nil {
if err := handlers.InitConfigs(ebpfConfigs); err != nil {
log.Fatal().Err(err).Msg("L3afd failed to initialise configs")
}

if conf.EBPFChainDebugEnabled {
kf.SetupKFDebug(conf.EBPFChainDebugAddr, kfConfigs)
kf.SetupKFDebug(conf.EBPFChainDebugAddr, ebpfConfigs)
}
select {}
}
Expand All @@ -124,7 +124,7 @@ func SetupNFConfigs(ctx context.Context, conf *config.Config) (*kf.NFConfigs, er
// setup Metrics endpoint
stats.SetupMetrics(machineHostname, daemonName, conf.MetricsAddr)

pMon := kf.NewpCheck(conf.MaxNFReStartCount, conf.BpfChainingEnabled, conf.KFPollInterval)
pMon := kf.NewpCheck(conf.MaxNFReStartCount, conf.BpfChainingEnabled, conf.EBPFPollInterval)
kfM := kf.NewpKFMetrics(conf.BpfChainingEnabled, conf.NMetricSamples)

nfConfigs, err := kf.NewNFConfigs(ctx, machineHostname, conf, pMon, kfM)
Expand Down

0 comments on commit c9908e2

Please sign in to comment.