From 65fc81e0827c3bb8b52287921b1aa8c72e7ec77d Mon Sep 17 00:00:00 2001 From: clerie Date: Mon, 15 Dec 2025 20:31:51 +0100 Subject: [PATCH] hosts/carbon: Set rps_cpus for ppp interface --- hosts/carbon/ppp-ncfttb.nix | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hosts/carbon/ppp-ncfttb.nix b/hosts/carbon/ppp-ncfttb.nix index 6733c43..8518149 100644 --- a/hosts/carbon/ppp-ncfttb.nix +++ b/hosts/carbon/ppp-ncfttb.nix @@ -56,6 +56,46 @@ ]; }; + environment.etc."ppp/ipv6-up" = { + text = '' + #! ${pkgs.runtimeShell} -e + + ${pkgs.systemd}/bin/systemctl restart --no-block "ppp-setup-interface-queues@''${IFNAME}.service" + ${pkgs.systemd}/bin/systemctl restart --no-block ds-lite-dhcpcd.service + ''; + mode = "555"; + }; + + systemd.services."ppp-setup-interface-queues@".serviceConfig = let + setup-interface-queues = pkgs.clerie-build-support.writePythonScript { + name = "setup-interface-queues"; + text = '' + import multiprocessing + from pathlib import Path + import sys + + interface_name = sys.argv[1] + + print(f"New ppp interface: {interface_name}") + + num_cpus = multiprocessing.cpu_count() + + print(f"Detected {num_cpus} cpus") + + bitmask = "1" * num_cpus + hexmask = "{:x}".format(int(bitmask, 2)) + + rps_cpus = Path(f"/sys/class/net/{interface_name}/queues/rx-0/rps_cpus") + rps_cpus.write_text(hexmask) + + print(f"Wrote hexmask {hexmask} to {rps_cpus}") + ''; + }; + in { + Type = "oneshot"; + ExecStart = "${lib.getExe setup-interface-queues} %i"; + }; + clerie.firewall.extraForwardMangleCommands = '' ip46tables -t mangle -A forward-mangle -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu '';