Skip to content

Commit

Permalink
debug: bpfd deployment map access issues
Browse files Browse the repository at this point in the history
Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
  • Loading branch information
maryamtahhan committed Nov 2, 2023
1 parent 6e43684 commit 16c8157
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ podman: ## Build podman image
@echo

image:
# if $(MAKE) podman; then \
# echo "Podman build succeeded"; \
# else \
# echo "Podman build failed, trying docker.."; \
if $(MAKE) podman; then \
echo "Podman build succeeded"; \
else \
echo "Podman build failed, trying docker.."; \
$(MAKE) docker; \
# fi
fi

undeploy: ## Undeploy the Deamonset
@echo "****** Stop Daemonset ******"
Expand Down
5 changes: 5 additions & 0 deletions deployments/daemonset-kind-bpfd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ spec:
mountPath: /var/log/afxdp-k8s-plugins/
- name: cnibin
mountPath: /opt/cni/bin/
- name: bpfd-maps
mountPath: /var/run/bpfd/fs/maps/
volumes:
- name: unixsock
hostPath:
Expand All @@ -113,6 +115,9 @@ spec:
- name: cnibin
hostPath:
path: /opt/cni/bin/
- name: bpfd-maps
hostPath:
path: /var/run/bpfd/fs/maps/
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
15 changes: 6 additions & 9 deletions examples/cndp-0-0.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# A working example of BPF MAP PINNING
apiVersion: v1
kind: Pod
metadata:
Expand All @@ -8,17 +7,15 @@ metadata:
spec:
containers:
- name: cndp-0
command: ["/bin/bash"]
args: ["-c", "./jsonc_gen.sh -kp ; cndpfwd -c config.jsonc lb;"]
command: ["tail", "-f", "/dev/null"]
image: quay.io/mtahhan/cndp-map-pinning:latest
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
#capabilities:
#add:
# - NET_RAW
# - IPC_LOCK
# - BPF
capabilities:
add:
- NET_RAW
- IPC_LOCK
- BPF
resources:
requests:
afxdp/myPool: '1'
Expand Down
18 changes: 9 additions & 9 deletions examples/nad_with_syncer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: afxdp-network # Name of this network, pods will request this network by name
name: afxdp-network
annotations:
k8s.v1.cni.cncf.io/resourceName: afxdp/myPool # Needs to match the device plugin pool name / resource type
k8s.v1.cni.cncf.io/resourceName: afxdp/myPool
spec:
config: '{
"cniVersion": "0.3.0",
"type": "afxdp", # CNI binary, leave as afxdp
"mode": "primary", # CNI mode setting (required)
"logFile": "afxdp-cni.log", # CNI log file location (optional)
"logLevel": "debug", # CNI logging level (optional)
"dpSyncer": true, # Sync with Device Plugin over gRPC MUST BE SET for bpf map pinning
"skipUnloadBpf": true, # Skip unloading BPF locally
"ipam": { # CNI IPAM plugin and associated config (optional)
"type": "afxdp",
"mode": "primary",
"logFile": "afxdp-cni.log",
"logLevel": "debug",
"dpSyncer": true,
"skipUnloadBpf": true,
"ipam": {
"type": "host-local",
"subnet": "192.168.1.0/24",
"rangeStart": "192.168.1.200",
Expand Down
6 changes: 4 additions & 2 deletions internal/bpfd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ func (b *BpfdClient) SubmitXdpProg(iface, node, pm, image, sec string) (string,
bpfProgName := node + "-" + pm + "-" + iface + "-" + node + "-" + iface
for _, bpfProgram := range bpfProgramList.Items {
if bpfProgram.ObjectMeta.Name == bpfProgName {
logging.Infof("FOUND bpfProgram %v", bpfProgram)
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", bpfProgName)
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 {
Expand Down
11 changes: 11 additions & 0 deletions setup-bpfd-afxdp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
make image
docker pull quay.io/mtahhan/cndp-map-pinning
docker pull quay.io/mtahhan/xsk_def_xdp_prog
make setup-multus
make KIND_CLUSTER_NAME=bpfd-deployment kind-label-cp
make KIND_CLUSTER_NAME=bpfd-deployment IMAGE=quay.io/mtahhan/cndp-map-pinning kind-load-custom-image
make KIND_CLUSTER_NAME=bpfd-deployment IMAGE=quay.io/mtahhan/xsk_def_xdp_prog kind-load-custom-image
make KIND_CLUSTER_NAME=bpfd-deployment kind-deploy-bpfd
kubectl create -f examples/nad_with_syncer.yaml
kubectl create -f examples/cndp-0-0.yaml

0 comments on commit 16c8157

Please sign in to comment.