r8168 with DKMS built for wrong kernel version
A computer of mine has one of those dreaded Realtek 8168 network chips, that are basically supported by the in-kernel r8169
module, but crashes in some way when under high load using that driver.
Well the solution is found many places in the internet: Use the r8168
module provided by Realtek themselves as open source and be happy. But obviously I want to automate the installation of this third-party module, and that’s exactly what DKMS (Dynamic Kernel Module Support) is for, all with triggers on kernel updates and stuff.
There are many places where the dkms.conf
for r8168
is described, often stating that we need to use 'make'
instead of make
and so on. But seemingly nobody noticed that there is a problem: The module is always built for the currently running kernel version. That’s obvious nonsense when you just installed a new kernel and want to built your network driver before booting the new kernel.
And that’s the fault of the Makefile
provided with the r8168
module, since it uses uname -r
no matter what to determine where to get the kernel headers. Using the DKMS Packaging guide at the Kubuntu wiki I modified the Makefile
and dkms.conf
to use the supplied kernel version if given:--- src.orig/Makefile 2014-05-27 10:47:58.024466161 +0200
+++ src/Makefile 2014-05-27 10:48:21.647967969 +0200
@@ -53,7 +53,8 @@
EXTRA_CFLAGS += -DENABLE_S5WOL
endif
else
- BASEDIR := /lib/modules/$(shell uname -r)
+ KVERSION := $(shell uname -r)
+ BASEDIR := /lib/modules/$(KVERSION)
KERNELDIR ?= $(BASEDIR)/build
PWD :=$(shell pwd)
DRIVERDIR := $(shell find $(BASEDIR)/kernel/drivers/net -name realtek -type d)
PACKAGE_NAME=r8168
PACKAGE_VERSION=8.038.00
MAKE[0]="'make' modules KVERSION=$kernelver"
BUILT_MODULE_NAME[0]=r8168
BUILT_MODULE_LOCATION[0]="src"
DEST_MODULE_LOCATION[0]="/kernel/updates/dkms"
AUTOINSTALL="YES"
Interestingly enough, even the r8168-dkms
package in Debian Sid seems to get this wrong (if I didn’t misinterpret the source). Or maybe they do something else to fix it, because they are using make
instead of 'make'
.
So hopefully I will never again boot without a fully functioning network card and maybe even someone else benefits from this little notice.