summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-11-28 10:47:30 +0000
committerErmal Luçi <eri@pfsense.org>2009-11-28 10:47:30 +0000
commit4400ad66dca98efa3bbd5d4935cc6ff821eece8b (patch)
tree66fff20bb549de7e5428baa322a158fcef90bd77
parenta726c0e83af3313c797726cdff3f3fd727467a78 (diff)
downloadpfsense-4400ad66dca98efa3bbd5d4935cc6ff821eece8b.zip
pfsense-4400ad66dca98efa3bbd5d4935cc6ff821eece8b.tar.gz
Rework qinq a bit. Make it use a vlan(4) as the firt Q and a ng_vlan(4) for the second Q in QinQ.
-rw-r--r--etc/inc/interfaces.inc58
-rwxr-xr-xusr/local/www/interfaces_qinq.php8
-rwxr-xr-xusr/local/www/interfaces_qinq_edit.php24
3 files changed, 28 insertions, 62 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 041521d..830ff36 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -175,12 +175,12 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
}
$qinqif = $vlan['if'];
- $vlanif = empty($vlan['vlanif']) ? "vlan{$vlan['tag']}" : $vlan['vlanif'];
$tag = $vlan['tag'];
if(empty($qinqif)) {
log_error("interface_qinq_confgure called with if undefined.\n");
return;
}
+ $vlanif = interface_vlan_configure($vlan);
if ($fd == NULL) {
$exec = true;
@@ -189,48 +189,28 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
$exec = false;
/* make sure the parent is converted to ng_vlan(4) and is up */
interfaces_bring_up($qinqif);
- /* Since we are going to add ng_vlan(4) try to enable all that hardware supports. */
- mwexec("/sbin/ifconfig {$qinqif} vlanhwtag\n");
- mwexec("/sbin/ifconfig {$qinqif} vlanmtu\n");
if (!empty($vlanif) && does_interface_exist($vlanif)) {
fwrite($fd, "shutdown {$qinqif}qinq:\n");
exec("/usr/sbin/ngctl msg {$qinqif}qinq: gettable", $result);
if (empty($result)) {
fwrite($fd, "mkpeer {$qinqif}: vlan lower downstream\n");
- fwrite($fd, "name {$qinqif}:lower {$qinqif}qinq\n");
- fwrite($fd, "connect {$qinqif}: {$qinqif}qinq: upper nomatch\n");
+ fwrite($fd, "name {$qinqif}:lower {$vlanif}qinq\n");
+ fwrite($fd, "connect {$qinqif}: {$vlanif}qinq: upper nomatch\n");
}
} else {
fwrite($fd, "mkpeer {$qinqif}: vlan lower downstream\n");
- fwrite($fd, "name {$qinqif}:lower {$qinqif}qinq\n");
- fwrite($fd, "connect {$qinqif}: {$qinqif}qinq: upper nomatch\n");
+ fwrite($fd, "name {$qinqif}:lower {$vlanif}qinq\n");
+ fwrite($fd, "connect {$qinqif}: {$vlanif}qinq: upper nomatch\n");
}
- if (!$g['booting']) {
- if (!empty($vlan['members'])) {
- $members = explode(" ", $vlan['members']);
- foreach ($members as $qtag) {
- fwrite($fd, "shutdown {$vlanif}h{$qtag}:\n");
- }
- }
- fwrite($fd, "shutdown vlanh{$tag}:\n");
- }
- fwrite($fd, "mkpeer {$qinqif}qinq: eiface vlan{$tag} ether\n");
- fwrite($fd, "name {$qinqif}qinq:vlan{$tag} vlanh{$tag}\n");
- fwrite($fd, "msg {$qinqif}qinq: addfilter { vlan={$tag} hook=\"vlan{$tag}\" }\n");
- fwrite($fd, "msg vlanh{$tag}: setifname \"{$vlanif}\"\n");
- $macaddr = get_interface_mac($qinqif);
- fwrite($fd, "msg {$vlanif}: setenaddr {$macaddr}\n");
-
- interfaces_bring_up($vlanif);
-
/* invalidate interface cache */
get_interface_arr(true);
if (!stristr($qinqif, "vlan"))
mwexec("/sbin/ifconfig {$qinqif} promisc\n");
+ $macaddr = get_interface_mac($qinqif);
if (!empty($vlan['members'])) {
$members = explode(" ", $vlan['members']);
foreach ($members as $qtag) {
@@ -249,7 +229,7 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
if (!empty($vlan['members'])) {
$members = explode(" ", $vlan['members']);
foreach ($members as $qif)
- interfaces_bring_up("{$vlanif}.{$qif}");
+ interfaces_bring_up("{$vlanif}_{$qif}");
}
return $vlanif;
@@ -260,16 +240,13 @@ function interfaces_qinq_configure() {
if($g['booting'])
echo "Configuring QinQ interfaces...";
if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) {
- $fd = fopen("{$g['tmp_path']}/netgraphcmd", "w");
foreach ($config['qinqs']['qinqentry'] as $qinq) {
/* XXX: Maybe we should report any errors?! */
- interface_qinq_configure($qinq, $fd);
+ interface_qinq_configure($qinq);
}
- fclose($fd);
- mwexec("/usr/sbin/ngctl -f {$g['tmp_path']}/netgraphcmd");
- }
- if($g['booting'])
- echo "done.\n";
+ }
+ if($g['booting'])
+ echo "done.\n";
}
function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
@@ -288,21 +265,12 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
return;
}
- $result = array();
- exec("/usr/sbin/ngctl msg {$if}qinq: gettable", $result);
- if (empty($result)) {
- fwrite($fd, "mkpeer {$if}: vlan lower downstream\n");
- fwrite($fd, "name {$if}:lower {$if}qinq \n");
- fwrite($fd, "connect {$if}: {$if}qinq: upper nomatch\n");
- }
-
- //fwrite($fd, "shutdown ${if}h{$tag}:\n");
+ fwrite($fd, "shutdown {$if}h{$tag}:\n");
fwrite($fd, "mkpeer {$if}qinq: eiface {$if}{$tag} ether\n");
fwrite($fd, "name {$if}qinq:{$if}{$tag} {$if}h{$tag}\n");
fwrite($fd, "msg {$if}qinq: addfilter { vlan={$tag} hook=\"{$if}{$tag}\" }\n");
fwrite($fd, "msg {$if}h{$tag}: setifname \"{$vlanif}\"\n");
- fwrite($fd, "msg {$vlanif}: setenaddr {$macaddr}\n");
- interfaces_bring_up($vlanif);
+ fwrite($fd, "msg {$if}h{$tag}: set {$macaddr}\n");
/* invalidate interface cache */
get_interface_arr(true);
diff --git a/usr/local/www/interfaces_qinq.php b/usr/local/www/interfaces_qinq.php
index b285fd9..84be902 100755
--- a/usr/local/www/interfaces_qinq.php
+++ b/usr/local/www/interfaces_qinq.php
@@ -68,10 +68,10 @@ if ($_GET['act'] == "del") {
$delmembers = explode(" ", $qinq['members']);
if (count($delmembers) > 0) {
foreach ($delmembers as $tag)
- mwexec("/usr/sbin/ngctl shutdown vlan{$qinq['tag']}h{$tag}:");
+ mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}h{$tag}:");
}
- mwexec("/usr/sbin/ngctl shutdown vlanh{$qinq['tag']}:");
- mwexec("/usr/sbin/ngctl shutdown {$qinq['if']}qinq:");
+ mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}qinq:");
+ mwexec("/usr/sbin/ngctl shutdown {$qinq['vlanif']}:");
unset($a_qinqs[$id]);
write_config();
@@ -127,7 +127,7 @@ include("head.inc");
<td class="listr">
<?php
if (strlen($qinq['members']) > 20)
- echo substr(htmlspecialchars($qinq['members']), 1, 20) . "...";
+ echo substr(htmlspecialchars($qinq['members']), 0, 20) . "...";
else
echo htmlspecialchars($qinq['members']);
?>
diff --git a/usr/local/www/interfaces_qinq_edit.php b/usr/local/www/interfaces_qinq_edit.php
index 8e6a900..9612aee0 100755
--- a/usr/local/www/interfaces_qinq_edit.php
+++ b/usr/local/www/interfaces_qinq_edit.php
@@ -143,7 +143,7 @@ if ($_POST) {
if (!$input_errors) {
$qinqentry['members'] = $members;
$qinqentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
- $qinqentry['vlanif'] = "vlan{$_POST['tag']}";
+ $qinqentry['vlanif'] = "{$_POST['if']}_{$_POST['tag']}";
$nmembers = explode(" ", $members);
if (isset($id) && $a_qinqs[$id]) {
@@ -151,21 +151,19 @@ if ($_POST) {
$delmembers = array_diff($omembers, $nmembers);
if (count($delmembers) > 0) {
foreach ($delmembers as $tag) {
- mwexec("/usr/sbin/ngctl shutdown vlan{$_POST['tag']}h{$tag}:");
- mwexec("/usr/sbin/ngctl msg vlan{$_POST['tag']}qinq: delfilter \\\"vlan{$_POST['tag']}{$tag}\\\"");
+ mwexec("/usr/sbin/ngctl shutdown {$qinqentry['vlanif']}h{$tag}:");
+ mwexec("/usr/sbin/ngctl msg {$qinqentry['vlanif']}qinq: delfilter \\\"{$qinqentry['vlanif']}{$tag}\\\"");
}
}
$addmembers = array_diff($nmembers, $omembers);
if (count($addmembers) > 0) {
foreach ($addmembers as $member) {
- $if = "vlan{$_POST['tag']}";
- $vlanif = "{$if}_{$member}";
- $macaddr = get_interface_mac($if);
- mwexec("/usr/sbin/ngctl mkpeer {$if}qinq: eiface {$if}{$member} ether");
- mwexec("/usr/sbin/ngctl name {$if}qinq:{$if}{$tag} {$if}h{$member}");
- mwexec("/usr/sbin/ngctl msg {$if}qinq: addfilter '{ vlan={$member} hook=\\\"{$if}{$member}\\\" }'");
- mwexec("/usr/sbin/ngctl msg {$if}h{$tag}: setifname \\\"{$vlanif}\\\"");
- mwexec("/usr/sbin/ngctl msg {$vlanif}: setenaddr {$macaddr}");
+ $macaddr = get_interface_mac($qinqentry['vlanif']);
+ mwexec("/usr/sbin/ngctl mkpeer {$$qinqentry['vlanif']}qinq: eiface {$$qinqentry['vlanif']}{$member} ether");
+ mwexec("/usr/sbin/ngctl name {$qinqentry['vlanif']}qinq:{$qinqentry['vlanif']}{$tag} {$qinqentry['vlanif']}h{$member}");
+ mwexec("/usr/sbin/ngctl msg {$qinqentry['vlanif']}qinq: addfilter '{ vlan={$member} hook=\\\"{$qinqentry['vlanif']}{$member}\\\" }'");
+ mwexec("/usr/sbin/ngctl msg {$qinqentry['vlanif']}h{$tag}: setifname \\\"{$qinqentry['vlanif']}_{$member}\\\"");
+ mwexec("/usr/sbin/ngctl msg {$qinqentry['vlanif']}h{$member}: set {$macaddr}");
}
}
$a_qinqs[$id] = $qinqentry;
@@ -184,8 +182,8 @@ if ($_POST) {
}
$additions = "";
foreach($nmembers as $qtag)
- $additions .= "vlan{$qinqentry['tag']}_{$qtag} ";
- $additions .= "vlan{$qinqentry['tag']} ";
+ $additions .= "{$qinqentry['vlanif']}_{$qtag} ";
+ $additions .= "{$qinqentry['vlanif']}";
if ($found == true)
$config['ifgroups']['ifgroupentry'][$gid]['members'] .= " {$additions}";
else {
OpenPOWER on IntegriCloud