]> git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/Zones/QinQPlugin.pm
evpn: remove uplink-id
[pve-network.git] / PVE / Network / SDN / Zones / QinQPlugin.pm
1 package PVE::Network::SDN::Zones::QinQPlugin;
2
3 use strict;
4 use warnings;
5 use PVE::Network::SDN::Zones::VlanPlugin;
6
7 use base('PVE::Network::SDN::Zones::VlanPlugin');
8
9 sub type {
10 return 'qinq';
11 }
12
13 sub properties {
14 return {
15 tag => {
16 type => 'integer',
17 description => "vlan tag",
18 },
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 {
32 nodes => { optional => 1},
33 'uplink-id' => { optional => 0 },
34 'tag' => { optional => 0 },
35 'vlan-protocol' => { optional => 1 },
36 };
37 }
38
39 # Plugin implementation
40 sub generate_sdn_config {
41 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $controller, $config) = @_;
42
43 my $tag = $vnet->{tag};
44 my $zone_tag = $plugin_config->{tag};
45 my $mtu = $vnet->{mtu};
46 my $alias = $vnet->{alias};
47 my $vlanprotocol = $plugin_config->{'vlan-protocol'};
48 my $uplink = $plugin_config->{'uplink-id'};
49
50 die "missing vlan tag" if !$tag;
51 die "missing zone vlan tag" if !$zone_tag;
52
53 my $iface = $uplinks->{$uplink}->{name};
54 $iface = "uplink${uplink}" if !$iface;
55 $iface .= ".$zone_tag";
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