Blame SOURCES/0047-bpf-print-struct-bpf_prog_info.gpl_compatible.patch

b484ca
From cabd6955d3c3048bb2ba19032b504eeb3776a86f Mon Sep 17 00:00:00 2001
b484ca
From: "Dmitry V. Levin" <ldv@altlinux.org>
b484ca
Date: Tue, 12 Mar 2019 11:17:20 +0000
b484ca
Subject: [PATCH] bpf: print struct bpf_prog_info.gpl_compatible
b484ca
b484ca
This bit field was added by Linux commit v4.18-rc1~114^2~376^2~6.
b484ca
b484ca
* bpf_attr.h (struct bpf_prog_info_struct): Add gpl_compatible field.
b484ca
* bpf.c (print_bpf_prog_info): Print gpl_compatible field.
b484ca
* tests/bpf-obj_get_info_by_fd.c (main): Update expected output.
b484ca
---
b484ca
 bpf.c                          | 5 ++++-
b484ca
 bpf_attr.h                     | 1 +
b484ca
 tests/bpf-obj_get_info_by_fd.c | 3 +++
b484ca
 3 files changed, 8 insertions(+), 1 deletion(-)
b484ca
b484ca
Index: strace-4.24/bpf.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/bpf.c	2020-01-28 00:12:27.629445789 +0100
b484ca
+++ strace-4.24/bpf.c	2020-01-28 00:14:36.905228319 +0100
b484ca
@@ -528,11 +528,14 @@
b484ca
 
b484ca
 	/*
b484ca
 	 * ifindex, netns_dev, and netns_ino fields were introduced
b484ca
-	 * by Linux commit v4.16-rc1~123^2~227^2~5^2~2.
b484ca
+	 * by Linux commit v4.16-rc1~123^2~227^2~5^2~2, and
b484ca
+	 * gpl_compatible was added later by Linux commit
b484ca
+	 * v4.18-rc1~114^2~376^2~6.
b484ca
 	 */
b484ca
 	if (len <= offsetof(struct bpf_prog_info_struct, ifindex))
b484ca
 		goto print_bpf_prog_info_end;
b484ca
 	PRINT_FIELD_IFINDEX(", ", info, ifindex);
b484ca
+	tprintf(", gpl_compatible=%u", info.gpl_compatible);
b484ca
 	PRINT_FIELD_DEV(", ", info, netns_dev);
b484ca
 	PRINT_FIELD_U(", ", info, netns_ino);
b484ca
 
b484ca
Index: strace-4.24/bpf_attr.h
b484ca
===================================================================
b484ca
--- strace-4.24.orig/bpf_attr.h	2020-01-28 00:14:12.107461855 +0100
b484ca
+++ strace-4.24/bpf_attr.h	2020-01-28 00:14:36.905228319 +0100
b484ca
@@ -259,6 +259,7 @@
b484ca
 	uint64_t ATTRIBUTE_ALIGNED(8) map_ids;
b484ca
 	char     name[BPF_OBJ_NAME_LEN];
b484ca
 	uint32_t ifindex;
b484ca
+	uint32_t gpl_compatible:1;
b484ca
 	/*
b484ca
 	 * The kernel UAPI is broken by Linux commit
b484ca
 	 * v4.16-rc1~123^2~227^2~5^2~2 .
b484ca
Index: strace-4.24/tests/bpf-obj_get_info_by_fd.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/tests/bpf-obj_get_info_by_fd.c	2020-01-28 00:12:27.629445789 +0100
b484ca
+++ strace-4.24/tests/bpf-obj_get_info_by_fd.c	2020-01-28 00:14:36.905228319 +0100
b484ca
@@ -461,6 +461,9 @@
b484ca
 		    offsetof(struct bpf_prog_info_struct, ifindex))
b484ca
 			printf(", ifindex=%u", prog_info->ifindex);
b484ca
 		if (bpf_prog_get_info_attr.info_len >
b484ca
+		    offsetofend(struct bpf_prog_info_struct, ifindex))
b484ca
+			printf(", gpl_compatible=%u", prog_info->gpl_compatible);
b484ca
+		if (bpf_prog_get_info_attr.info_len >
b484ca
 		    offsetof(struct bpf_prog_info_struct, netns_dev))
b484ca
 			printf(", netns_dev=makedev(%u, %u)",
b484ca
 			       major(prog_info->netns_dev),
b484ca
Index: strace-4.24/tests-m32/bpf-obj_get_info_by_fd.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/tests-m32/bpf-obj_get_info_by_fd.c	2020-01-27 17:41:26.542587684 +0100
b484ca
+++ strace-4.24/tests-m32/bpf-obj_get_info_by_fd.c	2020-01-28 00:15:16.441855977 +0100
b484ca
@@ -461,6 +461,9 @@
b484ca
 		    offsetof(struct bpf_prog_info_struct, ifindex))
b484ca
 			printf(", ifindex=%u", prog_info->ifindex);
b484ca
 		if (bpf_prog_get_info_attr.info_len >
b484ca
+		    offsetofend(struct bpf_prog_info_struct, ifindex))
b484ca
+			printf(", gpl_compatible=%u", prog_info->gpl_compatible);
b484ca
+		if (bpf_prog_get_info_attr.info_len >
b484ca
 		    offsetof(struct bpf_prog_info_struct, netns_dev))
b484ca
 			printf(", netns_dev=makedev(%u, %u)",
b484ca
 			       major(prog_info->netns_dev),
b484ca
Index: strace-4.24/tests-m32/bpf.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/tests-m32/bpf.c	2018-07-11 02:00:57.000000000 +0200
b484ca
+++ strace-4.24/tests-m32/bpf.c	2020-01-28 00:15:08.917926835 +0100
b484ca
@@ -5,27 +5,7 @@
b484ca
  * Copyright (c) 2015-2018 The strace developers.
b484ca
  * All rights reserved.
b484ca
  *
b484ca
- * Redistribution and use in source and binary forms, with or without
b484ca
- * modification, are permitted provided that the following conditions
b484ca
- * are met:
b484ca
- * 1. Redistributions of source code must retain the above copyright
b484ca
- *    notice, this list of conditions and the following disclaimer.
b484ca
- * 2. Redistributions in binary form must reproduce the above copyright
b484ca
- *    notice, this list of conditions and the following disclaimer in the
b484ca
- *    documentation and/or other materials provided with the distribution.
b484ca
- * 3. The name of the author may not be used to endorse or promote products
b484ca
- *    derived from this software without specific prior written permission.
b484ca
- *
b484ca
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
b484ca
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b484ca
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
b484ca
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
b484ca
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
b484ca
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
b484ca
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
b484ca
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
b484ca
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
b484ca
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
b484ca
+ * SPDX-License-Identifier: GPL-2.0-or-later
b484ca
  */
b484ca
 
b484ca
 #include "tests.h"
b484ca
Index: strace-4.24/tests-mx32/bpf-obj_get_info_by_fd.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/tests-mx32/bpf-obj_get_info_by_fd.c	2020-01-27 17:41:26.542587684 +0100
b484ca
+++ strace-4.24/tests-mx32/bpf-obj_get_info_by_fd.c	2020-01-28 00:15:18.824833536 +0100
b484ca
@@ -461,6 +461,9 @@
b484ca
 		    offsetof(struct bpf_prog_info_struct, ifindex))
b484ca
 			printf(", ifindex=%u", prog_info->ifindex);
b484ca
 		if (bpf_prog_get_info_attr.info_len >
b484ca
+		    offsetofend(struct bpf_prog_info_struct, ifindex))
b484ca
+			printf(", gpl_compatible=%u", prog_info->gpl_compatible);
b484ca
+		if (bpf_prog_get_info_attr.info_len >
b484ca
 		    offsetof(struct bpf_prog_info_struct, netns_dev))
b484ca
 			printf(", netns_dev=makedev(%u, %u)",
b484ca
 			       major(prog_info->netns_dev),
b484ca
Index: strace-4.24/tests-mx32/bpf.c
b484ca
===================================================================
b484ca
--- strace-4.24.orig/tests-mx32/bpf.c	2018-07-11 02:00:57.000000000 +0200
b484ca
+++ strace-4.24/tests-mx32/bpf.c	2020-01-28 00:15:10.852908612 +0100
b484ca
@@ -5,27 +5,7 @@
b484ca
  * Copyright (c) 2015-2018 The strace developers.
b484ca
  * All rights reserved.
b484ca
  *
b484ca
- * Redistribution and use in source and binary forms, with or without
b484ca
- * modification, are permitted provided that the following conditions
b484ca
- * are met:
b484ca
- * 1. Redistributions of source code must retain the above copyright
b484ca
- *    notice, this list of conditions and the following disclaimer.
b484ca
- * 2. Redistributions in binary form must reproduce the above copyright
b484ca
- *    notice, this list of conditions and the following disclaimer in the
b484ca
- *    documentation and/or other materials provided with the distribution.
b484ca
- * 3. The name of the author may not be used to endorse or promote products
b484ca
- *    derived from this software without specific prior written permission.
b484ca
- *
b484ca
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
b484ca
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b484ca
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
b484ca
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
b484ca
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
b484ca
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
b484ca
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
b484ca
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
b484ca
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
b484ca
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
b484ca
+ * SPDX-License-Identifier: GPL-2.0-or-later
b484ca
  */
b484ca
 
b484ca
 #include "tests.h"