From 8b5ee878956f481660ee74854b00524f3861b449 Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Thu, 25 Nov 2021 11:39:38 +0200 Subject: [PATCH] Load tun kernel driver This commit extend the sriov-network-config-daemon to try and load the tun device on start. Signed-off-by: Sebastian Sch --- bindata/scripts/load-kmod.sh | 2 +- pkg/daemon/daemon.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bindata/scripts/load-kmod.sh b/bindata/scripts/load-kmod.sh index fb80eebf3..7f3d4dc58 100755 --- a/bindata/scripts/load-kmod.sh +++ b/bindata/scripts/load-kmod.sh @@ -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 diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index a35b2db28..a5d9917b6 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -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 @@ -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