On Fri, 13 Jul 2018 13:43:59 -0700
Jakub Kicinski <jakub.kicin...@netronome.com> wrote:

>  
> +static void xdp_dump_prog_one(FILE *fp, struct rtattr *tb[IFLA_XDP_MAX + 1],
> +                           __u32 attr, bool link, bool details, char *pfx)
> +{
> +     __u32 prog_id;
> +
> +     if (!tb[attr])
> +             return;
> +
> +     prog_id = rta_getattr_u32(tb[attr]);
> +     if (!details) {
> +             if (prog_id && !link && attr == IFLA_XDP_PROG_ID)
> +                     fprintf(fp, "/id:%u", prog_id);
> +             return;
> +     }
> +
> +     if (prog_id) {
> +             fprintf(fp, "%s    prog/xdp%s ", _SL_, pfx);
> +             bpf_dump_prog_info(fp, prog_id);
> +     }

Maybe const char *pfx.

I prefer to not use "printf(fp," and use print_string(PRINT_FP, NULL, "%s", ...)
because otherwise you end up mixing strings and json format output in the
same result.

You should be able to do
        tc -j ... 
and always get valid JSON output.

One quick way to test json validation is to pipe it into python:
        tc -j ... | python -mjson.tool

Reply via email to