Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFS XDR spec does not parse properly #34

Open
SriRamanujam opened this issue Apr 22, 2018 · 0 comments
Open

NFS XDR spec does not parse properly #34

SriRamanujam opened this issue Apr 22, 2018 · 0 comments

Comments

@SriRamanujam
Copy link

SriRamanujam commented Apr 22, 2018

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.

@SriRamanujam SriRamanujam changed the title Unsigned hyper integers are parsed as signed hyper integers NFS XDR spec does not parse properly Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant