From 43bc14032d39a06f04d302977aa72558ee5a91e6 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 6 Mar 2023 10:53:12 +0100 Subject: vidhar: cake --- hosts/vidhar/network/dsl.nix | 45 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/hosts/vidhar/network/dsl.nix b/hosts/vidhar/network/dsl.nix index 5b7c5ac7..7a1dab58 100644 --- a/hosts/vidhar/network/dsl.nix +++ b/hosts/vidhar/network/dsl.nix @@ -59,13 +59,44 @@ in { }; environment.etc = { - "ppp/ip-up" = { - text = '' - #!${pkgs.runtimeShell} - ${pkgs.iproute2}/bin/ip route add default via "$5" dev "${pppInterface}" metric 512 - ''; - mode = "0555"; - }; + "ppp/ip-pre-up".source = let + app = pkgs.writeShellApplication { + name = "ip-pre-up"; + runtimeInputs = with pkgs; [ iproute2 ethtool ]; + text = '' + ethtool -K telekom tso off gso off gro off + + tc qdisc replace dev "${pppInterface}" root cake pppoe-ptm nat bandwidth 35mbit + + modprobe ifb + ip link del "ifb4${pppInterface}" || true + ip link add name "ifb4${pppInterface}" type ifb + tc qdisc del dev "${pppInterface}" ingress || true + tc qdisc add dev "${pppInterface}" handle ffff: ingress + tc qdisc replace dev "ifb4${pppInterface}" root cake pppoe-ptm bandwidth 93mbit + ip link set "ifb4${pppInterface}" up + tc filter add dev "${pppInterface}" parent ffff: matchall action mirred egress redirect dev "ifb4${pppInterface}" + ''; + }; + in "${app}/bin/${app.meta.mainProgram}"; + "ppp/ip-up".source = let + app = pkgs.writeShellApplication { + name = "ip-up"; + runtimeInputs = with pkgs; [ iproute2 ]; + text = '' + ip route add default via "$5" dev "${pppInterface}" metric 512 + ''; + }; + in "${app}/bin/${app.meta.mainProgram}"; + "ppp/ip-down".source = let + app = pkgs.writeShellApplication { + name = "ip-down"; + runtimeInputs = with pkgs; [ iproute2 ]; + text = '' + ip link del "ifb4${pppInterface}" + ''; + }; + in "${app}/bin/${app.meta.mainProgram}"; }; systemd.network.networks.${pppInterface} = { -- cgit v1.2.3