]> git.proxmox.com Git - pve-network.git/commitdiff
vxlanplugin: add vrf and vrfvxlan
authorAlexandre Derumier <aderumier@odiso.com>
Thu, 29 Aug 2019 10:32:48 +0000 (12:32 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 3 Sep 2019 06:22:56 +0000 (08:22 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Network/SDN/VxlanPlugin.pm

index ae1f86adbd367d412e81da097c35d0d3201af9be..c93dbc45520bd242a2f041d0e98b2c6722dc9ee4 100644 (file)
@@ -34,6 +34,14 @@ sub properties {
            description => "Unicast peers address ip list.",
            type => 'string',  #fixme: format 
        },
+       'vrf' => {
+           description => "vrf name.",
+           type => 'string',  #fixme: format 
+       },
+       'vrf-vxlan' => {
+           type => 'integer',
+           description => "l3vni.",
+       },
     };
 }
 
@@ -44,6 +52,8 @@ sub options {
         'multicast-address' => { optional => 1 },
         'unicast-address' => { optional => 1 },
         'vxlan-allowed' => { optional => 1 },
+        'vrf' => { optional => 1 },
+        'vrf-vxlan' => { optional => 1 },
     };
 }
 
@@ -58,6 +68,8 @@ sub generate_sdn_config {
 
     my $uplink = $plugin_config->{'uplink-id'};
     my $vxlanallowed = $plugin_config->{'vxlan-allowed'};
+    my $vrf = $plugin_config->{'vrf'};
+    my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
 
     die "missing vxlan tag" if !$tag;
     my $iface = "uplink$uplink";
@@ -90,8 +102,6 @@ sub generate_sdn_config {
        $config .= "       vxlan-local-tunnelip $ifaceip\n" if $ifaceip;
        $config .= "       bridge-learning off\n";
        $config .= "       bridge-arp-nd-suppress on\n";
-       $config .= "       bridge-unicast-flood off\n";
-       $config .= "       bridge-multicast-flood off\n";
     }
 
     $config .= "       mtu $mtu\n" if $mtu;
@@ -103,6 +113,37 @@ sub generate_sdn_config {
     $config .= "       bridge_fd 0\n";
     $config .= "       mtu $mtu\n" if $mtu;
     $config .= "       alias $alias\n" if $alias;
+    $config .= "       vrf $vrf\n" if $vrf;
+
+    if ($vrf) {
+       $config .= "\n";
+       $config .= "auto $vrf\n";
+       $config .= "iface $vrf\n";
+       $config .= "       vrf-table auto\n";
+
+       if ($vrfvxlan) {
+
+           my $vxlanvrf = "vxlan$vrf";
+           my $brvrf = "br$vrf";
+
+           $config .= "\n";
+           $config .= "auto $vxlanvrf\n";
+           $config .= "iface $vxlanvrf\n";
+           $config .= "        vxlan-id $vrfvxlan\n";
+           $config .= "        vxlan-local-tunnelip $ifaceip\n" if $ifaceip;
+           $config .= "        bridge-learning off\n";
+           $config .= "        bridge-arp-nd-suppress on\n";
+           $config .= "        mtu $mtu\n" if $mtu;
+
+           $config .= "\n";
+           $config .= "auto $brvrf\n";
+           $config .= "        bridge-ports $vxlanvrf\n";
+           $config .= "        bridge_stp off\n";
+           $config .= "        bridge_fd 0\n";
+           $config .= "        mtu $mtu\n" if $mtu;
+           $config .= "        vrf $vrf\n";
+       }
+    }
 
     return $config;
 }