sock: permit SO_ZEROCOPY on PF_RDS socket
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 15 Feb 2018 18:49:34 +0000 (10:49 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Feb 2018 21:04:16 +0000 (16:04 -0500)
allow the application to set SO_ZEROCOPY on the underlying sk
of a PF_RDS socket

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index e90d461748f0fe8a0e15c02f59231d4d6d7a171c..a1fa4a548f1be714c5b505b4f269ffbee5572321 100644 (file)
@@ -1049,18 +1049,21 @@ set_rcvbuf:
                break;
 
        case SO_ZEROCOPY:
-               if (sk->sk_family != PF_INET && sk->sk_family != PF_INET6)
+               if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6) {
+                       if (sk->sk_protocol != IPPROTO_TCP)
+                               ret = -ENOTSUPP;
+                       else if (sk->sk_state != TCP_CLOSE)
+                               ret = -EBUSY;
+               } else if (sk->sk_family != PF_RDS) {
                        ret = -ENOTSUPP;
-               else if (sk->sk_protocol != IPPROTO_TCP)
-                       ret = -ENOTSUPP;
-               else if (sk->sk_state != TCP_CLOSE)
-                       ret = -EBUSY;
-               else if (val < 0 || val > 1)
-                       ret = -EINVAL;
-               else
-                       sock_valbool_flag(sk, SOCK_ZEROCOPY, valbool);
-               break;
-
+               }
+               if (!ret) {
+                       if (val < 0 || val > 1)
+                               ret = -EINVAL;
+                       else
+                               sock_valbool_flag(sk, SOCK_ZEROCOPY, valbool);
+                       break;
+               }
        default:
                ret = -ENOPROTOOPT;
                break;