1 package PVE
::Network
::SDN
::FrrPlugin
;
5 use PVE
::Network
::SDN
::Plugin
;
8 use base
('PVE::Network::SDN::Plugin');
18 description
=> "autonomous system number",
21 description
=> "peers address list.",
22 type
=> 'string', #fixme: format
30 'uplink-id' => { optional
=> 0 },
31 'asn' => { optional
=> 0 },
32 'peers' => { optional
=> 0 },
36 # Plugin implementation
37 sub generate_frr_config
{
38 my ($class, $plugin_config, $asn, $id, $uplinks, $config) = @_;
40 my @peers = split(',', $plugin_config->{'peers'}) if $plugin_config->{'peers'};
42 my $uplink = $plugin_config->{'uplink-id'};
44 my $iface = "uplink$uplink";
47 if($uplinks->{$uplink}->{name
}) {
48 $iface = $uplinks->{$uplink}->{name
};
49 $ifaceip = PVE
::Network
::SDN
::Plugin
::get_first_local_ipv4_from_interface
($iface);
52 my @router_config = ();
54 push @router_config, "bgp router-id $ifaceip";
55 push @router_config, "coalesce-time 1000";
57 foreach my $address (@peers) {
58 next if $address eq $ifaceip;
59 push @router_config, "neighbor $address remote-as $asn";
61 push @router_config, "!";
62 push @router_config, "address-family l2vpn evpn";
63 foreach my $address (@peers) {
64 next if $address eq $ifaceip;
65 push @router_config, " neighbor $address activate";
67 push @router_config, " advertise-all-vni";
68 push @router_config, "exit-address-family";
70 push(@{$config->{router
}->{"router bgp $asn"}}, @router_config);
76 my ($class, $routerid, $sdn_cfg) = @_;
78 # verify that transport is associated to this router
79 foreach my $id (keys %{$sdn_cfg->{ids
}}) {
80 my $sdn = $sdn_cfg->{ids
}->{$id};
81 die "router $routerid is used by $id"
82 if (defined($sdn->{router
}) && $sdn->{router
} eq $routerid);
87 my ($class, $routerid, $sdn_cfg) = @_;
89 # verify that asn is not already used by another router
90 my $asn = $sdn_cfg->{ids
}->{$routerid}->{asn
};
91 foreach my $id (keys %{$sdn_cfg->{ids
}}) {
92 next if $id eq $routerid;
93 my $sdn = $sdn_cfg->{ids
}->{$id};
94 die "asn $asn is already used by $id"
95 if (defined($sdn->{asn
}) && $sdn->{asn
} eq $asn);