Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libbpf for openSUSE:Factory checked in at 2024-05-16 17:12:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libbpf (Old) and /work/SRC/openSUSE:Factory/.libbpf.new.1880 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libbpf" Thu May 16 17:12:33 2024 rev:21 rq:1173943 version:1.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/libbpf/libbpf.changes 2024-05-03 00:10:26.156622669 +0200 +++ /work/SRC/openSUSE:Factory/.libbpf.new.1880/libbpf.changes 2024-05-16 17:12:35.222293737 +0200 @@ -1,0 +2,12 @@ +Sat May 11 07:03:51 UTC 2024 - Fredrik Lönnegren <[email protected]> + +- update to 1.4.2: + * Another struct_ops-focused bug fix release. It addresses a few more corner + cases when dealing with SEC("struct_ops") programs. + * It also improves error messaging around common use case of declaring + struct_ops BPF program and not referencing it from SEC(".struct_ops") + variable (backed by struct_ops BPF map). + * This release should improve overall experience of using BPF struct_ops + functionality. + +------------------------------------------------------------------- Old: ---- libbpf-1.4.1.tar.gz New: ---- libbpf-1.4.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libbpf.spec ++++++ --- /var/tmp/diff_new_pack.T1sYTl/_old 2024-05-16 17:12:40.098470468 +0200 +++ /var/tmp/diff_new_pack.T1sYTl/_new 2024-05-16 17:12:40.098470468 +0200 @@ -19,7 +19,7 @@ %define sover_major 1 %define libname libbpf%{sover_major} Name: libbpf -Version: 1.4.1 +Version: 1.4.2 Release: 0 Summary: C library for managing eBPF programs and maps License: LGPL-2.1-only ++++++ libbpf-1.4.1.tar.gz -> libbpf-1.4.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libbpf-1.4.1/src/Makefile new/libbpf-1.4.2/src/Makefile --- old/libbpf-1.4.1/src/Makefile 2024-05-02 02:16:13.000000000 +0200 +++ new/libbpf-1.4.2/src/Makefile 2024-05-10 22:57:28.000000000 +0200 @@ -10,7 +10,7 @@ LIBBPF_MAJOR_VERSION := 1 LIBBPF_MINOR_VERSION := 4 -LIBBPF_PATCH_VERSION := 1 +LIBBPF_PATCH_VERSION := 2 LIBBPF_VERSION := $(LIBBPF_MAJOR_VERSION).$(LIBBPF_MINOR_VERSION).$(LIBBPF_PATCH_VERSION) LIBBPF_MAJMIN_VERSION := $(LIBBPF_MAJOR_VERSION).$(LIBBPF_MINOR_VERSION).0 LIBBPF_MAP_VERSION := $(shell grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | sort -rV | head -n1 | cut -d'_' -f2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libbpf-1.4.1/src/libbpf.c new/libbpf-1.4.2/src/libbpf.c --- old/libbpf-1.4.1/src/libbpf.c 2024-05-02 02:16:13.000000000 +0200 +++ new/libbpf-1.4.2/src/libbpf.c 2024-05-10 22:57:28.000000000 +0200 @@ -1150,22 +1150,15 @@ return -ENOTSUP; } - prog = st_ops->progs[i]; - if (prog) { + if (st_ops->progs[i]) { /* If we had declaratively set struct_ops callback, we need to - * first validate that it's actually a struct_ops program. - * And then force its autoload to false, because it doesn't have + * force its autoload to false, because it doesn't have * a chance of succeeding from POV of the current struct_ops map. * If this program is still referenced somewhere else, though, * then bpf_object_adjust_struct_ops_autoload() will update its * autoload accordingly. */ - if (!is_valid_st_ops_program(obj, prog)) { - pr_warn("struct_ops init_kern %s: member %s is declaratively assigned a non-struct_ops program\n", - map->name, mname); - return -EINVAL; - } - prog->autoload = false; + st_ops->progs[i]->autoload = false; st_ops->progs[i] = NULL; } @@ -1198,11 +1191,19 @@ } if (btf_is_ptr(mtype)) { - /* Update the value from the shadow type */ prog = *(void **)mdata; + /* just like for !kern_member case above, reset declaratively + * set (at compile time) program's autload to false, + * if user replaced it with another program or NULL + */ + if (st_ops->progs[i] && st_ops->progs[i] != prog) + st_ops->progs[i]->autoload = false; + + /* Update the value from the shadow type */ st_ops->progs[i] = prog; if (!prog) continue; + if (!is_valid_st_ops_program(obj, prog)) { pr_warn("struct_ops init_kern %s: member %s is not a struct_ops program\n", map->name, mname); @@ -7355,7 +7356,11 @@ __u32 log_level = prog->log_level; int ret, err; - if (prog->type == BPF_PROG_TYPE_UNSPEC) { + /* Be more helpful by rejecting programs that can't be validated early + * with more meaningful and actionable error message. + */ + switch (prog->type) { + case BPF_PROG_TYPE_UNSPEC: /* * The program type must be set. Most likely we couldn't find a proper * section definition at load time, and thus we didn't infer the type. @@ -7363,6 +7368,15 @@ pr_warn("prog '%s': missing BPF prog type, check ELF section name '%s'\n", prog->name, prog->sec_name); return -EINVAL; + case BPF_PROG_TYPE_STRUCT_OPS: + if (prog->attach_btf_id == 0) { + pr_warn("prog '%s': SEC(\"struct_ops\") program isn't referenced anywhere, did you forget to use it?\n", + prog->name); + return -EINVAL; + } + break; + default: + break; } if (!insns || !insns_cnt) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libbpf-1.4.1/src/str_error.c new/libbpf-1.4.2/src/str_error.c --- old/libbpf-1.4.1/src/str_error.c 2024-05-02 02:16:13.000000000 +0200 +++ new/libbpf-1.4.2/src/str_error.c 2024-05-10 22:57:28.000000000 +0200 @@ -2,6 +2,7 @@ #undef _GNU_SOURCE #include <string.h> #include <stdio.h> +#include <errno.h> #include "str_error.h" /* make sure libbpf doesn't use kernel-only integer typedefs */ @@ -15,7 +16,18 @@ char *libbpf_strerror_r(int err, char *dst, int len) { int ret = strerror_r(err < 0 ? -err : err, dst, len); - if (ret) - snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); + /* on glibc <2.13, ret == -1 and errno is set, if strerror_r() can't + * handle the error, on glibc >=2.13 *positive* (errno-like) error + * code is returned directly + */ + if (ret == -1) + ret = errno; + if (ret) { + if (ret == EINVAL) + /* strerror_r() doesn't recognize this specific error */ + snprintf(dst, len, "unknown error (%d)", err < 0 ? err : -err); + else + snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); + } return dst; }
