Bug 1596188

Summary: XDR files contain illegal "long" integer declarations.
Product: [Community] GlusterFS Reporter: Sven Anderson <svanders>
Component: rpcAssignee: Niels de Vos <ndevos>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.12CC: atumball, bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-4.1.4 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1596206 (view as bug list) Environment:
Last Closed: 2018-10-08 17:46:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1596206    
Bug Blocks:    
Attachments:
Description Flags
fix-xdr-file.patch none

Description Sven Anderson 2018-06-28 12:01:58 UTC
Created attachment 1455275 [details]
fix-xdr-file.patch

Description of problem:

With some toolchains (latest buildroot for example) the rpcgen rejects to process the rpc/xdr/src/changelog-xdr.x file, because it contains "unsigned long" integer declarations. Looking at the standard, long is not supported in XDR: https://tools.ietf.org/html/rfc4506#section-4.2


Version-Release number of selected component (if applicable):


How reproducible:
Compile gluster with buildroot 2018.05.

Actual results:

------------------------------------
Making all in rpc/xdr/gen
       unsigned long seq;
^^^^^^^^^^^^^^^^^^^^^^^^
changelog-xdr.x, line 30: expected ';'
Makefile:562: recipe for target 'changelog-xdr.h' failed
make[5]: *** [changelog-xdr.h] Error 1
------------------------------------

Expected results:

Compilation without error.

Additional info:

fix attached

Comment 1 Niels de Vos 2018-06-28 12:55:38 UTC
Thanks for the patch!

In most occasions an 'unsigned long' should be converted to a u_quad_t in the .x file. That matches a uint64_t for the C interface for most common architectures.

Comment 2 Sven Anderson 2018-07-03 13:27:10 UTC
(In reply to Niels de Vos from comment #1)
> In most occasions an 'unsigned long' should be converted to a u_quad_t in
> the .x file. That matches a uint64_t for the C interface for most common
> architectures.

I did some more research on this. So the XDR specification really only allows "int" (32 bit) and "hyper" (64 bit) declarations in .x files. "unsigned hyper" on my machine is converted to "u_quad_t" in the generated .h file, but that seems to be an internal compatibility type, that is mapped then to the corresponding platform specific type then. Since "int" in XDR is already 32 bit (which is the minimum size of a C long), my understanding is to use only "int" in .x files, if you don't need more than 32 bit.

One might think that rpcgen also accepts u_long or u_quad_t in .x files, but that is only true in a way that it accepts everything that it doesn't know about (like foo_bar_t) and just puts it 1:1 into the .h file then. But that I would regard as a hack, because it makes the RPC definition platform dependent, which undermines it's original idea.

Comment 3 Sven Anderson 2018-07-03 13:36:09 UTC
BTW, the rpcgen, that doesn't accept "long" is the one from nfs-utils, which is used in buildroot. It doesn't implement "hyper" either, apparently.