]>
Commit | Line | Data |
---|---|---|
f5eabba0 | 1 | package PVE::Network::SDN::Zones::QinQPlugin; |
20e19696 AD |
2 | |
3 | use strict; | |
4 | use warnings; | |
f5eabba0 | 5 | use PVE::Network::SDN::Zones::VlanPlugin; |
20e19696 | 6 | |
f5eabba0 | 7 | use base('PVE::Network::SDN::Zones::VlanPlugin'); |
20e19696 AD |
8 | |
9 | sub type { | |
10 | return 'qinq'; | |
11 | } | |
12 | ||
20e19696 AD |
13 | sub properties { |
14 | return { | |
f5eabba0 AD |
15 | tag => { |
16 | type => 'integer', | |
17 | description => "vlan tag", | |
18 | }, | |
20e19696 AD |
19 | 'vlan-protocol' => { |
20 | type => 'string', | |
21 | enum => ['802.1q', '802.1ad'], | |
22 | default => '802.1q', | |
23 | optional => 1, | |
24 | description => "vlan protocol", | |
25 | } | |
26 | }; | |
27 | } | |
28 | ||
29 | sub options { | |
30 | ||
31 | return { | |
c2b9c173 | 32 | nodes => { optional => 1}, |
20e19696 AD |
33 | 'uplink-id' => { optional => 0 }, |
34 | 'tag' => { optional => 0 }, | |
20e19696 AD |
35 | 'vlan-protocol' => { optional => 1 }, |
36 | }; | |
37 | } | |
38 | ||
39 | # Plugin implementation | |
40 | sub generate_sdn_config { | |
4405f2de | 41 | my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $controller, $config) = @_; |
20e19696 AD |
42 | |
43 | my $tag = $vnet->{tag}; | |
56cdcac9 | 44 | my $zone_tag = $plugin_config->{tag}; |
20e19696 AD |
45 | my $mtu = $vnet->{mtu}; |
46 | my $alias = $vnet->{alias}; | |
47 | my $vlanprotocol = $plugin_config->{'vlan-protocol'}; | |
48 | my $uplink = $plugin_config->{'uplink-id'}; | |
20e19696 AD |
49 | |
50 | die "missing vlan tag" if !$tag; | |
56cdcac9 | 51 | die "missing zone vlan tag" if !$zone_tag; |
20e19696 AD |
52 | |
53 | my $iface = $uplinks->{$uplink}->{name}; | |
54 | $iface = "uplink${uplink}" if !$iface; | |
56cdcac9 | 55 | $iface .= ".$zone_tag"; |
20e19696 AD |
56 | |
57 | #tagged interface | |
58 | my @iface_config = (); | |
59 | push @iface_config, "vlan-protocol $vlanprotocol" if $vlanprotocol; | |
60 | push @iface_config, "mtu $mtu" if $mtu; | |
61 | push(@{$config->{$iface}}, @iface_config) if !$config->{$iface}; | |
62 | ||
63 | $iface .= ".$tag"; | |
64 | #vnet bridge | |
65 | @iface_config = (); | |
66 | push @iface_config, "bridge_ports $iface"; | |
67 | push @iface_config, "bridge_stp off"; | |
68 | push @iface_config, "bridge_fd 0"; | |
69 | push @iface_config, "mtu $mtu" if $mtu; | |
70 | push @iface_config, "alias $alias" if $alias; | |
71 | push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid}; | |
72 | ||
73 | return $config; | |
74 | } | |
75 | ||
76 | 1; | |
77 | ||
78 |