Skip to content

Commit 54752b3

Browse files
committed
add onlink network config support
1 parent dff629d commit 54752b3

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

os/flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
(route: {
233233
destination = if (route.dst == "default") then "0.0.0.0/0" else route.dst;
234234
gateway = route.gateway;
235+
onlink = builtins.elem "onlink" route.flags;
235236
})
236237
(
237238
builtins.filter (
@@ -251,6 +252,7 @@
251252
routes = builtins.map (route: {
252253
Destination = route.destination;
253254
Gateway = route.gateway;
255+
GatewayOnLink = if (route.onlink) then "yes" else "no";
254256
}) interface.value.route;
255257
};
256258
}) network-config

os/installer/kexec.nix

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
systemd.services.apply-network-config = {
7979
wantedBy = [ "multi-user.target" ];
8080
description = "Apply run time provided network config.";
81-
wants = [ "network-pre.target" ];
82-
before = [ "network-pre.target" ];
81+
wants = [ "network-online.target" ];
82+
after = [ "network-online.target" ];
8383
serviceConfig = {
8484
Type = "oneshot";
8585
User = "root";
@@ -115,6 +115,8 @@
115115
ip address add $config dev $name
116116
done
117117
118+
ip link set $name up
119+
118120
for route in $routes; do
119121
protocol=$(echo "$route" | jq -r '.protocol')
120122
dev=$(echo "$route" | jq -r '.dev')
@@ -123,8 +125,15 @@
123125
continue
124126
fi
125127
126-
config="$(echo $route | jq -r '.dst') via $(echo $route | jq -r '.gateway')"
127-
ip route add $config dev $name
128+
args=""
129+
flags=$(echo "$route" | jq -r '.flags')
130+
if [[ $flags == *"onlink"* ]]; then
131+
args="$args onlink"
132+
fi
133+
134+
destination=$(echo $route | jq -r '.dst')
135+
gateway=$(echo $route | jq -r '.gateway')
136+
ip route add $destination via $gateway $args dev $name
128137
done
129138
done
130139
fi

0 commit comments

Comments
 (0)