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 },
42 # Plugin implementation
43 sub generate_sdn_config
{
44 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $interfaces_config, $config) = @_;
46 my $tag = $vnet->{tag
};
47 my $alias = $vnet->{alias
};
48 my $ipv4 = $vnet->{ipv4
};
49 my $ipv6 = $vnet->{ipv6
};
50 my $mac = $vnet->{mac
};
51 my $multicastaddress = $plugin_config->{'multicast-address'};
52 my @peers = split(',', $plugin_config->{'peers'}) if $plugin_config->{'peers'};
54 die "missing vxlan tag" if !$tag;
56 my ($ifaceip, $iface) = PVE
::Network
::SDN
::Zones
::Plugin
::find_local_ip_interface_peers
(\
@peers);
59 $mtu = $interfaces_config->{$iface}->{mtu
} - 50 if $interfaces_config->{$iface}->{mtu
};
60 $mtu = $vnet->{mtu
} if $vnet->{mtu
};
63 my @iface_config = ();
64 push @iface_config, "vxlan-id $tag";
66 foreach my $address (@peers) {
67 next if $address eq $ifaceip;
68 push @iface_config, "vxlan_remoteip $address";
71 push @iface_config, "mtu $mtu" if $mtu;
72 push(@{$config->{"vxlan$vnetid"}}, @iface_config) if !$config->{"vxlan$vnetid"};
76 push @iface_config, "address $ipv4" if $ipv4;
77 push @iface_config, "address $ipv6" if $ipv6;
78 push @iface_config, "hwaddress $mac" if $mac;
79 push @iface_config, "bridge_ports vxlan$vnetid";
80 push @iface_config, "bridge_stp off";
81 push @iface_config, "bridge_fd 0";
82 push @iface_config, "mtu $mtu" if $mtu;
83 push @iface_config, "alias $alias" if $alias;
84 push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid};