Skip to contentSkip to conversation

net/bpfilter: specify the log level for the kmsg message

PATCH In review Gary Lin 4 participants 6 messages Jun 23, 2021 – Jun 25, 2021

Subsystems (3)
lore
Share & tools
lore

Gary Lin

author
#0 lore raw

PATCH 1/1 net/bpfilter: specify the log level for the kmsg message

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
 net/bpfilter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpfilter/main.c +1 -1
index 05e1cfc1e5cd..291a92546246 100644
@@ -57,7 +57,7 @@ int main(void)
 {
 	debug_f = fopen("/dev/kmsg", "w");
 	setvbuf(debug_f, 0, _IOLBF, 0);
-	fprintf(debug_f, "Started bpfilter\n");
+	fprintf(debug_f, "<5>Started bpfilter\n");
 	loop();
 	fclose(debug_f);
 	return 0;
Signature · 1 line
2.31.1
#1 lore raw
Quoted 22 lines · Gary Lin

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
 net/bpfilter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpfilter/main.c +0 -0
index 05e1cfc1e5cd..291a92546246 100644

net/bpfilter/main.c int main(void) · line 63

Quoted 8 lines
net/bpfilter/main.c +1 -1
@@ -57,7 +57,7 @@ int main(void)
 {
        debug_f = fopen("/dev/kmsg", "w");
        setvbuf(debug_f, 0, _IOLBF, 0);
-       fprintf(debug_f, "Started bpfilter\n");
+       fprintf(debug_f, "<5>Started bpfilter\n");
        loop();
        fclose(debug_f);
        return 0;

Adding Dmitrii who is redesigning the whole bpfilter.

#2 lore raw
Quoted 18 lines · Alexei Starovoitov
Quoted 17 lines · Gary Lin

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
 net/bpfilter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

net/bpfilter/main.c int main(void) · line 63

Quoted 13 lines
net/bpfilter/main.c +1 -1
index 05e1cfc1e5cd..291a92546246 100644
@@ -57,7 +57,7 @@ int main(void)
 {
        debug_f = fopen("/dev/kmsg", "w");
        setvbuf(debug_f, 0, _IOLBF, 0);
-       fprintf(debug_f, "Started bpfilter\n");
+       fprintf(debug_f, "<5>Started bpfilter\n");
        loop();
        fclose(debug_f);
        return 0;

Adding Dmitrii who is redesigning the whole bpfilter.

Thanks. The same logic already exists in the bpfilter v1 patchset
- [1].

1. https://lore.kernel.org/bpf/[email protected]/T/#mb36e20c4e5e4a70746bd50a109b1630687990214

Signature · 1 line
Dmitrii Banshchikov
#3 lore raw
Quoted 36 lines · Dmitrii Banshchikov
Quoted 18 lines · Alexei Starovoitov
Quoted 17 lines · Gary Lin

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
 net/bpfilter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

net/bpfilter/main.c int main(void) · line 63

Quoted 13 lines
net/bpfilter/main.c +1 -1
index 05e1cfc1e5cd..291a92546246 100644
@@ -57,7 +57,7 @@ int main(void)
 {
        debug_f = fopen("/dev/kmsg", "w");
        setvbuf(debug_f, 0, _IOLBF, 0);
-       fprintf(debug_f, "Started bpfilter\n");
+       fprintf(debug_f, "<5>Started bpfilter\n");
        loop();
        fclose(debug_f);
        return 0;

Adding Dmitrii who is redesigning the whole bpfilter.

Quoted 4 lines

Thanks. The same logic already exists in the bpfilter v1 patchset
- [1].

1. https://lore.kernel.org/bpf/[email protected]/T/#mb36e20c4e5e4a70746bd50a109b1630687990214

Dmitrii,

what do you prefer we should do with this patch then?

#4 lore raw
Quoted 37 lines · Alexei Starovoitov
Quoted 36 lines · Dmitrii Banshchikov
Quoted 33 lines · Alexei Starovoitov
Quoted 22 lines · Gary Lin

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
 net/bpfilter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpfilter/main.c +0 -0
index 05e1cfc1e5cd..291a92546246 100644

net/bpfilter/main.c int main(void) · line 63

Quoted 8 lines
net/bpfilter/main.c +1 -1
@@ -57,7 +57,7 @@ int main(void)
 {
        debug_f = fopen("/dev/kmsg", "w");
        setvbuf(debug_f, 0, _IOLBF, 0);
-       fprintf(debug_f, "Started bpfilter\n");
+       fprintf(debug_f, "<5>Started bpfilter\n");
        loop();
        fclose(debug_f);
        return 0;

Adding Dmitrii who is redesigning the whole bpfilter.

Quoted 8 lines
Quoted 4 lines

Thanks. The same logic already exists in the bpfilter v1 patchset
- [1].

1. https://lore.kernel.org/bpf/[email protected]/T/#mb36e20c4e5e4a70746bd50a109b1630687990214

Dmitrii,

what do you prefer we should do with this patch then?

There was an explicit request to make an event of loading a UMH visible - [1]. Given that the default for MaxLevelConsole is info and the patch makes the behavior slightly more accurate - ack from me.

1. https://lore.kernel.org/netdev/CA+55aFx5Q8D3cmuoXJFV9Ok_vc3fd3rNP-5onqFTPTtfZgi=HQ@mail.gmail.com/

Signature · 1 line
Dmitrii Banshchikov
maintainer
#5 lore raw
Quoted 42 lines · Dmitrii Banshchikov
Quoted 41 lines · Alexei Starovoitov
Quoted 39 lines · Dmitrii Banshchikov
Quoted 18 lines · Alexei Starovoitov
Quoted 17 lines · Gary Lin

Per the kmsg document(*), if we don't specify the log level with a prefix "<N>" in the message string, the default log level will be applied to the message. Since the default level could be warning(4), this would make the log utility such as journalctl treat the message, "Started bpfilter", as a warning. To avoid confusion, this commit adds the prefix "<5>" to make the message always a notice.

(*) https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Fixes 36c4357c63f3 ("net: bpfilter: print umh messages to /dev/kmsg")
---
  net/bpfilter/main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

net/bpfilter/main.c int main(void) · line 63

Quoted 13 lines
net/bpfilter/main.c +1 -1
index 05e1cfc1e5cd..291a92546246 100644
@@ -57,7 +57,7 @@ int main(void)
  {
         debug_f = fopen("/dev/kmsg", "w");
         setvbuf(debug_f, 0, _IOLBF, 0);
-       fprintf(debug_f, "Started bpfilter\n");
+       fprintf(debug_f, "<5>Started bpfilter\n");
         loop();
         fclose(debug_f);
         return 0;

Adding Dmitrii who is redesigning the whole bpfilter.

Thanks. The same logic already exists in the bpfilter v1 patchset
- [1].

1. https://lore.kernel.org/bpf/[email protected]/T/#mb36e20c4e5e4a70746bd50a109b1630687990214

Quoted 8 lines
Quoted 3 lines

Dmitrii,

what do you prefer we should do with this patch then?

There was an explicit request to make an event of loading a UMH visible - [1]. Given that the default for MaxLevelConsole is info and the patch makes the behavior slightly more accurate - ack from me.

Ok, sounds good, applied, thanks!