struct nbd_reply not packed => trouble?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello kernel hackers,


I noticed that in [linux]/include/uapi/linux/nbd.h the structure

   struct nbd_request {
           __be32 magic;
           __be32 type;    /* == READ || == WRITE */
           char handle[8];
           __be64 from;
           __be32 len;
   } __attribute__((packed));

is packed but its reply counter part

   struct nbd_reply {
           __be32 magic;
           __be32 error;    /* 0 = ok, else error */
	  char handle[8];  /* handle you got from request */
   };

is not.  Since Linux seems to read sizeof(nbd_reply) bytes from the 
network (see [1]), the number of bytes read varies with the number of 
bytes of the structure.

So my understanding is that if the size of struct nbd_reply varies from 
platform/compiler to another that means trouble.  I wonder:

  - Is there anything about struct nbd_reply that would keep its size
    equal everywhere or a reason why variance in size is no problem here?

  - Any ideas for a platform where you would expect struct nbd_reply to
    be other than 4 + 4 + 8 = 16 bytes in size?

Best,



Sebastian


[1] http://lxr.linux.no/#linux+v3.7.1/drivers/block/nbd.c#L336

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux