Skip to content

eBPF-based security platform

otel: refuse an OTLP timeout of zero and bound the largest

Daniel Borkmannb6ab3f8e23b2
diff --git a/Documentation/telemetry.rst b/Documentation/telemetry.rst
index 4dbfe8f7..a29eca53 100644
--- a/Documentation/telemetry.rst
+++ b/Documentation/telemetry.rst
@@ -283,8 +283,8 @@ Cleartext ``http://`` is allowed only to loopback. ``--otel-insecure``
disables certificate verification for ``https://``, with a warning each
time; it exists for test rigs.
-Retries. ``OTEL_EXPORTER_OTLP_TIMEOUT`` (milliseconds, default 10000)
-bounds each attempt. A transport error and the responses OTLP calls
+Retries. ``OTEL_EXPORTER_OTLP_TIMEOUT`` (milliseconds, default 10000,
+from 1 to 120000) bounds each attempt. A transport error and the responses OTLP calls
retryable, 429, 502, 503 and 504, are retried with exponential backoff
from 250 ms, honouring ``Retry-After`` up to 30 s, for
``--otel-retries`` attempts (``map_export.otel_retries``, default 3,
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index 7b8d51a4..11b2821c 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -48,6 +48,7 @@
#define OTEL_ENDPOINT_MAX 2048
#define OTEL_RESPONSE_MAX (64U * 1024U)
#define OTEL_DEFAULT_TIMEOUT_MS 10000L
+#define OTEL_MAX_TIMEOUT_MS 120000L
#define OTEL_MAX_HEADER_BYTES 16384U
#define OTEL_MAX_TYPE_UNWRAP 32
@@ -1328,7 +1329,8 @@ static int parse_timeout(const char *value, long *out)
*out = OTEL_DEFAULT_TIMEOUT_MS;
return 0;
}
- if (parse_u64(value, strlen(value), LONG_MAX, &n))
+ /* curl reads 0 as no limit at all, which would let a run hang. */
+ if (parse_u64(value, strlen(value), OTEL_MAX_TIMEOUT_MS, &n) || !n)
return -EINVAL;
*out = (long)n;
return 0;