Skip to content

Commit

Permalink
interface names hook doesn't allow more than one function per interfa…
Browse files Browse the repository at this point in the history
…ce per direction

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed Nov 4, 2024
1 parent bb8e382 commit 55cd2da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions controllers/bpfman-agent/application-program.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
for j, p := range a.Spec.Programs {
switch p.Type {
case bpfmaniov1alpha1.ProgTypeFentry:
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Fentry.FunctionName))
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Fentry.FunctionName), p.Fentry.BpfFunctionName)
fentryProgram := bpfmaniov1alpha1.FentryProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -100,7 +100,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, fentryObjects)

case bpfmaniov1alpha1.ProgTypeFexit:
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Fexit.FunctionName))
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Fexit.FunctionName), p.Fexit.BpfFunctionName)

Check warning on line 103 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L103

Added line #L103 was not covered by tests
fexitProgram := bpfmaniov1alpha1.FexitProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -123,7 +123,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque

case bpfmaniov1alpha1.ProgTypeKprobe,
bpfmaniov1alpha1.ProgTypeKretprobe:
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Kprobe.FunctionName))
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Kprobe.FunctionName), p.Kprobe.BpfFunctionName)
kprobeProgram := bpfmaniov1alpha1.KprobeProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -146,7 +146,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque

case bpfmaniov1alpha1.ProgTypeUprobe,
bpfmaniov1alpha1.ProgTypeUretprobe:
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Uprobe.FunctionName))
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Uprobe.FunctionName), p.Uprobe.BpfFunctionName)

Check warning on line 149 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L149

Added line #L149 was not covered by tests
uprobeProgram := bpfmaniov1alpha1.UprobeProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -168,7 +168,7 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, uprobeObjects)

case bpfmaniov1alpha1.ProgTypeTracepoint:
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), sanitize(p.Tracepoint.Names[0]))
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), p.Tracepoint.BpfFunctionName)

Check warning on line 171 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L171

Added line #L171 was not covered by tests
tracepointProgram := bpfmaniov1alpha1.TracepointProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -190,13 +190,13 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, tracepointObjects)

case bpfmaniov1alpha1.ProgTypeTC:
interfaces, ifErr := getInterfaces(&p.TC.InterfaceSelector, r.ourNode)
_, ifErr := getInterfaces(&p.TC.InterfaceSelector, r.ourNode)

Check warning on line 193 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L193

Added line #L193 was not covered by tests
if ifErr != nil {
ctxLogger.Error(ifErr, "failed to get interfaces for TC Program",
"app program name", a.Name, "program index", j)
continue
}
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), p.TC.Direction, interfaces[0])
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), p.TC.Direction, p.TC.BpfFunctionName)

Check warning on line 199 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L199

Added line #L199 was not covered by tests
tcProgram := bpfmaniov1alpha1.TcProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -218,13 +218,13 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, tcObjects)

case bpfmaniov1alpha1.ProgTypeTCX:
interfaces, ifErr := getInterfaces(&p.TCX.InterfaceSelector, r.ourNode)
_, ifErr := getInterfaces(&p.TCX.InterfaceSelector, r.ourNode)

Check warning on line 221 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L221

Added line #L221 was not covered by tests
if ifErr != nil {
ctxLogger.Error(ifErr, "failed to get interfaces for TCX Program",
"app program name", a.Name, "program index", j)
continue
}
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), p.TCX.Direction, interfaces[0])
appProgramId := fmt.Sprintf("%s-%s-%s", strings.ToLower(string(p.Type)), p.TCX.Direction, p.TCX.BpfFunctionName)

Check warning on line 227 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L227

Added line #L227 was not covered by tests
tcxProgram := bpfmaniov1alpha1.TcxProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand All @@ -246,13 +246,13 @@ func (r *BpfApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
complete, res, err = r.reconcileCommon(ctx, rec, tcxObjects)

case bpfmaniov1alpha1.ProgTypeXDP:
interfaces, ifErr := getInterfaces(&p.XDP.InterfaceSelector, r.ourNode)
_, ifErr := getInterfaces(&p.XDP.InterfaceSelector, r.ourNode)

Check warning on line 249 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L249

Added line #L249 was not covered by tests
if ifErr != nil {
ctxLogger.Error(ifErr, "failed to get interfaces for XDP Program",
"app program name", a.Name, "program index", j)
continue
}
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), interfaces[0])
appProgramId := fmt.Sprintf("%s-%s", strings.ToLower(string(p.Type)), p.XDP.BpfFunctionName)

Check warning on line 255 in controllers/bpfman-agent/application-program.go

View check run for this annotation

Codecov / codecov/patch

controllers/bpfman-agent/application-program.go#L255

Added line #L255 was not covered by tests
xdpProgram := bpfmaniov1alpha1.XdpProgram{
ObjectMeta: metav1.ObjectMeta{
Name: buildProgramName(a, p),
Expand Down
4 changes: 2 additions & 2 deletions controllers/bpfman-agent/application-program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ func TestBpfApplicationControllerCreate(t *testing.T) {
// fentry program config
bpfFentryFunctionName = "fentry_test"
fentryFunctionName = "do_unlinkat"
fentryAppProgramId = fmt.Sprintf("%s-%s", "fentry", sanitize(fentryFunctionName))
fentryAppProgramId = fmt.Sprintf("%s-%s-%s", "fentry", sanitize(fentryFunctionName), bpfFentryFunctionName)
fentryAttachPoint = sanitize(fentryFunctionName)
fentryBpfProg = &bpfmaniov1alpha1.BpfProgram{}
fentryFakeUID = "ef71d42c-aa21-48e8-a697-82391d801a81"
// kprobe program config
bpfKprobeFunctionName = "kprobe_test"
kprobeFunctionName = "try_to_wake_up"
kprobeAppProgramId = fmt.Sprintf("%s-%s", "kprobe", sanitize(kprobeFunctionName))
kprobeAppProgramId = fmt.Sprintf("%s-%s-%s", "kprobe", sanitize(kprobeFunctionName), bpfKprobeFunctionName)
kprobeAttachPoint = sanitize(kprobeFunctionName)
kprobeBpfProg = &bpfmaniov1alpha1.BpfProgram{}
kprobeFakeUID = "ef71d42c-aa21-48e8-a697-82391d801a82"
Expand Down

0 comments on commit 55cd2da

Please sign in to comment.