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'};
54 my $vxlan_iface = "vxlan_$vnetid";
56 die "missing vxlan tag" if !$tag;
58 my ($ifaceip, $iface) = PVE
::Network
::SDN
::Zones
::Plugin
::find_local_ip_interface_peers
(\
@peers);
61 $mtu = $interfaces_config->{$iface}->{mtu
} - 50 if $interfaces_config->{$iface}->{mtu
};
62 $mtu = $plugin_config->{mtu
} if $plugin_config->{mtu
};
65 my @iface_config = ();
66 push @iface_config, "vxlan-id $tag";
68 foreach my $address (@peers) {
69 next if $address eq $ifaceip;
70 push @iface_config, "vxlan_remoteip $address";
74 push @iface_config, "mtu $mtu" if $mtu;
75 push(@{$config->{$vxlan_iface}}, @iface_config) if !$config->{$vxlan_iface};
79 push @iface_config, "address $ipv4" if $ipv4;
80 push @iface_config, "address $ipv6" if $ipv6;
81 push @iface_config, "hwaddress $mac" if $mac;
82 push @iface_config, "bridge_ports $vxlan_iface";
83 push @iface_config, "bridge_stp off";
84 push @iface_config, "bridge_fd 0";
85 push @iface_config, "mtu $mtu" if $mtu;
86 push @iface_config, "alias $alias" if $alias;
87 push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid};