Add explicit static addresses and routes for both hypervisors

This commit is contained in:
Alex D. 2024-10-29 11:05:58 +00:00
parent 4c0f94fd79
commit 3d68806a9f
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 65 additions and 16 deletions

View File

@ -23,6 +23,13 @@ func main() {
Type: &s6netdev.NetdevIfTypes.Loopback,
})
// VRFs
ifs.AddIf(&s6netdev.Iface{
Name: "vrf-phys",
Type: &s6netdev.NetdevIfTypes.Vrf,
Table: 10,
})
// Physical interfaces
for _, v := range []string{"p4s0f0", "p4s0f1", "p2s0f0", "p2s0f1", "p2s0f2", "p2s0f3"} {
ifs.AddIf(&s6netdev.Iface{
@ -65,7 +72,6 @@ func main() {
ifs.AddIf(&s6netdev.Iface{
Name: "phys",
Type: &s6netdev.NetdevIfTypes.Bridge,
DHCP: s6netdev.DHCP_IP{V4: true},
Properties: []s6netdev.Property{
{Key: "priority", Value: "16384", Default: "32768"},
{Key: "stp_state", Value: "1", Default: "0"},
@ -74,9 +80,34 @@ func main() {
Sysctls: s6netdev.Sysctl_IP{
V6: []s6netdev.Property{
{Key: "forwarding", Value: "0", Default: "0"},
{Key: "accept_ra", Value: "0", Default: "1"},
},
},
})
// Currently there exists no mechanism to depend routes on the addresses, these are manual deps
phys_defrt_v4 := t.NetdevRoute(*ifs["phys"],
s6netdev.Route{
Default: true,
IPver: 4,
Vrf: ifs["vrf-phys"],
Via: netip.MustParseAddr("10.24.0.1"),
Metric: 1024,
},
)
phys_addr_v4 := t.NetdevIfaceAddr(*ifs["phys"], netip.MustParsePrefix("10.24.0.10/24"))
phys_defrt_v4.Children = append(phys_defrt_v4.Children, phys_addr_v4)
phys_defrt_v6 := t.NetdevRoute(*ifs["phys"],
s6netdev.Route{
Default: true,
IPver: 6,
Vrf: ifs["vrf-phys"],
Via: netip.MustParseAddr("fe80::2e91:abff:fe90:9bb5"),
Metric: 1024,
},
)
phys_addr_v6 := t.NetdevIfaceAddr(*ifs["phys"], netip.MustParsePrefix("2a02:810d:95bf:f999:921b:eff:fee3:9e84/64"))
phys_defrt_v6.Children = append(phys_defrt_v6.Children, phys_addr_v6)
// Private Bridges
for _, name := range []string{
@ -101,13 +132,6 @@ func main() {
})
}
// VRFs
ifs.AddIf(&s6netdev.Iface{
Name: "vrf-phys",
Type: &s6netdev.NetdevIfTypes.Vrf,
Table: 10,
})
for _, m := range []struct {
Master string
Slaves []string

View File

@ -23,6 +23,13 @@ func main() {
Type: &s6netdev.NetdevIfTypes.Loopback,
})
// VRFs
ifs.AddIf(&s6netdev.Iface{
Name: "vrf-phys",
Type: &s6netdev.NetdevIfTypes.Vrf,
Table: 10,
})
// Physical interfaces
for _, v := range []string{"p129s0f0", "p129s0f1", "p131s0f0", "p131s0f1", "p131s0f2", "p131s0f3"} {
ifs.AddIf(&s6netdev.Iface{
@ -65,7 +72,6 @@ func main() {
ifs.AddIf(&s6netdev.Iface{
Name: "phys",
Type: &s6netdev.NetdevIfTypes.Bridge,
DHCP: s6netdev.DHCP_IP{V4: true},
Properties: []s6netdev.Property{
{Key: "priority", Value: "16384", Default: "32768"},
{Key: "stp_state", Value: "1", Default: "0"},
@ -74,10 +80,36 @@ func main() {
Sysctls: s6netdev.Sysctl_IP{
V6: []s6netdev.Property{
{Key: "forwarding", Value: "0", Default: "0"},
{Key: "accept_ra", Value: "0", Default: "1"},
},
},
})
// Currently there exists no mechanism to depend routes on the addresses, these are manual deps
phys_addr_v4 := t.NetdevIfaceAddr(*ifs["phys"], netip.MustParsePrefix("10.24.0.11/24"))
phys_defrt_v4_vrf := t.NetdevRoute(*ifs["phys"],
s6netdev.Route{
Default: true,
IPver: 4,
Vrf: ifs["vrf-phys"],
Via: netip.MustParseAddr("10.24.0.1"),
Metric: 1024,
},
)
phys_defrt_v4_vrf.Children = append(phys_defrt_v4_vrf.Children, phys_addr_v4)
phys_addr_v6 := t.NetdevIfaceAddr(*ifs["phys"], netip.MustParsePrefix("2a02:810d:95bf:f999:921b:eff:fe55:75ab/64"))
phys_defrt_v6_vrf := t.NetdevRoute(*ifs["phys"],
s6netdev.Route{
Default: true,
IPver: 6,
Vrf: ifs["vrf-phys"],
Via: netip.MustParseAddr("fe80::2e91:abff:fe90:9bb5"),
Metric: 1024,
},
)
phys_defrt_v6_vrf.Children = append(phys_defrt_v6_vrf.Children, phys_addr_v6)
// Private Bridges
for _, name := range []string{
"b00b",
@ -101,13 +133,6 @@ func main() {
})
}
// VRFs
ifs.AddIf(&s6netdev.Iface{
Name: "vrf-phys",
Type: &s6netdev.NetdevIfTypes.Vrf,
Table: 10,
})
for _, m := range []struct {
Master string
Slaves []string