[pve-devel] [PATCH pve-network 2/8] vxlan: move transport controller config to frrplugin

Alexandre Derumier aderumier at odiso.com
Mon Sep 30 11:03:33 CEST 2019


To be able to use differents controllers model

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Network/SDN.pm             |  4 +--
 PVE/Network/SDN/FrrPlugin.pm   | 51 ++++++++++++++++++++++++++++++++++
 PVE/Network/SDN/VxlanPlugin.pm | 50 ---------------------------------
 3 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index 1e5ba67..b5d98b7 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -199,8 +199,8 @@ sub generate_controller_config {
 	    if ($controllerid) {
 		my $controller = $sdn_cfg->{ids}->{$controllerid};
 		if ($controller) {
-		    my $controller_plugin = PVE::Network::SDN::Plugin->lookup($plugin_config->{type});
-		    $controller_plugin->generate_controller_config($plugin_config, $controller, $id, $uplinks, $config);
+		    my $controller_plugin = PVE::Network::SDN::Plugin->lookup($controller->{type});
+		    $controller_plugin->generate_controller_transport_config($plugin_config, $controller, $id, $uplinks, $config);
 		}
 	    }
 	}
diff --git a/PVE/Network/SDN/FrrPlugin.pm b/PVE/Network/SDN/FrrPlugin.pm
index 455b185..532247a 100644
--- a/PVE/Network/SDN/FrrPlugin.pm
+++ b/PVE/Network/SDN/FrrPlugin.pm
@@ -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;
 
+
diff --git a/PVE/Network/SDN/VxlanPlugin.pm b/PVE/Network/SDN/VxlanPlugin.pm
index 986a250..d39a533 100644
--- a/PVE/Network/SDN/VxlanPlugin.pm
+++ b/PVE/Network/SDN/VxlanPlugin.pm
@@ -188,56 +188,6 @@ sub generate_sdn_config {
     return $config;
 }
 
-sub generate_controller_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, $transportid, $sdn_cfg) = @_;
 
-- 
2.20.1




More information about the pve-devel mailing list