Print this page
OS-3893 sendfile compat checks shouldn't be done in so_sendmblk
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
        
*** 80,90 ****
  /*
   * 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
  sendvec_chunk64(file_t *fp, u_offset_t *fileoff, struct ksendfilevec64 *sfv,
      int copy_cnt, ssize32_t *count)
  {
          struct vnode *vp;
          ushort_t fflag;
--- 80,90 ----
  /*
   * 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.
   */
! 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,351 ****
                  sfv++;
          }
          return (0);
  }
  
! ssize32_t
  sendvec64(file_t *fp, const struct ksendfilevec64 *vec, int sfvcnt,
          size32_t *xferred, int fildes)
  {
          u_offset_t              fileoff;
          int                     copy_cnt;
--- 341,351 ----
                  sfv++;
          }
          return (0);
  }
  
! 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,398 ****
                  return (set_errno(error));
          return (count);
  }
  #endif
  
! 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;
--- 388,398 ----
                  return (set_errno(error));
          return (count);
  }
  #endif
  
! 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,688 ****
  
          return (0);
  }
  
  
! 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;
--- 678,688 ----
  
          return (0);
  }
  
  
! 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,1167 ****
--- 1158,1178 ----
                  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;