summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-06-04 21:37:15 +0000
committerErmal Luçi <eri@pfsense.org>2008-06-04 21:37:15 +0000
commita3f9082f46e573fab5b600a94ed8f721a9f6c74d (patch)
treeaa8e1e3224b9890e969feacf1dd40db54d54cc7a /usr
parent2075fadb5fce5e844d96c500cdc804a1bb7f1da9 (diff)
downloadpfsense-a3f9082f46e573fab5b600a94ed8f721a9f6c74d.zip
pfsense-a3f9082f46e573fab5b600a94ed8f721a9f6c74d.tar.gz
Fix braindead vlan creation procedures.
Now we do not need to go through all vlans just to delete/create one of them.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/interfaces_vlan.php20
-rwxr-xr-xusr/local/www/interfaces_vlan_edit.php58
2 files changed, 35 insertions, 43 deletions
diff --git a/usr/local/www/interfaces_vlan.php b/usr/local/www/interfaces_vlan.php
index 0ed7ee6..276312b 100755
--- a/usr/local/www/interfaces_vlan.php
+++ b/usr/local/www/interfaces_vlan.php
@@ -52,34 +52,16 @@ function vlan_inuse($num) {
return false;
}
-function renumber_vlan($if, $delvlan) {
- if (!preg_match("/^vlan/", $if))
- return $if;
-
- $vlan = substr($if, 4);
- if ($vlan > $delvlan)
- return "vlan" . ($vlan - 1);
- else
- return $if;
-}
-
if ($_GET['act'] == "del") {
/* check if still in use */
if (vlan_inuse($_GET['id'])) {
$input_errors[] = "This VLAN cannot be deleted because it is still being used as an interface.";
} else {
+ mwexec("/sbin/ifconfig " . $a_vlans[$_GET['id']]['vlanif'] . " destroy");
unset($a_vlans[$_GET['id']]);
- /* renumber all interfaces that use VLANs */
- $config['interfaces']['lan']['if'] = renumber_vlan($config['interfaces']['lan']['if'], $_GET['id']);
- $config['interfaces']['wan']['if'] = renumber_vlan($config['interfaces']['wan']['if'], $_GET['id']);
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++)
- $config['interfaces']['opt' . $i]['if'] = renumber_vlan($config['interfaces']['opt' . $i]['if'], $_GET['id']);
-
write_config();
- interfaces_vlan_configure();
-
header("Location: interfaces_vlan.php");
exit;
}
diff --git a/usr/local/www/interfaces_vlan_edit.php b/usr/local/www/interfaces_vlan_edit.php
index b5384c7..87775ad 100755
--- a/usr/local/www/interfaces_vlan_edit.php
+++ b/usr/local/www/interfaces_vlan_edit.php
@@ -44,6 +44,7 @@ if (isset($_POST['id']))
if (isset($id) && $a_vlans[$id]) {
$pconfig['if'] = $a_vlans[$id]['if'];
+ $pconfig['vlanif'] = $a_vlans[$id]['vlanif'];
$pconfig['tag'] = $a_vlans[$id]['tag'];
$pconfig['descr'] = $a_vlans[$id]['descr'];
}
@@ -79,33 +80,42 @@ if ($_POST) {
$vlan['tag'] = $_POST['tag'];
$vlan['descr'] = $_POST['descr'];
- if (isset($id) && $a_vlans[$id])
- $a_vlans[$id] = $vlan;
- else
- $a_vlans[] = $vlan;
+ $vlan['vlanif'] = interface_vlan_configure($vlan['if'], $vlan['tag']);
+ if ($vlan['vlanif'] == "" || !stristr($vlan['vlanif'], "vlan"))
+ $input_errors[] = "Error occured creating interface, please retry.";
+ else {
+ if (isset($id) && $a_vlans[$id])
+ $a_vlans[$id] = $vlan;
+ else
+ $a_vlans[] = $vlan;
- write_config();
+ write_config();
- /* TODO
- this does not always work, some systems require
- a reboot before VLANs function properly. Suspect
- FreeBSD driver issue.
+
+ /* TODO
+ this does not always work, some systems require
+ a reboot before VLANs function properly. Suspect
+ FreeBSD driver issue.
- This portion of code is also very slow, this is why
- it takes a long time to add a new VLAN.
- Benchmark_Timer on a 800 MHz VIA:
- interfaces_lan_configure() takes about 6 seconds
- interfaces_wan_configure() takes about 9.5 seconds
- interfaces_optional_configure() takes about 5 seconds
- */
-
- interfaces_vlan_configure();
- interfaces_lan_configure();
- interfaces_wan_configure();
- interfaces_optional_configure();
-
- header("Location: interfaces_vlan.php");
- exit;
+ This portion of code is also very slow, this is why
+ it takes a long time to add a new VLAN.
+ Benchmark_Timer on a 800 MHz VIA:
+ interfaces_lan_configure() takes about 6 seconds
+ interfaces_wan_configure() takes about 9.5 seconds
+ interfaces_optional_configure() takes about 5 seconds
+ */
+
+ /* XXX: ermal -- on my test these now are only needed if the vlan
+ modification touches only one of these interfaces.
+ It needs some more testing to be activated though.
+ */
+ interfaces_lan_configure();
+ interfaces_wan_configure();
+ interfaces_optional_configure();
+
+ header("Location: interfaces_vlan.php");
+ exit;
+ }
}
}
OpenPOWER on IntegriCloud