all lists on 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] frr: add prefix-list support
Date: Wed, 30 Nov 2022 16:18:59 +0100	[thread overview]
Message-ID: <20221130151859.2795918-1-aderumier@odiso.com> (raw)

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@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




             reply	other threads:[~2022-11-30 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 15:18 Alexandre Derumier [this message]
2023-01-16 15:54 ` [pve-devel] applied: " 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=20221130151859.2795918-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal