Skip to content

Commit

Permalink
bpfd: fixup pinned map access
Browse files Browse the repository at this point in the history
Temporary fix to for bpfd v0.3.0 API.

Signed-off-by: astoycos <[email protected]>
Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan committed Nov 3, 2023
1 parent 7d8de97 commit 61865ea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
5 changes: 3 additions & 2 deletions deployments/daemonset-kind-bpfd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ spec:
- name: cnibin
mountPath: /opt/cni/bin/
- name: bpfd-maps
mountPath: /var/run/bpfd/fs/maps/
mountPath: /run/bpfd/fs/maps/
readOnly: true
volumes:
- name: unixsock
hostPath:
Expand Down Expand Up @@ -117,7 +118,7 @@ spec:
path: /opt/cni/bin/
- name: bpfd-maps
hostPath:
path: /var/run/bpfd/fs/maps/
path: /run/bpfd/fs/maps/
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
3 changes: 2 additions & 1 deletion examples/cndp-0-0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ metadata:
spec:
containers:
- name: cndp-0
command: ["tail", "-f", "/dev/null"]
command: ["/bin/bash"]
args: ["-c", "./jsonc_gen.sh -kp ; cndpfwd -c config.jsonc lb;"]
image: quay.io/mtahhan/cndp-map-pinning:latest
imagePullPolicy: IfNotPresent
securityContext:
Expand Down
21 changes: 7 additions & 14 deletions internal/bpfd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bpfd

import (
"context"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -148,25 +149,17 @@ func (b *BpfdClient) SubmitXdpProg(iface, node, pm, image, sec string) (string,
return "", errors.Wrapf(err, "Failed to get bpf prog resources: %v", err)
}

var xskmap string

// Try to get the xspmap path from the bpf program resource
xskmap := ""
if bpfProgramList != nil {
bpfProgName := node + "-" + pm + "-" + iface + "-" + node + "-" + iface
for _, bpfProgram := range bpfProgramList.Items {
if bpfProgram.ObjectMeta.Name == bpfProgName {
time.Sleep(1 * time.Second)
logging.Infof("FOUND bpfProgram %s", bpfProgram.ObjectMeta.Name)
logging.Infof("bpfProgram.Spec.Maps %v", bpfProgram.Spec.Maps)
if len(bpfProgram.Spec.Maps) == 0 {
logging.Errorf("NO MAPS FOUND for %s", bpfProgram.ObjectMeta.Name)
return "", errors.New("Failed to find a map for the loaded bpf program")
}
for m, path := range bpfProgram.Spec.Maps {
logging.Infof("map: %v", m)
xskmap = path
id, ok := bpfProgram.Annotations["bpfd.dev/ProgramId"]
if !ok {
logging.Errorf("BpfProgram %s does not have a program id", bpfProgName)
return "", errors.New("BpfProgram does not have a program id")
}

xskmap = fmt.Sprintf("/run/bpfd/fs/maps/%s/xsks_map", id)
}
}
}
Expand Down
11 changes: 0 additions & 11 deletions setup-bpfd-afxdp.sh

This file was deleted.

0 comments on commit 61865ea

Please sign in to comment.