From: Daan De Meyer Date: Tue, 15 Mar 2022 17:14:19 +0000 (+0000) Subject: bpf: Fix error handling X-Git-Tag: v251-rc1~144^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F22757%2Fhead;p=thirdparty%2Fsystemd.git bpf: Fix error handling The __open() functions actually set errno on failure so let's update the error handling to account for that. --- diff --git a/src/core/bpf-socket-bind.c b/src/core/bpf-socket-bind.c index c5176aa481a..806df84ea72 100644 --- a/src/core/bpf-socket-bind.c +++ b/src/core/bpf-socket-bind.c @@ -78,8 +78,7 @@ static int prepare_socket_bind_bpf( obj = socket_bind_bpf__open(); if (!obj) - return log_unit_full_errno(u, u ? LOG_ERR : LOG_DEBUG, SYNTHETIC_ERRNO(ENOMEM), - "Failed to open BPF object"); + return log_unit_full_errno(u, u ? LOG_ERR : LOG_DEBUG, errno, "Failed to open BPF object: %m"); if (sym_bpf_map__resize(obj->maps.sd_bind_allow, MAX(allow_count, 1u)) != 0) return log_unit_full_errno(u, u ? LOG_ERR : LOG_WARNING, errno, diff --git a/src/core/restrict-ifaces.c b/src/core/restrict-ifaces.c index 00dc4290789..efa5c8d85ab 100644 --- a/src/core/restrict-ifaces.c +++ b/src/core/restrict-ifaces.c @@ -34,8 +34,7 @@ static int prepare_restrict_ifaces_bpf( obj = restrict_ifaces_bpf__open(); if (!obj) - return log_unit_full_errno(u, u ? LOG_ERR : LOG_DEBUG, - SYNTHETIC_ERRNO(ENOMEM), "Failed to open BPF object"); + return log_unit_full_errno(u, u ? LOG_ERR : LOG_DEBUG, errno, "Failed to open BPF object: %m"); r = sym_bpf_map__resize(obj->maps.sd_restrictif, MAX(set_size(restrict_network_interfaces), 1u)); if (r != 0)