Skip to contentSkip to conversation

kni: Use utsrelease.h to determine Ubuntu kernel version

PATCH In review Simon Kagstrom 5 participants 10 messages Aug 20, 2015 – Nov 19, 2015

lore
Share & tools
lore
#0 lore raw

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
index fb673d9..ac99d3f 100644
@@ -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
#1 lore raw

Ping?

// Simon

Quoted 39 lines · On Thu, 20 Aug 2015 08:51:06 +0200 Simon Kagstrom…

/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
index fb673d9..ac99d3f 100644
@@ -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
 
#2 lore raw

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_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 +1 -4
index fb673d9..ac99d3f 100644
@@ -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 \

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
#3 lore raw
In reply to Simon Kagstrom

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_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
index fb673d9..ac99d3f 100644
@@ -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
 
Acked-by on v2 1/1
#4 lore raw
In reply to Simon Kagstrom
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: 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.

Quoted 7 lines

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.

#5 lore raw
Quoted 5 lines
Quoted 5 lines

/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.

Quoted 8 lines
Quoted 7 lines

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.

It doesn't fix every cases but Ubuntu chroot in Ubuntu, so Applied, thanks

#6 lore raw
In reply to Simon Kagstrom

2015-08-20 08:51, Simon Kagstrom:

Quoted 10 lines

/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.

[...]

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.

#7 lore raw
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))"
 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.

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

#8 lore raw
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))"
 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.

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_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

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.

#9 lore raw
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_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.

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