bpf: add trace logging
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 9 Nov 2019 11:34:30 +0000 (12:34 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Nov 2019 13:55:57 +0000 (14:55 +0100)
Very helpful when trying to figure out what exactly is going on.

src/core/bpf-devices.c

index 49c8456..c94b935 100644 (file)
@@ -44,6 +44,8 @@ static int bpf_prog_whitelist_device(BPFProgram *prog, int type, int major, int
         assert(prog);
         assert(acc);
 
+        log_trace("%s: %c %d:%d %s", __func__, type, major, minor, acc);
+
         access = bpf_access_type(acc);
         if (access <= 0)
                 return -EINVAL;
@@ -71,6 +73,8 @@ static int bpf_prog_whitelist_major(BPFProgram *prog, int type, int major, const
         assert(prog);
         assert(acc);
 
+        log_trace("%s: %c %d:* %s", __func__, type, major, acc);
+
         access = bpf_access_type(acc);
         if (access <= 0)
                 return -EINVAL;
@@ -97,6 +101,8 @@ static int bpf_prog_whitelist_class(BPFProgram *prog, int type, const char *acc)
         assert(prog);
         assert(acc);
 
+        log_trace("%s: %c *:* %s", __func__, type, acc);
+
         access = bpf_access_type(acc);
         if (access <= 0)
                 return -EINVAL;
@@ -323,6 +329,8 @@ int bpf_devices_whitelist_device(BPFProgram *prog, const char *path, const char
         assert(acc);
         assert(strlen(acc) <= 3);
 
+        log_trace("%s: %s %s", __func__, node, acc);
+
         /* Some special handling for /dev/block/%u:%u, /dev/char/%u:%u, /run/systemd/inaccessible/chr and
          * /run/systemd/inaccessible/blk paths. Instead of stat()ing these we parse out the major/minor directly. This
          * means clients can use these path without the device node actually around */