Subject: [nfsv4] layouttype4 and site-specific types in RFC5661

From: Lev Solomonov <[email-masked]>
Date: Tue, 15 May 2012 22:28:07 +0300

hi there.

while interfacing with some non-linux kernel pNFS client i bumped
into a slight issue with layouttype4 definition. i would appreciate if
someone could point out the problem with my interpretation of RFC5661
or, conversely, confirm that this should be added as an erratum.

in a nutshell, it would appear that 'site specific and for private use
only' range of layout types (0x80000000-0xFFFFFFFF) can not be used
safely given its current wording.

unless otherwise specified, in most contexts 0x80000000 == 2147483648.
XDR enums are *signed* 32-bits. code that does not specifically abuse
host language type system ends up looking at [2's compl] negative values
while expecting positive ones.

pynfs appears to be one victim of this signed/unsigned ambiguity.

boring quotes from RFCs follow below. on page 92 of RFC5661 we see:

> 3.3.13. layouttype4
>
>  enum layouttype4 {
>          LAYOUT4_NFSV4_1_FILES   = 0x1,
>          LAYOUT4_OSD2_OBJECTS    = 0x2,
>          LAYOUT4_BLOCK_VOLUME    = 0x3
>  };
>
>  This data type indicates what type of layout is being used.  The file
>  server advertises the layout types it supports through the
>  fs_layout_type file system attribute (Section 5.12.1).  A client asks
>  for layouts of a particular type in LAYOUTGET, and processes those
>  layouts in its layout-type-specific logic.
>
>  The layouttype4 data type is 32 bits in length.  The range
>  represented by the layout type is split into three parts.  Type 0x0
>  is reserved.  Types within the range 0x00000001-0x7FFFFFFF are
>  globally unique and are assigned according to the description in
>  Section 22.4; they are maintained by IANA.  Types within the range
>  0x80000000-0xFFFFFFFF are site specific and for private use only.

on pages 4-5 of RFC4506 we see:

> 4.1. Integer
>
>  An XDR signed integer is a 32-bit datum that encodes an integer in
>  the range [-2147483648,2147483647].  The integer is represented in
>  two's complement notation.  The most and least significant bytes are
>  0 and 3, respectively.  Integers are declared as follows:
    <snip>
> 4.3. Enumeration
>
>  Enumerations have the same representation as signed integers.

what say you?

thanks.

solo.