[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD4GDZwf4dBoTgm_fWgyk0JiipidRntqRq9a3q0gVO8i==V-cg@mail.gmail.com>
Date: Wed, 6 Mar 2024 22:14:57 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Jacob Keller <jacob.e.keller@...el.com>, Jiri Pirko <jiri@...nulli.us>,
Stanislav Fomichev <sdf@...gle.com>, donald.hunter@...hat.com
Subject: Re: [PATCH net-next v2 0/5] tools/net/ynl: Add support for nlctrl
netlink family
On Wed, 6 Mar 2024 at 18:32, Jakub Kicinski <kuba@...nel.org> wrote:
>
> Somewhat incredibly the C seems to work, I tested with this sample:
Wow, above and beyond for writing a sample. Was it ever in any doubt
that it would work ;-)
> // SPDX-License-Identifier: GPL-2.0
> #include <stdio.h>
> #include <string.h>
>
> #include <ynl.h>
>
> #include "nlctrl-user.h"
>
> int main(int argc, char **argv)
> {
> struct nlctrl_getfamily_list *fams;
> struct ynl_error yerr;
> struct ynl_sock *ys;
> char *name;
>
> ys = ynl_sock_create(&ynl_nlctrl_family, &yerr);
> if (!ys) {
> fprintf(stderr, "YNL: %s\n", yerr.msg);
> return 1;
> }
>
> printf("Select family ($name; or 0 = dump): ");
> scanf("%ms", &name);
>
> if (!name || !strcmp(name, "0")) {
> fams = nlctrl_getfamily_dump(ys);
> if (!fams)
> goto err_close;
>
> ynl_dump_foreach(fams, f)
> printf("%d: %s\n", f->family_id, f->family_name);
> nlctrl_getfamily_list_free(fams);
> } else {
> struct nlctrl_getfamily_req *req;
> struct nlctrl_getfamily_rsp *f;
>
> req = nlctrl_getfamily_req_alloc();
> nlctrl_getfamily_req_set_family_name(req, name);
>
> f = nlctrl_getfamily(ys, req);
> nlctrl_getfamily_req_free(req);
> if (!f)
> goto err_close;
>
> printf("%d: %s\n", f->family_id, f->family_name);
> nlctrl_getfamily_rsp_free(f);
> }
> free(name);
>
> ynl_sock_destroy(ys);
> return 0;
>
> err_close:
> fprintf(stderr, "YNL: %s\n", ys->err.msg);
> ynl_sock_destroy(ys);
> return 2;
> }
Powered by blists - more mailing lists