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

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