public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 07/10] zones: evpn : add rt-import
Date: Fri, 11 Feb 2022 10:33:28 +0100	[thread overview]
Message-ID: <20220211093331.609127-8-aderumier@odiso.com> (raw)
In-Reply-To: <20220211093331.609127-1-aderumier@odiso.com>

Allow to import external route target list from external evpn network
(main usecase is DC inter-connect)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm     |  9 ++++
 PVE/Network/SDN/Zones/EvpnPlugin.pm           | 28 ++++++++++++-
 .../evpn/rt_import/expected_controller_config | 41 ++++++++++++++++++
 .../evpn/rt_import/expected_sdn_interfaces    | 42 +++++++++++++++++++
 test/zones/evpn/rt_import/interfaces          |  7 ++++
 test/zones/evpn/rt_import/sdn_config          | 26 ++++++++++++
 6 files changed, 152 insertions(+), 1 deletion(-)
 create mode 100644 test/zones/evpn/rt_import/expected_controller_config
 create mode 100644 test/zones/evpn/rt_import/expected_sdn_interfaces
 create mode 100644 test/zones/evpn/rt_import/interfaces
 create mode 100644 test/zones/evpn/rt_import/sdn_config

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 96abb9f..6d9b059 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -121,6 +121,7 @@ sub generate_controller_zone_config {
     my $exitnodes_primary = $plugin_config->{'exitnodes-primary'};
     my $advertisesubnets = $plugin_config->{'advertise-subnets'};
     my $exitnodes_local_routing = $plugin_config->{'exitnodes-local-routing'};
+    my $rt_import = [PVE::Tools::split_list($plugin_config->{'rt-import'})] if $plugin_config->{'rt-import'};
 
     my $asn = $controller->{asn};
     my @peers = PVE::Tools::split_list($controller->{'peers'}) if $controller->{'peers'};
@@ -202,6 +203,14 @@ sub generate_controller_zone_config {
 	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @controller_config);
     }
 
+    if($rt_import) {
+	@controller_config = ();
+	foreach my $rt (sort @{$rt_import}) {
+	    push @controller_config, "route-target import $rt";
+	}
+	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @controller_config);
+    }
+
     return $config;
 }
 
diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm b/PVE/Network/SDN/Zones/EvpnPlugin.pm
index 62c968c..a5a7539 100644
--- a/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -19,6 +19,26 @@ sub type {
     return 'evpn';
 }
 
+PVE::JSONSchema::register_format('pve-sdn-bgp-rt', \&pve_verify_sdn_bgp_rt);
+sub pve_verify_sdn_bgp_rt {
+    my ($rt) = @_;
+
+    if ($rt =~ m/^(\d+):(\d+)$/) {
+	my $asn = $1;
+	my $id = $2;
+
+	if ($asn < 0 || $asn > 4294967295) {
+	    die "value does not look like a valid bgp route-target\n";
+	}
+	if ($id < 0 || $id > 4294967295) {
+	    die "value does not look like a valid bgp route-target\n";
+	}
+    } else {
+	die "value does not look like a valid bgp route-target\n";
+    }
+    return $rt;
+}
+
 sub properties {
     return {
 	'vrf-vxlan' => {
@@ -51,7 +71,12 @@ sub properties {
 	    type => 'boolean',
 	    description => "Disable ipv4 arp && ipv6 neighbour discovery suppression",
 	    optional => 1
-	}
+	},
+	'rt-import' => {
+	    type => 'string',
+	    description => "Route-Target import",
+	    optional => 1, format => 'pve-sdn-bgp-rt-list'
+        }
     };
 }
 
@@ -65,6 +90,7 @@ sub options {
 	'exitnodes-primary' => { optional => 1 },
 	'advertise-subnets' => { optional => 1 },
 	'disable-arp-nd-suppression' => { optional => 1 },
+	'rt-import' => { optional => 1 },
 	mtu => { optional => 1 },
 	mac => { optional => 1 },
 	dns => { optional => 1 },
diff --git a/test/zones/evpn/rt_import/expected_controller_config b/test/zones/evpn/rt_import/expected_controller_config
new file mode 100644
index 0000000..dc15476
--- /dev/null
+++ b/test/zones/evpn/rt_import/expected_controller_config
@@ -0,0 +1,41 @@
+log syslog informational
+ip forwarding
+ipv6 forwarding
+frr defaults datacenter
+service integrated-vtysh-config
+hostname localhost
+!
+!
+vrf vrf_myzone
+ vni 1000
+exit-vrf
+!
+router bgp 65000
+ bgp router-id 192.168.0.1
+ no bgp default ipv4-unicast
+ coalesce-time 1000
+ neighbor VTEP peer-group
+ neighbor VTEP remote-as 65000
+ neighbor VTEP bfd
+ neighbor 192.168.0.2 peer-group VTEP
+ neighbor 192.168.0.3 peer-group VTEP
+ !
+ address-family l2vpn evpn
+  neighbor VTEP route-map MAP_VTEP_OUT out
+  neighbor VTEP activate
+  advertise-all-vni
+ exit-address-family
+!
+router bgp 65000 vrf vrf_myzone
+ bgp router-id 192.168.0.1
+ !
+ address-family l2vpn evpn
+  route-target import 65001:1000
+  route-target import 65002:1000
+  route-target import 65003:1000
+ exit-address-family
+!
+route-map MAP_VTEP_OUT permit 1
+!
+line vty
+!
\ No newline at end of file
diff --git a/test/zones/evpn/rt_import/expected_sdn_interfaces b/test/zones/evpn/rt_import/expected_sdn_interfaces
new file mode 100644
index 0000000..9d1c64c
--- /dev/null
+++ b/test/zones/evpn/rt_import/expected_sdn_interfaces
@@ -0,0 +1,42 @@
+#version:1
+
+auto myvnet
+iface myvnet
+	address 10.0.0.1/24
+	hwaddress A2:1D:CB:1A:C0:8B
+	bridge_ports vxlan_myvnet
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	ip-forward on
+	arp-accept on
+	vrf vrf_myzone
+
+auto vrf_myzone
+iface vrf_myzone
+	vrf-table auto
+	post-up ip route add vrf vrf_myzone unreachable default metric 4278198272
+
+auto vrfbr_myzone
+iface vrfbr_myzone
+	bridge-ports vrfvx_myzone
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	vrf vrf_myzone
+
+auto vrfvx_myzone
+iface vrfvx_myzone
+	vxlan-id 1000
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
+
+auto vxlan_myvnet
+iface vxlan_myvnet
+	vxlan-id 100
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
diff --git a/test/zones/evpn/rt_import/interfaces b/test/zones/evpn/rt_import/interfaces
new file mode 100644
index 0000000..66bb826
--- /dev/null
+++ b/test/zones/evpn/rt_import/interfaces
@@ -0,0 +1,7 @@
+auto vmbr0
+iface vmbr0 inet static
+	address 192.168.0.1/24
+	gateway 192.168.0.254
+        bridge-ports eth0
+        bridge-stp off
+        bridge-fd 0
diff --git a/test/zones/evpn/rt_import/sdn_config b/test/zones/evpn/rt_import/sdn_config
new file mode 100644
index 0000000..b62bb2e
--- /dev/null
+++ b/test/zones/evpn/rt_import/sdn_config
@@ -0,0 +1,26 @@
+{
+  version => 1,
+  vnets   => {
+               ids => {
+                        myvnet => { tag => "100", type => "vnet", zone => "myzone" },
+                      },
+             },
+
+  zones   => {
+               ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, 'mac' => 'A2:1D:CB:1A:C0:8B', 'rt-import' => '65001:1000,65002:1000,65003:1000' } },
+             },
+  controllers  => {
+               ids => { evpnctl => { type => "evpn", 'peers' => '192.168.0.1,192.168.0.2,192.168.0.3', asn => "65000" } },
+             },
+
+  subnets => {
+              ids => { 'myzone-10.0.0.0-24' => {
+							'type' => 'subnet',
+							'vnet' => 'myvnet',
+							'gateway' => '10.0.0.1',
+						  }
+		     }
+	     }
+}
+
+
-- 
2.30.2




  parent reply	other threads:[~2022-02-11  9:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  9:33 [pve-devel] [PATCH pve-network 00/10] bgp/evpn improvements Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 01/10] zones: status : skip node if node don't have the zone Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 02/10] controllers: bgp: use loopback ip src for loopback network Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 03/10] controllers: bgp: add bgp-multipath-as-path-relax option Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 04/10] controllers: evpn : add min/max value to asn Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 05/10] controllers: evpn/bgp : add exitnodes-primary && rework route-map Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 06/10] controllers: evpn: add missing bgp router-id in vrf Alexandre Derumier
2022-02-11  9:33 ` Alexandre Derumier [this message]
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 08/10] controllers: evpn : remove "no bgp ebgp-requires-policy" Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 09/10] controllers: bgp : remove bgp network import-check Alexandre Derumier
2022-02-11  9:33 ` [pve-devel] [PATCH pve-network 10/10] controllers: evpn : remove ip forwarding, ipv6 forwarding and add frr version Alexandre Derumier
2022-02-14  7:12 ` [pve-devel] applied-series: [PATCH pve-network 00/10] bgp/evpn improvements Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211093331.609127-8-aderumier@odiso.com \
    --to=aderumier@odiso.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal