xdrgen: Fix code generated for counted arraysWhen an XDR counted array has a maximum element count, xdrgen addsa bounds check to the encoder or decoder for that type. But in caseswhere the .x pro
xdrgen: Fix code generated for counted arraysWhen an XDR counted array has a maximum element count, xdrgen addsa bounds check to the encoder or decoder for that type. But in caseswhere the .x provides no maximum element count, such asstruct notify4 { /* composed from notify_type4 or notify_deviceid_type4 */ bitmap4 notify_mask; notifylist4 notify_vals;};struct CB_NOTIFY4args { stateid4 cna_stateid; nfs_fh4 cna_fh; notify4 cna_changes<>;};xdrgen is supposed to omit that bounds check. Some of the Jinja2templates handle that correctly, but a few are incorrect and leavethe bounds check in place with a maximum of zero, which causesencoding/decoding of that type to fail unconditionally.Reported-by: Jeff Layton <jlayton@kernel.org>Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
show more ...
xdrgen: Rename "variable-length strings"I misread RFC 4506. The built-in data type is called simply"string", as there is no fixed-length variety.Signed-off-by: Chuck Lever <chuck.lever@oracle.co
xdrgen: Rename "variable-length strings"I misread RFC 4506. The built-in data type is called simply"string", as there is no fixed-length variety.Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
tools: Add xdrgenAdd a Python-based tool for translating XDR specifications into XDRencoder and decoder functions written in the Linux kernel's C codingstyle. The generator attempts to match the
tools: Add xdrgenAdd a Python-based tool for translating XDR specifications into XDRencoder and decoder functions written in the Linux kernel's C codingstyle. The generator attempts to match the usual C coding style ofthe Linux kernel's SunRPC consumers.This approach is similar to the netlink code generator intools/net/ynl .The maintainability benefits of machine-generated XDR code include:- Stronger type checking- Reduces the number of bugs introduced by human error- Makes the XDR code easier to audit and analyze- Enables rapid prototyping of new RPC-based protocols- Hardens the layering between protocol logic and marshaling- Makes it easier to add observability on demand- Unit tests might be built for both the tool and (automatically) for the generated codeIn addition, converting the XDR layer to use memory-safe languagessuch as Rust will be easier if much of the code can be convertedautomatically.Tested-by: Jeff Layton <jlayton@kernel.org>Signed-off-by: Chuck Lever <chuck.lever@oracle.com>