kni: Use utsrelease.h to determine Ubuntu kernel version
PATCH v2 1/1 kni: Use utsrelease.h to determine Ubuntu kernel version
/proc/version_signature is the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.
The patch uses utsrelease.h from the kernel sources instead and fakes the upload version.
Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
---
ChangeLog:
v2: Improve description and motivation for the patch.
lib/librte_eal/linuxapp/kni/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/librte_eal/linuxapp/kni/Makefile +3 -3
@@ -44,10 +44,10 @@ MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h MODULE_CFLAGS += -Wall -Werror -ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Signature · 1 line
1.9.1
Ping?
// Simon
Quoted 39 lines · On Thu, 20 Aug 2015 08:51:06 +0200 Simon Kagstrom…
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.The patch uses
utsrelease.hfrom the kernel sources instead and fakes the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
Signed-off-by Simon Kagstrom <[email protected]>Signed-off-by Johan Faltstrom <[email protected]>---
ChangeLog:v2: Improve description and motivation for the patch.
lib/librte_eal/linuxapp/kni/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/librte_eal/linuxapp/kni/Makefile +3
-3@@ -44,10 +44,10 @@ MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h MODULE_CFLAGS += -Wall -Werror -ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Hi Simon,
I'm looking forward to this patch since we also build the DPDK for kernel versions which differ from the host kernel.
IMHO, the check for "Ubuntu" also needs change since this is also a "host system" check instead of "target system" check.
I.e. A user may want to build for Ubuntu on a non-Ubuntu system and vice versa.
With best regards,
Tom.
Signature · 2 lines
Tom Ghyselinck <[email protected]> Excentis N.V.
Quoted 58 lines · Simon Kagstrom
Ping?
// Simon
Quoted 50 lines · On Thu, 20 Aug 2015 08:51:06 +0200 Simon Kagstrom…
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the
server, and not that installed in the (build) chroot.The patch uses
utsrelease.hfrom the kernel sources instead and fakes
the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu
14.04.Signed-off-by Simon Kagstrom <[email protected]>Signed-off-by Johan Faltstrom <[email protected]>---
ChangeLog:v2: Improve description and motivation for the patch.
lib/librte_eal/linuxapp/kni/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/librte_eal/linuxapp/kni/Makefile +1
-4@@ -44,10 +44,10 @@ MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h MODULE_CFLAGS += -Wall -Werror -ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .-$(comma))
+UBUNTU_KERNEL_CODE := $(shell echo `grepUTS_RELEASE$(RTE_KERNELDIR)/include/generated/utsrelease.h \lib/librte_eal/linuxapp/kni/Makefile +1
-1+ | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Ping?
(Also including Stephen, Patrice and Pawel which has had comments on an earlier iteration of this patch).
// Simon
Quoted 40 lines · Simon Kagstrom
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.The patch uses
utsrelease.hfrom the kernel sources instead and fakes the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
Signed-off-by Simon Kagstrom <[email protected]>Signed-off-by Johan Faltstrom <[email protected]>---
ChangeLog:v2: Improve description and motivation for the patch.
lib/librte_eal/linuxapp/kni/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/librte_eal/linuxapp/kni/Makefile +3
-3@@ -44,10 +44,10 @@ MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h MODULE_CFLAGS += -Wall -Werror -ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Quoted 13 lines
-----Original Message-----
From: Simon Kagstrom [mailto:[email protected]]
Sent: Thursday, August 20, 2015 2:51 PM
To: Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH v2] kni: Useutsrelease.hto determine Ubuntu kernel version
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.
Quoted 7 lines
The patch uses
utsrelease.hfrom the kernel sources instead and fakes the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
Signed-off-by Simon Kagstrom <[email protected]>Signed-off-by Johan Faltstrom <[email protected]>
Quoted 5 lines
Quoted 5 lines
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.
Quoted 8 lines
Quoted 7 lines
The patch uses
utsrelease.hfrom the kernel sources instead and fakes the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
Signed-off-by Simon Kagstrom <[email protected]>Signed-off-by Johan Faltstrom <[email protected]>Acked-by Helin Zhang <[email protected]>
It doesn't fix every cases but Ubuntu chroot in Ubuntu, so Applied, thanks
2015-08-20 08:51, Simon Kagstrom:
Quoted 10 lines
/proc/version_signatureis the version for the host machine, but in e.g., chroots, this does not necessarily match that DPDK is built for. DPDK will then build for the wrong kernel version - that of the server, and not that installed in the (build) chroot.The patch uses
utsrelease.hfrom the kernel sources instead and fakes the upload version.Tested on a server with Ubuntu 12.04, building in a chroot for Ubuntu 14.04.
[...]
Quoted 5 lines
lib/librte_eal/linuxapp/kni/Makefile +0
-0@@ -44,10 +44,10 @@ MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h MODULE_CFLAGS += -Wall -Werror
lib/librte_eal/linuxapp/kni/Makefile MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e · line 52
Quoted 10 lines
lib/librte_eal/linuxapp/kni/Makefile +3
-3-ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Yes we must check RTE_KERNELDIR instead of the running kernel. But it is still checking lsb_release for the running system. It seems not consistent.
Quoted 14 lines · Thomas Monjalon
2015-08-20 08:51, Simon Kagstrom:
lib/librte_eal/linuxapp/kni/Makefile MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e · line 52
Quoted 9 lines
lib/librte_eal/linuxapp/kni/Makefile +3
-3-ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endifYes we must check
RTE_KERNELDIRinstead of the running kernel. But it is still checkinglsb_releasefor the running system. It seems not consistent.
I don't think so: the case the patch addresses is where the running kernel and rootfs doesn't match, like in a chroot environment.
So lsb_release will come from the chroot, as it should, but without the patch, the kernel version will not come from the installed kernel headers in the chroot, but the running kernel - which might even not be Ubuntu.
// Simon
Quoted 19 lines · On Wed, 4 Nov 2015 12:29:01 +0100 Simon Kågström…
Quoted 14 lines · Thomas Monjalon
2015-08-20 08:51, Simon Kagstrom:
lib/librte_eal/linuxapp/kni/Makefile MODULE_CFLAGS += -I$(RTE_OUTPUT)/include -I$(SRCDIR)/ethtool/ixgbe -I$(SRCDIR)/e · line 52
Quoted 9 lines
lib/librte_eal/linuxapp/kni/Makefile +3
-3-ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endifYes we must check
RTE_KERNELDIRinstead of the running kernel. But it is still checkinglsb_releasefor the running system. It seems not consistent.I don't think so: the case the patch addresses is where the running kernel and rootfs doesn't match, like in a chroot environment.
Quoted 7 lines
So
lsb_releasewill come from the chroot, as it should, but without the patch, the kernel version will not come from the installed kernel headers in the chroot, but the running kernel - which might even not be Ubuntu.// Simon
The danger here is starting to assume the build machine is the same as the running image. Using /proc to determine runtime environment is wrong.
Quoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Wed, 4 Nov 2015 12:29:01 +0100 Simon Kågström…
Quoted 11 lines · Thomas Monjalon
2015-08-20 08:51, Simon Kagstrom:
Quoted 9 lines
lib/librte_eal/linuxapp/kni/Makefile +3
-3-ifeq ($(shell test -f /proc/version_signature && lsb_release -si 2>/dev/null),Ubuntu) +ifeq ($(shell lsb_release -si 2>/dev/null),Ubuntu) MODULE_CFLAGS += -DUBUNTU_RELEASE_CODE=$(shell lsb_release -sr | tr -d .) -UBUNTU_KERNEL_CODE := $(shell cut -d' ' -f2 /proc/version_signature | \ - cut -d'~' -f1 | cut -d- -f1,2 | tr .- $(comma)) +UBUNTU_KERNEL_CODE := $(shell echo `grep UTS_RELEASE $(RTE_KERNELDIR)/include/generated/utsrelease.h \ + | cut -d '"' -f2 | cut -d- -f1,2 | tr .- $(comma)`,1) MODULE_CFLAGS += -D"UBUNTU_KERNEL_CODE=UBUNTU_KERNEL_VERSION($(UBUNTU_KERNEL_CODE))" endif
Quoted 7 lines
Quoted 4 lines
So
lsb_releasewill come from the chroot, as it should, but without the patch, the kernel version will not come from the installed kernel headers in the chroot, but the running kernel - which might even not be Ubuntu.The danger here is starting to assume the build machine is the same as the running image. Using /proc to determine runtime environment is wrong.
Exactly, and our build breaks because of this without the patch. So the patch removes the check in /proc and instead takes the kernel version from the kernel headers.
// Simon