[pve-devel] [PATCH v4 pve-common 1/6] INotify : add uplink-id option

Alexandre Derumier aderumier at odiso.com
Wed Apr 3 00:18:29 CEST 2019


uplink-id is an integer

it's used to abstract the interface name (could be different on differents hosts)
and map it to a transportzone.

uplink-id is only allowed on physical interfaces (bond,eth,vlan)
as it's used for traffic to external

example:

auto eth0
iface eth0 inet manual
        uplink-id 1
---
 src/PVE/INotify.pm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index c52d992..d1c563f 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -954,6 +954,7 @@ sub __read_etc_network_interfaces {
 			'bridge-multicast-flood' => 1,
 			'bond_miimon' => 1,
 			'bond_xmit_hash_policy' => 1,
+			'uplink-id' => 1,
 			'vlan-protocol' => 1,
 			'vxlan-id' => 1,
 			'vxlan-svcnodeip' => 1,
@@ -1155,7 +1156,7 @@ sub __interface_to_string {
 		 comments => 1, autostart => 1, options => 1,
 		 address => 1, netmask => 1, gateway => 1, broadcast => 1,
 		 method6 => 1, families => 1, options6 => 1,
-		 address6 => 1, netmask6 => 1, gateway6 => 1, broadcast6 => 1 };
+		 address6 => 1, netmask6 => 1, gateway6 => 1, broadcast6 => 1, 'uplink-id' => 1 };
 
     if (!$first_block) {
 	# not printing out options
@@ -1456,6 +1457,21 @@ sub __write_etc_network_interfaces {
 	}
     }
 
+    # check uplink
+    my $uplinks = {};
+    foreach my $iface (keys %$ifaces) {
+	my $d = $ifaces->{$iface};
+	if (my $uplinkid = $d->{'uplink-id'}) {
+	    die "iface '$iface' - uplink-id $uplinkid is only allowed on physical and linux bond interfaces\n"
+		if $d->{type} ne 'eth' && $d->{type} ne 'bond' && $d->{type} ne 'vlan'; 
+
+	    die "iface '$iface' - uplink-id $uplinkid is already assigned on '$uplinks->{$uplinkid}'\n"
+		if $uplinks->{$uplinkid};
+
+	    $uplinks->{$uplinkid} = $iface;
+	}
+    }
+
     # check bridgeport option
     my $bridgeports = {};
     my $bridges = {};
-- 
2.11.0




More information about the pve-devel mailing list