1 package PVE
::Network
::Network
::VlanPlugin
;
5 use PVE
::Network
::Network
::Plugin
;
7 use base
('PVE::Network::Network::Plugin');
13 PVE
::JSONSchema
::register_format
('pve-network-vlanrange', \
&pve_verify_network_vlanrange
);
14 sub pve_verify_network_vlanrange
{
17 PVE
::Network
::Network
::Plugin
::parse_tag_number_or_range
($vlanstr, '4096');
26 minimum
=> 1, maximum
=> 4096,
27 description
=> 'Uplink interface',
30 type
=> 'string', format
=> 'pve-network-vlanrange',
31 description
=> "Allowed vlan range",
35 description
=> "enable 802.1q stacked vlan",
39 enum
=> ['802.1q', '802.1ad'],
42 description
=> "vlan protocol",
50 'uplink-id' => { optional
=> 0 },
51 'vlan-allowed' => { optional
=> 1 },
52 'vlan-protocol' => { optional
=> 1 },
53 'vlan-aware' => { optional
=> 1 },
58 # Plugin implementation
59 sub generate_network_config
{
60 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks) = @_;
62 my $tag = $vnet->{tag
};
63 my $mtu = $vnet->{mtu
};
64 my $vlanaware = $plugin_config->{'vlan-aware'};
65 my $vlanprotocol = $plugin_config->{'vlan-protocol'};
66 my $uplink = $plugin_config->{'uplink-id'};
67 my $vlanallowed = $plugin_config->{'vlan-allowed'};
69 die "missing vlan tag" if !$tag;
70 die "uplink $uplink is not defined" if !$uplinks->{$uplink};
73 PVE
::Network
::Network
::Plugin
::parse_tag_number_or_range
($vlanallowed, '4096', $tag) if $vlanallowed;
76 die "vlan $tag is not allowed in transport $zoneid";
79 my $iface = $uplinks->{$uplink};
83 $config .= "auto $iface\n";
84 $config .= "iface $iface inet manual\n";
85 $config .= " vlan-protocol $vlanprotocol\n" if $vlanprotocol;
86 $config .= " mtu $mtu\n" if $mtu;
88 $config .= "auto $vnetid\n";
89 $config .= "iface $vnetid inet manual\n";
90 $config .= " bridge_ports $iface\n";
91 $config .= " bridge_stp off\n";
92 $config .= " bridge_fd 0\n";
93 $config .= " bridge-vlan-aware yes \n" if $vlanaware;
94 $config .= " mtu $mtu\n" if $mtu;
100 my ($class, $networkid, $scfg) = @_;
102 # verify that no vnet are associated to this transport
106 my ($class, $networkid, $scfg) = @_;
108 # verify that vlan-allowed don't conflict with another vlan-allowed transport
110 # verify that vlan-allowed is matching currently vnet tag in this transport