]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/VxlanPlugin.pm
move gateway-nodes option to frr plugin and add gateway-external-peers
[pve-network.git] / PVE / Network / SDN / VxlanPlugin.pm
index ec1729c6d50c31fe7a33275d3cf3da0090d98f74..d3b923c6bd7d47ce645192bb6e7df7b49f354c96 100644 (file)
@@ -5,7 +5,6 @@ use warnings;
 use PVE::Network::SDN::Plugin;
 use PVE::Tools;
 use PVE::INotify;
-use PVE::JSONSchema qw(get_standard_option);
 
 use base('PVE::Network::SDN::Plugin');
 
@@ -48,7 +47,6 @@ sub properties {
            type => 'string',
            description => "Frr router name",
        },
-       'gateway-nodes' => get_standard_option('pve-node-list'),
     };
 }
 
@@ -62,7 +60,6 @@ sub options {
         'vrf' => { optional => 1 },
         'vrf-vxlan' => { optional => 1 },
         'router' => { optional => 1 },
-        'gateway-nodes' => { optional => 1 },
     };
 }
 
@@ -128,6 +125,9 @@ sub generate_sdn_config {
     push @iface_config, "bridge_fd 0";
     push @iface_config, "mtu $mtu" if $mtu;
     push @iface_config, "alias $alias" if $alias;
+    push @iface_config, "ip-forward on" if $ipv4;
+    push @iface_config, "ip6-forward on" if $ipv6;
+    push @iface_config, "arp-accept on" if $ipv4||$ipv6;
     push @iface_config, "vrf $vrf" if $vrf;
     push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid};
 
@@ -164,20 +164,19 @@ sub generate_sdn_config {
 }
 
 sub generate_frr_config {
-    my ($class, $plugin_config, $asn, $id, $uplinks, $config) = @_;
+    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
 
     my $vrf = $plugin_config->{'vrf'};
     my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
-    my $gatewaynodes = $plugin_config->{'gateway-nodes'};
+    my $asn = $router->{asn};
+    my $gatewaynodes = $router->{'gateway-nodes'};
 
-    return if !$vrf || !$vrfvxlan;
+    return if !$vrf || !$vrfvxlan || !$asn;
 
     #vrf
     my @router_config = ();
     push @router_config, "vni $vrfvxlan";
-    push @router_config, "exit-vrf";
-    push(@{$config->{vrf}->{"vrf $vrf"}}, @router_config);
-
+    push(@{$config->{vrf}->{"$vrf"}}, @router_config);
 
     @router_config = ();
 
@@ -194,20 +193,21 @@ sub generate_frr_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, "!";
-       push @router_config, "address-family ipv4 unicast";
-       push @router_config, " import vrf $vrf";
-       push @router_config, "exit-address-family";
-       push(@{$config->{router}->{"router bgp $asn"}}, @router_config);
+       push @router_config, "import vrf $vrf";
+       push(@{$config->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
+       push(@{$config->{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->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
+       push(@{$config->{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, "!";
-       push @router_config, "address-family l2vpn evpn";
-       push @router_config, " default-originate ipv4";
-       push @router_config, "exit-address-family";
-       push(@{$config->{router}->{"router bgp $asn vrf $vrf"}}, @router_config);
+       push @router_config, "default-originate ipv4";
+       push @router_config, "default-originate ipv6";
+       push(@{$config->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @router_config);
     }
 
     return $config;