Print this page
OS-3893 sendfile compat checks shouldn't be done in so_sendmblk
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

@@ -80,11 +80,11 @@
 /*
  * 64 bit offsets for 32 bit applications only running either on
  * 64 bit kernel or 32 bit kernel. For 32 bit apps, we can't transfer
  * more than 2GB of data.
  */
-int
+static int
 sendvec_chunk64(file_t *fp, u_offset_t *fileoff, struct ksendfilevec64 *sfv,
     int copy_cnt, ssize32_t *count)
 {
         struct vnode *vp;
         ushort_t fflag;

@@ -341,11 +341,11 @@
                 sfv++;
         }
         return (0);
 }
 
-ssize32_t
+static ssize32_t
 sendvec64(file_t *fp, const struct ksendfilevec64 *vec, int sfvcnt,
         size32_t *xferred, int fildes)
 {
         u_offset_t              fileoff;
         int                     copy_cnt;

@@ -388,11 +388,11 @@
                 return (set_errno(error));
         return (count);
 }
 #endif
 
-int
+static int
 sendvec_small_chunk(file_t *fp, u_offset_t *fileoff, struct sendfilevec *sfv,
     int copy_cnt, ssize_t total_size, int maxblk, ssize_t *count)
 {
         struct vnode *vp;
         struct uio auio;

@@ -678,11 +678,11 @@
 
         return (0);
 }
 
 
-int
+static int
 sendvec_chunk(file_t *fp, u_offset_t *fileoff, struct sendfilevec *sfv,
     int copy_cnt, ssize_t *count)
 {
         struct vnode *vp;
         struct uio auio;

@@ -1158,10 +1158,21 @@
                 if (SOCK_IS_NONSTR(so)) {
                         maxblk = so->so_proto_props.sopp_maxblk;
                 } else {
                         maxblk = (int)vp->v_stream->sd_maxblk;
                 }
+
+                /*
+                 * We need to make sure that the socket that we're sending on
+                 * supports sendfile behavior. sockfs doesn't know that the APIs
+                 * we want to use are coming from sendfile, so we can't rely on
+                 * it to check for us.
+                 */
+                if ((so->so_mode & SM_SENDFILESUPP) == 0) {
+                        error = EOPNOTSUPP;
+                        goto err;
+                }
                 break;
         case VREG:
                 break;
         default:
                 error = EINVAL;