[pve-devel] [PATCH pve-network 02/10] controllers: bgp: use loopback ip src for loopback network
Alexandre Derumier
aderumier at odiso.com
Fri Feb 11 10:33:23 CET 2022
can be usefull if we want to join other loopback ips,
like a ceph cluster in the underlay network
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Network/SDN/Controllers/BgpPlugin.pm | 7 +++++++
PVE/Network/SDN/Controllers/EvpnPlugin.pm | 2 ++
test/zones/evpn/ebgp_loopback/expected_controller_config | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/PVE/Network/SDN/Controllers/BgpPlugin.pm b/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 69c688b..075ca90 100644
--- a/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -110,6 +110,13 @@ 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");
+ push(@{$config->{frr}->{'route-map'}->{'correct_src permit 1'}}, "match ip address prefix-list loopbacks_ips");
+ push(@{$config->{frr}->{'route-map'}->{'correct_src permit 1'}}, "set src $ifaceip");
+ }
+
return $config;
}
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 3e450cf..61a6314 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -258,6 +258,7 @@ sub sort_frr_config {
$order->{'ipv4 unicast'} = 1;
$order->{'ipv6 unicast'} = 2;
$order->{'l2vpn evpn'} = 3;
+ $order->{'route-map'} = 200;
my $a_val = 100;
my $b_val = 100;
@@ -283,6 +284,7 @@ sub generate_frr_recurse{
$keylist->{vrf} = 1;
$keylist->{'address-family'} = 1;
$keylist->{router} = 1;
+ $keylist->{'route-map'} = 1;
my $exitkeylist = {};
$exitkeylist->{vrf} = 1;
diff --git a/test/zones/evpn/ebgp_loopback/expected_controller_config b/test/zones/evpn/ebgp_loopback/expected_controller_config
index 23be7f9..01cb2c2 100644
--- a/test/zones/evpn/ebgp_loopback/expected_controller_config
+++ b/test/zones/evpn/ebgp_loopback/expected_controller_config
@@ -5,6 +5,8 @@ frr defaults datacenter
service integrated-vtysh-config
hostname localhost
!
+ip prefix-list loopbacks_ips seq 10 permit 0.0.0.0/0 le 32
+ip protocol bgp route-map correct_src
!
vrf vrf_myzone
vni 1000
@@ -49,5 +51,9 @@ router bgp 65001 vrf vrf_myzone
route-target export 65000:1000
exit-address-family
!
+route-map correct_src permit 1
+ match ip address prefix-list loopbacks_ips
+ set src 192.168.0.1
+!
line vty
!
\ No newline at end of file
--
2.30.2
More information about the pve-devel
mailing list