NetBpfLoad: Prevent libbpf log truncation
The liblog logger truncates messages over 1024 bytes, which was cutting off kernel verifier logs. This change bypasses the limit by splitting the log by newline and logging each line individually. Bug: 428792764 Flag: EXEMPT logging only change Test: TH Change-Id: I327c7e6d717b93bad0ef3e0e9b2e45a5208728ae
This commit is contained in:
parent
3e3e18b2f1
commit
47fcb86960
1 changed files with 14 additions and 2 deletions
|
|
@ -1848,11 +1848,23 @@ static int libbpfPrint(enum libbpf_print_level lvl, const char *const formatStr,
|
|||
prio = ANDROID_LOG_DEBUG;
|
||||
break;
|
||||
}
|
||||
char *s = strdup(formatStr ?: "(no format string)");
|
||||
if (!formatStr) {
|
||||
LOG_PRI(prio, LOG_TAG, "libbpf (null format string)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Print each line to avoid being truncated.
|
||||
char *s = NULL;
|
||||
int ret = vasprintf(&s, formatStr, argList);
|
||||
if (ret == -1) {
|
||||
LOG_PRI(prio, LOG_TAG, "libbpf (format failure)");
|
||||
return 0;
|
||||
}
|
||||
int len = strlen(s);
|
||||
if (len && s[len - 1] == '\n')
|
||||
s[len - 1] = 0;
|
||||
LOG_PRI_VA(prio, LOG_TAG, s, argList);
|
||||
vector<string> lines = Split(s, "\n");
|
||||
for (const auto& line : lines) LOG_PRI(prio, LOG_TAG, "%s", line.c_str());
|
||||
free(s);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue