157 lines
7.7 KiB
Diff
157 lines
7.7 KiB
Diff
From cabd6955d3c3048bb2ba19032b504eeb3776a86f Mon Sep 17 00:00:00 2001
|
|
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
|
Date: Tue, 12 Mar 2019 11:17:20 +0000
|
|
Subject: [PATCH] bpf: print struct bpf_prog_info.gpl_compatible
|
|
|
|
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 | 5 ++++-
|
|
bpf_attr.h | 1 +
|
|
tests/bpf-obj_get_info_by_fd.c | 3 +++
|
|
3 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
Index: strace-4.24/bpf.c
|
|
===================================================================
|
|
--- strace-4.24.orig/bpf.c 2020-01-28 00:12:27.629445789 +0100
|
|
+++ strace-4.24/bpf.c 2020-01-28 00:14:36.905228319 +0100
|
|
@@ -528,11 +528,14 @@
|
|
|
|
/*
|
|
* 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: strace-4.24/bpf_attr.h
|
|
===================================================================
|
|
--- strace-4.24.orig/bpf_attr.h 2020-01-28 00:14:12.107461855 +0100
|
|
+++ strace-4.24/bpf_attr.h 2020-01-28 00:14:36.905228319 +0100
|
|
@@ -259,6 +259,7 @@
|
|
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: strace-4.24/tests/bpf-obj_get_info_by_fd.c
|
|
===================================================================
|
|
--- strace-4.24.orig/tests/bpf-obj_get_info_by_fd.c 2020-01-28 00:12:27.629445789 +0100
|
|
+++ strace-4.24/tests/bpf-obj_get_info_by_fd.c 2020-01-28 00:14:36.905228319 +0100
|
|
@@ -461,6 +461,9 @@
|
|
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(%u, %u)",
|
|
major(prog_info->netns_dev),
|
|
Index: strace-4.24/tests-m32/bpf-obj_get_info_by_fd.c
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-m32/bpf-obj_get_info_by_fd.c 2020-01-27 17:41:26.542587684 +0100
|
|
+++ strace-4.24/tests-m32/bpf-obj_get_info_by_fd.c 2020-01-28 00:15:16.441855977 +0100
|
|
@@ -461,6 +461,9 @@
|
|
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(%u, %u)",
|
|
major(prog_info->netns_dev),
|
|
Index: strace-4.24/tests-m32/bpf.c
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-m32/bpf.c 2018-07-11 02:00:57.000000000 +0200
|
|
+++ strace-4.24/tests-m32/bpf.c 2020-01-28 00:15:08.917926835 +0100
|
|
@@ -5,27 +5,7 @@
|
|
* Copyright (c) 2015-2018 The strace developers.
|
|
* All rights reserved.
|
|
*
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
- * modification, are permitted provided that the following conditions
|
|
- * are met:
|
|
- * 1. Redistributions of source code must retain the above copyright
|
|
- * notice, this list of conditions and the following disclaimer.
|
|
- * 2. Redistributions in binary form must reproduce the above copyright
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
- * documentation and/or other materials provided with the distribution.
|
|
- * 3. The name of the author may not be used to endorse or promote products
|
|
- * derived from this software without specific prior written permission.
|
|
- *
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "tests.h"
|
|
Index: strace-4.24/tests-mx32/bpf-obj_get_info_by_fd.c
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-mx32/bpf-obj_get_info_by_fd.c 2020-01-27 17:41:26.542587684 +0100
|
|
+++ strace-4.24/tests-mx32/bpf-obj_get_info_by_fd.c 2020-01-28 00:15:18.824833536 +0100
|
|
@@ -461,6 +461,9 @@
|
|
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(%u, %u)",
|
|
major(prog_info->netns_dev),
|
|
Index: strace-4.24/tests-mx32/bpf.c
|
|
===================================================================
|
|
--- strace-4.24.orig/tests-mx32/bpf.c 2018-07-11 02:00:57.000000000 +0200
|
|
+++ strace-4.24/tests-mx32/bpf.c 2020-01-28 00:15:10.852908612 +0100
|
|
@@ -5,27 +5,7 @@
|
|
* Copyright (c) 2015-2018 The strace developers.
|
|
* All rights reserved.
|
|
*
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
- * modification, are permitted provided that the following conditions
|
|
- * are met:
|
|
- * 1. Redistributions of source code must retain the above copyright
|
|
- * notice, this list of conditions and the following disclaimer.
|
|
- * 2. Redistributions in binary form must reproduce the above copyright
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
- * documentation and/or other materials provided with the distribution.
|
|
- * 3. The name of the author may not be used to endorse or promote products
|
|
- * derived from this software without specific prior written permission.
|
|
- *
|
|
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "tests.h"
|