1 package PVE
::Network
::SDN
::VxlanMulticastPlugin
;
5 use PVE
::Network
::SDN
::Plugin
;
7 use base
('PVE::Network::SDN::Plugin');
9 PVE
::JSONSchema
::register_format
('pve-sdn-vxlanrange', \
&pve_verify_sdn_vxlanrange
);
10 sub pve_verify_sdn_vxlanrange
{
13 PVE
::Network
::SDN
::Plugin
::parse_tag_number_or_range
($vxlanstr, '16777216');
19 return 'vxlanmulticast';
25 type
=> 'string', format
=> 'pve-sdn-vxlanrange',
26 description
=> "Allowed vlan range",
28 'multicast-address' => {
29 description
=> "Multicast address.",
30 type
=> 'string', #fixme: format
39 'uplink-id' => { optional
=> 0 },
40 'multicast-address' => { optional
=> 0 },
41 'vxlan-allowed' => { optional
=> 1 },
45 # Plugin implementation
46 sub generate_sdn_config
{
47 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks) = @_;
49 my $tag = $vnet->{tag
};
50 my $alias = $vnet->{alias
};
51 my $multicastaddress = $plugin_config->{'multicast-address'};
52 my $uplink = $plugin_config->{'uplink-id'};
53 my $vxlanallowed = $plugin_config->{'vxlan-allowed'};
55 die "missing vxlan tag" if !$tag;
56 my $iface = $uplinks->{$uplink}->{name
} ?
$uplinks->{$uplink}->{name
} : "uplink$uplink";
59 $mtu = $uplinks->{$uplink}->{mtu
} - 50 if $uplinks->{$uplink}->{mtu
};
60 $mtu = $vnet->{mtu
} if $vnet->{mtu
};
63 $config .= "auto vxlan$vnetid\n";
64 $config .= "iface vxlan$vnetid inet manual\n";
65 $config .= " vxlan-id $tag\n";
66 $config .= " vxlan-svcnodeip $multicastaddress\n" if $multicastaddress;
67 $config .= " vxlan-physdev $iface\n" if $iface;
68 $config .= " mtu $mtu\n" if $mtu;
70 $config .= "auto $vnetid\n";
71 $config .= "iface $vnetid inet manual\n";
72 $config .= " bridge_ports vxlan$vnetid\n";
73 $config .= " bridge_stp off\n";
74 $config .= " bridge_fd 0\n";
75 $config .= " mtu $mtu\n" if $mtu;
76 $config .= " alias $alias\n" if $alias;
82 my ($class, $transportid, $sdn_cfg) = @_;
84 # verify that no vnet are associated to this transport
85 foreach my $id (keys %{$sdn_cfg->{ids
}}) {
86 my $sdn = $sdn_cfg->{ids
}->{$id};
87 die "transport $transportid is used by vnet $id"
88 if ($sdn->{type
} eq 'vnet' && defined($sdn->{transportzone
}) && $sdn->{transportzone
} eq $transportid);
93 my ($class, $transportid, $sdn_cfg) = @_;
95 my $transport = $sdn_cfg->{ids
}->{$transportid};
97 # verify that vxlan-allowed don't conflict with another vxlan-allowed transport
99 # verify that vxlan-allowed is matching currently vnet tag in this transport
100 my $vxlanallowed = $transport->{'vxlan-allowed'};
102 foreach my $id (keys %{$sdn_cfg->{ids
}}) {
103 my $sdn = $sdn_cfg->{ids
}->{$id};
104 if ($sdn->{type
} eq 'vnet' && defined($sdn->{tag
})) {
105 if(defined($sdn->{transportzone
}) && $sdn->{transportzone
} eq $transportid) {
106 my $tag = $sdn->{tag
};
108 PVE
::Network
::SDN
::Plugin
::parse_tag_number_or_range
($vxlanallowed, '16777216', $tag);
111 die "vnet $id - vlan $tag is not allowed in transport $transportid";