public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* Re: [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
       [not found] <20241219161723.951909-1-alexandre.derumier@groupe-cyllene.com>
@ 2025-03-12 17:40 ` Stefan Hanreich
  2025-03-12 18:53   ` DERUMIER, Alexandre via pve-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hanreich @ 2025-03-12 17:40 UTC (permalink / raw)
  To: Alexandre Derumier, pve-devel

gave this a quick spin on my test cluster, notes below

On 12/19/24 17:17, Alexandre Derumier wrote:
> reported by user on the forum:
> https://forum.proxmox.com/threads/sdn-mismatch-afi-with-bgp-controller-ipv6-session.159250/
> 
> This is for dualstack, when evpn is ipv4, and bgp is ipv6+(ipv4)
> 
> Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
> ---
>  src/PVE/Network/SDN/Controllers/BgpPlugin.pm  | 43 ++++++++-----
>  .../bgp_ipv4_ipv6/expected_controller_config  | 63 +++++++++++++++++++
>  .../bgp_ipv4_ipv6/expected_sdn_interfaces     | 41 ++++++++++++
>  src/test/zones/evpn/bgp_ipv4_ipv6/interfaces  | 11 ++++
>  src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config  | 48 ++++++++++++++
>  5 files changed, 192 insertions(+), 14 deletions(-)
>  create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
>  create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
>  create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
>  create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config
> 
> diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
> index 53963e5..24828db 100644
> --- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
> +++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
> @@ -94,28 +94,43 @@ sub generate_controller_config {
>  
>      push @controller_config, "bgp bestpath as-path multipath-relax" if $multipath_relax;
>  
> +    my $peers_ipversion = { 4 => [], 6 => [] };
> +    foreach my $address (@peers) {
> +	my $ipversion = Net::IP::ip_is_ipv6($address) ? "6" : "4";
> +	push (@{$peers_ipversion->{$ipversion}}, $address);
> +    }
> +
>      #BGP neighbors
> -    if(@peers) {
> -	push @controller_config, "neighbor BGP peer-group";
> -	push @controller_config, "neighbor BGP remote-as $remoteas";
> -	push @controller_config, "neighbor BGP bfd";
> -	push @controller_config, "neighbor BGP ebgp-multihop $ebgp_multihop" if $ebgp && $ebgp_multihop;
> +    for my $version (sort keys %$peers_ipversion) {
> +	next if !@{$peers_ipversion->{$version}};
> +	$version = "" if $version eq '4';
> +	push @controller_config, "neighbor BGP${version} peer-group";
> +	push @controller_config, "neighbor BGP${version} remote-as $remoteas";
> +	push @controller_config, "neighbor BGP${version} bfd";
> +	push @controller_config, "neighbor BGP${version} ebgp-multihop $ebgp_multihop" if $ebgp && $ebgp_multihop;
>      }
>  
>      # BGP peers
> -    foreach my $address (@peers) {
> -	push @controller_config, "neighbor $address peer-group BGP";
> +    for my $version (sort keys %$peers_ipversion) {
> +	for my $address (@{$peers_ipversion->{$version}}) {
> +	    $version = "" if $version eq '4';
> +	    push @controller_config, "neighbor $address peer-group BGP${version}";
> +	}
>      }
> +
>      push(@{$bgp->{""}}, @controller_config);
>  
>      # address-family unicast
> -    if (@peers) {
> -	my $ipversion = Net::IP::ip_is_ipv6($ifaceip) ? "ipv6" : "ipv4";
> -	my $mask = Net::IP::ip_is_ipv6($ifaceip) ? "/128" : "32";
> -
> -	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "network $ifaceip/$mask") if $loopback;
> -	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP activate");
> -	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP soft-reconfiguration inbound");
> +    for my $version (sort keys %$peers_ipversion) {
> +	next if !@{$peers_ipversion->{$version}};
> +	my $ipversion = "ipv${version}";
> +	$version = "" if $version eq '4';
> +	if($loopback) {
> +	    my $mask = Net::IP::ip_is_ipv6($ifaceip) ? "/128" : "32";
> +	    push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "network $ifaceip/$mask");


It should work for redistributing EVPN routes via BGP, but if you want
to use the BGP controller with loopback + multiple address families this
doesn't seem to work. My generated configuration looks like this if I
try to do dual-stack BGP:

 address-family ipv6 unicast
  network 172.20.1.1/32
  neighbor BGP6 activate
  neighbor BGP6 soft-reconfiguration inbound
 exit-address-family

This should take the IPv6 from the loopback, right? We would also need
to create a correct_src_ipv6 route map then I suppose. Not sure how much
sense a dual-stack underlay makes, maybe when transitioning from 4 to 6?


If I have no IPv4 on my loopback and try an IPv6 only BGP underlay
(peers are only IPv6, loopback is IPv6 /128), then it fails on creating
a router-id:

TASK ERROR: can't autofind a router-id value from ip or mac at
/usr/share/perl5/PVE/Network/SDN/Controllers/Plugin.pm line 135.


Not 100% sure why that is, I will need to check tomorrow, I think it is
because we are only checking the address field of the interfaces file
(in find_local_ip_interface_peers), but IPv6 addresses are in the
address6 field. That seems to break when using IPv6.

Reading the MAC from "/sys/class/net/$iface/master/address" also doesn't
always work if the interface is not part of a bridge. I have my ptp
links configured directly on the interfaces, so that might also be a
problem.


Redistributing IPv4 and IPv6 routes from an EVPN zone exit-node worked
on my machine with this patch.

> +	}
> +	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP${version} activate");
> +	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP${version} soft-reconfiguration inbound");
>      }
>  
>      if ($loopback) {
> diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
> new file mode 100644
> index 0000000..a5671c8
> --- /dev/null
> +++ b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
> @@ -0,0 +1,63 @@
> +frr version 8.5.2
> +frr defaults datacenter
> +hostname localhost
> +log syslog informational
> +service integrated-vtysh-config
> +!
> +!
> +vrf vrf_myzone
> + vni 1000
> +exit-vrf
> +!
> +router bgp 65000
> + bgp router-id 192.168.0.1
> + no bgp hard-administrative-reset
> + no bgp default ipv4-unicast
> + coalesce-time 1000
> + no bgp graceful-restart notification
> + 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
> + neighbor BGP peer-group
> + neighbor BGP remote-as 65000
> + neighbor BGP bfd
> + neighbor BGP6 peer-group
> + neighbor BGP6 remote-as 65000
> + neighbor BGP6 bfd
> + neighbor 192.168.0.10 peer-group BGP
> + neighbor 2a08:2142:302:3::2 peer-group BGP6
> + !
> + address-family ipv4 unicast
> +  neighbor BGP activate
> +  neighbor BGP soft-reconfiguration inbound
> + exit-address-family
> + !
> + address-family ipv6 unicast
> +  neighbor BGP6 activate
> +  neighbor BGP6 soft-reconfiguration inbound
> + exit-address-family
> + !
> + address-family l2vpn evpn
> +  neighbor VTEP activate
> +  neighbor VTEP route-map MAP_VTEP_IN in
> +  neighbor VTEP route-map MAP_VTEP_OUT out
> +  advertise-all-vni
> + exit-address-family
> +exit
> +!
> +router bgp 65000 vrf vrf_myzone
> + bgp router-id 192.168.0.1
> + no bgp hard-administrative-reset
> + no bgp graceful-restart notification
> +exit
> +!
> +route-map MAP_VTEP_IN permit 1
> +exit
> +!
> +route-map MAP_VTEP_OUT permit 1
> +exit
> +!
> +line vty
> +!
> \ No newline at end of file
> diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
> new file mode 100644
> index 0000000..4cf13e0
> --- /dev/null
> +++ b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
> @@ -0,0 +1,41 @@
> +#version:1
> +
> +auto myvnet
> +iface myvnet
> +	address 10.0.0.1/24
> +	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/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces b/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
> new file mode 100644
> index 0000000..36e97ce
> --- /dev/null
> +++ b/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
> @@ -0,0 +1,11 @@
> +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
> +
> +auto vmbr0
> +iface vmbr0 inet6 static
> +        address 2a08:2142:302:3::1/64
> diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config b/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config
> new file mode 100644
> index 0000000..e5674bf
> --- /dev/null
> +++ b/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config
> @@ -0,0 +1,48 @@
> +{
> +    version => 1,
> +    vnets => {
> +        ids => {
> +            myvnet => {
> +                tag => "100",
> +                type => "vnet",
> +                zone => "myzone",
> +            },
> +        },
> +    },
> +
> +    zones   => {
> +        ids => {
> +            myzone => {
> +                ipam => "pve",
> +                type => "evpn",
> +                controller => "evpnctl",
> +                'vrf-vxlan' => 1000,
> +            },
> +        },
> +    },
> +    controllers  => {
> +        ids => {
> +            evpnctl => {
> +                type => "evpn",
> +                'peers' => '192.168.0.1,192.168.0.2,192.168.0.3',
> +                asn => "65000",
> +            },
> +            localhost => {
> +                type => "bgp",
> +                'peers' => '192.168.0.10,2a08:2142:302:3::2',
> +                asn => "65000",
> +                node => "localhost",
> +            },
> +        },
> +    },
> +
> +    subnets => {
> +        ids => {
> +            'myzone-10.0.0.0-24' => {
> +                'type' => 'subnet',
> +                'vnet' => 'myvnet',
> +                'gateway' => '10.0.0.1',
> +            },
> +        },
> +    },
> +}



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
  2025-03-12 17:40 ` [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups Stefan Hanreich
@ 2025-03-12 18:53   ` DERUMIER, Alexandre via pve-devel
  0 siblings, 0 replies; 4+ messages in thread
From: DERUMIER, Alexandre via pve-devel @ 2025-03-12 18:53 UTC (permalink / raw)
  To: pve-devel, s.hanreich; +Cc: DERUMIER, Alexandre

[-- Attachment #1: Type: message/rfc822, Size: 15415 bytes --]

From: "DERUMIER, Alexandre" <alexandre.derumier@groupe-cyllene.com>
To: "pve-devel@lists.proxmox.com" <pve-devel@lists.proxmox.com>, "s.hanreich@proxmox.com" <s.hanreich@proxmox.com>
Subject: Re: [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
Date: Wed, 12 Mar 2025 18:53:36 +0000
Message-ID: <8f81c3a13efb7c32d4b797a8838fe3544713d188.camel@groupe-cyllene.com>

Hi Stefan !


>>It should work for redistributing EVPN routes via BGP, but if you
>>want
>>to use the BGP controller with loopback + multiple address families
>>this
>>doesn't seem to work.
ah  shit, never tested mutiple address families on loopback on my side.
(Need to add a unit test about it )


>> My generated configuration looks like this if I
>>try to do dual-stack BGP:
>>
>> address-family ipv6 unicast
>>  network 172.20.1.1/32
>>  neighbor BGP6 activate
>>  neighbor BGP6 soft-reconfiguration inbound
>> exit-address-family

>>This should take the IPv6 from the loopback, right? 
yes, definitively


>>We would also need
>>to create a correct_src_ipv6 route map then I suppose. Not sure how
>>much
>>sense a dual-stack underlay makes, maybe when transitioning from 4 to
>>6?


>>If I have no IPv4 on my loopback and try an IPv6 only BGP underlay
>>(peers are only IPv6, loopback is IPv6 /128), then it fails on
>>creating
>>a router-id:
>>
>>TASK ERROR: can't autofind a router-id value from ip or mac at
>>/usr/share/perl5/PVE/Network/SDN/Controllers/Plugin.pm line 135.
>>
>>
>>Not 100% sure why that is, I will need to check tomorrow, I think it
>>is
>>because we are only checking the address field of the interfaces file
>>(in find_local_ip_interface_peers), but IPv6 addresses are in the
>>address6 field. That seems to break when using IPv6.

yes, it must be something like that.


>>Reading the MAC from "/sys/class/net/$iface/master/address" also
>>doesn't
>>always work if the interface is not part of a bridge. I have my ptp
>>links configured directly on the interfaces, so that might also be a
>>problem.
yes, this is common to use directly ifaces for ptp links. (I'm doing it
myself, ipv4 only). should be /sys/class/net/$IFACE/address .
(bridge should inherited from enslave iface, so it should works to for
enslaved iface in bridge)

Redistributing IPv4 and IPv6 routes from an EVPN zone exit-node worked
on my machine with this patch.



(I'll not be able to look at this until monday)


[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
  2024-12-19 16:17 Alexandre Derumier via pve-devel
@ 2025-03-11 12:47 ` DERUMIER, Alexandre via pve-devel
  0 siblings, 0 replies; 4+ messages in thread
From: DERUMIER, Alexandre via pve-devel @ 2025-03-11 12:47 UTC (permalink / raw)
  To: pve-devel; +Cc: DERUMIER, Alexandre

[-- Attachment #1: Type: message/rfc822, Size: 13759 bytes --]

From: "DERUMIER, Alexandre" <alexandre.derumier@groupe-cyllene.com>
To: "pve-devel@lists.proxmox.com" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
Date: Tue, 11 Mar 2025 12:47:44 +0000
Message-ID: <7ed2b8701fbf83ef49a7be9c0c3aa3b25fb51498.camel@groupe-cyllene.com>

Hi,

just a remember to not lost this patch.

could it be possible to apply it ?


-------- Message initial --------
De: Alexandre Derumier via pve-devel <pve-devel@lists.proxmox.com>
Répondre à: Proxmox VE development discussion <pve-
devel@lists.proxmox.com>
À: pve-devel@lists.proxmox.com
Cc: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Objet: [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6
peers in different groups
Date: 19/12/2024 17:17:23

reported by user on the forum:


This is for dualstack, when evpn is ipv4, and bgp is ipv6+(ipv4)

Signed-off-by: Alexandre Derumier <
>
---
 src/PVE/Network/SDN/Controllers/BgpPlugin.pm  | 43 ++++++++-----
 .../bgp_ipv4_ipv6/expected_controller_config  | 63 +++++++++++++++++++
 .../bgp_ipv4_ipv6/expected_sdn_interfaces     | 41 ++++++++++++
 src/test/zones/evpn/bgp_ipv4_ipv6/interfaces  | 11 ++++
 src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config  | 48 ++++++++++++++
 5 files changed, 192 insertions(+), 14 deletions(-)
 create mode 100644
src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
 create mode 100644
src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config


[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
@ 2024-12-19 16:17 Alexandre Derumier via pve-devel
  2025-03-11 12:47 ` DERUMIER, Alexandre via pve-devel
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Derumier via pve-devel @ 2024-12-19 16:17 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 10932 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups
Date: Thu, 19 Dec 2024 17:17:23 +0100
Message-ID: <20241219161723.951909-1-alexandre.derumier@groupe-cyllene.com>

reported by user on the forum:
https://forum.proxmox.com/threads/sdn-mismatch-afi-with-bgp-controller-ipv6-session.159250/

This is for dualstack, when evpn is ipv4, and bgp is ipv6+(ipv4)

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Network/SDN/Controllers/BgpPlugin.pm  | 43 ++++++++-----
 .../bgp_ipv4_ipv6/expected_controller_config  | 63 +++++++++++++++++++
 .../bgp_ipv4_ipv6/expected_sdn_interfaces     | 41 ++++++++++++
 src/test/zones/evpn/bgp_ipv4_ipv6/interfaces  | 11 ++++
 src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config  | 48 ++++++++++++++
 5 files changed, 192 insertions(+), 14 deletions(-)
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
 create mode 100644 src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config

diff --git a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
index 53963e5..24828db 100644
--- a/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
+++ b/src/PVE/Network/SDN/Controllers/BgpPlugin.pm
@@ -94,28 +94,43 @@ sub generate_controller_config {
 
     push @controller_config, "bgp bestpath as-path multipath-relax" if $multipath_relax;
 
+    my $peers_ipversion = { 4 => [], 6 => [] };
+    foreach my $address (@peers) {
+	my $ipversion = Net::IP::ip_is_ipv6($address) ? "6" : "4";
+	push (@{$peers_ipversion->{$ipversion}}, $address);
+    }
+
     #BGP neighbors
-    if(@peers) {
-	push @controller_config, "neighbor BGP peer-group";
-	push @controller_config, "neighbor BGP remote-as $remoteas";
-	push @controller_config, "neighbor BGP bfd";
-	push @controller_config, "neighbor BGP ebgp-multihop $ebgp_multihop" if $ebgp && $ebgp_multihop;
+    for my $version (sort keys %$peers_ipversion) {
+	next if !@{$peers_ipversion->{$version}};
+	$version = "" if $version eq '4';
+	push @controller_config, "neighbor BGP${version} peer-group";
+	push @controller_config, "neighbor BGP${version} remote-as $remoteas";
+	push @controller_config, "neighbor BGP${version} bfd";
+	push @controller_config, "neighbor BGP${version} ebgp-multihop $ebgp_multihop" if $ebgp && $ebgp_multihop;
     }
 
     # BGP peers
-    foreach my $address (@peers) {
-	push @controller_config, "neighbor $address peer-group BGP";
+    for my $version (sort keys %$peers_ipversion) {
+	for my $address (@{$peers_ipversion->{$version}}) {
+	    $version = "" if $version eq '4';
+	    push @controller_config, "neighbor $address peer-group BGP${version}";
+	}
     }
+
     push(@{$bgp->{""}}, @controller_config);
 
     # address-family unicast
-    if (@peers) {
-	my $ipversion = Net::IP::ip_is_ipv6($ifaceip) ? "ipv6" : "ipv4";
-	my $mask = Net::IP::ip_is_ipv6($ifaceip) ? "/128" : "32";
-
-	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "network $ifaceip/$mask") if $loopback;
-	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP activate");
-	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP soft-reconfiguration inbound");
+    for my $version (sort keys %$peers_ipversion) {
+	next if !@{$peers_ipversion->{$version}};
+	my $ipversion = "ipv${version}";
+	$version = "" if $version eq '4';
+	if($loopback) {
+	    my $mask = Net::IP::ip_is_ipv6($ifaceip) ? "/128" : "32";
+	    push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "network $ifaceip/$mask");
+	}
+	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP${version} activate");
+	push(@{$bgp->{"address-family"}->{"$ipversion unicast"}}, "neighbor BGP${version} soft-reconfiguration inbound");
     }
 
     if ($loopback) {
diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
new file mode 100644
index 0000000..a5671c8
--- /dev/null
+++ b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_controller_config
@@ -0,0 +1,63 @@
+frr version 8.5.2
+frr defaults datacenter
+hostname localhost
+log syslog informational
+service integrated-vtysh-config
+!
+!
+vrf vrf_myzone
+ vni 1000
+exit-vrf
+!
+router bgp 65000
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp default ipv4-unicast
+ coalesce-time 1000
+ no bgp graceful-restart notification
+ 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
+ neighbor BGP peer-group
+ neighbor BGP remote-as 65000
+ neighbor BGP bfd
+ neighbor BGP6 peer-group
+ neighbor BGP6 remote-as 65000
+ neighbor BGP6 bfd
+ neighbor 192.168.0.10 peer-group BGP
+ neighbor 2a08:2142:302:3::2 peer-group BGP6
+ !
+ address-family ipv4 unicast
+  neighbor BGP activate
+  neighbor BGP soft-reconfiguration inbound
+ exit-address-family
+ !
+ address-family ipv6 unicast
+  neighbor BGP6 activate
+  neighbor BGP6 soft-reconfiguration inbound
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  neighbor VTEP activate
+  neighbor VTEP route-map MAP_VTEP_IN in
+  neighbor VTEP route-map MAP_VTEP_OUT out
+  advertise-all-vni
+ exit-address-family
+exit
+!
+router bgp 65000 vrf vrf_myzone
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp graceful-restart notification
+exit
+!
+route-map MAP_VTEP_IN permit 1
+exit
+!
+route-map MAP_VTEP_OUT permit 1
+exit
+!
+line vty
+!
\ No newline at end of file
diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
new file mode 100644
index 0000000..4cf13e0
--- /dev/null
+++ b/src/test/zones/evpn/bgp_ipv4_ipv6/expected_sdn_interfaces
@@ -0,0 +1,41 @@
+#version:1
+
+auto myvnet
+iface myvnet
+	address 10.0.0.1/24
+	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/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces b/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
new file mode 100644
index 0000000..36e97ce
--- /dev/null
+++ b/src/test/zones/evpn/bgp_ipv4_ipv6/interfaces
@@ -0,0 +1,11 @@
+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
+
+auto vmbr0
+iface vmbr0 inet6 static
+        address 2a08:2142:302:3::1/64
diff --git a/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config b/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config
new file mode 100644
index 0000000..e5674bf
--- /dev/null
+++ b/src/test/zones/evpn/bgp_ipv4_ipv6/sdn_config
@@ -0,0 +1,48 @@
+{
+    version => 1,
+    vnets => {
+        ids => {
+            myvnet => {
+                tag => "100",
+                type => "vnet",
+                zone => "myzone",
+            },
+        },
+    },
+
+    zones   => {
+        ids => {
+            myzone => {
+                ipam => "pve",
+                type => "evpn",
+                controller => "evpnctl",
+                'vrf-vxlan' => 1000,
+            },
+        },
+    },
+    controllers  => {
+        ids => {
+            evpnctl => {
+                type => "evpn",
+                'peers' => '192.168.0.1,192.168.0.2,192.168.0.3',
+                asn => "65000",
+            },
+            localhost => {
+                type => "bgp",
+                'peers' => '192.168.0.10,2a08:2142:302:3::2',
+                asn => "65000",
+                node => "localhost",
+            },
+        },
+    },
+
+    subnets => {
+        ids => {
+            'myzone-10.0.0.0-24' => {
+                'type' => 'subnet',
+                'vnet' => 'myvnet',
+                'gateway' => '10.0.0.1',
+            },
+        },
+    },
+}
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-12 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20241219161723.951909-1-alexandre.derumier@groupe-cyllene.com>
2025-03-12 17:40 ` [pve-devel] [PATCH pve-network] controllers: bgp: split v4 && v6 peers in different groups Stefan Hanreich
2025-03-12 18:53   ` DERUMIER, Alexandre via pve-devel
2024-12-19 16:17 Alexandre Derumier via pve-devel
2025-03-11 12:47 ` DERUMIER, Alexandre via pve-devel

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