Merge pull request #187714 from veehaitch/systemd-bpf-framework

systemd: enable `BPF_FRAMEWORK` by default (`withLibBPF=true`)
This commit is contained in:
Florian Klink 2022-08-21 16:59:14 +02:00 committed by GitHub
commit 4a641f7ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View file

@ -541,6 +541,7 @@ in {
systemd-analyze = handleTest ./systemd-analyze.nix {};
systemd-binfmt = handleTestOn ["x86_64-linux"] ./systemd-binfmt.nix {};
systemd-boot = handleTest ./systemd-boot.nix {};
systemd-bpf = handleTest ./systemd-bpf.nix {};
systemd-confinement = handleTest ./systemd-confinement.nix {};
systemd-coredump = handleTest ./systemd-coredump.nix {};
systemd-cryptenroll = handleTest ./systemd-cryptenroll.nix {};

View file

@ -0,0 +1,42 @@
import ./make-test-python.nix ({ lib, ... }: {
name = "systemd-bpf";
meta = with lib.maintainers; {
maintainers = [ veehaitch ];
};
nodes = {
node1 = {
virtualisation.vlans = [ 1 ];
networking = {
useNetworkd = true;
useDHCP = false;
firewall.enable = false;
interfaces.eth1.ipv4.addresses = [
{ address = "192.168.1.1"; prefixLength = 24; }
];
};
};
node2 = {
virtualisation.vlans = [ 1 ];
networking = {
useNetworkd = true;
useDHCP = false;
firewall.enable = false;
interfaces.eth1.ipv4.addresses = [
{ address = "192.168.1.2"; prefixLength = 24; }
];
};
};
};
testScript = ''
start_all()
node1.wait_for_unit("systemd-networkd-wait-online.service")
node2.wait_for_unit("systemd-networkd-wait-online.service")
with subtest("test RestrictNetworkInterfaces= works"):
node1.succeed("ping -c 5 192.168.1.2")
node1.succeed("systemd-run -t -p RestrictNetworkInterfaces='eth1' ping -c 5 192.168.1.2")
node1.fail("systemd-run -t -p RestrictNetworkInterfaces='lo' ping -c 5 192.168.1.2")
'';
})

View file

@ -83,7 +83,7 @@
, withHostnamed ? true
, withHwdb ? true
, withImportd ? !stdenv.hostPlatform.isMusl
, withLibBPF ? false # currently fails while generating BPF objects
, withLibBPF ? true
, withLocaled ? true
, withLogind ? true
, withMachined ? true
@ -207,6 +207,10 @@ stdenv.mkDerivation {
--replace \
"run_command(cc.cmd_array(), '-print-prog-name=objcopy', check: true).stdout().strip()" \
"'${stdenv.cc.bintools.targetPrefix}objcopy'"
'' + lib.optionalString withLibBPF ''
# BPF does not work with stack protector
substituteInPlace src/core/bpf/meson.build \
--replace "clang_flags = [" "clang_flags = [ '-fno-stack-protector',"
'' + (
let
# The following patches references to dynamic libraries to ensure that