1 package PVE
::Network
::SDN
::Zones
::VxlanPlugin
;
5 use PVE
::Network
::SDN
::Zones
::Plugin
;
6 use PVE
::Tools
qw($IPV4RE);
8 use PVE
::Network
::SDN
::Controllers
::EvpnPlugin
;
10 use base
('PVE::Network::SDN::Zones::Plugin');
12 PVE
::JSONSchema
::register_format
('pve-sdn-vxlanrange', \
&pve_verify_sdn_vxlanrange
);
13 sub pve_verify_sdn_vxlanrange
{
16 PVE
::Network
::SDN
::Zones
::Plugin
::parse_tag_number_or_range
($vxlanstr, '16777216');
28 description
=> "peers address list.",
29 type
=> 'string', format
=> 'ip-list'
37 nodes
=> { optional
=> 1},
38 peers
=> { optional
=> 0 },
39 mtu
=> { optional
=> 1 },
43 # Plugin implementation
44 sub generate_sdn_config
{
45 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $interfaces_config, $config) = @_;
47 my $tag = $vnet->{tag
};
48 my $alias = $vnet->{alias
};
49 my $ipv4 = $vnet->{ipv4
};
50 my $ipv6 = $vnet->{ipv6
};
51 my $mac = $vnet->{mac
};
52 my $multicastaddress = $plugin_config->{'multicast-address'};
53 my @peers = split(',', $plugin_config->{'peers'}) if $plugin_config->{'peers'};
55 die "missing vxlan tag" if !$tag;
57 my ($ifaceip, $iface) = PVE
::Network
::SDN
::Zones
::Plugin
::find_local_ip_interface_peers
(\
@peers);
60 $mtu = $interfaces_config->{$iface}->{mtu
} - 50 if $interfaces_config->{$iface}->{mtu
};
61 $mtu = $plugin_config->{mtu
} if $plugin_config->{mtu
};
64 my @iface_config = ();
65 push @iface_config, "vxlan-id $tag";
67 foreach my $address (@peers) {
68 next if $address eq $ifaceip;
69 push @iface_config, "vxlan_remoteip $address";
72 push @iface_config, "mtu $mtu" if $mtu;
73 push(@{$config->{"vxlan$vnetid"}}, @iface_config) if !$config->{"vxlan$vnetid"};
77 push @iface_config, "address $ipv4" if $ipv4;
78 push @iface_config, "address $ipv6" if $ipv6;
79 push @iface_config, "hwaddress $mac" if $mac;
80 push @iface_config, "bridge_ports vxlan$vnetid";
81 push @iface_config, "bridge_stp off";
82 push @iface_config, "bridge_fd 0";
83 push @iface_config, "mtu $mtu" if $mtu;
84 push @iface_config, "alias $alias" if $alias;
85 push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid};