linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rxrpc: Enable IPv6 checksums on transport socket
@ 2022-04-27 21:30 David Howells
  2022-04-28  2:18 ` Xin Long
  2022-04-29 12:20 ` Marc Dionne
  0 siblings, 2 replies; 3+ messages in thread
From: David Howells @ 2022-04-27 21:30 UTC (permalink / raw)
  To: marc.dionne
  Cc: Xin Long, Vadim Fedorenko, David S. Miller, linux-afs, dhowells,
	linux-kernel

AF_RXRPC doesn't currently enable IPv6 UDP Tx checksums on the transport
socket it opens and the checksums in the packets it generates end up 0.

It probably should also enable IPv6 UDP Rx checksums and IPv4 UDP
checksums.  The latter only seem to be applied if the socket family is
AF_INET and don't seem to apply if it's AF_INET6.  IPv4 packets from an
IPv6 socket seem to have checksums anyway.

What seems to have happened is that the inet_inv_convert_csum() call didn't
get converted to the appropriate udp_port_cfg parameters - and
udp_sock_create() disables checksums unless explicitly told not too.

Fix this by enabling the three udp_port_cfg checksum options.

Fixes: 1a9b86c9fd95 ("rxrpc: use udp tunnel APIs instead of open code in rxrpc_open_socket")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Xin Long <lucien.xin@gmail.com>
cc: Vadim Fedorenko <vfedorenko@novek.ru>
cc: David S. Miller <davem@davemloft.net>
cc: linux-afs@lists.infradead.org
---

 net/rxrpc/local_object.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index a4111408ffd0..6a1611b0e303 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -117,6 +117,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
 	       local, srx->transport_type, srx->transport.family);
 
 	udp_conf.family = srx->transport.family;
+	udp_conf.use_udp_checksums = true;
 	if (udp_conf.family == AF_INET) {
 		udp_conf.local_ip = srx->transport.sin.sin_addr;
 		udp_conf.local_udp_port = srx->transport.sin.sin_port;
@@ -124,6 +125,8 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
 	} else {
 		udp_conf.local_ip6 = srx->transport.sin6.sin6_addr;
 		udp_conf.local_udp_port = srx->transport.sin6.sin6_port;
+		udp_conf.use_udp6_tx_checksums = true;
+		udp_conf.use_udp6_rx_checksums = true;
 #endif
 	}
 	ret = udp_sock_create(net, &udp_conf, &local->socket);



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rxrpc: Enable IPv6 checksums on transport socket
  2022-04-27 21:30 [PATCH] rxrpc: Enable IPv6 checksums on transport socket David Howells
@ 2022-04-28  2:18 ` Xin Long
  2022-04-29 12:20 ` Marc Dionne
  1 sibling, 0 replies; 3+ messages in thread
From: Xin Long @ 2022-04-28  2:18 UTC (permalink / raw)
  To: David Howells
  Cc: marc.dionne, Vadim Fedorenko, David S. Miller, linux-afs, LKML

On Wed, Apr 27, 2022 at 5:30 PM David Howells <dhowells@redhat.com> wrote:
>
> AF_RXRPC doesn't currently enable IPv6 UDP Tx checksums on the transport
> socket it opens and the checksums in the packets it generates end up 0.
>
> It probably should also enable IPv6 UDP Rx checksums and IPv4 UDP
> checksums.  The latter only seem to be applied if the socket family is
> AF_INET and don't seem to apply if it's AF_INET6.  IPv4 packets from an
> IPv6 socket seem to have checksums anyway.
>
> What seems to have happened is that the inet_inv_convert_csum() call didn't
> get converted to the appropriate udp_port_cfg parameters - and
> udp_sock_create() disables checksums unless explicitly told not too.
>
> Fix this by enabling the three udp_port_cfg checksum options.
>
> Fixes: 1a9b86c9fd95 ("rxrpc: use udp tunnel APIs instead of open code in rxrpc_open_socket")
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Xin Long <lucien.xin@gmail.com>
> cc: Vadim Fedorenko <vfedorenko@novek.ru>
> cc: David S. Miller <davem@davemloft.net>
> cc: linux-afs@lists.infradead.org
> ---
>
>  net/rxrpc/local_object.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
> index a4111408ffd0..6a1611b0e303 100644
> --- a/net/rxrpc/local_object.c
> +++ b/net/rxrpc/local_object.c
> @@ -117,6 +117,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
>                local, srx->transport_type, srx->transport.family);
>
>         udp_conf.family = srx->transport.family;
> +       udp_conf.use_udp_checksums = true;
>         if (udp_conf.family == AF_INET) {
>                 udp_conf.local_ip = srx->transport.sin.sin_addr;
>                 udp_conf.local_udp_port = srx->transport.sin.sin_port;
> @@ -124,6 +125,8 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
>         } else {
>                 udp_conf.local_ip6 = srx->transport.sin6.sin6_addr;
>                 udp_conf.local_udp_port = srx->transport.sin6.sin6_port;
> +               udp_conf.use_udp6_tx_checksums = true;
> +               udp_conf.use_udp6_rx_checksums = true;
>  #endif
>         }
>         ret = udp_sock_create(net, &udp_conf, &local->socket);
>
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rxrpc: Enable IPv6 checksums on transport socket
  2022-04-27 21:30 [PATCH] rxrpc: Enable IPv6 checksums on transport socket David Howells
  2022-04-28  2:18 ` Xin Long
@ 2022-04-29 12:20 ` Marc Dionne
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Dionne @ 2022-04-29 12:20 UTC (permalink / raw)
  To: David Howells
  Cc: Xin Long, Vadim Fedorenko, David S. Miller, linux-afs,
	Linux Kernel Mailing List

On Wed, Apr 27, 2022 at 6:30 PM David Howells <dhowells@redhat.com> wrote:
>
> AF_RXRPC doesn't currently enable IPv6 UDP Tx checksums on the transport
> socket it opens and the checksums in the packets it generates end up 0.
>
> It probably should also enable IPv6 UDP Rx checksums and IPv4 UDP
> checksums.  The latter only seem to be applied if the socket family is
> AF_INET and don't seem to apply if it's AF_INET6.  IPv4 packets from an
> IPv6 socket seem to have checksums anyway.
>
> What seems to have happened is that the inet_inv_convert_csum() call didn't
> get converted to the appropriate udp_port_cfg parameters - and
> udp_sock_create() disables checksums unless explicitly told not too.
>
> Fix this by enabling the three udp_port_cfg checksum options.
>
> Fixes: 1a9b86c9fd95 ("rxrpc: use udp tunnel APIs instead of open code in rxrpc_open_socket")
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Xin Long <lucien.xin@gmail.com>
> cc: Vadim Fedorenko <vfedorenko@novek.ru>
> cc: David S. Miller <davem@davemloft.net>
> cc: linux-afs@lists.infradead.org
> ---
>
>  net/rxrpc/local_object.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
> index a4111408ffd0..6a1611b0e303 100644
> --- a/net/rxrpc/local_object.c
> +++ b/net/rxrpc/local_object.c
> @@ -117,6 +117,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
>                local, srx->transport_type, srx->transport.family);
>
>         udp_conf.family = srx->transport.family;
> +       udp_conf.use_udp_checksums = true;
>         if (udp_conf.family == AF_INET) {
>                 udp_conf.local_ip = srx->transport.sin.sin_addr;
>                 udp_conf.local_udp_port = srx->transport.sin.sin_port;
> @@ -124,6 +125,8 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
>         } else {
>                 udp_conf.local_ip6 = srx->transport.sin6.sin6_addr;
>                 udp_conf.local_udp_port = srx->transport.sin6.sin6_port;
> +               udp_conf.use_udp6_tx_checksums = true;
> +               udp_conf.use_udp6_rx_checksums = true;
>  #endif
>         }
>         ret = udp_sock_create(net, &udp_conf, &local->socket);

Works for me, and I think we want all 3 settings, as a socket created
by a userspace application other than kafs may be a V4 socket.

Reviewed-by: Marc Dionne <marc.dionne@auristor.com>

Marc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-29 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 21:30 [PATCH] rxrpc: Enable IPv6 checksums on transport socket David Howells
2022-04-28  2:18 ` Xin Long
2022-04-29 12:20 ` Marc Dionne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).