From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C9711DA0F1 for ; Mon, 7 Oct 2024 16:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728318573; cv=none; b=QYG4ZgDUuhwB3Bkw+Wldj4Zp5/DGzkOz3IewF7HrEPmiNQQb3Ty1qhImVQ1LWQ75P/7OzgoRndRGHYAWkC4yRAAi2+F6xqRSDFNokYM1Hi/VqHJeSnzadIEeLmOD7ResqAT8b6PcPLnZVBgLlHifXz79/3JhveWGZpHJi5ZsR78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728318573; c=relaxed/simple; bh=seMg8uShAlv89Vnk+a3uzwgv2w5lgwY+0LajYHgk9xQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=VfCFD7y2yszdYbO0cBQGm7aThT8zt+seyu8bwJspZmi5o3Vu1DHUHzx+EsEegBVpWSR3zJrFUeecAH5ClKJ6cxo4bTW70LXHjyCDyL5GmoHH0iiTsMmibS0D3bY+enaQL0M1qdW8B0C/iOfXxZp5s79k/Dk2bnRiqFc+SeVYq44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uigeFOEp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uigeFOEp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D64DC4CEC6; Mon, 7 Oct 2024 16:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728318572; bh=seMg8uShAlv89Vnk+a3uzwgv2w5lgwY+0LajYHgk9xQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uigeFOEp5A17yWCwNILf46A4HCaElmfk/NWXZXwcqONz+7kn2XEWJLKu6KPQjoQaj Ry9HiTVw2hRd9nhW6RybPzGjhyuPMyNE/vsFksMPq8eqZk+ZV5LtcNoaGg2JqeeCTq 9POA+RW9br7tf/8glzvfsNG2+/XOyX5FcYEldy3SefkjENyojq3qbVXZtptFotyy4s UbwBp3b5/UEtaWheYJE9+WBFmtpl+nUDvwkKN1Pkabb/CZ1Mxaukg8tH2zKM17wo+E O7besPJoZvPGpBNlRg8OJNA6zWDPw0LZv4GF8hQKFLUIntS6qNv5E3Mo+RDa90Dnkj +Ky+xtVAfb7BQ== Message-ID: <34cb72c6488d7da068dfc312905e6e0cb4aae359.camel@kernel.org> Subject: Re: [PATCH v2 1/2] tools: Add xdrgen From: Jeff Layton To: cel@kernel.org, linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 07 Oct 2024 12:29:31 -0400 In-Reply-To: <20240827162718.42342-2-cel@kernel.org> References: <20240827162718.42342-1-cel@kernel.org> <20240827162718.42342-2-cel@kernel.org> Autocrypt: addr=jlayton@kernel.org; prefer-encrypt=mutual; keydata=mQINBE6V0TwBEADXhJg7s8wFDwBMEvn0qyhAnzFLTOCHooMZyx7XO7dAiIhDSi7G1NPxw n8jdFUQMCR/GlpozMFlSFiZXiObE7sef9rTtM68ukUyZM4pJ9l0KjQNgDJ6Fr342Htkjxu/kFV1Wv egyjnSsFt7EGoDjdKqr1TS9syJYFjagYtvWk/UfHlW09X+jOh4vYtfX7iYSx/NfqV3W1D7EDi0PqV T2h6v8i8YqsATFPwO4nuiTmL6I40ZofxVd+9wdRI4Db8yUNA4ZSP2nqLcLtFjClYRBoJvRWvsv4lm 0OX6MYPtv76hka8lW4mn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BhZ/Ab4sph3EaiZfdXKhiQqSGdK4La3OTJOJYZphPdGgnkvDV9Pl1QZ0ijXQrVIy3zd6VCNaKYq7B AKidn5g/2Q8oio9Tf4XfdZ9dtwcB+bwDJFgvvDYaZ5bI3ln4V3EyW5i2NfXazz/GA/I/ZtbsigCFc 8ftCBKZWZmIExheXRvbiA8amxheXRvbkBrZXJuZWwub3JnPokCOAQTAQIAIgUCWe8u6AIbAwYLCQg HAwIGFQgCCQoLBBYCAwECHgECF4AACgkQAA5oQRlWghUuCg/+Lb/xGxZD2Q1oJVAE37uW308UpVSD 2tAMJUvFTdDbfe3zKlPDTuVsyNsALBGclPLagJ5ZTP+Vp2irAN9uwBuacBOTtmOdz4ZN2tdvNgozz uxp4CHBDVzAslUi2idy+xpsp47DWPxYFIRP3M8QG/aNW052LaPc0cedYxp8+9eiVUNpxF4SiU4i9J DfX/sn9XcfoVZIxMpCRE750zvJvcCUz9HojsrMQ1NFc7MFT1z3MOW2/RlzPcog7xvR5ENPH19ojRD CHqumUHRry+RF0lH00clzX/W8OrQJZtoBPXv9ahka/Vp7kEulcBJr1cH5Wz/WprhsIM7U9pse1f1g Yy9YbXtWctUz8uvDR7shsQxAhX3qO7DilMtuGo1v97I/Kx4gXQ52syh/w6EBny71CZrOgD6kJwPVV AaM1LRC28muq91WCFhs/nzHozpbzcheyGtMUI2Ao4K6mnY+3zIuXPygZMFr9KXE6fF7HzKxKuZMJO aEZCiDOq0anx6FmOzs5E6Jqdpo/mtI8beK+BE7Va6ni7YrQlnT0i3vaTVMTiCThbqsB20VrbMjlhp f8lfK1XVNbRq/R7GZ9zHESlsa35ha60yd/j3pu5hT2xyy8krV8vGhHvnJ1XRMJBAB/UYb6FyC7S+m QZIQXVeAA+smfTT0tDrisj1U5x6ZB9b3nBg65kc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-1.fc40) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-08-27 at 12:27 -0400, cel@kernel.org wrote: > From: Chuck Lever >=20 > Add a Python-based tool for translating XDR specifications into XDR > encoder and decoder functions written in the Linux kernel's C coding > style. The generator attempts to match the usual C coding style of > the Linux kernel's SunRPC consumers. >=20 > This approach is similar to the netlink code generator in > tools/net/ynl . >=20 > The maintainability benefits of machine-generated XDR code include: >=20 > - 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 code >=20 > In addition, converting the XDR layer to use memory-safe languages > such as Rust will be easier if much of the code can be converted > automatically. >=20 > Signed-off-by: Chuck Lever > --- > include/linux/sunrpc/xdrgen-builtins.h | 256 +++++++++ > tools/net/sunrpc/xdrgen/.gitignore | 2 + > tools/net/sunrpc/xdrgen/README | 249 +++++++++ > tools/net/sunrpc/xdrgen/__init__.py | 2 + > .../net/sunrpc/xdrgen/generators/__init__.py | 49 ++ > .../sunrpc/xdrgen/generators/boilerplate.py | 58 +++ > .../net/sunrpc/xdrgen/generators/constant.py | 20 + > tools/net/sunrpc/xdrgen/generators/enum.py | 41 ++ > tools/net/sunrpc/xdrgen/generators/pointer.py | 283 ++++++++++ > tools/net/sunrpc/xdrgen/generators/program.py | 141 +++++ > tools/net/sunrpc/xdrgen/generators/struct.py | 283 ++++++++++ > tools/net/sunrpc/xdrgen/generators/typedef.py | 225 ++++++++ > tools/net/sunrpc/xdrgen/generators/union.py | 238 +++++++++ > tools/net/sunrpc/xdrgen/grammars/xdr.lark | 119 +++++ > tools/net/sunrpc/xdrgen/subcmds/__init__.py | 2 + > tools/net/sunrpc/xdrgen/subcmds/header.py | 88 ++++ > tools/net/sunrpc/xdrgen/subcmds/lint.py | 33 ++ > tools/net/sunrpc/xdrgen/subcmds/source.py | 121 +++++ > .../templates/C/boilerplate/header_bottom.j2 | 3 + > .../templates/C/boilerplate/header_top.j2 | 11 + > .../templates/C/boilerplate/source_top.j2 | 5 + > .../templates/C/constants/definition.j2 | 3 + > .../xdrgen/templates/C/enum/decoder/enum.j2 | 19 + > .../templates/C/enum/definition/close.j2 | 7 + > .../templates/C/enum/definition/enumerator.j2 | 2 + > .../templates/C/enum/definition/open.j2 | 3 + > .../xdrgen/templates/C/enum/encoder/enum.j2 | 14 + > .../templates/C/pointer/decoder/basic.j2 | 6 + > .../templates/C/pointer/decoder/close.j2 | 3 + > .../C/pointer/decoder/fixed_length_array.j2 | 8 + > .../C/pointer/decoder/fixed_length_opaque.j2 | 6 + > .../templates/C/pointer/decoder/open.j2 | 22 + > .../C/pointer/decoder/optional_data.j2 | 6 + > .../pointer/decoder/variable_length_array.j2 | 13 + > .../pointer/decoder/variable_length_opaque.j2 | 6 + > .../pointer/decoder/variable_length_string.j2 | 6 + > .../templates/C/pointer/definition/basic.j2 | 5 + > .../templates/C/pointer/definition/close.j2 | 7 + > .../pointer/definition/fixed_length_array.j2 | 5 + > .../pointer/definition/fixed_length_opaque.j2 | 5 + > .../templates/C/pointer/definition/open.j2 | 6 + > .../C/pointer/definition/optional_data.j2 | 5 + > .../definition/variable_length_array.j2 | 8 + > .../definition/variable_length_opaque.j2 | 5 + > .../definition/variable_length_string.j2 | 5 + > .../templates/C/pointer/encoder/basic.j2 | 10 + > .../templates/C/pointer/encoder/close.j2 | 3 + > .../C/pointer/encoder/fixed_length_array.j2 | 12 + > .../C/pointer/encoder/fixed_length_opaque.j2 | 6 + > .../templates/C/pointer/encoder/open.j2 | 20 + > .../C/pointer/encoder/optional_data.j2 | 6 + > .../pointer/encoder/variable_length_array.j2 | 15 + > .../pointer/encoder/variable_length_opaque.j2 | 8 + > .../pointer/encoder/variable_length_string.j2 | 8 + > .../C/program/declaration/argument.j2 | 2 + > .../templates/C/program/declaration/result.j2 | 2 + > .../templates/C/program/decoder/argument.j2 | 21 + > .../templates/C/program/decoder/result.j2 | 22 + > .../templates/C/program/encoder/argument.j2 | 16 + > .../templates/C/program/encoder/result.j2 | 21 + > .../templates/C/struct/decoder/basic.j2 | 6 + > .../templates/C/struct/decoder/close.j2 | 3 + > .../C/struct/decoder/fixed_length_array.j2 | 8 + > .../C/struct/decoder/fixed_length_opaque.j2 | 6 + > .../xdrgen/templates/C/struct/decoder/open.j2 | 12 + > .../C/struct/decoder/optional_data.j2 | 6 + > .../C/struct/decoder/variable_length_array.j2 | 13 + > .../struct/decoder/variable_length_opaque.j2 | 6 + > .../struct/decoder/variable_length_string.j2 | 6 + > .../templates/C/struct/definition/basic.j2 | 5 + > .../templates/C/struct/definition/close.j2 | 7 + > .../C/struct/definition/fixed_length_array.j2 | 5 + > .../struct/definition/fixed_length_opaque.j2 | 5 + > .../templates/C/struct/definition/open.j2 | 6 + > .../C/struct/definition/optional_data.j2 | 5 + > .../definition/variable_length_array.j2 | 8 + > .../definition/variable_length_opaque.j2 | 5 + > .../definition/variable_length_string.j2 | 5 + > .../templates/C/struct/encoder/basic.j2 | 10 + > .../templates/C/struct/encoder/close.j2 | 3 + > .../C/struct/encoder/fixed_length_array.j2 | 12 + > .../C/struct/encoder/fixed_length_opaque.j2 | 6 + > .../xdrgen/templates/C/struct/encoder/open.j2 | 12 + > .../C/struct/encoder/optional_data.j2 | 6 + > .../C/struct/encoder/variable_length_array.j2 | 15 + > .../struct/encoder/variable_length_opaque.j2 | 8 + > .../struct/encoder/variable_length_string.j2 | 8 + > .../templates/C/typedef/decoder/basic.j2 | 17 + > .../C/typedef/decoder/fixed_length_array.j2 | 25 + > .../C/typedef/decoder/fixed_length_opaque.j2 | 17 + > .../typedef/decoder/variable_length_array.j2 | 26 + > .../typedef/decoder/variable_length_opaque.j2 | 17 + > .../typedef/decoder/variable_length_string.j2 | 17 + > .../templates/C/typedef/definition/basic.j2 | 15 + > .../typedef/definition/fixed_length_array.j2 | 11 + > .../typedef/definition/fixed_length_opaque.j2 | 11 + > .../definition/variable_length_array.j2 | 14 + > .../definition/variable_length_opaque.j2 | 11 + > .../definition/variable_length_string.j2 | 11 + > .../templates/C/typedef/encoder/basic.j2 | 21 + > .../C/typedef/encoder/fixed_length_array.j2 | 25 + > .../C/typedef/encoder/fixed_length_opaque.j2 | 17 + > .../typedef/encoder/variable_length_array.j2 | 30 ++ > .../typedef/encoder/variable_length_opaque.j2 | 17 + > .../typedef/encoder/variable_length_string.j2 | 17 + > .../xdrgen/templates/C/union/decoder/basic.j2 | 6 + > .../xdrgen/templates/C/union/decoder/break.j2 | 2 + > .../templates/C/union/decoder/case_spec.j2 | 2 + > .../xdrgen/templates/C/union/decoder/close.j2 | 4 + > .../templates/C/union/decoder/default_spec.j2 | 2 + > .../xdrgen/templates/C/union/decoder/open.j2 | 12 + > .../C/union/decoder/optional_data.j2 | 6 + > .../templates/C/union/decoder/switch_spec.j2 | 7 + > .../C/union/decoder/variable_length_array.j2 | 13 + > .../C/union/decoder/variable_length_opaque.j2 | 6 + > .../C/union/decoder/variable_length_string.j2 | 6 + > .../xdrgen/templates/C/union/decoder/void.j2 | 3 + > .../templates/C/union/definition/case_spec.j2 | 2 + > .../templates/C/union/definition/close.j2 | 8 + > .../C/union/definition/default_spec.j2 | 2 + > .../templates/C/union/definition/open.j2 | 6 + > .../C/union/definition/switch_spec.j2 | 3 + > .../xdrgen/templates/C/union/encoder/basic.j2 | 10 + > .../xdrgen/templates/C/union/encoder/break.j2 | 2 + > .../templates/C/union/encoder/case_spec.j2 | 2 + > .../xdrgen/templates/C/union/encoder/close.j2 | 4 + > .../templates/C/union/encoder/default_spec.j2 | 2 + > .../xdrgen/templates/C/union/encoder/open.j2 | 12 + > .../templates/C/union/encoder/switch_spec.j2 | 7 + > .../xdrgen/templates/C/union/encoder/void.j2 | 3 + > tools/net/sunrpc/xdrgen/tests/test.x | 36 ++ > tools/net/sunrpc/xdrgen/xdr_ast.py | 485 ++++++++++++++++++ > tools/net/sunrpc/xdrgen/xdr_parse.py | 36 ++ > tools/net/sunrpc/xdrgen/xdrgen | 111 ++++ > 134 files changed, 3892 insertions(+) > create mode 100644 include/linux/sunrpc/xdrgen-builtins.h > create mode 100644 tools/net/sunrpc/xdrgen/.gitignore > create mode 100644 tools/net/sunrpc/xdrgen/README > create mode 100644 tools/net/sunrpc/xdrgen/__init__.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/__init__.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/boilerplate.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/constant.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/enum.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/pointer.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/program.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/struct.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/typedef.py > create mode 100644 tools/net/sunrpc/xdrgen/generators/union.py > create mode 100644 tools/net/sunrpc/xdrgen/grammars/xdr.lark > create mode 100644 tools/net/sunrpc/xdrgen/subcmds/__init__.py > create mode 100644 tools/net/sunrpc/xdrgen/subcmds/header.py > create mode 100644 tools/net/sunrpc/xdrgen/subcmds/lint.py > create mode 100644 tools/net/sunrpc/xdrgen/subcmds/source.py > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/heade= r_bottom.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/heade= r_top.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/sourc= e_top.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/constants/definit= ion.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum= .j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/c= lose.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/e= numerator.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/o= pen.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum= .j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/b= asic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/c= lose.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/f= ixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/f= ixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/o= pen.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/o= ptional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/v= ariable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/v= ariable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/v= ariable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/basic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/close.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/fixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/fixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/open.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/optional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/variable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/variable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definitio= n/variable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/b= asic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/c= lose.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/f= ixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/f= ixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/o= pen.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/o= ptional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/v= ariable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/v= ariable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/v= ariable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declarati= on/argument.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declarati= on/result.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/a= rgument.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/r= esult.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/a= rgument.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/r= esult.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/ba= sic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/cl= ose.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fi= xed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fi= xed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/op= en.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/op= tional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/va= riable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/va= riable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/va= riable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /basic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /close.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /fixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /fixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /open.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /optional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /variable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /variable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition= /variable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/ba= sic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/cl= ose.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fi= xed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fi= xed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/op= en.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/op= tional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/va= riable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/va= riable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/va= riable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/b= asic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/f= ixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/f= ixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/v= ariable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/v= ariable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/v= ariable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/basic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/fixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/fixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/variable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/variable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definitio= n/variable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/b= asic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/f= ixed_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/f= ixed_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/v= ariable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/v= ariable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/v= ariable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/bas= ic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/bre= ak.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/cas= e_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/clo= se.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/def= ault_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/ope= n.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/opt= ional_data.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/swi= tch_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/var= iable_length_array.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/var= iable_length_opaque.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/var= iable_length_string.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/voi= d.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/= case_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/= close.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/= default_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/= open.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/= switch_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/bas= ic.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/bre= ak.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/cas= e_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/clo= se.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/def= ault_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/ope= n.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/swi= tch_spec.j2 > create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/voi= d.j2 > create mode 100644 tools/net/sunrpc/xdrgen/tests/test.x > create mode 100644 tools/net/sunrpc/xdrgen/xdr_ast.py > create mode 100644 tools/net/sunrpc/xdrgen/xdr_parse.py > create mode 100755 tools/net/sunrpc/xdrgen/xdrgen >=20 [...] > diff --git a/tools/net/sunrpc/xdrgen/README b/tools/net/sunrpc/xdrgen/REA= DME > new file mode 100644 > index 000000000000..a1a2454a5edf > --- /dev/null > +++ b/tools/net/sunrpc/xdrgen/README > @@ -0,0 +1,249 @@ > +xdrgen - Linux Kernel XDR code generator > + > +Introduction > +------------ > + > +SunRPC programs are typically specified using a language defined by > +RFC 4506. In fact, all IETF-published NFS specifications provide a > +description of the specified protocol using this language. > + > +Since the 1990's, user space consumers of SunRPC have had access to > +a tool that could read such XDR specifications and then generate C > +code that implements the RPC portions of that protocol. This tool is > +called rpcgen. > + > +This RPC-level code is code that handles input directly from the > +network, and thus a high degree of memory safety and sanity checking > +is needed to help ensure proper levels of security. Bugs in this > +code can have significant impact on security and performance. > + > +However, it is code that is repetitive and tedious to write by hand. > + > +The C code generated by rpcgen makes extensive use of the facilities > +of the user space TI-RPC library and libc. Furthermore, the dialect > +of the generated code is very traditional K&R C. > + > +The Linux kernel's implementation of SunRPC-based protocols hand-roll > +their XDR implementation. There are two main reasons for this: > + > +1. libtirpc (and its predecessors) operate only in user space. The > + kernel's RPC implementation and its API are significantly > + different than libtirpc. > + > +2. rpcgen-generated code is believed to be less efficient than code > + that is hand-written. > + > +These days, gcc and its kin are capable of optimizing code better > +than human authors. There are only a few instances where writing > +XDR code by hand will make a measurable performance different. > + > +In addition, the current hand-written code in the Linux kernel is > +difficult to audit and prove that it implements exactly what is in > +the protocol specification. > + > +In order to accrue the benefits of machine-generated XDR code in the > +kernel, a tool is needed that will output C code that works against > +the kernel's SunRPC implementation rather than libtirpc. > + > +Enter xdrgen. > + > + > +Dependencies > +------------ > + > +These dependencies are typically packaged by Linux distributions: > + > +- python3 > +- python3-lark > +- python3-jinja2 > + > +These dependencies are available via PyPi: > + > +- pip install 'lark[interegular]' > + > + > +XDR Specifications > +------------------ > + > +When adding a new protocol implementation to the kernel, the XDR > +specification can be derived by feeding a .txt copy of the RFC to > +the script located in tools/net/sunrpc/extract.sh. > + > + $ extract.sh < rfc0001.txt > new2.x > + I just noticed that the above blurb is in the README, but there is no extract.sh script in this patch (or any later one). We should either remove this (or preferably?) add the appropriate extract.sh script. --=20 Jeff Layton