Skip to content

Commit

Permalink
Load tun kernel driver
Browse files Browse the repository at this point in the history
This commit extend the sriov-network-config-daemon to try and load the tun device on start.

Signed-off-by: Sebastian Sch <[email protected]>
  • Loading branch information
SchSeba committed Nov 30, 2021
1 parent 3bacfa5 commit 8b5ee87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindata/scripts/load-kmod.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# chroot /host/ modprobe $1
kmod_name=$(tr "-" "_" <<< $1)
chroot /host/ lsmod | grep $1 >& /dev/null
chroot /host/ lsmod | grep "^$1" >& /dev/null

if [ $? -eq 0 ]
then
Expand Down
7 changes: 7 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error {
defer dn.workqueue.ShutDown()

tryEnableRdma()
tryEnableTun()

if err := sriovnetworkv1.InitNicIdMap(dn.kubeClient, namespace); err != nil {
return err
Expand Down Expand Up @@ -942,6 +943,12 @@ func registerPlugins(ns *sriovnetworkv1.SriovNetworkNodeState) []string {
return nameList
}

func tryEnableTun() {
if err := utils.LoadKernelModule("tun"); err != nil {
glog.Errorf("tryEnableTun(): TUN kernel module not loaded: %v", err)
}
}

func tryEnableRdma() (bool, error) {
glog.V(2).Infof("tryEnableRdma()")
var stdout, stderr bytes.Buffer
Expand Down

0 comments on commit 8b5ee87

Please sign in to comment.