summaryrefslogtreecommitdiff
path: root/PVE/Network/SDN/Controllers/EvpnPlugin.pm
diff options
context:
space:
mode:
authorAlexandre Derumier <aderumier@odiso.com>2019-11-28 09:40:27 +0100
committerThomas Lamprecht <t.lamprecht@proxmox.com>2019-11-28 14:15:25 +0100
commit1f543c5f3c7b64cd2278e71a1480c8a3ce0b430f (patch)
treeb1bea2ec622d836707691210afdfce2cfbe81158 /PVE/Network/SDN/Controllers/EvpnPlugin.pm
parent3794e4297275bc74d63ccb281601461ccb919ad6 (diff)
move find_local_ip_interface sub helper to zone plugin
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'PVE/Network/SDN/Controllers/EvpnPlugin.pm')
-rw-r--r--PVE/Network/SDN/Controllers/EvpnPlugin.pm46
1 files changed, 3 insertions, 43 deletions
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 66b4568..c8bf76a 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -3,10 +3,10 @@ package PVE::Network::SDN::Controllers::EvpnPlugin;
use strict;
use warnings;
use PVE::Network::SDN::Controllers::Plugin;
-use PVE::Tools qw(run_command);
+use PVE::Tools;
use PVE::INotify;
use PVE::JSONSchema qw(get_standard_option);
-
+use PVE::Network::SDN::Zones::Plugin;
use base('PVE::Network::SDN::Controllers::Plugin');
sub type {
@@ -41,46 +41,6 @@ sub options {
};
}
-sub get_local_route_ip {
- my ($targetip) = @_;
-
- my $ip = undef;
- my $interface = undef;
-
- run_command(['/sbin/ip', 'route', 'get', $targetip], outfunc => sub {
- if ($_[0] =~ m/src ($PVE::Tools::IPRE)/) {
- $ip = $1;
- }
- if ($_[0] =~ m/dev (\S+)/) {
- $interface = $1;
- }
-
- });
- return ($ip, $interface);
-}
-
-sub find_local_ip_interface {
- my ($peers) = @_;
-
- my $network_config = PVE::INotify::read_file('interfaces');
- my $ifaces = $network_config->{ifaces};
- #is a local ip member of peers list ?
- foreach my $address (@{$peers}) {
- while (my $interface = each %$ifaces) {
- my $ip = $ifaces->{$interface}->{address};
- if ($ip && $ip eq $address) {
- return ($ip, $interface);
- }
- }
- }
-
- #if peer is remote, find source with ip route
- foreach my $address (@{$peers}) {
- my ($ip, $interface) = get_local_route_ip($address);
- return ($ip, $interface);
- }
-}
-
# Plugin implementation
sub generate_controller_config {
my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
@@ -93,7 +53,7 @@ sub generate_controller_config {
return if !$asn;
- my ($ifaceip, $interface) = find_local_ip_interface(\@peers);
+ my ($ifaceip, $interface) = PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers);
my $is_gateway = undef;
my $local_node = PVE::INotify::nodename();