/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "fd-util.h"
-#include "restrict-ifaces.h"
+#include "bpf-restrict-ifaces.h"
#include "netlink-util.h"
#if BPF_FRAMEWORK
return 0;
}
-int restrict_network_interfaces_supported(void) {
+int bpf_restrict_ifaces_supported(void) {
_cleanup_(restrict_ifaces_bpf_freep) struct restrict_ifaces_bpf *obj = NULL;
static int supported = -1;
int r;
return (supported = bpf_can_link_program(obj->progs.sd_restrictif_i));
}
-static int restrict_network_interfaces_install_impl(Unit *u) {
+static int restrict_ifaces_install_impl(Unit *u) {
_cleanup_(bpf_link_freep) struct bpf_link *egress_link = NULL, *ingress_link = NULL;
_cleanup_(restrict_ifaces_bpf_freep) struct restrict_ifaces_bpf *obj = NULL;
_cleanup_free_ char *cgroup_path = NULL;
return 0;
}
-int restrict_network_interfaces_install(Unit *u) {
- int r = restrict_network_interfaces_install_impl(u);
+int bpf_restrict_ifaces_install(Unit *u) {
+ int r;
+
+ r = restrict_ifaces_install_impl(u);
fdset_close(u->initial_restric_ifaces_link_fds);
return r;
}
-int serialize_restrict_network_interfaces(Unit *u, FILE *f, FDSet *fds) {
+int bpf_restrict_ifaces_serialize(Unit *u, FILE *f, FDSet *fds) {
int r;
assert(u);
return bpf_serialize_link(f, fds, "restrict-ifaces-bpf-fd", u->restrict_ifaces_egress_bpf_link);
}
-int restrict_network_interfaces_add_initial_link_fd(Unit *u, int fd) {
+int bpf_restrict_ifaces_add_initial_link_fd(Unit *u, int fd) {
int r;
assert(u);
}
#else /* ! BPF_FRAMEWORK */
-int restrict_network_interfaces_supported(void) {
+int bpf_restrict_ifaces_supported(void) {
return 0;
}
-int restrict_network_interfaces_install(Unit *u) {
+int bpf_restrict_ifaces_install(Unit *u) {
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP),
"restrict-interfaces: Failed to install; BPF programs built from source code are not supported: %m");
}
-int serialize_restrict_network_interfaces(Unit *u, FILE *f, FDSet *fds) {
+int bpf_restrict_ifaces_serialize(Unit *u, FILE *f, FDSet *fds) {
return 0;
}
-int restrict_network_interfaces_add_initial_link_fd(Unit *u, int fd) {
+int bpf_restrict_ifaces_add_initial_link_fd(Unit *u, int fd) {
return 0;
}
#endif
typedef struct Unit Unit;
-int restrict_network_interfaces_supported(void);
-int restrict_network_interfaces_install(Unit *u);
+int bpf_restrict_ifaces_supported(void);
+int bpf_restrict_ifaces_install(Unit *u);
-int serialize_restrict_network_interfaces(Unit *u, FILE *f, FDSet *fds);
+int bpf_restrict_ifaces_serialize(Unit *u, FILE *f, FDSet *fds);
/* Add BPF link fd created before daemon-reload or daemon-reexec.
* FDs will be closed at the end of restrict_network_interfaces_install. */
-int restrict_network_interfaces_add_initial_link_fd(Unit *u, int fd);
+int bpf_restrict_ifaces_add_initial_link_fd(Unit *u, int fd);
#include "bpf-devices.h"
#include "bpf-firewall.h"
#include "bpf-foreign.h"
+#include "bpf-restrict-ifaces.h"
#include "bpf-socket-bind.h"
#include "btrfs-util.h"
#include "bus-error.h"
#include "percent-util.h"
#include "process-util.h"
#include "procfs-util.h"
-#include "restrict-ifaces.h"
#include "set.h"
#include "special.h"
#include "stdio-util.h"
static void cgroup_apply_restrict_network_interfaces(Unit *u) {
assert(u);
- (void) restrict_network_interfaces_install(u);
+ (void) bpf_restrict_ifaces_install(u);
}
static int cgroup_apply_devices(Unit *u) {
mask |= CGROUP_MASK_BPF_SOCKET_BIND;
/* BPF-based cgroup_skb/{egress|ingress} hooks */
- r = restrict_network_interfaces_supported();
+ r = bpf_restrict_ifaces_supported();
if (r < 0)
return r;
if (r > 0)
'bpf-firewall.c',
'bpf-foreign.c',
'bpf-restrict-fs.c',
+ 'bpf-restrict-ifaces.c',
'bpf-socket-bind.c',
'cgroup.c',
'core-varlink.c',
'mount.c',
'namespace.c',
'path.c',
- 'restrict-ifaces.c',
'scope.c',
'selinux-access.c',
'selinux-setup.c',
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "bpf-restrict-ifaces.h"
#include "bpf-socket-bind.h"
#include "bus-util.h"
#include "dbus.h"
#include "fileio.h"
#include "format-util.h"
#include "parse-util.h"
-#include "restrict-ifaces.h"
#include "serialize.h"
#include "string-table.h"
#include "unit-serialize.h"
(void) bpf_program_serialize_attachment_set(f, fds, "ip-bpf-custom-ingress-installed", u->ip_bpf_custom_ingress_installed);
(void) bpf_program_serialize_attachment_set(f, fds, "ip-bpf-custom-egress-installed", u->ip_bpf_custom_egress_installed);
- (void) serialize_restrict_network_interfaces(u, f, fds);
+ (void) bpf_restrict_ifaces_serialize(u, f, fds);
if (uid_is_valid(u->ref_uid))
(void) serialize_item_format(f, "ref-uid", UID_FMT, u->ref_uid);
fd = deserialize_fd(fds, v);
if (fd >= 0)
- (void) restrict_network_interfaces_add_initial_link_fd(u, fd);
+ (void) bpf_restrict_ifaces_add_initial_link_fd(u, fd);
continue;