Control: tags -1 patch
--

Hi Sean, Gregor,

On Wed, Sep 14, 2022 at 05:29:57PM +0100, Sean Young wrote:
> Hi Gregor,
> 
> On Wed, Sep 07, 2022 at 02:53:49PM +0200, Gregor Jasny wrote:
> > Hello Sudip,
> > 
> > thanks for the report.
> > 
> > On 02.09.22 01:19, Sudip Mukherjee wrote:
> > > Package: v4l-utils
> > > Version: 1.22.1-4
> > > Severity: important
> > > Tags: ftbfs
> > > X-Debbugs-Cc: sudipm.mukher...@gmail.com
> > > Usertags: libbpf1
> > > 
> > > Dear Maintainer,
> > > 
> > > v4l-utils FTBFS with libbpf 1.0.0 (available in experimental).
> > > This is the first error from the build log:
> > > 

<snip>

> > 
> > Sean, would you be able to port the existing code to libbpf 1.0? I noticed
> > that the current code already triggers deprecation warnings with libbpf
> > 0.8.0.
> 
> This needs porting, I'll add it to my todo list.

Can you please test the attached patch and confirm that it does not break
any of the functionality. This is the only one now which is blocking me
from requesting libbbpf transition.

-- 
Regards
Sudip
diff -Nru v4l-utils-1.22.1/debian/changelog v4l-utils-1.22.1/debian/changelog
--- v4l-utils-1.22.1/debian/changelog	2022-05-22 14:08:50.000000000 +0100
+++ v4l-utils-1.22.1/debian/changelog	2022-10-29 11:33:37.000000000 +0100
@@ -1,3 +1,10 @@
+v4l-utils (1.22.1-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Port changes for libbpf/1.0.1
+
+ -- Sudip Mukherjee <sudipm.mukher...@gmail.com>  Sat, 29 Oct 2022 11:33:37 +0100
+
 v4l-utils (1.22.1-4) unstable; urgency=high
 
   * Bump standards to version 4.6.1.0 (no changes needed)
diff -Nru v4l-utils-1.22.1/debian/patches/libbpf.patch v4l-utils-1.22.1/debian/patches/libbpf.patch
--- v4l-utils-1.22.1/debian/patches/libbpf.patch	1970-01-01 01:00:00.000000000 +0100
+++ v4l-utils-1.22.1/debian/patches/libbpf.patch	2022-10-29 11:33:37.000000000 +0100
@@ -0,0 +1,113 @@
+Description: Changes for libbpf/1.0.1
+
+Author: Sudip Mukherjee <sudipm.mukher...@gmail.com>
+
+---
+
+Bug-Debian: https://bugs.debian.org/1018915
+Forwarded: no
+
+--- 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) {
diff -Nru v4l-utils-1.22.1/debian/patches/series v4l-utils-1.22.1/debian/patches/series
--- v4l-utils-1.22.1/debian/patches/series	2021-10-15 17:59:25.000000000 +0100
+++ v4l-utils-1.22.1/debian/patches/series	2022-10-29 11:33:37.000000000 +0100
@@ -1 +1,2 @@
 dont-gererate-treeview.diff
+libbpf.patch

Reply via email to