kni: fix build with Linux 5.18
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
@@ -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
@@ -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
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
@@ -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
@@ -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
Quoted 5 lines · Jiri Slaby
Since commit
2655926aea9b(net: Removenetif_rx_any_context()andnetif_rx_ni().) in 5.18,netif_rx_ni()no longer exists asnetif_rx()can be called from any context. So defineHAVE_NETIF_RX_NIfor older releases and call the appropriate function inkni_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
Signed-off-by Jiri Slaby <[email protected]>---
[v2]
- forgot to amend the #else/#endif typo fixkernel/linux/kni/compat.h | 4 ++++ kernel/linux/kni/kni_net.c | 4 ++++ 2 files changed, 8 insertions(+)kernel/linux/kni/compat.h +0
-0
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@@ -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;
PATCH v3 1/1 kni: fix build with Linux 5.18
In reply to Jiri SlabySince 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
@@ -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
@@ -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
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
@@ -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
@@ -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
Andrew Rybchenko
AppliedQuoted 45 lines · Jiri Slaby
Since commit
2655926aea9b(net: Removenetif_rx_any_context()andnetif_rx_ni().) in 5.18,netif_rx_ni()no longer exists asnetif_rx()can be called from any context. So defineHAVE_NETIF_RX_NIfor older releases and call the appropriate function inkni_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.Signed-off-by Jiri Slaby <[email protected]>---
[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 fixkernel/linux/kni/compat.h | 4 ++++ kernel/linux/kni/kni_net.c | 4 ++++ 2 files changed, 8 insertions(+)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 KERNEL_VERSION (5 ,18 ,0 ) >LINUX_VERSION_CODE +#define HAVE_NETIF_RX_NI +#endif kernel/linux/kni/kni_net.c +0
-0@@ -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.
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
--- kernel/linux/kni/kni_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/linux/kni/kni_net.c +1 -1
@@ -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
Quoted 50 lines · Andrew Rybchenko
Quoted 49 lines · Jiri Slaby
Since commit
2655926aea9b(net: Removenetif_rx_any_context()andnetif_rx_ni().) in 5.18,netif_rx_ni()no longer exists asnetif_rx()can be called from any context. So defineHAVE_NETIF_RX_NIfor older releases and call the appropriate function inkni_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.Signed-off-by Jiri Slaby <[email protected]>---
[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 fixkernel/linux/kni/compat.h | 4 ++++
kernel/linux/kni/kni_net.c| 4 ++++2 files changed, 8 insertions(+)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 KERNEL_VERSION (5 ,18 ,0 ) >LINUX_VERSION_CODE +#define HAVE_NETIF_RX_NI +#endif kernel/linux/kni/kni_net.c +1
-0@@ -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
-0netif_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
Quoted 60 lines · Jiri Slaby
Quoted 50 lines · Andrew Rybchenko
Quoted 49 lines · Jiri Slaby
Since commit
2655926aea9b(net: Removenetif_rx_any_context()andnetif_rx_ni().) in 5.18,netif_rx_ni()no longer exists asnetif_rx()can be called from any context. So defineHAVE_NETIF_RX_NIfor older releases and call the appropriate function inkni_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.Signed-off-by Jiri Slaby <[email protected]>---
[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 fixkernel/linux/kni/compat.h | 4 ++++
kernel/linux/kni/kni_net.c| 4 ++++2 files changed, 8 insertions(+)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 KERNEL_VERSION (5 ,18 ,0 ) >LINUX_VERSION_CODE +#define HAVE_NETIF_RX_NI +#endif kernel/linux/kni/kni_net.c +1
-0@@ -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
-0netif_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.
PATCH v3 1/1 kni: fix build with Linux 5.18
In reply to Jiri SlabyFrom: 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
@@ -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
@@ -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
Quoted 11 lines · Andrew Rybchenko
From: Jiri Slaby <[email protected]>
Since commit
2655926aea9b(net: Removenetif_rx_any_context()andnetif_rx_ni().) in 5.18,netif_rx_ni()no longer exists asnetif_rx()can be called from any context. So defineHAVE_NETIF_RX_NIfor older releases and call the appropriate function inkni_net.Signed-off-by Jiri Slaby <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
Self NACK. I've found correct patch in patchwork finally.