]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rxrpc: Fix DATA Tx to disable nofrag for UDP on AF_INET6 socket
authorDavid Howells <dhowells@redhat.com>
Mon, 13 Apr 2020 12:57:14 +0000 (13:57 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 14 May 2020 08:54:28 +0000 (10:54 +0200)
BugLink: https://bugs.launchpad.net/bugs/1878256
commit 0e631eee17dcea576ab922fa70e4fdbd596ee452 upstream.

Fix the DATA packet transmission to disable nofrag for UDPv4 on an AF_INET6
socket as well as UDPv6 when trying to transmit fragmentably.

Without this, packets filled to the normal size used by the kernel AFS
client of 1412 bytes be rejected by udp_sendmsg() with EMSGSIZE
immediately.  The ->sk_error_report() notification hook is called, but
rxrpc doesn't generate a trace for it.

This is a temporary fix; a more permanent solution needs to involve
changing the size of the packets being filled in accordance with the MTU,
which isn't currently done in AF_RXRPC.  The reason for not doing so was
that, barring the last packet in an rx jumbo packet, jumbos can only be
assembled out of 1412-byte packets - and the plan was to construct jumbos
on the fly at transmission time.

Also, there's no point turning on IPV6_MTU_DISCOVER, since IPv6 has to
engage in this anyway since fragmentation is only done by the sender.  We
can then condense the switch-statement in rxrpc_send_data_packet().

Fixes: 75b54cb57ca3 ("rxrpc: Add IPv6 support")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/rxrpc/local_object.c
net/rxrpc/output.c

index 62f599fdb887f04055867df1b4c7ea7b1b5cffcc..b189c827857d6438724f0c594bd7b9e8b1cb1ada 100644 (file)
@@ -144,15 +144,6 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
                        goto error;
                }
 
-               /* we want to set the don't fragment bit */
-               opt = IPV6_PMTUDISC_DO;
-               ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_MTU_DISCOVER,
-                                       (char *) &opt, sizeof(opt));
-               if (ret < 0) {
-                       _debug("setsockopt failed");
-                       goto error;
-               }
-
                /* Fall through and set IPv4 options too otherwise we don't get
                 * errors from IPv4 packets sent through the IPv6 socket.
                 */
index 41195647a0928111a4390859a09acb0699de641a..3f379455570c8e7511bda58dd6a9fe2d8aa28bfc 100644 (file)
@@ -453,39 +453,20 @@ send_fragmentable:
        down_write(&conn->params.local->defrag_sem);
 
        switch (conn->params.local->srx.transport.family) {
+       case AF_INET6:
        case AF_INET:
                opt = IP_PMTUDISC_DONT;
-               ret = kernel_setsockopt(conn->params.local->socket,
-                                       SOL_IP, IP_MTU_DISCOVER,
-                                       (char *)&opt, sizeof(opt));
-               if (ret == 0) {
-                       ret = kernel_sendmsg(conn->params.local->socket, &msg,
-                                            iov, 2, len);
-
-                       opt = IP_PMTUDISC_DO;
-                       kernel_setsockopt(conn->params.local->socket, SOL_IP,
-                                         IP_MTU_DISCOVER,
-                                         (char *)&opt, sizeof(opt));
-               }
-               break;
-
-#ifdef CONFIG_AF_RXRPC_IPV6
-       case AF_INET6:
-               opt = IPV6_PMTUDISC_DONT;
-               ret = kernel_setsockopt(conn->params.local->socket,
-                                       SOL_IPV6, IPV6_MTU_DISCOVER,
-                                       (char *)&opt, sizeof(opt));
-               if (ret == 0) {
-                       ret = kernel_sendmsg(conn->params.local->socket, &msg,
-                                            iov, 2, len);
-
-                       opt = IPV6_PMTUDISC_DO;
-                       kernel_setsockopt(conn->params.local->socket,
-                                         SOL_IPV6, IPV6_MTU_DISCOVER,
-                                         (char *)&opt, sizeof(opt));
-               }
+               kernel_setsockopt(conn->params.local->socket,
+                                 SOL_IP, IP_MTU_DISCOVER,
+                                 (char *)&opt, sizeof(opt));
+               ret = kernel_sendmsg(conn->params.local->socket, &msg,
+                                    iov, 2, len);
+
+               opt = IP_PMTUDISC_DO;
+               kernel_setsockopt(conn->params.local->socket,
+                                 SOL_IP, IP_MTU_DISCOVER,
+                                 (char *)&opt, sizeof(opt));
                break;
-#endif
 
        default:
                BUG();