File: libbpf.patch

package info (click to toggle)
v4l-utils 1.22.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,140 kB
  • sloc: ansic: 81,718; cpp: 51,598; perl: 11,014; sh: 5,276; makefile: 682; python: 544; php: 119; sed: 16
file content (109 lines) | stat: -rw-r--r-- 3,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Description: Changes for libbpf/1.0.1
Author: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Bug-Debian: https://bugs.debian.org/1018915
Forwarded: https://lore.kernel.org/linux-media/20221101202528.27306-1-sudipm.mukherjee@gmail.com/

--- v4l-utils-1.22.1.orig/utils/keytable/bpf_load.c
+++ v4l-utils-1.22.1/utils/keytable/bpf_load.c
@@ -63,19 +63,16 @@ struct bpf_file {
 
 static int load_and_attach(int lirc_fd, struct bpf_file *bpf_file, struct bpf_insn *prog, int size)
 {
-	struct bpf_load_program_attr load_attr;
-	int fd, err;
+	LIBBPF_OPTS(bpf_prog_load_opts, opts);
+	int fd, err, insn_cnt;
 
-	memset(&load_attr, 0, sizeof(struct bpf_load_program_attr));
+	insn_cnt = size / sizeof(struct bpf_insn);
 
-	load_attr.prog_type = BPF_PROG_TYPE_LIRC_MODE2;
-	load_attr.expected_attach_type = BPF_LIRC_MODE2;
-	load_attr.name = bpf_file->name;
-	load_attr.insns = prog;
-	load_attr.insns_cnt = size / sizeof(struct bpf_insn);
-	load_attr.license = bpf_file->license;
+	opts.expected_attach_type = BPF_LIRC_MODE2;
+	opts.log_buf = bpf_log_buf;
+	opts.log_size = LOG_BUF_SIZE;
 
-	fd = bpf_load_program_xattr(&load_attr, bpf_log_buf, LOG_BUF_SIZE);
+	fd = bpf_prog_load(BPF_PROG_TYPE_LIRC_MODE2, bpf_file->name, bpf_file->license, prog, insn_cnt, &opts);
 	if (fd < 0) {
 		printf("bpf_load_program() err=%m\n%s", bpf_log_buf);
 		return -1;
@@ -95,6 +92,9 @@ static int build_raw_map(struct bpf_map_
 	int no_patterns, value_size, fd, key, i;
 	struct raw_entry *e;
 	struct raw_pattern *p;
+	LIBBPF_OPTS(bpf_map_create_opts, opts,
+		.map_flags = map->def.map_flags,
+	);
 
 	no_patterns = 0;
 
@@ -110,14 +110,13 @@ static int build_raw_map(struct bpf_map_
 
 	value_size = sizeof(struct raw_pattern) + max_length * sizeof(short);
 
-	fd = bpf_create_map_node(map->def.type,
-				 map->name,
-				 map->def.key_size,
-				 value_size,
-				 no_patterns,
-				 map->def.map_flags,
-				 numa_node);
-
+	opts.numa_node = numa_node;
+	fd = bpf_map_create(map->def.type,
+			    map->name,
+			    map->def.key_size,
+			    value_size,
+			    no_patterns,
+			    &opts);
 	if (fd < 0) {
 		printf(_("failed to create a map: %d %s\n"),
 		       errno, strerror(errno));
@@ -174,27 +173,34 @@ static int load_maps(struct bpf_file *bp
 
 		if (maps[i].def.type == BPF_MAP_TYPE_ARRAY_OF_MAPS ||
 		    maps[i].def.type == BPF_MAP_TYPE_HASH_OF_MAPS) {
-			int inner_map_fd = bpf_file->map_fd[maps[i].def.inner_map_idx];
+			LIBBPF_OPTS(bpf_map_create_opts, opts,
+				.inner_map_fd = bpf_file->map_fd[maps[i].def.inner_map_idx],
+				.map_flags = maps[i].def.map_flags,
+				.numa_node = numa_node,
+			);
 
-			bpf_file->map_fd[i] = bpf_create_map_in_map_node(
+			bpf_file->map_fd[i] = bpf_map_create(
 							maps[i].def.type,
 							maps[i].name,
 							maps[i].def.key_size,
-							inner_map_fd,
+							4,
 							maps[i].def.max_entries,
-							maps[i].def.map_flags,
-							numa_node);
+							&opts);
 		} else if (!strcmp(maps[i].name, "raw_map")) {
 			bpf_file->map_fd[i] = build_raw_map(&maps[i], raw, numa_node);
 		} else {
-			bpf_file->map_fd[i] = bpf_create_map_node(
+			LIBBPF_OPTS(bpf_map_create_opts, opts,
+				.map_flags = maps[i].def.map_flags,
+				.numa_node = numa_node,
+			);
+
+			bpf_file->map_fd[i] = bpf_map_create(
 							maps[i].def.type,
 							maps[i].name,
 							maps[i].def.key_size,
 							maps[i].def.value_size,
 							maps[i].def.max_entries,
-							maps[i].def.map_flags,
-							numa_node);
+							&opts);
 		}
 
 		if (bpf_file->map_fd[i] < 0) {