This file is indexed.

/usr/src/open-vm-tools-10.0.7/vsock/linux/util.c is in open-vm-tools-dkms 2:10.0.7-3227872-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
/*********************************************************
 * Copyright (C) 2007 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation version 2 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 *********************************************************/


/*
 * util.c --
 *
 *      Utility functions for Linux VSocket module.
 */

#include "driver-config.h"
#include <linux/list.h>
#include <linux/socket.h>
#include "compat_sock.h"

#include "af_vsock.h"
#include "util.h"

struct list_head vsockBindTable[VSOCK_HASH_SIZE + 1];
struct list_head vsockConnectedTable[VSOCK_HASH_SIZE];

DEFINE_SPINLOCK(vsockTableLock);


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciLogPkt --
 *
 *    Logs the provided packet.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciLogPkt(char const *function,   // IN
                uint32 line,            // IN
                VSockPacket *pkt)       // IN
{
   char buf[256];
   char *cur = buf;
   int left = sizeof buf;
   int written = 0;
   char *typeStrings[] = {
      [VSOCK_PACKET_TYPE_INVALID]        = "INVALID",
      [VSOCK_PACKET_TYPE_REQUEST]        = "REQUEST",
      [VSOCK_PACKET_TYPE_NEGOTIATE]      = "NEGOTIATE",
      [VSOCK_PACKET_TYPE_OFFER]          = "OFFER",
      [VSOCK_PACKET_TYPE_ATTACH]         = "ATTACH",
      [VSOCK_PACKET_TYPE_WROTE]          = "WROTE",
      [VSOCK_PACKET_TYPE_READ]           = "READ",
      [VSOCK_PACKET_TYPE_RST]            = "RST",
      [VSOCK_PACKET_TYPE_SHUTDOWN]       = "SHUTDOWN",
      [VSOCK_PACKET_TYPE_WAITING_WRITE]  = "WAITING_WRITE",
      [VSOCK_PACKET_TYPE_WAITING_READ]   = "WAITING_READ",
      [VSOCK_PACKET_TYPE_REQUEST2]       = "REQUEST2",
      [VSOCK_PACKET_TYPE_NEGOTIATE2]     = "NEGOTIATE2",
   };

   written = snprintf(cur, left, "PKT: %u:%u -> %u:%u",
                      VMCI_HANDLE_TO_CONTEXT_ID(pkt->dg.src),
                      pkt->srcPort,
                      VMCI_HANDLE_TO_CONTEXT_ID(pkt->dg.dst),
                      pkt->dstPort);
   if (written >= left) {
      goto error;
   }

   left -= written;
   cur += written;

   switch (pkt->type) {
   case VSOCK_PACKET_TYPE_REQUEST:
   case VSOCK_PACKET_TYPE_NEGOTIATE:
      written = snprintf(cur, left, ", %s, size = %"FMT64"u",
                         typeStrings[pkt->type], pkt->u.size);
      break;

   case VSOCK_PACKET_TYPE_OFFER:
   case VSOCK_PACKET_TYPE_ATTACH:
      written = snprintf(cur, left, ", %s, handle = %u:%u",
                         typeStrings[pkt->type],
                         VMCI_HANDLE_TO_CONTEXT_ID(pkt->u.handle),
                         VMCI_HANDLE_TO_RESOURCE_ID(pkt->u.handle));
      break;

   case VSOCK_PACKET_TYPE_WROTE:
   case VSOCK_PACKET_TYPE_READ:
   case VSOCK_PACKET_TYPE_RST:
      written = snprintf(cur, left, ", %s", typeStrings[pkt->type]);
      break;
   case VSOCK_PACKET_TYPE_SHUTDOWN: {
      Bool recv;
      Bool send;

      recv = pkt->u.mode & RCV_SHUTDOWN;
      send = pkt->u.mode & SEND_SHUTDOWN;
      written = snprintf(cur, left, ", %s, mode = %c%c",
                         typeStrings[pkt->type],
                         recv ? 'R' : ' ',
                         send ? 'S' : ' ');
   }
   break;

   case VSOCK_PACKET_TYPE_WAITING_WRITE:
   case VSOCK_PACKET_TYPE_WAITING_READ:
      written = snprintf(cur, left, ", %s, generation = %"FMT64"u, "
                         "offset = %"FMT64"u", typeStrings[pkt->type],
                         pkt->u.wait.generation, pkt->u.wait.offset);

      break;

   case VSOCK_PACKET_TYPE_REQUEST2:
   case VSOCK_PACKET_TYPE_NEGOTIATE2:
      written = snprintf(cur, left, ", %s, size = %"FMT64"u, "
                         "proto = %u",
                         typeStrings[pkt->type], pkt->u.size,
                         pkt->proto);
      break;

   default:
      written = snprintf(cur, left, ", unrecognized type");
   }

   if (written >= left) {
      goto error;
   }

   left -= written;
   cur += written;

   written = snprintf(cur, left, "  [%s:%u]\n", function, line);
   if (written >= left) {
      goto error;
   }

   LOG(8, ("%s", buf));

   return;

error:
   LOG(8, ("could not log packet\n"));
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciInitTables --
 *
 *    Initializes the tables used for socket lookup.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciInitTables(void)
{
   uint32 i;

   for (i = 0; i < ARRAYSIZE(vsockBindTable); i++) {
      INIT_LIST_HEAD(&vsockBindTable[i]);
   }

   for (i = 0; i < ARRAYSIZE(vsockConnectedTable); i++) {
      INIT_LIST_HEAD(&vsockConnectedTable[i]);
   }
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciInsertBound --
 *
 *    Inserts socket into the bound table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count for sk is incremented.
 *
 *----------------------------------------------------------------------------
 */

void
__VSockVmciInsertBound(struct list_head *list,          // IN
                       struct sock *sk)                 // IN
{
   VSockVmciSock *vsk;

   ASSERT(list);
   ASSERT(sk);

   vsk = vsock_sk(sk);

   sock_hold(sk);
   list_add(&vsk->boundTable, list);
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciInsertConnected --
 *
 *    Inserts socket into the connected table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count for sk is incremented.
 *
 *----------------------------------------------------------------------------
 */

void
__VSockVmciInsertConnected(struct list_head *list,   // IN
                           struct sock *sk)          // IN
{
   VSockVmciSock *vsk;

   ASSERT(list);
   ASSERT(sk);

   vsk = vsock_sk(sk);

   sock_hold(sk);
   list_add(&vsk->connectedTable, list);
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciRemoveBound --
 *
 *    Removes socket from the bound table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count for sk is decremented.
 *
 *----------------------------------------------------------------------------
 */

void
__VSockVmciRemoveBound(struct sock *sk)  // IN
{
   VSockVmciSock *vsk;

   ASSERT(sk);
   ASSERT(__VSockVmciInBoundTable(sk));

   vsk = vsock_sk(sk);

   list_del_init(&vsk->boundTable);
   sock_put(sk);
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciRemoveConnected --
 *
 *    Removes socket from the connected table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count for sk is decremented.
 *
 *----------------------------------------------------------------------------
 */

void
__VSockVmciRemoveConnected(struct sock *sk)  // IN
{
   VSockVmciSock *vsk;

   ASSERT(sk);
   ASSERT(__VSockVmciInConnectedTable(sk));

   vsk = vsock_sk(sk);

   list_del_init(&vsk->connectedTable);
   sock_put(sk);
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciFindBoundSocket --
 *
 *    Finds the socket corresponding to the provided address in the bound
 *    sockets hash table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    The sock structure if found, NULL if not found.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

struct sock *
__VSockVmciFindBoundSocket(struct sockaddr_vm *addr)  // IN
{
   VSockVmciSock *vsk;
   struct sock *sk;

   ASSERT(addr);

   list_for_each_entry(vsk, vsockBoundSockets(addr), boundTable) {
      if (addr->svm_port == vsk->localAddr.svm_port) {
         sk = sk_vsock(vsk);

         /* We only store stream sockets in the bound table. */
         ASSERT(sk->sk_socket ?
                   sk->sk_socket->type == SOCK_STREAM :
                   1);
         goto found;
      }
   }

   sk = NULL;
found:
   return sk;
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciFindConnectedSocket --
 *
 *    Finds the socket corresponding to the provided addresses in the connected
 *    sockets hash table.
 *
 *    Note that this assumes any necessary locks are held.
 *
 * Results:
 *    The sock structure if found, NULL if not found.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

struct sock *
__VSockVmciFindConnectedSocket(struct sockaddr_vm *src,    // IN
                               struct sockaddr_vm *dst)    // IN
{
   VSockVmciSock *vsk;
   struct sock *sk;

   ASSERT(src);
   ASSERT(dst);

   list_for_each_entry(vsk, vsockConnectedSockets(src, dst), connectedTable) {
      if (VSockAddr_EqualsAddr(src, &vsk->remoteAddr) &&
          dst->svm_port == vsk->localAddr.svm_port) {
         sk = sk_vsock(vsk);
         goto found;
      }
   }

   sk = NULL;
found:
   return sk;
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciInBoundTable --
 *
 *    Determines whether the provided socket is in the bound table.
 *
 * Results:
 *    TRUE is socket is in bound table, FALSE otherwise.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

Bool
__VSockVmciInBoundTable(struct sock *sk)     // IN
{
   VSockVmciSock *vsk;

   ASSERT(sk);

   vsk = vsock_sk(sk);

   return !list_empty(&vsk->boundTable);
}


/*
 *----------------------------------------------------------------------------
 *
 * __VSockVmciInConnectedTable --
 *
 *    Determines whether the provided socket is in the connected table.
 *
 * Results:
 *    TRUE is socket is in connected table, FALSE otherwise.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

Bool
__VSockVmciInConnectedTable(struct sock *sk)     // IN
{
   VSockVmciSock *vsk;

   ASSERT(sk);

   vsk = vsock_sk(sk);

   return !list_empty(&vsk->connectedTable);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciGetPending --
 *
 *    Retrieves a pending connection that matches the addresses specified in
 *    the provided packet.
 *
 *    Assumes the socket lock is held for listener.
 *
 * Results:
 *    Socket of the pending connection on success, NULL if not found.
 *
 * Side effects:
 *    A reference is held on the socket until the release function is called.
 *
 *----------------------------------------------------------------------------
 */

struct sock *
VSockVmciGetPending(struct sock *listener,      // IN: listening socket
                    VSockPacket *pkt)           // IN: incoming packet
{
   VSockVmciSock *vlistener;
   VSockVmciSock *vpending;
   struct sock *pending;
   struct sockaddr_vm src;

   ASSERT(listener);
   ASSERT(pkt);

   VSockAddr_Init(&src, VMCI_HANDLE_TO_CONTEXT_ID(pkt->dg.src), pkt->srcPort);

   vlistener = vsock_sk(listener);

   list_for_each_entry(vpending, &vlistener->pendingLinks, pendingLinks) {
      if (VSockAddr_EqualsAddr(&src, &vpending->remoteAddr) &&
          pkt->dstPort == vpending->localAddr.svm_port) {
         pending = sk_vsock(vpending);
         sock_hold(pending);
         goto found;
      }
   }

   pending = NULL;
found:
   return pending;
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciReleasePending --
 *
 *    Releases the reference on a socket previously obtained by a call to
 *    VSockVmciGetPending().
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The socket may be freed if this was the last reference.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciReleasePending(struct sock *pending)   // IN: pending connection
{
   ASSERT(pending);

   sock_put(pending);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciAddPending --
 *
 *    Adds a pending connection on listener's pending list.
 *
 *    Assumes the socket lock is held for listener.
 *    Assumes the socket lock is held for pending.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count of the sockets is incremented.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciAddPending(struct sock *listener,  // IN: listening socket
                    struct sock *pending)   // IN: pending connection
{
   VSockVmciSock *vlistener;
   VSockVmciSock *vpending;

   ASSERT(listener);
   ASSERT(pending);

   vlistener = vsock_sk(listener);
   vpending = vsock_sk(pending);

   sock_hold(pending);
   sock_hold(listener);
   list_add_tail(&vpending->pendingLinks, &vlistener->pendingLinks);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciRemovePending --
 *
 *    Removes a pending connection from the listener's pending list.
 *
 *    Assumes the socket lock is held for listener.
 *    Assumes the socket lock is held for pending.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The reference count of the sockets is decremented.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciRemovePending(struct sock *listener,   // IN: listening socket
                       struct sock *pending)    // IN: pending connection
{
   VSockVmciSock *vpending;

   ASSERT(listener);
   ASSERT(pending);

   vpending = vsock_sk(pending);

   list_del_init(&vpending->pendingLinks);
   sock_put(listener);
   sock_put(pending);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciEnqueueAccept --
 *
 *    Enqueues the connected socket on the listening socket's accepting
 *    queue.
 *
 *    Assumes the socket lock is held for listener.
 *    Assumes the socket lock is held for connected.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The sockets' reference counts are incremented.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciEnqueueAccept(struct sock *listener,    // IN: listening socket
                       struct sock *connected)   // IN: connected socket
{
   VSockVmciSock *vlistener;
   VSockVmciSock *vconnected;

   ASSERT(listener);
   ASSERT(connected);

   vlistener = vsock_sk(listener);
   vconnected = vsock_sk(connected);

   sock_hold(connected);
   sock_hold(listener);
   list_add_tail(&vconnected->acceptQueue, &vlistener->acceptQueue);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciDequeueAccept --
 *
 *    Dequeues the next connected socket from the listening socket's accept
 *    queue.
 *
 *    Assumes the socket lock is held for listener.
 *
 *    Note that the caller must call sock_put() on the returned socket once it
 *    is done with the socket.
 *
 * Results:
 *    The next socket from the queue, or NULL if the queue is empty.
 *
 * Side effects:
 *    The reference count of the listener is decremented.
 *
 *----------------------------------------------------------------------------
 */

struct sock *
VSockVmciDequeueAccept(struct sock *listener)     // IN: listening socket
{
   VSockVmciSock *vlistener;
   VSockVmciSock *vconnected;

   ASSERT(listener);

   vlistener = vsock_sk(listener);

   if (list_empty(&vlistener->acceptQueue)) {
      return NULL;
   }

   vconnected = list_entry(vlistener->acceptQueue.next,
                           VSockVmciSock, acceptQueue);
   ASSERT(vconnected);

   list_del_init(&vconnected->acceptQueue);
   sock_put(listener);
   /*
    * The caller will need a reference on the connected socket so we let it
    * call sock_put().
    */

   ASSERT(sk_vsock(vconnected));
   return sk_vsock(vconnected);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciRemoveAccept --
 *
 *    Removes a socket from the accept queue of a listening socket.
 *
 *    Assumes the socket lock is held for listener.
 *    Assumes the socket lock is held for connected.
 *
 * Results:
 *    None.
 *
 * Side effects:
 *    The sockets' reference counts are decremented.
 *
 *----------------------------------------------------------------------------
 */

void
VSockVmciRemoveAccept(struct sock *listener,    // IN: listening socket
                      struct sock *connected)   // IN: connected socket
{
   VSockVmciSock *vconnected;

   ASSERT(listener);
   ASSERT(connected);

   if (!VSockVmciInAcceptQueue(connected)) {
      return;
   }

   vconnected = vsock_sk(connected);
   ASSERT(vconnected->listener == listener);

   list_del_init(&vconnected->acceptQueue);
   sock_put(listener);
   sock_put(connected);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciInAcceptQueue --
 *
 *    Determines whether a socket is on an accept queue.
 *
 *    Assumes the socket lock is held for sk.
 *
 * Results:
 *    TRUE if the socket is in an accept queue, FALSE otherwise.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

Bool
VSockVmciInAcceptQueue(struct sock *sk)   // IN: socket
{
   ASSERT(sk);

   /*
    * If our accept queue isn't empty, it means we're linked into some listener
    * socket's accept queue.
    */
   return !VSockVmciIsAcceptQueueEmpty(sk);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciIsAcceptQueueEmpty --
 *
 *    Determines whether the provided socket's accept queue is empty.
 *
 *    Assumes the socket lock is held for sk.
 *
 * Results:
 *    TRUE if the socket's accept queue is empty, FALSE otherwsise.
 *
 * Side effects:
 *    None.
 *
 *
 *----------------------------------------------------------------------------
 */

Bool
VSockVmciIsAcceptQueueEmpty(struct sock *sk)    // IN: socket
{
   VSockVmciSock *vsk;

   ASSERT(sk);

   vsk = vsock_sk(sk);
   return list_empty(&vsk->acceptQueue);
}


/*
 *----------------------------------------------------------------------------
 *
 * VSockVmciIsPending --
 *
 *    Determines whether a socket is pending.
 *
 *    Assumes the socket lock is held for sk.
 *
 * Results:
 *    TRUE if the socket is pending, FALSE otherwise.
 *
 * Side effects:
 *    None.
 *
 *----------------------------------------------------------------------------
 */

Bool
VSockVmciIsPending(struct sock *sk)     // IN: socket
{
   VSockVmciSock *vsk;

   ASSERT(sk);

   vsk = vsock_sk(sk);
   return !list_empty(&vsk->pendingLinks);
}