aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Janosch Hofmeyr <nhofmeyr@sysmocom.de>2022-12-08 03:25:22 +0100
committerNeels Janosch Hofmeyr <nhofmeyr@sysmocom.de>2022-12-08 04:23:09 +0100
commitbf8e49a1bde4862eda5c32192ffb696b9963d90a (patch)
treef79d7ac62d39d359346c168cbab9528c41932f54
parent43dd5ddf97023552d0f3cd695d73603645414320 (diff)
gtlv: decoding error: log size limited hexdump of IE
When a decoding error is encountered, log the value part of the root cause as hexdump, but at most 16 bytes (16*3 chars as hexdump). Contrived example of the change: before this patch: <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument) <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE (-22: Invalid argument) after this patch: <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: Invalid FQDN (-22: Invalid argument) <-tx- PFCP seq-4 ASSOC_SETUP_RESP: 0: tag 0x3c = Node ID: Error while decoding this IE. L=20 V=[ 02 07 65 78 61 6d 70 6c 65 03 63 6f 6d 01 02 03 ...] (-22: Invalid argument) Change-Id: Ie814a117db3dfea32cf3f01cf124a2e472cb869f
-rw-r--r--src/libosmo-gtlv/gtlv_dec_enc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libosmo-gtlv/gtlv_dec_enc.c b/src/libosmo-gtlv/gtlv_dec_enc.c
index 385ebfa..37e8a51 100644
--- a/src/libosmo-gtlv/gtlv_dec_enc.c
+++ b/src/libosmo-gtlv/gtlv_dec_enc.c
@@ -218,8 +218,12 @@ static int osmo_gtlvs_decode_unordered(void *decoded_struct, size_t decoded_stru
if (!iec->dec_func)
RETURN_ERROR(-EIO, gtlv->ti, "IE definition lacks a dec_func()");
rc = iec->dec_func(decoded_struct, membof(obj, obj_maxlen, memb_ofs), gtlv);
- if (rc)
- RETURN_ERROR(rc, gtlv->ti, "Error while decoding this IE");
+ if (rc) {
+ const size_t maxlen = 16;
+ RETURN_ERROR(rc, gtlv->ti, "Error while decoding this IE. L=%zu V=[ %s%s]",
+ gtlv->len, osmo_hexdump(gtlv->val, OSMO_MIN(maxlen, gtlv->len)),
+ gtlv->len > maxlen ? "..." : "");
+ }
}
if (multi_count_p) {