diff --git a/Makefile b/Makefile index e0de350..336d418 100644 --- a/Makefile +++ b/Makefile @@ -73,14 +73,14 @@ build: builddp buildcni docker: ## Build docker image @echo "****** Docker Image ******" @echo - docker build -t localhost:5000/afxdp-device-plugin -f images/amd64.dockerfile . + docker build -t afxdp-device-plugin -f images/amd64.dockerfile . @echo @echo podman: ## Build podman image @echo "****** Podman Image ******" @echo - podman build -t localhost:5000/afxdp-device-plugin -f images/amd64.dockerfile . + podman build -t afxdp-device-plugin -f images/amd64.dockerfile . @echo @echo diff --git a/constants/constants.go b/constants/constants.go index 3ae67af..2f4b4f2 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -74,16 +74,17 @@ var ( afxdpMinimumLinux = "4.18.0" // minimum Linux version for AF_XDP support /* UDS*/ - udsMaxTimeout = 300 // maximum configurable uds timeout in seconds - udsMinTimeout = 30 // minimum (and default) uds timeout in seconds - udsMsgBufSize = 64 // uds message buffer size - udsCtlBufSize = 4 // uds control buffer size - udsProtocol = "unixpacket" // uds protocol: "unix"=SOCK_STREAM, "unixdomain"=SOCK_DGRAM, "unixpacket"=SOCK_SEQPACKET - udsSockDir = "/tmp/afxdp_dp/" // host location where we place our uds sockets. If changing location remember to update daemonset mount point - udsPodPath = "/tmp/afxdp.sock" // the uds filepath as it will appear in the end user application pod + udsMaxTimeout = 300 // maximum configurable uds timeout in seconds + udsMinTimeout = 30 // minimum (and default) uds timeout in seconds + udsMsgBufSize = 64 // uds message buffer size + udsCtlBufSize = 4 // uds control buffer size + udsProtocol = "unixpacket" // uds protocol: "unix"=SOCK_STREAM, "unixdomain"=SOCK_DGRAM, "unixpacket"=SOCK_SEQPACKET + udsSockDir = "/tmp/afxdp_dp/" // host location where we place our uds sockets. If changing location remember to update daemonset mount point + udsPodPath = "/tmp/" // the uds filepath as it will appear in the end user application pod + udsPodSock = "/afxdp.sock" /* BPF*/ - bpfMapPodPath = "/tmp/xsks_map" + bpfMapPodPath = "/tmp/" xsk_map = "/xsks_map" udsDirFileMode = 0700 // permissions for the directory in which we create our uds sockets @@ -216,6 +217,7 @@ type uds struct { SockDir string DirFileMode int PodPath string + SockName string Handshake handshake } @@ -326,6 +328,7 @@ func init() { SockDir: udsSockDir, DirFileMode: udsDirFileMode, PodPath: udsPodPath, + SockName: udsPodSock, Handshake: handshake{ Version: handshakeHandshakeVersion, RequestVersion: handshakeRequestVersion, diff --git a/internal/deviceplugin/poolManager.go b/internal/deviceplugin/poolManager.go index 1541476..1cbdebf 100644 --- a/internal/deviceplugin/poolManager.go +++ b/internal/deviceplugin/poolManager.go @@ -196,20 +196,22 @@ func (pm *PoolManager) Allocate(ctx context.Context, cresp := new(pluginapi.ContainerAllocateResponse) envs := make(map[string]string) - if !pm.UdsServerDisable { - cresp.Mounts = append(cresp.Mounts, &pluginapi.Mount{ - HostPath: udsPath, - ContainerPath: constants.Uds.PodPath, - ReadOnly: false, - }) - } - //loop each device request per container for _, devName := range crqt.DevicesIDs { device := pm.Devices[devName] pretty, _ := tools.PrettyString(device.Public()) logging.Debugf("Device: %s", pretty) + containerSockPath := constants.Uds.PodPath + device.Name() + constants.Uds.SockName + + if !pm.UdsServerDisable { + cresp.Mounts = append(cresp.Mounts, &pluginapi.Mount{ + HostPath: udsPath, + ContainerPath: containerSockPath, + ReadOnly: false, + }) + } + if device.Mode() != pm.Mode { err := fmt.Errorf("pool mode %s does not match device mode %s", pm.Mode, device.Mode()) logging.Errorf("%v", err) @@ -265,16 +267,21 @@ func (pm *PoolManager) Allocate(ctx context.Context, //FULL PATH WILL INCLUDE THE XSKMAP... fullPath := pinPath + constants.Bpf.Xsk_map - logging.Debugf("mapping %s to %s", fullPath, constants.Bpf.BpfMapPodPath) + containerMapPath := constants.Bpf.BpfMapPodPath + device.Name() + constants.Bpf.Xsk_map + logging.Debugf("mapping %s to %s", fullPath, containerMapPath) cresp.Mounts = append(cresp.Mounts, &pluginapi.Mount{ HostPath: fullPath, - ContainerPath: constants.Bpf.BpfMapPodPath, + ContainerPath: containerMapPath, ReadOnly: false, }) } } - envs[constants.Devices.EnvVarList] = strings.Join(crqt.DevicesIDs, " ") + // MT this doesn't really work as the env var is being set per Allocate request + // Could leave the app to deduce the af_xdp device name from the path above + // or write the device name into a file in the same path as the xskmap + // or just drop altogher? + envs[constants.Devices.EnvVarList] = strings.Join(crqt.DevicesIDs[:], " ") envsPrint, err := tools.PrettyString(envs) if err != nil { logging.Errorf("Error printing container environment variables: %v", err) @@ -283,7 +290,6 @@ func (pm *PoolManager) Allocate(ctx context.Context, } cresp.Envs = envs response.ContainerResponses = append(response.ContainerResponses, cresp) - } if !pm.UdsServerDisable {