mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
core: rename socket-bind.[ch] → bpf-socket-bind.[ch]
The other BPF infra has a file name prefix of "bpf-" hence do so here too.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#endif
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "socket-bind.h"
|
||||
#include "bpf-socket-bind.h"
|
||||
|
||||
#if BPF_FRAMEWORK
|
||||
/* libbpf, clang, llvm and bpftool compile time dependencies are satisfied */
|
||||
@@ -114,7 +114,7 @@ static int prepare_socket_bind_bpf(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int socket_bind_supported(void) {
|
||||
int bpf_socket_bind_supported(void) {
|
||||
_cleanup_(socket_bind_bpf_freep) struct socket_bind_bpf *obj = NULL;
|
||||
int r;
|
||||
|
||||
@@ -143,7 +143,7 @@ int socket_bind_supported(void) {
|
||||
return can_link_bpf_program(obj->progs.sd_bind4);
|
||||
}
|
||||
|
||||
int socket_bind_add_initial_link_fd(Unit *u, int fd) {
|
||||
int bpf_socket_bind_add_initial_link_fd(Unit *u, int fd) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
@@ -208,7 +208,7 @@ static int socket_bind_install_impl(Unit *u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int socket_bind_install(Unit *u) {
|
||||
int bpf_socket_bind_install(Unit *u) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
@@ -221,7 +221,7 @@ int socket_bind_install(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int serialize_socket_bind(Unit *u, FILE *f, FDSet *fds) {
|
||||
int bpf_serialize_socket_bind(Unit *u, FILE *f, FDSet *fds) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
@@ -234,19 +234,19 @@ int serialize_socket_bind(Unit *u, FILE *f, FDSet *fds) {
|
||||
}
|
||||
|
||||
#else /* ! BPF_FRAMEWORK */
|
||||
int socket_bind_supported(void) {
|
||||
int bpf_socket_bind_supported(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int socket_bind_add_initial_link_fd(Unit *u, int fd) {
|
||||
int bpf_socket_bind_add_initial_link_fd(Unit *u, int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int socket_bind_install(Unit *u) {
|
||||
int bpf_socket_bind_install(Unit *u) {
|
||||
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP), "Failed to install socket bind: BPF framework is not supported");
|
||||
}
|
||||
|
||||
int serialize_socket_bind(Unit *u, FILE *f, FDSet *fds) {
|
||||
int bpf_serialize_socket_bind(Unit *u, FILE *f, FDSet *fds) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
15
src/core/bpf-socket-bind.h
Normal file
15
src/core/bpf-socket-bind.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "fdset.h"
|
||||
#include "unit.h"
|
||||
|
||||
int bpf_socket_bind_supported(void);
|
||||
|
||||
/* Add BPF link fd created before daemon-reload or daemon-reexec. FDs will be closed at the end of
|
||||
* socket_bind_install. */
|
||||
int bpf_socket_bind_add_initial_link_fd(Unit *u, int fd);
|
||||
|
||||
int bpf_socket_bind_install(Unit *u);
|
||||
|
||||
int bpf_serialize_socket_bind(Unit *u, FILE *f, FDSet *fds);
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "bpf-devices.h"
|
||||
#include "bpf-firewall.h"
|
||||
#include "bpf-foreign.h"
|
||||
#include "bpf-socket-bind.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "cgroup-setup.h"
|
||||
@@ -26,7 +27,6 @@
|
||||
#include "percent-util.h"
|
||||
#include "process-util.h"
|
||||
#include "procfs-util.h"
|
||||
#include "socket-bind.h"
|
||||
#include "special.h"
|
||||
#include "stat-util.h"
|
||||
#include "stdio-util.h"
|
||||
@@ -1096,7 +1096,7 @@ static void cgroup_apply_firewall(Unit *u) {
|
||||
static void cgroup_apply_socket_bind(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
(void) socket_bind_install(u);
|
||||
(void) bpf_socket_bind_install(u);
|
||||
}
|
||||
|
||||
static int cgroup_apply_devices(Unit *u) {
|
||||
@@ -3126,7 +3126,7 @@ static int cg_bpf_mask_supported(CGroupMask *ret) {
|
||||
mask |= CGROUP_MASK_BPF_FOREIGN;
|
||||
|
||||
/* BPF-based bind{4|6} hooks */
|
||||
r = socket_bind_supported();
|
||||
r = bpf_socket_bind_supported();
|
||||
if (r > 0)
|
||||
mask |= CGROUP_MASK_BPF_SOCKET_BIND;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "bpf-firewall.h"
|
||||
#include "bpf-program.h"
|
||||
#include "bpf-socket-bind.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-internal.h"
|
||||
#include "bus-util.h"
|
||||
@@ -55,7 +56,6 @@
|
||||
#endif
|
||||
#include "securebits-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-bind.h"
|
||||
#include "socket-netlink.h"
|
||||
#include "specifier.h"
|
||||
#include "stat-util.h"
|
||||
|
||||
@@ -13,6 +13,8 @@ libcore_sources = '''
|
||||
bpf-firewall.h
|
||||
bpf-foreign.c
|
||||
bpf-foreign.h
|
||||
bpf-socket-bind.c
|
||||
bpf-socket-bind.h
|
||||
cgroup.c
|
||||
cgroup.h
|
||||
core-varlink.c
|
||||
@@ -83,10 +85,10 @@ libcore_sources = '''
|
||||
load-fragment.h
|
||||
locale-setup.c
|
||||
locale-setup.h
|
||||
manager.c
|
||||
manager.h
|
||||
manager-dump.c
|
||||
manager-dump.h
|
||||
manager.c
|
||||
manager.h
|
||||
mount.c
|
||||
mount.h
|
||||
namespace.c
|
||||
@@ -107,8 +109,6 @@ libcore_sources = '''
|
||||
slice.h
|
||||
smack-setup.c
|
||||
smack-setup.h
|
||||
socket-bind.c
|
||||
socket-bind.h
|
||||
socket.c
|
||||
socket.h
|
||||
swap.c
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include "fdset.h"
|
||||
#include "unit.h"
|
||||
|
||||
int socket_bind_supported(void);
|
||||
|
||||
/* Add BPF link fd created before daemon-reload or daemon-reexec.
|
||||
* FDs will be closed at the end of socket_bind_install. */
|
||||
int socket_bind_add_initial_link_fd(Unit *u, int fd);
|
||||
|
||||
int socket_bind_install(Unit *u);
|
||||
|
||||
int serialize_socket_bind(Unit *u, FILE *f, FDSet *fds);
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "bpf-socket-bind.h"
|
||||
#include "bus-util.h"
|
||||
#include "dbus.h"
|
||||
#include "fileio-label.h"
|
||||
@@ -7,7 +8,6 @@
|
||||
#include "format-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "serialize.h"
|
||||
#include "socket-bind.h"
|
||||
#include "string-table.h"
|
||||
#include "unit-serialize.h"
|
||||
#include "user-util.h"
|
||||
@@ -164,7 +164,7 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool switching_root) {
|
||||
(void) serialize_cgroup_mask(f, "cgroup-enabled-mask", u->cgroup_enabled_mask);
|
||||
(void) serialize_cgroup_mask(f, "cgroup-invalidated-mask", u->cgroup_invalidated_mask);
|
||||
|
||||
(void) serialize_socket_bind(u, f, fds);
|
||||
(void) bpf_serialize_socket_bind(u, f, fds);
|
||||
|
||||
if (uid_is_valid(u->ref_uid))
|
||||
(void) serialize_item_format(f, "ref-uid", UID_FMT, u->ref_uid);
|
||||
@@ -389,7 +389,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(void) socket_bind_add_initial_link_fd(u, fd);
|
||||
(void) bpf_socket_bind_add_initial_link_fd(u, fd);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "bpf-firewall.h"
|
||||
#include "bpf-foreign.h"
|
||||
#include "bpf-socket-bind.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-setup.h"
|
||||
@@ -41,7 +42,6 @@
|
||||
#include "rm-rf.h"
|
||||
#include "set.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-bind.h"
|
||||
#include "sparse-endian.h"
|
||||
#include "special.h"
|
||||
#include "specifier.h"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "bpf-socket-bind.h"
|
||||
#include "load-fragment.h"
|
||||
#include "manager.h"
|
||||
#include "process-util.h"
|
||||
#include "rlimit-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "service.h"
|
||||
#include "socket-bind.h"
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
#include "unit.h"
|
||||
@@ -122,7 +122,7 @@ int main(int argc, char *argv[]) {
|
||||
if (!can_memlock())
|
||||
return log_tests_skipped("Can't use mlock(), skipping.");
|
||||
|
||||
r = socket_bind_supported();
|
||||
r = bpf_socket_bind_supported();
|
||||
if (r <= 0)
|
||||
return log_tests_skipped("socket-bind is not supported, skipping.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user