]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/Controllers/BgpPlugin.pm
controllers: evpn : use frr restart if reload fail
[pve-network.git] / PVE / Network / SDN / Controllers / BgpPlugin.pm
index ccc06a81b8d56d550708c0f99c6ffc29d5af174a..73ed17199a8fa6e02591387456a1f96a45185d44 100644 (file)
@@ -19,11 +19,19 @@ sub type {
 
 sub properties {
     return {
+       'bgp-multipath-as-path-relax' => {
+           type => 'boolean',
+           optional => 1,
+       },
        ebgp => {
            type => 'boolean',
            optional => 1,
            description => "Enable ebgp. (remote-as external)",
        },
+       'ebgp-multihop' => {
+           type => 'integer',
+           optional => 1,
+       },
        loopback => {
            description => "source loopback interface.",
            type => 'string'
@@ -37,7 +45,9 @@ sub options {
        'node' => { optional => 0 },
        'asn' => { optional => 0 },
        'peers' => { optional => 0 },
+       'bgp-multipath-as-path-relax' => { optional => 1 },
        'ebgp' => { optional => 1 },
+       'ebgp-multihop' => { optional => 1 },
        'loopback' => { optional => 1 },
     };
 }
@@ -51,7 +61,10 @@ sub generate_controller_config {
 
     my $asn = $plugin_config->{asn};
     my $ebgp = $plugin_config->{ebgp};
+    my $ebgp_multihop = $plugin_config->{'ebgp-multihop'};
     my $loopback = $plugin_config->{loopback};
+    my $multipath_relax = $plugin_config->{'bgp-multipath-as-path-relax'};
+
     my $local_node = PVE::INotify::nodename();
 
 
@@ -68,23 +81,24 @@ sub generate_controller_config {
     my @controller_config = (
         "bgp router-id $ifaceip",
         "no bgp default ipv4-unicast",
-        "coalesce-time 1000",
-        "bgp network import-check"
+        "coalesce-time 1000"
     );
 
     push(@{$bgp->{""}}, @controller_config) if keys %{$bgp} == 0;
 
     @controller_config = ();
     if($ebgp) {
-       push @controller_config, "no bgp ebgp-requires-policy";
        push @controller_config, "bgp disable-ebgp-connected-route-check" if $loopback;
     }
 
+    push @controller_config, "bgp bestpath as-path multipath-relax" if $multipath_relax;
+
     #BGP neighbors
     if(@peers) {
        push @controller_config, "neighbor BGP peer-group";
        push @controller_config, "neighbor BGP remote-as $remoteas";
        push @controller_config, "neighbor BGP bfd";
+       push @controller_config, "neighbor BGP ebgp-multihop $ebgp_multihop" if $ebgp && $ebgp_multihop;
     }
 
     # BGP peers
@@ -103,6 +117,16 @@ sub generate_controller_config {
        push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP soft-reconfiguration inbound");
     }
 
+    if ($loopback) {
+       push(@{$config->{frr}->{''}}, "ip prefix-list loopbacks_ips seq 10 permit 0.0.0.0/0 le 32");
+       push(@{$config->{frr}->{''}}, "ip protocol bgp route-map correct_src");
+
+       my $routemap_config = [];
+       push @{$routemap_config}, "match ip address prefix-list loopbacks_ips";
+       push @{$routemap_config}, "set src $ifaceip";
+       push(@{$config->{frr_routemap}->{'correct_src'}}, $routemap_config);
+    }
+
     return $config;
 }
 
@@ -138,6 +162,11 @@ sub on_update_hook {
     }
 }
 
+sub generate_controller_rawconfig {
+    my ($class, $plugin_config, $config) = @_;
+    return "";
+}
+
 sub write_controller_config {
     my ($class, $plugin_config, $config) = @_;
     return;