linux-stable/net/l2tp
Tom Parkin a460592e43 l2tp: fix ICMP error handling for UDP-encap sockets
[ Upstream commit 6e828dc60e ]

Since commit a36e185e8c
("udp: Handle ICMP errors for tunnels with same destination port on both endpoints")
UDP's handling of ICMP errors has allowed for UDP-encap tunnels to
determine socket associations in scenarios where the UDP hash lookup
could not.

Subsequently, commit d26796ae58
("udp: check udp sock encap_type in __udp_lib_err")
subtly tweaked the approach such that UDP ICMP error handling would be
skipped for any UDP socket which has encapsulation enabled.

In the case of L2TP tunnel sockets using UDP-encap, this latter
modification effectively broke ICMP error reporting for the L2TP
control plane.

To a degree this isn't catastrophic inasmuch as the L2TP control
protocol defines a reliable transport on top of the underlying packet
switching network which will eventually detect errors and time out.

However, paying attention to the ICMP error reporting allows for more
timely detection of errors in L2TP userspace, and aids in debugging
connectivity issues.

Reinstate ICMP error handling for UDP encap L2TP tunnels:

 * implement struct udp_tunnel_sock_cfg .encap_err_rcv in order to allow
   the L2TP code to handle ICMP errors;

 * only implement error-handling for tunnels which have a managed
   socket: unmanaged tunnels using a kernel socket have no userspace to
   report errors back to;

 * flag the error on the socket, which allows for userspace to get an
   error such as -ECONNREFUSED back from sendmsg/recvmsg;

 * pass the error into ip[v6]_icmp_error() which allows for userspace to
   get extended error information via. MSG_ERRQUEUE.

Fixes: d26796ae58 ("udp: check udp sock encap_type in __udp_lib_err")
Signed-off-by: Tom Parkin <tparkin@katalix.com>
Link: https://lore.kernel.org/r/20240513172248.623261-1-tparkin@katalix.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-30 09:49:52 +02:00
..
Kconfig
Makefile
l2tp_core.c l2tp: fix ICMP error handling for UDP-encap sockets 2024-05-30 09:49:52 +02:00
l2tp_core.h net: ioctl: Use kernel memory on protocol ioctl callbacks 2023-06-15 22:33:26 -07:00
l2tp_debugfs.c l2tp: l2tp_debugfs: fix Clang -Wformat warnings 2022-07-08 12:14:36 +01:00
l2tp_eth.c net l2tp: drop flow hash on forward 2024-05-17 12:14:29 +02:00
l2tp_ip.c inet: introduce inet->inet_flags 2023-08-16 11:09:16 +01:00
l2tp_ip6.c l2tp: pass correct message length to ip6_append_data 2024-02-22 10:42:17 +01:00
l2tp_netlink.c genetlink: start to validate reserved header bytes 2022-08-29 12:47:15 +01:00
l2tp_ppp.c l2tp: fix incorrect parameter validation in the pppol2tp_getsockopt() function 2024-03-26 18:16:57 -04:00
trace.h