[pve-devel] [PATCH pve-network] frr: add prefix-list support

Alexandre Derumier aderumier at odiso.com
Wed Nov 30 16:18:59 CET 2022


parsing of prefix-list in frr.conf.local was missing

reported on forum:
https://forum.proxmox.com/threads/using-the-proxmox-sdn-to-manage-host-connectivity-with-bgp.118553

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Network/SDN/Controllers/BgpPlugin.pm      |  2 +-
 PVE/Network/SDN/Controllers/EvpnPlugin.pm     | 20 +++++++++++--------
 .../ebgp_loopback/expected_controller_config  |  3 ++-
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/PVE/Network/SDN/Controllers/BgpPlugin.pm b/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 6e69f67..0b8cf1a 100644
--- a/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -118,7 +118,7 @@ sub generate_controller_config {
     }
 
     if ($loopback) {
-	push(@{$config->{frr}->{''}}, "ip prefix-list loopbacks_ips seq 10 permit 0.0.0.0/0 le 32");
+	$config->{frr_prefix_list}->{loopbacks_ips}->{10} = "permit 0.0.0.0/0 le 32";
 	push(@{$config->{frr}->{''}}, "ip protocol bgp route-map correct_src");
 
 	my $routemap_config = ();
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 74ec018..b72d669 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -384,17 +384,17 @@ sub generate_frr_routemap {
    }
 }
 
-sub generate_frr_accesslist {
-    my ($final_config, $accesslists) = @_;
+sub generate_frr_list {
+    my ($final_config, $lists, $type) = @_;
 
     my $config = [];
 
-    for my $id (sort keys %$accesslists) {
-	my $accesslist = $accesslists->{$id};
+    for my $id (sort keys %$lists) {
+	my $list = $lists->{$id};
 
-	for my $seq (sort keys %$accesslist) {
-	    my $rule = $accesslist->{$seq};
-	    push @$config, "access-list $id seq $seq $rule";
+	for my $seq (sort keys %$list) {
+	    my $rule = $list->{$seq};
+	    push @$config, "$type $id seq $seq $rule";
 	}
     }
 
@@ -422,7 +422,8 @@ sub generate_controller_rawconfig {
     }
 
     generate_frr_recurse($final_config, $config->{frr}, undef, 0);
-    generate_frr_accesslist($final_config, $config->{frr_access_list});
+    generate_frr_list($final_config, $config->{frr_access_list}, "access-list");
+    generate_frr_list($final_config, $config->{frr_prefix_list}, "ip prefix-list");
     generate_frr_routemap($final_config, $config->{frr_routemap});
 
     push @{$final_config}, "!";
@@ -467,6 +468,9 @@ sub parse_merge_frr_local_config {
 	} elsif ($line =~ m/^access-list (.+) seq (\d+) (.+)$/) {
 	    $config->{'frr_access_list'}->{$1}->{$2} = $3;
 	    next;
+	} elsif ($line =~ m/^ip prefix-list (.+) seq (\d+) (.*)$/) {
+	    $config->{'frr_prefix_list'}->{$1}->{$2} = $3;
+	    next;
 	} elsif($line =~ m/^exit-address-family$/) {
 	    next;
 	} elsif($line =~ m/^exit$/) {
diff --git a/test/zones/evpn/ebgp_loopback/expected_controller_config b/test/zones/evpn/ebgp_loopback/expected_controller_config
index 64fca31..548d532 100644
--- a/test/zones/evpn/ebgp_loopback/expected_controller_config
+++ b/test/zones/evpn/ebgp_loopback/expected_controller_config
@@ -4,7 +4,6 @@ hostname localhost
 log syslog informational
 service integrated-vtysh-config
 !
-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
@@ -53,6 +52,8 @@ router bgp 65001 vrf vrf_myzone
  exit-address-family
 exit
 !
+ip prefix-list loopbacks_ips seq 10 permit 0.0.0.0/0 le 32
+!
 route-map MAP_VTEP_IN permit 1
 exit
 !
-- 
2.30.2





More information about the pve-devel mailing list