]> granicus.if.org Git - strace/commitdiff
bpf: print struct bpf_prog_info.gpl_compatible
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Mar 2019 11:17:20 +0000 (11:17 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Mar 2019 11:17:20 +0000 (11:17 +0000)
This bit field was added by Linux commit v4.18-rc1~114^2~376^2~6.

* bpf_attr.h (struct bpf_prog_info_struct): Add gpl_compatible field.
* bpf.c (print_bpf_prog_info): Print gpl_compatible field.
* tests/bpf-obj_get_info_by_fd.c (main): Update expected output.

bpf.c
bpf_attr.h
tests/bpf-obj_get_info_by_fd.c

diff --git a/bpf.c b/bpf.c
index 397521e88bea30508f454bf6ddd34ee8d7b011c1..6fb4c2c2bc51ee4873c2b66d09d00cec6a70f5e2 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -525,11 +525,14 @@ print_bpf_prog_info(struct tcb * const tcp, uint32_t bpf_fd,
 
        /*
         * ifindex, netns_dev, and netns_ino fields were introduced
-        * by Linux commit v4.16-rc1~123^2~227^2~5^2~2.
+        * by Linux commit v4.16-rc1~123^2~227^2~5^2~2, and
+        * gpl_compatible was added later by Linux commit
+        * v4.18-rc1~114^2~376^2~6.
         */
        if (len <= offsetof(struct bpf_prog_info_struct, ifindex))
                goto print_bpf_prog_info_end;
        PRINT_FIELD_IFINDEX(", ", info, ifindex);
+       tprintf(", gpl_compatible=%u", info.gpl_compatible);
        PRINT_FIELD_DEV(", ", info, netns_dev);
        PRINT_FIELD_U(", ", info, netns_ino);
 
index dc7694ccf095a54c3d2ac95b521e92779be82009..cb4989631ac723f11f8ff0081a6df94d41526829 100644 (file)
@@ -259,6 +259,7 @@ struct bpf_prog_info_struct {
        uint64_t ATTRIBUTE_ALIGNED(8) map_ids;
        char     name[BPF_OBJ_NAME_LEN];
        uint32_t ifindex;
+       uint32_t gpl_compatible:1;
        /*
         * The kernel UAPI is broken by Linux commit
         * v4.16-rc1~123^2~227^2~5^2~2 .
index fba0e75b0f263c64f651f979ae4ecf71f6736103..ff06e27dc27e096d7729c1767b13c001912f28e7 100644 (file)
@@ -460,6 +460,9 @@ main(void)
                if (bpf_prog_get_info_attr.info_len >
                    offsetof(struct bpf_prog_info_struct, ifindex))
                        printf(", ifindex=%u", prog_info->ifindex);
+               if (bpf_prog_get_info_attr.info_len >
+                   offsetofend(struct bpf_prog_info_struct, ifindex))
+                       printf(", gpl_compatible=%u", prog_info->gpl_compatible);
                if (bpf_prog_get_info_attr.info_len >
                    offsetof(struct bpf_prog_info_struct, netns_dev))
                        printf(", netns_dev=makedev(%#x, %#x)",