[packages/v4l-utils] - added bpf patch (fixes build with libbpf 1+); release 2
qboosh
qboosh at pld-linux.org
Tue Oct 25 21:49:36 CEST 2022
commit 58f3835f950ae7c9bf32f0ec2f0b3813b2af6584
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Tue Oct 25 21:50:42 2022 +0200
- added bpf patch (fixes build with libbpf 1+); release 2
v4l-utils-bpf.patch | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++
v4l-utils.spec | 6 ++-
2 files changed, 122 insertions(+), 2 deletions(-)
---
diff --git a/v4l-utils.spec b/v4l-utils.spec
index 86e07eb..8a6d940 100644
--- a/v4l-utils.spec
+++ b/v4l-utils.spec
@@ -7,11 +7,12 @@ Summary: Collection of Video4Linux utilities
Summary(pl.UTF-8): Zbiór narzędzi do urządzeń Video4Linux
Name: v4l-utils
Version: 1.22.1
-Release: 1
+Release: 2
License: GPL v2+ (utilities), LGPL v2.1+ (libraries)
Group: Applications/System
Source0: https://linuxtv.org/downloads/v4l-utils/%{name}-%{version}.tar.bz2
# Source0-md5: 8aa73287320a49e9170a8255d7b2c7e6
+Patch0: %{name}-bpf.patch
URL: https://linuxtv.org/wiki/index.php/V4l-utils
BuildRequires: OpenGL-devel
BuildRequires: OpenGL-GLU-devel
@@ -31,7 +32,7 @@ BuildRequires: automake >= 1:1.9
BuildRequires: clang
BuildRequires: elfutils-devel
BuildRequires: gettext-tools >= 0.19.8
-BuildRequires: libbpf-devel
+BuildRequires: libbpf-devel >= 0.6
BuildRequires: libjpeg-devel
BuildRequires: libstdc++-devel
BuildRequires: libtool
@@ -141,6 +142,7 @@ Statyczne biblioteki libv4l.
%prep
%setup -q
+%patch0 -p1
%build
%{__libtoolize}
diff --git a/v4l-utils-bpf.patch b/v4l-utils-bpf.patch
new file mode 100644
index 0000000..60fd42d
--- /dev/null
+++ b/v4l-utils-bpf.patch
@@ -0,0 +1,118 @@
+--- v4l-utils-1.22.1/utils/keytable/bpf_load.c.orig 2022-10-25 21:46:09.072545347 +0200
++++ v4l-utils-1.22.1/utils/keytable/bpf_load.c 2022-10-25 21:46:15.542510296 +0200
+@@ -63,19 +63,21 @@ 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;
++ struct bpf_prog_load_opts load_opts;
+ int fd, err;
+
+- memset(&load_attr, 0, sizeof(struct bpf_load_program_attr));
++ memset(&load_opts, 0, sizeof(struct bpf_prog_load_opts));
+
+- 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;
+-
+- fd = bpf_load_program_xattr(&load_attr, bpf_log_buf, LOG_BUF_SIZE);
++ load_opts.sz = sizeof(struct bpf_prog_load_opts);
++ load_opts.expected_attach_type = BPF_LIRC_MODE2;
++ load_opts.log_size = LOG_BUF_SIZE;
++ load_opts.log_buf = bpf_log_buf;
++
++ fd = bpf_prog_load(BPF_PROG_TYPE_LIRC_MODE2,
++ bpf_file->name,
++ bpf_file->license,
++ prog, size / sizeof(struct bpf_insn),
++ &load_opts);
+ if (fd < 0) {
+ printf("bpf_load_program() err=%m\n%s", bpf_log_buf);
+ return -1;
+@@ -95,6 +97,7 @@ static int build_raw_map(struct bpf_map_
+ int no_patterns, value_size, fd, key, i;
+ struct raw_entry *e;
+ struct raw_pattern *p;
++ struct bpf_map_create_opts map_opts;
+
+ no_patterns = 0;
+
+@@ -110,13 +113,17 @@ 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);
++ memset(&map_opts, 0, sizeof(struct bpf_map_create_opts));
++ map_opts.sz = sizeof(struct bpf_map_create_opts);
++ map_opts.map_flags = map->def.map_flags;
++ map_opts.numa_node = numa_node;
++
++ fd = bpf_map_create(map->def.type,
++ map->name,
++ map->def.key_size,
++ value_size,
++ no_patterns,
++ &map_opts);
+
+ if (fd < 0) {
+ printf(_("failed to create a map: %d %s\n"),
+@@ -167,6 +174,10 @@ static int load_maps(struct bpf_file *bp
+ {
+ struct bpf_map_data *maps = bpf_file->map_data;
+ int i, numa_node;
++ struct bpf_map_create_opts map_opts;
++
++ memset(&map_opts, 0, sizeof(struct bpf_map_create_opts));
++ map_opts.sz = sizeof(struct bpf_map_create_opts);
+
+ for (i = 0; i < bpf_file->nr_maps; i++) {
+ numa_node = maps[i].def.map_flags & BPF_F_NUMA_NODE ?
+@@ -174,27 +185,31 @@ 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];
++ map_opts.inner_map_fd = bpf_file->map_fd[maps[i].def.inner_map_idx];
++ map_opts.map_flags = maps[i].def.map_flags;
++ map_opts.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,
++ 0,
+ maps[i].def.max_entries,
+- maps[i].def.map_flags,
+- numa_node);
++ &map_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(
++ map_opts.inner_map_fd = 0;
++ map_opts.map_flags = maps[i].def.map_flags;
++ map_opts.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);
++ &map_opts);
+ }
+
+ if (bpf_file->map_fd[i] < 0) {
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/v4l-utils.git/commitdiff/58f3835f950ae7c9bf32f0ec2f0b3813b2af6584
More information about the pld-cvs-commit
mailing list