Skip to content

Commit fb085c2

Browse files
committed
systemd-networkd: add option to ignore devices by pciAddress
1 parent e7b2ca7 commit fb085c2

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

hosts/adelaide.nix

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# iommu for sebastians students
66
../modules/vfio/iommu-intel.nix
77
../modules/disko-zfs.nix
8+
../modules/dpdk.nix
89
];
910

1011
disko.rootDisk = "/dev/sdc";
@@ -15,4 +16,9 @@
1516

1617
system.stateVersion = "21.11";
1718

19+
boot.hugepages1GB.number = 20;
20+
systemd.network.ignorePci = [
21+
"0000:00:1c.0"
22+
"0000:00:1c.1"
23+
];
1824
}

hosts/christina.nix

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
];
99

1010
boot.hugepages1GB.number = 8;
11+
systemd.network.ignorePci = [
12+
"0000:00:1c.0"
13+
"0000:00:1c.1"
14+
];
1115

1216
networking.hostName = "christina";
1317

modules/dpdk.nix

+22-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ with lib;
2727
'';
2828
default = true;
2929
};
30+
systemd.network.ignorePci = mkOption {
31+
type = types.listOf types.nonEmptyStr;
32+
description = ''
33+
Pci addresses to be ignored by systemd-networkd.
34+
'';
35+
default = [];
36+
};
3037
};
3138
config = {
3239
boot.kernelParams = [
@@ -59,8 +66,21 @@ with lib;
5966
users.groups.kvm.members = lib.optionals config.users.addAllToKvm (
6067
builtins.attrNames (lib.filterAttrs (_userName: user: user.isNormalUser) config.users.users)
6168
);
62-
systemd.network.networks = {
63-
# leave container interfaces alone
69+
systemd.network.networks = let
70+
ignoreConfig = pciAddress: ''
71+
[Match]
72+
Property=DEVPATH=/devices/pci0000:00/${pciAddress}/*
73+
74+
[Link]
75+
Unmanaged = yes
76+
'';
77+
pciIgnoreRules = builtins.listToAttrs ( builtins.map (
78+
pciAddress: {
79+
name = "09-ignore-${pciAddress}";
80+
value = { extraConfig = (ignoreConfig pciAddress); };
81+
}) config.systemd.network.ignorePci);
82+
in pciIgnoreRules // {
83+
# leave 100G interfaces alone
6484
"09-ignore-e810".extraConfig = ''
6585
[Match]
6686
Driver = ice

0 commit comments

Comments
 (0)