]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/FrrPlugin.pm
vxlan: evpn: fix routing to local vms on gateway nodes
[pve-network.git] / PVE / Network / SDN / FrrPlugin.pm
index a628cf297c2fcf1c324a8791f04190caaf9d5039..b22774597029bf32374234670adeb83a505c49ed 100644 (file)
@@ -19,7 +19,7 @@ sub properties {
         },
         'peers' => {
             description => "peers address list.",
-            type => 'string',  #fixme: format 
+            type => 'string',  #fixme: format
         },
     };
 }
@@ -49,6 +49,7 @@ sub generate_frr_config {
         $ifaceip = PVE::Network::SDN::Plugin::get_first_local_ipv4_from_interface($iface);
     }
 
+
     my @router_config = ();
 
     push @router_config, "bgp router-id $ifaceip";
@@ -57,17 +58,23 @@ sub generate_frr_config {
     foreach my $address (@peers) {
        next if $address eq $ifaceip;
        push @router_config, "neighbor $address remote-as $asn";
-    } 
-    push @router_config, "!";
-    push @router_config, "address-family l2vpn evpn";
+    }
+    push(@{$config->{router}->{"bgp $asn"}->{""}}, @router_config);
+    @router_config = ();
     foreach my $address (@peers) {
        next if $address eq $ifaceip;
-       push @router_config, " neighbor $address activate";
+       push @router_config, "neighbor $address activate";
     }
-    push @router_config, " advertise-all-vni";
-    push @router_config, "exit-address-family";
+    push @router_config, "advertise-all-vni";
+    push(@{$config->{router}->{"bgp $asn"}->{"address-family"}->{"l2vpn evpn"}}, @router_config);
 
-    push(@{$config->{router}->{"router bgp $asn"}}, @router_config);
+    #don't distribute default vrf route to other peers
+    @router_config = ();
+    foreach my $address (@peers) {
+       next if $address eq $ifaceip;
+       push @router_config, "neighbor $address prefix-list deny out";
+    }
+    push(@{$config->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
 
     return $config;
 }