diff mbox series

[ipsec] xfrm: lwtunnel: squelch kernel warning in case XFRM encap type is not available

Message ID 20221011080137.440419-1-eyal.birger@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [ipsec] xfrm: lwtunnel: squelch kernel warning in case XFRM encap type is not available | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eyal Birger Oct. 11, 2022, 8:01 a.m. UTC
Ido reported that a kernel warning [1] can be triggered from
user space when the kernel is compiled with CONFIG_MODULES=y and
CONFIG_XFRM=n when adding an xfrm encap type route, e.g:

$ ip route add 198.51.100.0/24 dev dummy1 encap xfrm if_id 1
Error: lwt encapsulation type not supported.

The reason for the warning is that the LWT infrastructure has an
autoloading feature which is meant only for encap types that don't
use a net device,  which is not the case in xfrm encap.

Mute this warning for xfrm encap as there's no encap module to autoload
in this case.

[1]
 WARNING: CPU: 3 PID: 2746262 at net/core/lwtunnel.c:57 lwtunnel_valid_encap_type+0x4f/0x120
[...]
 Call Trace:
  <TASK>
  rtm_to_fib_config+0x211/0x350
  inet_rtm_newroute+0x3a/0xa0
  rtnetlink_rcv_msg+0x154/0x3c0
  netlink_rcv_skb+0x49/0xf0
  netlink_unicast+0x22f/0x350
  netlink_sendmsg+0x208/0x440
  ____sys_sendmsg+0x21f/0x250
  ___sys_sendmsg+0x83/0xd0
  __sys_sendmsg+0x54/0xa0
  do_syscall_64+0x35/0x80
  entry_SYSCALL_64_after_hwframe+0x63/0xcd

Reported-by: Ido Schimmel <idosch@idosch.org>
Fixes: 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces in collect_md mode")
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
---
 net/core/lwtunnel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ido Schimmel Oct. 11, 2022, 9 a.m. UTC | #1
On Tue, Oct 11, 2022 at 11:01:37AM +0300, Eyal Birger wrote:
> Ido reported that a kernel warning [1] can be triggered from
> user space when the kernel is compiled with CONFIG_MODULES=y and
> CONFIG_XFRM=n when adding an xfrm encap type route, e.g:
> 
> $ ip route add 198.51.100.0/24 dev dummy1 encap xfrm if_id 1
> Error: lwt encapsulation type not supported.
> 
> The reason for the warning is that the LWT infrastructure has an
> autoloading feature which is meant only for encap types that don't
> use a net device,  which is not the case in xfrm encap.
> 
> Mute this warning for xfrm encap as there's no encap module to autoload
> in this case.

[...]

> 
> Reported-by: Ido Schimmel <idosch@idosch.org>
> Fixes: 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces in collect_md mode")
> Signed-off-by: Eyal Birger <eyal.birger@gmail.com>

Tested-by: Ido Schimmel <idosch@nvidia.com>

Thanks
Nikolay Aleksandrov Oct. 11, 2022, 9:07 a.m. UTC | #2
On 11/10/2022 11:01, Eyal Birger wrote:
> Ido reported that a kernel warning [1] can be triggered from
> user space when the kernel is compiled with CONFIG_MODULES=y and
> CONFIG_XFRM=n when adding an xfrm encap type route, e.g:
> 
> $ ip route add 198.51.100.0/24 dev dummy1 encap xfrm if_id 1
> Error: lwt encapsulation type not supported.
> 
> The reason for the warning is that the LWT infrastructure has an
> autoloading feature which is meant only for encap types that don't
> use a net device,  which is not the case in xfrm encap.
> 
> Mute this warning for xfrm encap as there's no encap module to autoload
> in this case.
> 
> [1]
>  WARNING: CPU: 3 PID: 2746262 at net/core/lwtunnel.c:57 lwtunnel_valid_encap_type+0x4f/0x120
> [...]
>  Call Trace:
>   <TASK>
>   rtm_to_fib_config+0x211/0x350
>   inet_rtm_newroute+0x3a/0xa0
>   rtnetlink_rcv_msg+0x154/0x3c0
>   netlink_rcv_skb+0x49/0xf0
>   netlink_unicast+0x22f/0x350
>   netlink_sendmsg+0x208/0x440
>   ____sys_sendmsg+0x21f/0x250
>   ___sys_sendmsg+0x83/0xd0
>   __sys_sendmsg+0x54/0xa0
>   do_syscall_64+0x35/0x80
>   entry_SYSCALL_64_after_hwframe+0x63/0xcd
> 
> Reported-by: Ido Schimmel <idosch@idosch.org>
> Fixes: 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces in collect_md mode")
> Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
> ---
>  net/core/lwtunnel.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
> index 6fac2f0ef074..711cd3b4347a 100644
> --- a/net/core/lwtunnel.c
> +++ b/net/core/lwtunnel.c
> @@ -48,9 +48,11 @@ static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)
>  		return "RPL";
>  	case LWTUNNEL_ENCAP_IOAM6:
>  		return "IOAM6";
> +	case LWTUNNEL_ENCAP_XFRM:
> +		/* module autoload not supported for encap type */
> +		return NULL;
>  	case LWTUNNEL_ENCAP_IP6:
>  	case LWTUNNEL_ENCAP_IP:
> -	case LWTUNNEL_ENCAP_XFRM:
>  	case LWTUNNEL_ENCAP_NONE:
>  	case __LWTUNNEL_ENCAP_MAX:
>  		/* should not have got here */

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Steffen Klassert Oct. 14, 2022, 1:38 p.m. UTC | #3
On Tue, Oct 11, 2022 at 11:01:37AM +0300, Eyal Birger wrote:
> Ido reported that a kernel warning [1] can be triggered from
> user space when the kernel is compiled with CONFIG_MODULES=y and
> CONFIG_XFRM=n when adding an xfrm encap type route, e.g:
> 
> $ ip route add 198.51.100.0/24 dev dummy1 encap xfrm if_id 1
> Error: lwt encapsulation type not supported.
> 
> The reason for the warning is that the LWT infrastructure has an
> autoloading feature which is meant only for encap types that don't
> use a net device,  which is not the case in xfrm encap.
> 
> Mute this warning for xfrm encap as there's no encap module to autoload
> in this case.
> 
> [1]
>  WARNING: CPU: 3 PID: 2746262 at net/core/lwtunnel.c:57 lwtunnel_valid_encap_type+0x4f/0x120
> [...]
>  Call Trace:
>   <TASK>
>   rtm_to_fib_config+0x211/0x350
>   inet_rtm_newroute+0x3a/0xa0
>   rtnetlink_rcv_msg+0x154/0x3c0
>   netlink_rcv_skb+0x49/0xf0
>   netlink_unicast+0x22f/0x350
>   netlink_sendmsg+0x208/0x440
>   ____sys_sendmsg+0x21f/0x250
>   ___sys_sendmsg+0x83/0xd0
>   __sys_sendmsg+0x54/0xa0
>   do_syscall_64+0x35/0x80
>   entry_SYSCALL_64_after_hwframe+0x63/0xcd
> 
> Reported-by: Ido Schimmel <idosch@idosch.org>
> Fixes: 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces in collect_md mode")
> Signed-off-by: Eyal Birger <eyal.birger@gmail.com>

Applied, thanks a lot!
diff mbox series

Patch

diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c
index 6fac2f0ef074..711cd3b4347a 100644
--- a/net/core/lwtunnel.c
+++ b/net/core/lwtunnel.c
@@ -48,9 +48,11 @@  static const char *lwtunnel_encap_str(enum lwtunnel_encap_types encap_type)
 		return "RPL";
 	case LWTUNNEL_ENCAP_IOAM6:
 		return "IOAM6";
+	case LWTUNNEL_ENCAP_XFRM:
+		/* module autoload not supported for encap type */
+		return NULL;
 	case LWTUNNEL_ENCAP_IP6:
 	case LWTUNNEL_ENCAP_IP:
-	case LWTUNNEL_ENCAP_XFRM:
 	case LWTUNNEL_ENCAP_NONE:
 	case __LWTUNNEL_ENCAP_MAX:
 		/* should not have got here */