~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to modules/linux/vsock/linux/af_vsock.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-30 12:56:49 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730125649-97sfj5li8axiseoo
Tags: 2009.07.22-179896-2
* Temporarily building without dumbnet, the recently uploaded
  new dumbnet upstream version broke down (Closes: #539006).
* Using more common name to store local debian additions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
701
701
 *      allocated as trusted (running in the guest).
702
702
 *
703
703
 * Results:
704
 
 *      0 on success. A VSock error on error.
 
704
 *      0 on success. A VMCI error on error.
705
705
 *
706
706
 * Side effects:
707
707
 *      None.
737
737
                                recvCB, clientData,
738
738
                                outHandle);
739
739
out:
740
 
   if (err < 0) {
741
 
      err = VSockVmci_ErrorToVSockError(err);
742
 
   }
743
 
 
744
740
   return err;
745
741
}
746
742
 
875
871
    * Ignore incoming packets from contexts without sockets, or resources that
876
872
    * aren't vsock implementations.
877
873
    */
878
 
   if (!VSockAddr_SocketContext(VMCI_HANDLE_TO_CONTEXT_ID(dg->src)) ||
 
874
 
 
875
   if (!VSockAddr_SocketContextStream(VMCI_HANDLE_TO_CONTEXT_ID(dg->src)) ||
879
876
       VSOCK_PACKET_RID != VMCI_HANDLE_TO_RESOURCE_ID(dg->src)) {
880
877
      return VMCI_ERROR_NO_ACCESS;
881
878
   }
1495
1492
   sk->compat_sk_ack_backlog++;
1496
1493
 
1497
1494
   pending->compat_sk_state = SS_CONNECTING;
1498
 
   vpending->produceSize = vpending->consumeSize = pkt->u.size;
 
1495
   vpending->produceSize = vpending->consumeSize = qpSize;
1499
1496
 
1500
1497
   /* XXX Move this into the notify file. */
1501
 
   vpending->notify.writeNotifyWindow = pkt->u.size;
 
1498
   vpending->notify.writeNotifyWindow = qpSize;
1502
1499
 
1503
1500
   /*
1504
1501
    * We might never receive another message for this socket and it's not
2823
2820
       vmciStreamHandle.context == VMCI_INVALID_ID ||
2824
2821
       vmciStreamHandle.resource == VMCI_INVALID_ID) {
2825
2822
      Warning("Unable to create datagram handle. (%d)\n", err);
2826
 
      return -ENOMEM;
 
2823
      return VSockVmci_ErrorToVSockError(err);
2827
2824
   }
2828
2825
 
2829
2826
   err = VMCIEvent_Subscribe(VMCI_EVENT_QP_RESUMED,
2832
2829
                             &qpResumedSubId);
2833
2830
   if (err < VMCI_SUCCESS) {
2834
2831
      Warning("Unable to subscribe to QP resumed event. (%d)\n", err);
2835
 
      err = -ENOMEM;
 
2832
      err = VSockVmci_ErrorToVSockError(err);
2836
2833
      qpResumedSubId = VMCI_INVALID_ID;
2837
2834
      goto error;
2838
2835
   }
3110
3107
      }
3111
3108
   }
3112
3109
 
 
3110
   if (!VSockAddr_SocketContextDgram(remoteAddr->svm_cid,
 
3111
                                     remoteAddr->svm_port)) {
 
3112
      err = -EINVAL;
 
3113
      goto out;
 
3114
   }
 
3115
 
3113
3116
   memcpy(&vsk->remoteAddr, remoteAddr, sizeof vsk->remoteAddr);
3114
3117
   sock->state = SS_CONNECTED;
3115
3118
 
3182
3185
      }
3183
3186
 
3184
3187
      /* The hypervisor and well-known contexts do not have socket endpoints. */
3185
 
      if (!VSockAddr_SocketContext(remoteAddr->svm_cid)) {
 
3188
      if (!VSockAddr_SocketContextStream(remoteAddr->svm_cid)) {
3186
3189
         err = -ENETUNREACH;
3187
3190
         goto out;
3188
3191
      }
3329
3332
         err = sock_intr_errno(timeout);
3330
3333
         goto outWait;
3331
3334
      } else if (timeout == 0) {
3332
 
         err = -ETIMEDOUT;
 
3335
         err = -EAGAIN;
3333
3336
         goto outWait;
3334
3337
      }
3335
3338
 
3532
3535
       * Sockets whose connections have been close, reset, or terminated should also
3533
3536
       * be considered read, and we check the shutdown flag for that.
3534
3537
       */
3535
 
      if (sk->compat_sk_shutdown) {
 
3538
      if (sk->compat_sk_shutdown & RCV_SHUTDOWN ||
 
3539
          vsk->peerShutdown & SEND_SHUTDOWN) {
3536
3540
          mask |= POLLIN | POLLRDNORM;
3537
3541
      }
3538
3542
 
3784
3788
   }
3785
3789
 
3786
3790
   /*
 
3791
    * Make sure that we don't allow a userlevel app to send datagrams
 
3792
    * to the hypervisor that modify VMCI device state.
 
3793
    */
 
3794
   if (!VSockAddr_SocketContextDgram(remoteAddr->svm_cid,
 
3795
                                     remoteAddr->svm_port)) {
 
3796
      err = -EINVAL;
 
3797
      goto out;
 
3798
   }
 
3799
 
 
3800
   /*
3787
3801
    * Allocate a buffer for the user's message and our packet header.
3788
3802
    */
3789
3803
   dg = kmalloc(len + sizeof *dg, GFP_KERNEL);