On Wed, Jun 20, 2018 at 07:36:56AM +0200, Alexandre Derumier wrote:
> default is 2-4094 if user don't have specified.
> 
> mandatory for ifupdown2 and compatible with
> current promox ifupdown bridgevlanport script
> ---
>  src/PVE/INotify.pm | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
> index 5d8a773..94712d5 100644
> --- a/src/PVE/INotify.pm
> +++ b/src/PVE/INotify.pm
> @@ -813,7 +813,8 @@ sub __read_etc_network_interfaces {
>       'bridge-vlan-aware' => 'bridge_vlan_aware',
>       'bridge-fd' => 'bridge_fd',
>       'bridge-stp' => 'bridge_stp',
> -     'bridge-ports' => 'bridge_ports'
> +     'bridge-ports' => 'bridge_ports',
> +     'bridge-vids' => 'bridge_vids'
>      };
>  
>      my $line;
> @@ -1091,6 +1092,8 @@ sub __interface_to_string {
>  
>       if( defined($d->{bridge_vlan_aware})) {
>           $raw .= "\tbridge-vlan-aware yes\n";
> +         $v = defined($d->{bridge_vids}) ? $d->{bridge_vids} : "2-4094";
> +         $raw .= "\tbridge-vids $v\n";

An existing bridge-vids is still in $d->{options} btw. so this would be
duplicated. There was no test catching this though.

I'll add one in a followup:

--- >8 ---

From f6c4a56381915ffaac4571173e986594000f84fc Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumil...@proxmox.com>
Date: Wed, 20 Jun 2018 10:27:08 +0200
Subject: [PATCH common] INotify: write network: don't duplicate bridge-vids

Signed-off-by: Wolfgang Bumiller <w.bumil...@proxmox.com>
---
 src/PVE/INotify.pm                              |  3 ++-
 test/etc_network_interfaces/t.parsed_options.pl | 35 +++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 test/etc_network_interfaces/t.parsed_options.pl

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index d745f0b..0b9ea4a 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -896,7 +896,7 @@ sub __read_etc_network_interfaces {
                        } else {
                            $d->{$id} = 'off';
                        }
-                   } elsif ($id eq 'bridge_fd') {
+                   } elsif ($id eq 'bridge_fd' || $id eq 'bridge_vids') {
                        $d->{$id} = $value;
                    } elsif ($id eq 'bridge_vlan_aware') {
                        $d->{$id} = 1;
@@ -1096,6 +1096,7 @@ sub __interface_to_string {
            $raw .= "\tbridge-vids $v\n";
        }
        $done->{bridge_vlan_aware} = 1;
+       $done->{bridge_vids} = 1;
     
     } elsif ($d->{type} eq 'bond') {
 
diff --git a/test/etc_network_interfaces/t.parsed_options.pl 
b/test/etc_network_interfaces/t.parsed_options.pl
new file mode 100644
index 0000000..40b5b11
--- /dev/null
+++ b/test/etc_network_interfaces/t.parsed_options.pl
@@ -0,0 +1,35 @@
+save('proc_net_dev', <<'/proc/net/dev');
+eth0:
+eth1:
+/proc/net/dev
+
+# Check for dropped or duplicated options
+
+my $ip = '192.168.0.2';
+my $nm = '255.255.255.0';
+my $gw = '192.168.0.1';
+my $ip6 = 'fc05::2';
+my $nm6 = '112';
+my $gw6 = 'fc05::1';
+
+# Load
+my $cfg = load('base') . <<"CHECK";
+iface eth1 inet manual
+
+auto vmbr0
+iface vmbr0 inet static
+       address  10.0.0.2
+       netmask  255.255.255.0
+       gateway  10.0.0.1
+       bridge-ports eth0
+       bridge-stp off
+       bridge-fd 0
+       bridge-vlan-aware yes
+       bridge-vids 2-4094
+
+CHECK
+
+r $cfg;
+expect $cfg;
+
+1;
-- 
2.11.0



_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to