1 package PVE
::Network
::VlanPlugin
;
5 use PVE
::Network
::Plugin
;
7 use base
('PVE::Network::Plugin');
13 PVE
::JSONSchema
::register_format
('pve-network-vlanrange', \
&pve_verify_network_vlanrange
);
14 sub pve_verify_network_vlanrange
{
17 PVE
::Network
::Plugin
::parse_tag_number_or_range
($vlanstr, '4096');
25 type
=> 'string', format
=> 'pve-network-vlanrange',
26 description
=> "Allowed vlan range",
30 description
=> "enable 802.1q stacked vlan",
34 enum
=> ['802.1q', '802.1ad'],
37 description
=> "vlan protocol",
45 'uplink-id' => { fixed
=> 1 },
46 'vlan-allowed' => { optional
=> 1 },
47 'vlan-protocol' => { optional
=> 1 },
48 'vlan-aware' => { optional
=> 1 },
53 # Plugin implementation
54 sub generate_network_config
{
55 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $interfaces, $uplinks) = @_;
57 my $tag = $vnet->{tag
};
58 my $mtu = $vnet->{mtu
};
59 my $vlanaware = $plugin_config->{'vlan-aware'};
60 my $vlanprotocol = $plugin_config->{'vlan-protocol'};
61 my $uplink = $plugin_config->{'uplink-id'};
62 my $vlanallowed = $plugin_config->{'vlan-allowed'};
64 die "missing vlan tag" if !$tag;
65 die "uplink $uplink is not defined" if !$uplinks->{$uplink};
68 PVE
::Network
::Plugin
::parse_tag_number_or_range
($vlanallowed, '4096', $tag) if $vlanallowed;
71 die "vlan $tag is not allowed in transport $zoneid";
74 my $iface = $uplinks->{$uplink};
77 die "interface $iface already exist in main configuration" if ($interfaces->{iface
}->{$iface});
80 $config .= "auto $iface\n";
81 $config .= "iface $iface inet manual\n";
82 $config .= " vlan-protocol $vlanprotocol\n" if $vlanprotocol;
83 $config .= " mtu $mtu\n" if $mtu;
85 $config .= "auto $vnetid\n";
86 $config .= "iface $vnetid inet manual\n";
87 $config .= " bridge_ports $iface\n";
88 $config .= " bridge_stp off\n";
89 $config .= " bridge_fd 0\n";
90 $config .= " vlan-aware 1 \n" if $vlanaware;
91 $config .= " mtu $mtu\n" if $mtu;