]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/FrrPlugin.pm
vxlan: move transport controller config to frrplugin
[pve-network.git] / PVE / Network / SDN / FrrPlugin.pm
index 455b1852fc9ea24a5700f37158707e52377d50a8..532247a2e177e42de8eec9cb5bf5a228f3362152 100644 (file)
@@ -119,6 +119,56 @@ sub generate_controller_config {
     return $config;
 }
 
+sub generate_controller_transport_config {
+    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+
+    my $vrf = $plugin_config->{'vrf'};
+    my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
+    my $asn = $router->{asn};
+    my $gatewaynodes = $router->{'gateway-nodes'};
+
+    return if !$vrf || !$vrfvxlan || !$asn;
+
+    #vrf
+    my @router_config = ();
+    push @router_config, "vni $vrfvxlan";
+    push(@{$config->{frr}->{vrf}->{"$vrf"}}, @router_config);
+
+    @router_config = ();
+
+    my $is_gateway = undef;
+    my $local_node = PVE::INotify::nodename();
+
+    foreach my $gatewaynode (PVE::Tools::split_list($gatewaynodes)) {
+       $is_gateway = 1 if $gatewaynode eq $local_node;
+    }
+
+    if ($is_gateway) {
+
+       @router_config = ();
+       #import /32 routes of evpn network from vrf1 to default vrf (for packet return)
+       #frr 7.1 tag is bugged -> works fine with 7.1 stable branch(20190829-02-g6ba76bbc1)
+       #https://github.com/FRRouting/frr/issues/4905
+       push @router_config, "import vrf $vrf";
+       push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
+       push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv6 unicast"}}, @router_config);
+
+       @router_config = ();
+       #redistribute connected to be able to route to local vms on the gateway
+       push @router_config, "redistribute connected";
+       push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
+       push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv6 unicast"}}, @router_config);
+
+       @router_config = ();
+       #add default originate to announce 0.0.0.0/0 type5 route in evpn
+       push @router_config, "default-originate ipv4";
+       push @router_config, "default-originate ipv6";
+       push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @router_config);
+    }
+
+    return $config;
+}
+
 sub on_delete_hook {
     my ($class, $routerid, $sdn_cfg) = @_;
 
@@ -242,3 +292,4 @@ sub write_controller_config {
 
 1;
 
+