Attempt to derive IP address family also from via in a route and add explicit default route to thetford and wireguard iface

This commit is contained in:
Alex D. 2024-09-20 06:50:12 +00:00
parent 28d66dcc64
commit a757587813
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 33 additions and 1 deletions

View File

@ -228,8 +228,17 @@ func (t *S6SvcTree) netdevRouteTemplate(iface Iface, route Route) (up, down stri
ExeclineXDGConfig(),
}
)
for _, v := range []netip.Addr{route.Net.Addr(), route.Via} {
if ipv != 0 {
break
}
if v.IsValid() {
ipv = NetdevIPAddrVer(v)
}
}
if ipv == 0 {
ipv = NetdevIPAddrVer(route.Net.Addr())
// Assume IPv6 if cannot derive
ipv = 6
}
svcname = append(svcname, fmt.Sprintf("%d", ipv))

View File

@ -150,6 +150,20 @@ func main() {
},
})
// Wireguard interfaces
ifs.AddIf(&s6netdev.Iface{
Name: "vultrbgp",
Type: &s6netdev.NetdevIfTypes.Wireguard,
Addresses: []netip.Prefix{
netip.MustParsePrefix("fe80::2/64"),
},
Sysctls: s6netdev.Sysctl_IP{
V6: []s6netdev.Property{
{Key: "forwarding", Value: "1", Default: "0"},
},
},
})
for _, m := range []struct {
Master string
Slaves []string
@ -163,6 +177,7 @@ func main() {
{
Master: "vrf-v6",
Slaves: []string{
"vultrbgp",
"b00b",
"f33d",
"d00d",
@ -230,6 +245,14 @@ func main() {
Metric: 4278198272,
})
// Default router for vrf (defrtr from ra isn't installed if autoconf not enabled)
ifs["b00b"].Routes = append(ifs["b00b"].Routes, s6netdev.Route{
Default: true,
Via: netip.MustParseAddr("fe80::ff:fe00:b00b"), // Link local of lakewood.united-states
Vrf: ifs["vrf-v6"],
Metric: 4096,
})
for _, v := range ifs {
t.Services(*v)
}