1
|
<?php
|
2
|
/*
|
3
|
* interfaces_qinq.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
##|+PRIV
|
25
|
##|*IDENT=page-interfaces-qinq
|
26
|
##|*NAME=Interfaces: QinQ
|
27
|
##|*DESCR=Allow access to the 'Interfaces: QinQ' page.
|
28
|
##|*MATCH=interfaces_qinq.php*
|
29
|
##|-PRIV
|
30
|
|
31
|
require_once("guiconfig.inc");
|
32
|
require_once("functions.inc");
|
33
|
|
34
|
config_init_path('qinqs/qinqentry');
|
35
|
|
36
|
if ($_POST['act'] == "del") {
|
37
|
$id = $_POST['id'];
|
38
|
|
39
|
/*
|
40
|
* Check user privileges to test if the user is allowed to make changes.
|
41
|
* Otherwise users can end up in an inconsistent state where some changes are
|
42
|
* performed and others denied. See https://redmine.pfsense.org/issues/15318
|
43
|
*/
|
44
|
phpsession_begin();
|
45
|
$guiuser = getUserEntry($_SESSION['Username']);
|
46
|
$read_only = (is_array($guiuser) && userHasPrivilege($guiuser, "user-config-readonly"));
|
47
|
phpsession_end();
|
48
|
|
49
|
if ($read_only) {
|
50
|
$input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
|
51
|
}
|
52
|
|
53
|
$this_qinq_config = config_get_path("qinqs/qinqentry/{$id}");
|
54
|
/* check if still in use */
|
55
|
if ((config_get_path('qinqs/qinqentry') !== null) && vlan_inuse($this_qinq_config)) {
|
56
|
$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
|
57
|
} elseif (empty($this_qinq_config['vlanif']) || !does_interface_exist($this_qinq_config['vlanif'])) {
|
58
|
$input_errors[] = gettext("QinQ interface does not exist");
|
59
|
} else {
|
60
|
$delmembers = explode(" ", $this_qinq_config['members']);
|
61
|
foreach ($delmembers as $tag) {
|
62
|
if (qinq_inuse($this_qinq_config, $tag)) {
|
63
|
$input_errors[] = gettext("This QinQ cannot be deleted because one of it tags is still being used as an interface.");
|
64
|
break;
|
65
|
}
|
66
|
}
|
67
|
}
|
68
|
|
69
|
if (empty($input_errors)) {
|
70
|
$delmembers = explode(" ", $this_qinq_config['members']);
|
71
|
foreach ($delmembers as $tag) {
|
72
|
exec("/sbin/ifconfig {$this_qinq_config['vlanif']}.{$tag} destroy");
|
73
|
}
|
74
|
pfSense_interface_destroy($this_qinq_config['vlanif']);
|
75
|
config_del_path("qinqs/qinqentry/{$id}");
|
76
|
|
77
|
write_config("QinQ interface deleted");
|
78
|
|
79
|
header("Location: interfaces_qinq.php");
|
80
|
exit;
|
81
|
}
|
82
|
}
|
83
|
|
84
|
$pgtitle = array(gettext("Interfaces"), gettext("QinQs"));
|
85
|
$shortcut_section = "interfaces";
|
86
|
include("head.inc");
|
87
|
|
88
|
if ($input_errors) {
|
89
|
print_input_errors($input_errors);
|
90
|
}
|
91
|
|
92
|
$tab_array = array();
|
93
|
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
|
94
|
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
|
95
|
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
|
96
|
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
|
97
|
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
|
98
|
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
|
99
|
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
|
100
|
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
|
101
|
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
|
102
|
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
|
103
|
display_top_tabs($tab_array);
|
104
|
|
105
|
?>
|
106
|
<div class="panel panel-default">
|
107
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('QinQ Interfaces')?></h2></div>
|
108
|
<div class="panel-body">
|
109
|
<div class="table-responsive">
|
110
|
<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
111
|
<thead>
|
112
|
<tr>
|
113
|
<th><?=gettext("Interface"); ?></th>
|
114
|
<th><?=gettext("Tag");?></th>
|
115
|
<th><?=gettext("QinQ members"); ?></th>
|
116
|
<th><?=gettext("Description"); ?></th>
|
117
|
<th><?=gettext("Actions"); ?></th>
|
118
|
</tr>
|
119
|
</thead>
|
120
|
<tbody>
|
121
|
<?php foreach (config_get_path('qinqs/qinqentry', []) as $i => $qinq):?>
|
122
|
<tr>
|
123
|
<td>
|
124
|
<?=htmlspecialchars($qinq['if'])?>
|
125
|
</td>
|
126
|
<td>
|
127
|
<?=htmlspecialchars($qinq['tag'])?>
|
128
|
</td>
|
129
|
<td>
|
130
|
<?php if (strlen($qinq['members']) > 20):?>
|
131
|
<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>…
|
132
|
<?php else:?>
|
133
|
<?=htmlspecialchars($qinq['members'])?>
|
134
|
<?php endif; ?>
|
135
|
</td>
|
136
|
<td>
|
137
|
<?=htmlspecialchars($qinq['descr'])?>
|
138
|
</td>
|
139
|
<td>
|
140
|
<a class="fa-solid fa-pencil" title="<?=gettext('Edit Q-in-Q interface')?>" href="interfaces_qinq_edit.php?id=<?=$i?>"></a>
|
141
|
<a class="fa-solid fa-trash-can" title="<?=gettext('Delete Q-in-Q interface')?>" href="interfaces_qinq.php?act=del&id=<?=$i?>" usepost></a>
|
142
|
</td>
|
143
|
</tr>
|
144
|
<?php
|
145
|
endforeach;
|
146
|
?>
|
147
|
</tbody>
|
148
|
</table>
|
149
|
</div>
|
150
|
</div>
|
151
|
</div>
|
152
|
|
153
|
<nav class="action-buttons">
|
154
|
<a href="interfaces_qinq_edit.php" class="btn btn-success btn-sm">
|
155
|
<i class="fa-solid fa-plus icon-embed-btn"></i>
|
156
|
<?=gettext("Add")?>
|
157
|
</a>
|
158
|
</nav>
|
159
|
|
160
|
<div class="infoblock">
|
161
|
<?php print_info_box(sprintf(gettext('Not all drivers/NICs support 802.1Q QinQ tagging properly. %1$sOn cards that do not explicitly support it, ' .
|
162
|
'QinQ tagging will still work, but the reduced MTU may cause problems.%1$s' .
|
163
|
'See the %2$s handbook for information on supported cards.'), '<br />', g_get('product_label')), 'info', false); ?>
|
164
|
</div>
|
165
|
|
166
|
<?php
|
167
|
include("foot.inc");
|