controllers: evpn: fix null routes order && ipv6

- don't duplicate ip
- ipv6 use "ipv6 route"
- order correctly

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2023-12-03 16:46:10 +01:00 committed by Thomas Lamprecht
parent dbacff605f
commit d7d1181ed5
4 changed files with 65 additions and 1 deletions

View file

@ -162,11 +162,25 @@ sub generate_controller_zone_config {
#null routes subnets of other zones
if ($is_gateway) {
my $subnets = PVE::Network::SDN::Vnets::get_subnets();
my $cidrs = {};
foreach my $subnetid (sort keys %{$subnets}) {
my $subnet = $subnets->{$subnetid};
my $cidr = $subnet->{cidr};
my $zone = $subnet->{zone};
push @controller_config, "ip route $cidr null0" if $zone ne $id;
my ($ip, $mask) = split(/\//, $cidr);
$cidrs->{$ip} = $mask if $zone ne $id;
}
my @sorted_ip =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, eval { Net::IP->new( $_ )->intip } ] }
keys %{$cidrs} if $cidrs;
foreach my $ip (@sorted_ip) {
my $ipversion = Net::IP::ip_is_ipv4($ip) ? 'ip' : 'ipv6';
push @controller_config, "$ipversion route $ip/$cidrs->{$ip} null0";
}
}

View file

@ -7,13 +7,20 @@ service integrated-vtysh-config
!
vrf vrf_myzone
vni 1000
ip route 10.0.0.0/24 null0
ip route 172.16.0.0/24 null0
ip route 172.16.1.0/24 null0
ip route 172.16.3.0/24 null0
exit-vrf
!
vrf vrf_myzone2
vni 1001
ip route 10.0.0.0/24 null0
ip route 192.168.0.1/24 null0
ip route 192.168.10.1/24 null0
ipv6 route 2b0f:1480::/64 null0
ipv6 route 2b0f:1480:4000:6000::/64 null0
ipv6 route 2b0f:1480:4000:8000::/64 null0
exit-vrf
!
router bgp 65000

View file

@ -3,17 +3,25 @@
auto myvnet
iface myvnet
address 10.0.0.1/24
address 192.168.0.1/24
address 192.168.10.1/24
address 2b0f:1480:4000:6000::1/64
address 2b0f:1480:4000:8000::1/64
address 2b0f:1480::1/64
bridge_ports vxlan_myvnet
bridge_stp off
bridge_fd 0
mtu 1450
ip-forward on
ip6-forward on
arp-accept on
vrf vrf_myzone
auto myvnet2
iface myvnet2
address 10.0.0.1/24
address 172.16.0.1/24
address 172.16.3.1/24
bridge_ports vxlan_myvnet2
bridge_stp off
bridge_fd 0

View file

@ -19,16 +19,51 @@
subnets => {
ids => {
'myzone-192.168.10.1-24' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '192.168.10.1',
},
'myzone-192.168.0.1-24' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '192.168.0.1',
},
'myzone-10.0.0.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '10.0.0.1',
},
'myzone2-10.0.0.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',
'gateway' => '10.0.0.1',
},
'myzone-2b0f:1480:4000:8000::-64' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '2b0f:1480:4000:8000::1',
},
'myzone-2b0f:1480::-64' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '2b0f:1480::1',
},
'myzone2-172.16.0.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',
'gateway' => '172.16.0.1',
},
'myzone2-172.16.3.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',
'gateway' => '172.16.3.1',
},
'myzone-2b0f:1480:4000:6000::-64' => {
'type' => 'subnet',
'vnet' => 'myvnet',
'gateway' => '2b0f:1480:4000:6000::1',
},
'myzone2-172.16.1.0-24' => {
'type' => 'subnet',
'vnet' => 'myvnet2',