Skip to content

NFS XDR spec does not parse properly #34

@SriRamanujam

Description

@SriRamanujam

I'm interested in using this library to autogen bindings for the NFS protocol (https://tools.ietf.org/html/rfc5662). Unfortunately, the spec has revealed several parsing issues.

In no particular order:

  1. Unsigned 64-bit (hyper) integers are parsed as signed hyper integers
NFS4_UINT_MAX = 0xffffffffffffffff;
  1. Empty structs throw a parsing error:
struct mode_masked64 {

};
thread 'main' panicked at 'Could not xdrgen lib/nfs41.x: Error(Msg("parse error: Eof: struct mode_masked64 {\n\n};\n"), State { next_error: None, backtrace: None })', libcore/result.rs:945:5
  1. Some unions fail to parse correctly:
enum nfsstat4 {
        NFS4ERR_BADIOMODE      = 10049,
        NFS4ERR_BADLAYOUT      = 10050,
        NFS4ERR_BAD_SESSION_DIGEST = 10051,
        NFS4ERR_BADSESSION     = 10052,
        NFS4ERR_BADSLOT        = 10053,
        NFS4ERR_COMPLETE_ALREADY = 10054,
        NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
        NFS4ERR_DELEG_ALREADY_WANTED = 10056,
        NFS4ERR_LAYOUTTRYLATER = 10058,
        NFS4ERR_LAYOUTUNAVAILABLE = 10059,
        NFS4ERR_NOMATCHING_LAYOUT = 10060,
        NFS4ERR_RECALLCONFLICT = 10061,
        NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062
};

struct ACCESS4resok {
        uint32_t        supported;
        uint32_t        access;
};

union ACCESS4res switch (nfsstat4 status) {
 case NFS4_OK:
         ACCESS4resok   resok4;
 default:
         void;
};
thread 'main' panicked at 'Could not xdrgen lib/nfs41.x: Error(Msg("incompat selector Named(\"status\", Ident(\"nfsstat4\", None)) case Ident(\"NFS4_OK\")")

I stopped here, but you get the idea. I'm not sure how much of this is due to a bad spec and how much of this is due to parsing difficulties, but considering these examples are from the canonical RFC laying out the XDR protocol for NFSv4 I have to assume it's probably correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions