Skip to contentSkip to conversation

kni: fix build with Linux 5.18

PATCH Superseded Jiri Slaby 4 participants 11 messages May 31, 2022 – Jun 7, 2022

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 kni: fix build with Linux 5.18

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

---
 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..a81846a8a895 100644
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
 		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#else
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.36.1
author
#1 lore raw

PATCH v2 1/1 kni: fix build with Linux 5.18

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

---
[v2]
- forgot to amend the #else/#endif typo fix

 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..a81846a8a895 100644
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f9e..41805fcabf7b 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
 		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.36.1
#2 lore raw
Quoted 5 lines · Jiri Slaby

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

I think there is another commit that makes 'netif_rx()' usable in place of 'netif_rx_ni()', can you please document that commit too for reference.

Quoted 15 lines

---
[v2]
- forgot to amend the #else/#endif typo fix

  kernel/linux/kni/compat.h  | 4 ++++
  kernel/linux/kni/kni_net.c | 4 ++++
  2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +0 -0
index 664785674ff1..a81846a8a895 100644

kernel/linux/kni/compat.h line 147

Quoted 7 lines
kernel/linux/kni/compat.h +4 -0
@@ -141,3 +141,7 @@
  #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
  #define HAVE_TSK_IN_GUP
  #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
+#define HAVE_NETIF_RX_NI
+#endif

Can you please switch sides in the comparison [1] to be compatible with rest of the file and to prevent checkpatch warning [2]?

Rest looks good to me.

[1]
#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE

[2]
WARNING:CONSTANT_COMPARISON: Comparisons should place the constant on the right side of the test #97: FILE: kernel/linux/kni/compat.h:145:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)

Quoted 16 lines
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f9e..41805fcabf7b 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
  		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
  		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
  		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#endif
 
  		/* Update statistics */
  		dev->stats.rx_bytes += len;
author
#3 lore raw

PATCH v3 1/1 kni: fix build with Linux 5.18

In reply to Jiri Slaby

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

There were other attempts to fix this:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

But neither of them ensures netif_rx_ni() is used on older kernel. This might lead to deadlocks or other problems there.

---
[v3]
- reference other patches
- switch the #if test expressions to conform to the checker [v2]
- forgot to amend the #else/#endif typo fix

 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..a81846a8a895 100644
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
 		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#else
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.36.1
author
#4 lore raw

PATCH v4 1/1 kni: fix build with Linux 5.18

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

There were other attempts to fix this:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

But neither of them ensures netif_rx_ni() is used on older kernel. This might lead to deadlocks or other problems there.

---
[v4]
- really switch the #if test
[v3]
- reference other patches
- switch the #if test expressions to conform to the checker [v2]
- forgot to amend the #else/#endif typo fix

 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..0db29a4a6f61 100644
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
 		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#else
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.36.1
#5 lore raw
Quoted 45 lines · Jiri Slaby

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

There were other attempts to fix this:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

But neither of them ensures netif_rx_ni() is used on older kernel. This might lead to deadlocks or other problems there.

---
[v4]
- really switch the #if test
[v3]
- reference other patches
- switch the #if test expressions to conform to the checker [v2]
- forgot to amend the #else/#endif typo fix

  kernel/linux/kni/compat.h  | 4 ++++
  kernel/linux/kni/kni_net.c | 4 ++++
  2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..0db29a4a6f61 100644
@@ -141,3 +141,7 @@
  #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
  #define HAVE_TSK_IN_GUP
  #endif
+
+#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +0 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
  		skb->ip_summed = CHECKSUM_UNNECESSARY;

kernel/linux/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 451

Quoted 10 lines
kernel/linux/kni/kni_net.c +4 -0
 
  		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
  		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#else
 
  		/* Update statistics */
  		dev->stats.rx_bytes += len;

Applied to dpdk-next-net/main with minor fixes in the description, thanks.

#6 lore raw

PATCH 1/1 kni: fix build

A previous fix had #else instead of #endif.
The error message is:

	kernel/linux/kni/kni_net.c: In function ‘kni_net_rx_normal’:
	kernel/linux/kni/kni_net.c:448:2: error: #else after #else

Bugzilla ID: 1025

Fixes c98600d4bed6 ("kni: fix build with Linux 5.18")
---
 kernel/linux/kni/kni_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/linux/kni/kni_net.c +1 -1
index a8b092b756..41805fcabf 100644
@@ -445,7 +445,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 		netif_rx_ni(skb);
 #else
 		netif_rx(skb);
-#else
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.36.0
author
#7 lore raw
In reply to Andrew Rybchenko
Quoted 50 lines · Andrew Rybchenko
Quoted 49 lines · Jiri Slaby

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

There were other attempts to fix this:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

https://patches.dpdk.org/project/dpdk/patch/[email protected]/

But neither of them ensures netif_rx_ni() is used on older kernel. This might lead to deadlocks or other problems there.

---
[v4]
- really switch the #if test
[v3]
- reference other patches
- switch the #if test expressions to conform to the checker [v2]
- forgot to amend the #else/#endif typo fix

  kernel/linux/kni/compat.h  | 4 ++++
  kernel/linux/kni/kni_net.c | 4 ++++

  2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..0db29a4a6f61 100644
@@ -141,3 +141,7 @@
   #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
   #define HAVE_TSK_IN_GUP
   #endif
+
+#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +1 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
           skb->ip_summed = CHECKSUM_UNNECESSARY;
           /* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
Quoted 8 lines

kernel/linux/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 451

Quoted 6 lines
kernel/linux/kni/kni_net.c +3 -0
           netif_rx_ni(skb);
+#else
+        netif_rx(skb);
+#else
           /* Update statistics */
           dev->stats.rx_bytes += len;

Applied to dpdk-next-net/main with minor fixes in the description, thanks.

Sorry, it appears I sent the old version again. The latter #else should have been #endif. Do you want me to send a followup patch?

thanks,

Signature · 2 lines
js
suse labs
#8 lore raw
Quoted 60 lines · Jiri Slaby
Quoted 50 lines · Andrew Rybchenko
Quoted 49 lines · Jiri Slaby

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

There were other attempts to fix this:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

https://patches.dpdk.org/project/dpdk/patch/[email protected]/

But neither of them ensures netif_rx_ni() is used on older kernel. This might lead to deadlocks or other problems there.

---
[v4]
- really switch the #if test
[v3]
- reference other patches
- switch the #if test expressions to conform to the checker [v2]
- forgot to amend the #else/#endif typo fix

  kernel/linux/kni/compat.h  | 4 ++++
  kernel/linux/kni/kni_net.c | 4 ++++

  2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674ff1..0db29a4a6f61 100644
@@ -141,3 +141,7 @@
   #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
   #define HAVE_TSK_IN_GUP
   #endif
+
+#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +1 -0
index 29e5b9e21f9e..a8b092b7567d 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
           skb->ip_summed = CHECKSUM_UNNECESSARY;
           /* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
Quoted 8 lines

kernel/linux/kni/kni_net.c kni_net_rx_normal(struct kni_dev *kni) · line 451

Quoted 6 lines
kernel/linux/kni/kni_net.c +3 -0
           netif_rx_ni(skb);
+#else
+        netif_rx(skb);
+#else
           /* Update statistics */
           dev->stats.rx_bytes += len;

Applied to dpdk-next-net/main with minor fixes in the description, thanks.

Quoted 3 lines

Sorry, it appears I sent the old version again. The latter #else should have been #endif. Do you want me to send a followup patch?

thanks,

Oh, I'm sorry as well that I didn't catch it. Frankly speaking I'm surprised that all CI does not catch it. test-meson-build.sh does not catch it as well with default. I've tuned my build checks to care about it.

Thomas, thanks a lot for the quick fix.

#9 lore raw

PATCH v3 1/1 kni: fix build with Linux 5.18

In reply to Jiri Slaby

From: Jiri Slaby <[email protected]>

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

---
v3:
- swap comparison in compat.h to make checkpatches.sh happy

 kernel/linux/kni/compat.h  | 4 ++++
 kernel/linux/kni/kni_net.c | 4 ++++
 2 files changed, 8 insertions(+)
kernel/linux/kni/compat.h +4 -0
index 664785674f..0db29a4a6f 100644
@@ -141,3 +141,7 @@
 #if KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE
 #define HAVE_TSK_IN_GUP
 #endif
+
+#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE
+#define HAVE_NETIF_RX_NI
+#endif
kernel/linux/kni/kni_net.c +4 -0
index 29e5b9e21f..41805fcabf 100644
@@ -441,7 +441,11 @@ kni_net_rx_normal(struct kni_dev *kni)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		/* Call netif interface */
+#ifdef HAVE_NETIF_RX_NI
 		netif_rx_ni(skb);
+#else
+		netif_rx(skb);
+#endif
 
 		/* Update statistics */
 		dev->stats.rx_bytes += len;
Signature · 1 line
2.30.2
#10 lore raw
Quoted 11 lines · Andrew Rybchenko

From: Jiri Slaby <[email protected]>

Since commit 2655926aea9b (net: Remove netif_rx_any_context() and netif_rx_ni().) in 5.18, netif_rx_ni() no longer exists as netif_rx() can be called from any context. So define HAVE_NETIF_RX_NI for older releases and call the appropriate function in kni_net.

Self NACK. I've found correct patch in patchwork finally.