eBPF-based security platform
upatch: say that a map without a decoder has no JSON form
ilai goldschmidt8a8e16581686
diff --git a/Documentation/reference/cli/upatch-map.rst b/Documentation/reference/cli/upatch-map.rstindex f258519c..c5874136 100644--- a/Documentation/reference/cli/upatch-map.rst+++ b/Documentation/reference/cli/upatch-map.rst@@ -57,7 +57,11 @@ With ``<upatch> <map>``, ``map`` reads the map:- The human output shows at most 256 entries unless ``--show-full``.JSON and OTLP output have no limit.- ``--json`` prints one JSON line to standard output. ``--json=<path>``- appends it to ``<path>``.+ appends it to ``<path>``. The line is what the map's signed Lua+ decoder returns (:doc:`/upatches/write/decoders`). A map without a+ decoder has no JSON form: the command prints ``upatch map:+ <upatch>/<map> has no decoder, and --json writes what a decoder+ returns`` and exits 1. The output without ``--json`` needs no decoder.- ``--otel`` sends the map to an OTLP collector. A map with a signed Luadecoder is sent as the log or metric the decoder declares. A mapwithout one is classified by shirudo (seediff --git a/Documentation/reference/formats/map-export.rst b/Documentation/reference/formats/map-export.rstindex f17b1e88..c0f476ad 100644--- a/Documentation/reference/formats/map-export.rst+++ b/Documentation/reference/formats/map-export.rst@@ -211,7 +211,9 @@ JSON lines``map_export.json_path`` or ``upatch map --json=<path>`` appends one lineper map to a file, instead of OTLP or besides it. The line is the JSONvalue the map's decoder returns, not an OTLP document. A map without a-decoder fails with ``ENODATA``. ``map_export.json_path`` must be an+decoder has no line: ``upatch map`` reports ``<upatch>/<map> has no+decoder, and --json writes what a decoder returns`` for it and exits 1+once the other maps are handled. ``map_export.json_path`` must be anabsolute path. A file or directory that carries shirudo's seal label isrefused. A new file gets mode ``0644``.diff --git a/Documentation/upatches/test/testing.rst b/Documentation/upatches/test/testing.rstindex 930419aa..9821d19b 100644--- a/Documentation/upatches/test/testing.rst+++ b/Documentation/upatches/test/testing.rst@@ -126,7 +126,8 @@ Load and observe itwith a serializer is rendered by it, and ``--peek`` asks the serializerto leave the records for the exporter. Add ``--json`` to see what themap's decoder returns. For a map without a decoder, ``--json`` fails- with ``upatch map: print JSON: No data available``.+ with ``upatch map: <name>/<map> has no decoder, and --json writes what+ a decoder returns``.Unload it---------diff --git a/builtin-upatch.c b/builtin-upatch.cindex a9b67d8d..b97bbd9f 100644--- a/builtin-upatch.c+++ b/builtin-upatch.c@@ -4399,7 +4399,11 @@ static int export_one_map(const char *upatch, const char *map,if (json_output) {err = append_one_map_json(json_path, &v);if (err) {- if (json_path)+ if (err == -ENODATA)+ pr_err("upatch map: %s/%s has no decoder, and "+ "--json writes what a decoder returns",+ upatch, map);+ else if (json_path)pr_err("upatch map: append JSON to %s: %s",json_path, strerror(-err));else