Project

General

Profile

Download (5.69 KB) Statistics
| Branch: | Tag: | Revision:
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-2025 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
if ($_POST['act'] == "del") {
35
	$id = is_numericint($_POST['id']) ? $_POST['id'] : null;
36

    
37
	/*
38
	 * Check user privileges to test if the user is allowed to make changes.
39
	 * Otherwise users can end up in an inconsistent state where some changes are
40
	 * performed and others denied. See https://redmine.pfsense.org/issues/15318
41
	 */
42
	phpsession_begin();
43
	$guiuser = getUserEntry($_SESSION['Username']);
44
	$read_only = (is_array($guiuser) && userHasPrivilege($guiuser['item'], "user-config-readonly"));
45
	phpsession_end();
46

    
47
	if ($read_only) {
48
		$input_errors = array(gettext("Insufficient privileges to make the requested change (read only)."));
49
	}
50

    
51
	$this_qinq_config = config_get_path("qinqs/qinqentry/{$id}");
52
	/* check if still in use */
53
	if ((config_get_path('qinqs/qinqentry') !== null) && vlan_inuse($this_qinq_config)) {
54
		$input_errors[] = gettext("This QinQ cannot be deleted because it is still being used as an interface.");
55
	} elseif (empty($this_qinq_config['vlanif']) || !does_interface_exist($this_qinq_config['vlanif'])) {
56
		$input_errors[] = gettext("QinQ interface does not exist");
57
	} else {
58
		$delmembers = explode(" ", $this_qinq_config['members']);
59
		foreach ($delmembers as $tag) {
60
			if (qinq_inuse($this_qinq_config, $tag)) {
61
				$input_errors[] = gettext("This QinQ cannot be deleted because one of it tags is still being used as an interface.");
62
				break;
63
			}
64
		}
65
	}
66

    
67
	if (empty($input_errors)) {
68
		$delmembers = explode(" ", $this_qinq_config['members']);
69
		foreach ($delmembers as $tag) {
70
			exec("/sbin/ifconfig {$this_qinq_config['vlanif']}.{$tag} destroy");
71
		}
72
		pfSense_interface_destroy($this_qinq_config['vlanif']);
73
		config_del_path("qinqs/qinqentry/{$id}");
74

    
75
		write_config("QinQ interface deleted");
76

    
77
		header("Location: interfaces_qinq.php");
78
		exit;
79
	}
80
}
81

    
82
$pgtitle = array(gettext("Interfaces"), gettext("QinQs"));
83
$shortcut_section = "interfaces";
84
include("head.inc");
85

    
86
if ($input_errors) {
87
	print_input_errors($input_errors);
88
}
89

    
90
$tab_array = array();
91
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
92
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
93
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
94
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
95
$tab_array[] = array(gettext("QinQs"), true, "interfaces_qinq.php");
96
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
97
$tab_array[] = array(gettext("GREs"), false, "interfaces_gre.php");
98
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
99
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
100
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
101
display_top_tabs($tab_array);
102

    
103
?>
104
<div class="panel panel-default">
105
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('QinQ Interfaces')?></h2></div>
106
	<div class="panel-body">
107
		<div class="table-responsive">
108
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
109
				<thead>
110
					<tr>
111
						<th><?=gettext("Interface"); ?></th>
112
						<th><?=gettext("Tag");?></th>
113
						<th><?=gettext("QinQ members"); ?></th>
114
						<th><?=gettext("Description"); ?></th>
115
						<th><?=gettext("Actions"); ?></th>
116
					</tr>
117
				</thead>
118
				<tbody>
119
<?php foreach (config_get_path('qinqs/qinqentry', []) as $i => $qinq):?>
120
					<tr>
121
						<td>
122
							<?=htmlspecialchars($qinq['if'])?>
123
						</td>
124
						<td>
125
							<?=htmlspecialchars($qinq['tag'])?>
126
						</td>
127
						<td>
128
<?php if (strlen($qinq['members']) > 20):?>
129
							<?=substr(htmlspecialchars($qinq['members']), 0, 20)?>&hellip;
130
<?php else:?>
131
							<?=htmlspecialchars($qinq['members'])?>
132
<?php endif; ?>
133
						</td>
134
						<td>
135
							<?=htmlspecialchars($qinq['descr'])?>&nbsp;
136
						</td>
137
						<td>
138
							<a class="fa-solid fa-pencil"	title="<?=gettext('Edit Q-in-Q interface')?>"	href="interfaces_qinq_edit.php?id=<?=$i?>"></a>
139
							<a class="fa-solid fa-trash-can"	title="<?=gettext('Delete Q-in-Q interface')?>"	href="interfaces_qinq.php?act=del&amp;id=<?=$i?>" usepost></a>
140
						</td>
141
					</tr>
142
<?php
143
endforeach;
144
?>
145
				</tbody>
146
			</table>
147
		</div>
148
	</div>
149
</div>
150

    
151
<nav class="action-buttons">
152
	<a href="interfaces_qinq_edit.php" class="btn btn-success btn-sm">
153
		<i class="fa-solid fa-plus icon-embed-btn"></i>
154
		<?=gettext("Add")?>
155
	</a>
156
</nav>
157

    
158
<div class="infoblock">
159
	<?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, ' .
160
		'QinQ tagging will still work, but the reduced MTU may cause problems.%1$s' .
161
		'See the %2$s handbook for information on supported cards.'), '<br />', g_get('product_label')), 'info', false); ?>
162
</div>
163

    
164
<?php
165
include("foot.inc");
(87-87/233)