Skip to content

Commit 2e52b4d

Browse files
authored
feat: Blacklist DOCA Drive modules on host (#1086)
We should not allow to load inbox or OFED-on-host drivers if DOCA Driver container deployment is enabled.
2 parents 530131b + ea72766 commit 2e52b4d

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# 2024 NVIDIA CORPORATION & AFFILIATES
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
apiVersion: v1
15+
kind: ConfigMap
16+
metadata:
17+
name: ofed-modules-blacklist
18+
namespace: {{ .RuntimeSpec.Namespace }}
19+
data:
20+
blacklist-ofed-modules.conf: |-
21+
# blacklist ofed-related modules on host to prevent inbox or host OFED driver loading
22+
blacklist mlx5_core
23+
blacklist mlx5_ib
24+
blacklist ib_umad
25+
blacklist ib_uverbs
26+
blacklist ib_ipoib
27+
blacklist rdma_cm
28+
blacklist rdma_ucm
29+
blacklist ib_core
30+
blacklist ib_cm

manifests/state-ofed-driver/0050_ofed-driver-ds.yaml renamed to manifests/state-ofed-driver/0060_ofed-driver-ds.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ spec:
8181
- image: {{ .RuntimeSpec.MOFEDImageName }}
8282
imagePullPolicy: IfNotPresent
8383
name: mofed-container
84+
lifecycle:
85+
postStart:
86+
exec:
87+
command: [ "cp", "/opt/blacklist-ofed-modules.conf", "/host/etc/modprobe.d/" ]
88+
preStop:
89+
exec:
90+
command: [ "rm", "/host/etc/modprobe.d/blacklist-ofed-modules.conf" ]
8491
securityContext:
8592
privileged: true
8693
seLinuxOptions:
@@ -118,6 +125,9 @@ spec:
118125
mountPath: /mnt/drivers-inventory
119126
- name: host-ib-core
120127
mountPath: /etc/modprobe.d/ib_core.conf
128+
- name: modules-blacklist
129+
mountPath: /opt/blacklist-ofed-modules.conf
130+
subPath: blacklist-ofed-modules.conf
121131
{{- if.AdditionalVolumeMounts.VolumeMounts }}
122132
{{- range .AdditionalVolumeMounts.VolumeMounts }}
123133
- name: {{ .Name }}
@@ -245,6 +255,9 @@ spec:
245255
hostPath:
246256
path: /etc/modprobe.d/ib_core.conf
247257
type: FileOrCreate
258+
- name: modules-blacklist
259+
configMap:
260+
name: ofed-modules-blacklist
248261
{{- range .AdditionalVolumeMounts.Volumes }}
249262
- name: {{ .Name }}
250263
{{- if and .ConfigMap .ConfigMap.Items }}

pkg/state/state_ofed_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ var _ = Describe("MOFED state test", func() {
307307
catalog.Add(InfoTypeDocaDriverImage, &dummyOfedImageProvider{tagExists: true})
308308
objs, err := ofedState.GetManifestObjects(ctx, cr, catalog, testLogger)
309309
Expect(err).NotTo(HaveOccurred())
310-
// Expect 5 objects: 1 DS per pool, Service Account, Role, RoleBinding
311-
Expect(len(objs)).To(Equal(5))
310+
// Expect 5 objects: 1 DS per pool, Service Account, Role, RoleBinding, ConfigMap
311+
Expect(len(objs)).To(Equal(6))
312312
By("Verify DaemonSets NodeSelector")
313313
for _, obj := range objs {
314314
if obj.GetKind() != "DaemonSet" {
@@ -365,8 +365,8 @@ var _ = Describe("MOFED state test", func() {
365365
catalog.Add(InfoTypeDocaDriverImage, &dummyOfedImageProvider{tagExists: false})
366366
objs, err := ofedState.GetManifestObjects(ctx, cr, catalog, testLogger)
367367
Expect(err).NotTo(HaveOccurred())
368-
// Expect 5 objects: 1 DS per pool, Service Account, Role, RoleBinding
369-
Expect(len(objs)).To(Equal(4))
368+
// Expect 5 objects: 1 DS per pool, Service Account, Role, RoleBinding, ConfigMap
369+
Expect(len(objs)).To(Equal(5))
370370
By("Verify Subscription mounts")
371371
for _, obj := range objs {
372372
if obj.GetKind() != "DaemonSet" {
@@ -470,8 +470,8 @@ var _ = Describe("MOFED state test", func() {
470470
objs, err := ofedState.GetManifestObjects(ctx, cr, catalog, testLogger)
471471
Expect(err).NotTo(HaveOccurred())
472472
// Expect 6 object due to OpenShift: DaemonSet, Service Account, ClusterRole, ClusterRoleBinding
473-
// Role, RoleBinding
474-
Expect(len(objs)).To(Equal(6))
473+
// Role, RoleBinding, ConfigMap
474+
Expect(len(objs)).To(Equal(7))
475475
By("Verify DaemonSet with DTK")
476476
for _, obj := range objs {
477477
if obj.GetKind() != "DaemonSet" {
@@ -539,8 +539,8 @@ var _ = Describe("MOFED state test", func() {
539539
objs, err := ofedState.GetManifestObjects(ctx, cr, catalog, testLogger)
540540
Expect(err).NotTo(HaveOccurred())
541541
By("Verify image is not precompiled format")
542-
// Expect 4 objects: DS , Service Account, Role, RoleBinding
543-
Expect(len(objs)).To(Equal(4))
542+
// Expect 4 objects: DS , Service Account, Role, RoleBinding, ConfigMap
543+
Expect(len(objs)).To(Equal(5))
544544
for _, obj := range objs {
545545
if obj.GetKind() != "DaemonSet" {
546546
continue
@@ -577,8 +577,8 @@ var _ = Describe("MOFED state test", func() {
577577
objs, err := ofedState.GetManifestObjects(ctx, cr, catalog, testLogger)
578578
Expect(err).NotTo(HaveOccurred())
579579
By("Verify image is not precompiled format")
580-
// Expect 4 objects: DS , Service Account, Role, RoleBinding
581-
Expect(len(objs)).To(Equal(4))
580+
// Expect 4 objects: DS , Service Account, Role, RoleBinding, ConfigMap
581+
Expect(len(objs)).To(Equal(5))
582582
for _, obj := range objs {
583583
if obj.GetKind() != "DaemonSet" {
584584
continue

0 commit comments

Comments
 (0)