Skip to content

Commit

Permalink
Merge pull request #338 from msherif1234/dbg_noo
Browse files Browse the repository at this point in the history
interface's based hooks don't allow more than one function per intf per direction
  • Loading branch information
mergify[bot] authored Nov 4, 2024
2 parents 06205c5 + 55cd2da commit d86dfcd
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)
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)
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)
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)
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)
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)
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)
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)
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)
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 d86dfcd

Please sign in to comment.