type => 'string',
description => "Frr router name",
},
+ 'mac' => {
+ type => 'string',
+ description => "Anycast logical router mac address",
+ optional => 1, format => 'mac-addr'
+ },
'exitnodes' => get_standard_option('pve-node-list'),
};
}
controller => { optional => 0 },
exitnodes => { optional => 1 },
mtu => { optional => 1 },
+ mac => { optional => 1 },
dns => { optional => 1 },
reversedns => { optional => 1 },
dnszone => { optional => 1 },
# Plugin implementation
sub generate_sdn_config {
- my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $subnet_cfg, $interfaces_config, $config) = @_;
+ my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $controller_cfg, $subnet_cfg, $interfaces_config, $config) = @_;
my $tag = $vnet->{tag};
my $alias = $vnet->{alias};
my $ipv4 = $vnet->{ipv4};
my $ipv6 = $vnet->{ipv6};
- my $mac = $vnet->{mac};
+ my $mac = $plugin_config->{'mac'};
my $vrf_iface = "vrf_$zoneid";
my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
warn "vlan-aware vnet can't be enabled with evpn plugin" if $vnet->{vlanaware};
my @peers = PVE::Tools::split_list($controller->{'peers'});
-# my $bgprouter = PVE::Network::SDN::Controllers::EvpnController::find_bgp_controller($local_node, $controller_cfg);
-# my $loopback = $bgprouter->{loopback} if $bgprouter->{loopback};
- my $loopback = undef;
+ my $bgprouter = PVE::Network::SDN::Controllers::EvpnPlugin::find_bgp_controller($local_node, $controller_cfg);
+ my $loopback = $bgprouter->{loopback} if $bgprouter->{loopback};
my ($ifaceip, $iface) = PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers, $loopback);
my $mtu = 1450;
foreach my $subnetid (sort keys %{$subnets}) {
my $subnet = $subnets->{$subnetid};
my $cidr = $subnet->{cidr};
+ my $mask = $subnet->{mask};
my $gateway = $subnet->{gateway};
if ($gateway) {
- push @iface_config, "address $gateway" if !defined($address->{$gateway});
+ push @iface_config, "address $gateway/$mask" if !defined($address->{$gateway});
$address->{$gateway} = 1;
}
+
if ($subnet->{snat}) {
- my $gatewaynodes = $controller->{'gateway-nodes'};
- my $is_evpn_gateway = "";
- foreach my $evpn_gatewaynode (PVE::Tools::split_list($gatewaynodes)) {
- $is_evpn_gateway = 1 if $evpn_gatewaynode eq $local_node;
- }
+
+ my $is_evpn_gateway = $plugin_config->{'exitnodes'}->{$local_node};
+
#find outgoing interface
my ($outip, $outiface) = PVE::Network::SDN::Zones::Plugin::get_local_route_ip('8.8.8.8');
if ($outip && $outiface && $is_evpn_gateway) {
#vrf interface
@iface_config = ();
push @iface_config, "vrf-table auto";
+ push @iface_config, "post-up ip route add vrf $vrf_iface unreachable default metric 4278198272";
push(@{$config->{$vrf_iface}}, @iface_config) if !$config->{$vrf_iface};
if ($vrfvxlan) {
if (defined($zone_cfg->{ids}->{$id}->{'vrf-vxlan'}) && $zone_cfg->{ids}->{$id}->{'vrf-vxlan'} eq $vrfvxlan);
}
+ if (!defined($zone_cfg->{ids}->{$zoneid}->{'mac'})) {
+ my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
+ $zone_cfg->{ids}->{$zoneid}->{'mac'} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
+ }
}
next if $other_zone->{type} ne 'vxlan' && $other_zone->{type} ne 'evpn';
raise_param_exc({ tag => "vxlan tag $tag already exist in vnet $id in zone $other_zoneid "}) if $other_tag && $tag eq $other_tag;
}
-
- if (!defined($vnet->{mac})) {
- my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
- $vnet->{mac} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
- }
}