commit 46ed8f01990a6a7374d1049bdb6ca29a9a2d57d7
parent dd44fbaec129863befa3a549254c6e3f8d043ba5
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 27 Mar 2025 20:23:26 +0000
add bandwidth as a service option for ppp (l2tp, pppoe)
Diffstat:
5 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/examples/rotuer.nix b/examples/rotuer.nix
@@ -71,6 +71,7 @@ rec {
interface = config.hardware.networkInterfaces.wan;
username = secrets.l2tp.name;
password = secrets.l2tp.password;
+ bandwidth = 70 * 1000 * 1000;
};
# once the wan has ipv4 connnectivity, should we run dhcp6
# client to potentially get an address range ("prefix
diff --git a/modules/ppp/common.nix b/modules/ppp/common.nix
@@ -13,6 +13,7 @@
username,
password,
lcpEcho,
+ bandwidth,
ppp-options,
dependencies ? [ ],
}:
@@ -115,7 +116,7 @@ let
${command}
'';
notification-fd = 10;
-# properties.bandwidth = 3 * 1000 * 1000;
+ properties.bandwidth = bandwidth;
timeout-up =
if lcpEcho.failure != null then (10 + lcpEcho.failure * lcpEcho.interval) * 1000 else 60 * 1000;
inherit dependencies;
diff --git a/modules/ppp/default.nix b/modules/ppp/default.nix
@@ -56,6 +56,11 @@ in
default = null;
description = "password";
};
+ bandwidth = mkOption {
+ type = types.nullOr (types.int);
+ default = null;
+ description = "approximate bandwidth in bytes/second. Used to calculate rate limits for ICMP";
+ };
lcpEcho = {
adaptive = mkOption {
description = "send LCP echo-request frames only if no traffic was received from the peer since the last echo-request was sent";
diff --git a/modules/ppp/l2tp.nix b/modules/ppp/l2tp.nix
@@ -13,6 +13,7 @@
lns,
ppp-options,
lcpEcho,
+ bandwidth,
username,
password,
debug,
@@ -40,6 +41,7 @@ common {
username
password
lcpEcho
+ bandwidth
ppp-options
;
command = ''
diff --git a/modules/ppp/pppoe.nix b/modules/ppp/pppoe.nix
@@ -13,6 +13,7 @@
interface,
ppp-options,
lcpEcho,
+ bandwidth,
username,
password,
debug,
@@ -31,6 +32,7 @@ common {
username
password
lcpEcho
+ bandwidth
ppp-options
;
command = ''