zoneconf: Fix bug in NIC assignment; Change visibility of unused zones

Fix a bug that allows users to add multiple NICs to non-bridged zones.
This fix includes a new error message.

Unused zones are now invisible instead of grey.
This commit is contained in:
Florian Bührle
2019-05-11 13:28:12 +02:00
parent 88e64c23c1
commit f60b61e04d
3 changed files with 22 additions and 16 deletions

View File

@@ -164,6 +164,11 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
my $slave_string = "";
my $zone_mode = $cgiparams{"MODE $uc"};
my $VALIDATE_vlancount = 0;
my $VALIDATE_zoneslaves = 0;
if ($zone_mode eq "") { # If this zone is not activated, we don't check it
next;
}
$ethsettings{"${uc}_MACADDR"} = "";
$ethsettings{"${uc}_MODE"} = "";
@@ -201,16 +206,22 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
if (! ($nic_access eq "NONE")) {
if ($VALIDATE_nic_check{"RESTRICT $mac"}) { # If this interface is already assigned to RED in PPP mode, throw an error
$VALIDATE_error = $Lang::tr{"zoneconf val ppp assignment error"};
next;
last;
}
if ($zone_mode ne "BRIDGE" && $VALIDATE_zoneslaves > 0) {
$VALIDATE_error = $Lang::tr{"zoneconf val zoneslave amount error"};
last;
}
$VALIDATE_nic_check{"ACC $mac"} = 1;
$VALIDATE_zoneslaves++;
}
if ($nic_access eq "NATIVE") {
if ($VALIDATE_nic_check{"NATIVE $mac"}) {
$VALIDATE_error = $Lang::tr{"zoneconf val native assignment error"};
next;
last;
}
$VALIDATE_nic_check{"NATIVE $mac"} = 1;
@@ -225,16 +236,16 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
if ($VALIDATE_nic_check{"VLAN $mac $vlan_tag"}) {
$VALIDATE_error = $Lang::tr{"zoneconf val vlan tag assignment error"};
next;
last;
}
$VALIDATE_nic_check{"VLAN $mac $vlan_tag"} = 1;
if (! looks_like_number($vlan_tag)) {
next;
last;
}
if ($vlan_tag < 1 || $vlan_tag > 4095) {
next;
last;
}
my $rnd_mac = &Network::random_mac();
@@ -253,7 +264,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) {
if ($VALIDATE_vlancount > 1) {
$VALIDATE_error = $Lang::tr{"zoneconf val vlan amount assignment error"};
next;
last;
}
chop($slave_string);
@@ -305,22 +316,15 @@ foreach (@nics) {
print "</tr>";
foreach (@zones) {
print "<tr>";
my $uc = uc $_;
my $dev_name = $ethsettings{"${uc}_DEV"};
if ($dev_name eq "") { # If the zone is not activated, color it light grey
print "<td class='h disabled'>$uc</td>";
foreach (@nics) {
print "<td class='disabled'/>";
}
print "</tr>";
if ($dev_name eq "") { # If the zone is not activated, don't show it
next;
}
print "<tr>";
if ($uc eq "RED") {
my $red_type = $ethsettings{"RED_TYPE"};
my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP"));

View File

@@ -2892,6 +2892,7 @@
'zoneconf val ppp assignment error' => 'Die Netzwerkkarte, die von RED im PPP-Modus verwendet wird, kann keiner anderen Zone zugeordnet werden.',
'zoneconf val vlan amount assignment error' => 'Pro Zone kann nur ein VLAN verwendet werden.',
'zoneconf val vlan tag assignment error' => 'Pro Netzwerkkarte kann derselbe VLAN-Tag nur einmal verwendet werden.',
'zoneconf val zoneslave amount error' => 'Wenn eine Zone nicht im Brückenmodus ist, kann ihr nur eine Netzwerkkarte zugewiesen werden.',
);
#EOF

View File

@@ -2941,6 +2941,7 @@
'zoneconf val ppp assignment error' => 'The NIC used for RED in PPP mode cannot be accessed by any other zone.',
'zoneconf val vlan amount assignment error' => 'A zone cannot have more than one VLAN assigned.',
'zoneconf val vlan tag assignment error' => 'You cannot use the same VLAN tag more than once per NIC.',
'zoneconf val zoneslave amount error' => 'A zone that is not in bridge mode can\'t have more than one NIC assigned',
);
#EOF