lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e39be343-95fb-1aa0-f690-a32071a9101d@intel.com>
Date:   Thu, 19 Jan 2023 16:50:41 -0800
From:   Jacob Keller <jacob.e.keller@...el.com>
To:     Jakub Kicinski <kuba@...nel.org>, <davem@...emloft.net>
CC:     <netdev@...r.kernel.org>, <edumazet@...gle.com>,
        <pabeni@...hat.com>, <robh@...nel.org>,
        <johannes@...solutions.net>, <stephen@...workplumber.org>,
        <ecree.xilinx@...il.com>, <sdf@...gle.com>, <f.fainelli@...il.com>,
        <fw@...len.de>, <linux-doc@...r.kernel.org>, <razor@...ckwall.org>,
        <nicolas.dichtel@...nd.com>
Subject: Re: [PATCH net-next v3 8/8] tools: ynl: add a completely generic
 client



On 1/18/2023 4:36 PM, Jakub Kicinski wrote:
> Add a CLI sample which can take in arbitrary request
> in JSON format, convert it to Netlink and do the inverse
> for output.
> 
> It's meant as a development tool primarily and perhaps
> for selftests which need to tickle netlink in a special way.
> 
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  tools/net/ynl/samples/cli.py |  47 +++
>  tools/net/ynl/samples/ynl.py | 534 +++++++++++++++++++++++++++++++++++
>  2 files changed, 581 insertions(+)
>  create mode 100755 tools/net/ynl/samples/cli.py
>  create mode 100644 tools/net/ynl/samples/ynl.py
> 
> diff --git a/tools/net/ynl/samples/cli.py b/tools/net/ynl/samples/cli.py
> new file mode 100755
> index 000000000000..b27159c70710
> --- /dev/null
> +++ b/tools/net/ynl/samples/cli.py
> @@ -0,0 +1,47 @@
> +#!/usr/bin/env python
> +# SPDX-License-Identifier: BSD-3-Clause
> +
> +import argparse
> +import json
> +import pprint
> +import time
> +
> +from ynl import YnlFamily
> +
> +
> +def main():
> +    parser = argparse.ArgumentParser(description='YNL CLI sample')
> +    parser.add_argument('--spec', dest='spec', type=str, required=True)
> +    parser.add_argument('--schema', dest='schema', type=str)
> +    parser.add_argument('--json', dest='json_text', type=str)
> +    parser.add_argument('--do', dest='do', type=str)
> +    parser.add_argument('--dump', dest='dump', type=str)
> +    parser.add_argument('--sleep', dest='sleep', type=int)
> +    parser.add_argument('--subscribe', dest='ntf', type=str)
> +    args = parser.parse_args()
> +
> +    attrs = {}
> +    if args.json_text:
> +        attrs = json.loads(args.json_text)
> +
> +    ynl = YnlFamily(args.spec, args.schema)
> +
> +    if args.ntf:
> +        ynl.ntf_subscribe(args.ntf)
> +
> +    if args.sleep:
> +        time.sleep(args.sleep)
> +
> +    if args.do or args.dump:
> +        method = getattr(ynl, args.do if args.do else args.dump)
> +
> +        reply = method(attrs, dump=bool(args.dump))
> +        pprint.PrettyPrinter().pprint(reply)
> +
> +    if args.ntf:
> +        ynl.check_ntf()
> +        pprint.PrettyPrinter().pprint(ynl.async_msg_queue)
> +
> +
> +if __name__ == "__main__":
> +    main()
> diff --git a/tools/net/ynl/samples/ynl.py b/tools/net/ynl/samples/ynl.py
> new file mode 100644
> index 000000000000..b71523d71d46
> --- /dev/null
> +++ b/tools/net/ynl/samples/ynl.py
> @@ -0,0 +1,534 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +
> +import functools
> +import jsonschema
> +import os
> +import random
> +import socket
> +import struct
> +import yaml
> +
> +#
> +# Generic Netlink code which should really be in some library, but I can't quickly find one.
> +#
> +

There is pyroute2, but it might be overkill, and I recall it seeming to
do some things a bit inconsistently.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ