1
|
<?php
|
2
|
/*
|
3
|
status_carp.php
|
4
|
*/
|
5
|
/* ====================================================================
|
6
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7
|
*
|
8
|
* Redistribution and use in source and binary forms, with or without modification,
|
9
|
* are permitted provided that the following conditions are met:
|
10
|
*
|
11
|
* 1. Redistributions of source code must retain the above copyright notice,
|
12
|
* this list of conditions and the following disclaimer.
|
13
|
*
|
14
|
* 2. Redistributions in binary form must reproduce the above copyright
|
15
|
* notice, this list of conditions and the following disclaimer in
|
16
|
* the documentation and/or other materials provided with the
|
17
|
* distribution.
|
18
|
*
|
19
|
* 3. All advertising materials mentioning features or use of this software
|
20
|
* must display the following acknowledgment:
|
21
|
* "This product includes software developed by the pfSense Project
|
22
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23
|
*
|
24
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25
|
* endorse or promote products derived from this software without
|
26
|
* prior written permission. For written permission, please contact
|
27
|
* coreteam@pfsense.org.
|
28
|
*
|
29
|
* 5. Products derived from this software may not be called "pfSense"
|
30
|
* nor may "pfSense" appear in their names without prior written
|
31
|
* permission of the Electric Sheep Fencing, LLC.
|
32
|
*
|
33
|
* 6. Redistributions of any form whatsoever must retain the following
|
34
|
* acknowledgment:
|
35
|
*
|
36
|
* "This product includes software developed by the pfSense Project
|
37
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38
|
*
|
39
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51
|
*
|
52
|
* ====================================================================
|
53
|
*
|
54
|
*/
|
55
|
|
56
|
##|+PRIV
|
57
|
##|*IDENT=page-status-carp
|
58
|
##|*NAME=Status: CARP
|
59
|
##|*DESCR=Allow access to the 'Status: CARP' page.
|
60
|
##|*MATCH=status_carp.php*
|
61
|
##|-PRIV
|
62
|
|
63
|
require_once("guiconfig.inc");
|
64
|
require_once("globals.inc");
|
65
|
|
66
|
unset($interface_arr_cache);
|
67
|
unset($interface_ip_arr_cache);
|
68
|
|
69
|
|
70
|
function find_ipalias($carpif) {
|
71
|
global $config;
|
72
|
|
73
|
$ips = array();
|
74
|
foreach ($config['virtualip']['vip'] as $vip) {
|
75
|
if ($vip['mode'] != "ipalias") {
|
76
|
continue;
|
77
|
}
|
78
|
if ($vip['interface'] != $carpif) {
|
79
|
continue;
|
80
|
}
|
81
|
$ips[] = "{$vip['subnet']}/{$vip['subnet_bits']}";
|
82
|
}
|
83
|
|
84
|
return ($ips);
|
85
|
}
|
86
|
|
87
|
$status = get_carp_status();
|
88
|
|
89
|
if ($_POST['carp_maintenancemode'] != "") {
|
90
|
interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"]));
|
91
|
}
|
92
|
|
93
|
if ($_POST['disablecarp'] != "") {
|
94
|
if ($status > 0) {
|
95
|
set_single_sysctl('net.inet.carp.allow', '0');
|
96
|
if (is_array($config['virtualip']['vip'])) {
|
97
|
$viparr = &$config['virtualip']['vip'];
|
98
|
foreach ($viparr as $vip) {
|
99
|
if ($vip['mode'] != "carp" && $vip['mode'] != "ipalias")
|
100
|
continue;
|
101
|
if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 4) != "_vip")
|
102
|
continue;
|
103
|
|
104
|
interface_vip_bring_down($vip);
|
105
|
|
106
|
/*
|
107
|
* Reconfigure radvd when necessary
|
108
|
* XXX: Is it the best way to do it?
|
109
|
*/
|
110
|
if (isset($config['dhcpdv6']) && is_array($config['dhcpdv6'])) {
|
111
|
foreach ($config['dhcpdv6'] as $dhcpv6if => $dhcpv6ifconf) {
|
112
|
if ($dhcpv6if !== $vip['interface'] ||
|
113
|
$dhcpv6ifconf['ramode'] === "disabled") {
|
114
|
continue;
|
115
|
}
|
116
|
|
117
|
services_radvd_configure();
|
118
|
break;
|
119
|
}
|
120
|
}
|
121
|
}
|
122
|
}
|
123
|
$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot and some configuration changes will re-enable."), $carp_counter);
|
124
|
$status = 0;
|
125
|
} else {
|
126
|
$savemsg = gettext("CARP has been enabled.");
|
127
|
if (is_array($config['virtualip']['vip'])) {
|
128
|
$viparr = &$config['virtualip']['vip'];
|
129
|
foreach ($viparr as $vip) {
|
130
|
switch ($vip['mode']) {
|
131
|
case "carp":
|
132
|
interface_carp_configure($vip);
|
133
|
break;
|
134
|
case 'ipalias':
|
135
|
if (substr($vip['interface'], 0, 4) == "_vip") {
|
136
|
interface_ipalias_configure($vip);
|
137
|
}
|
138
|
break;
|
139
|
}
|
140
|
}
|
141
|
}
|
142
|
interfaces_sync_setup();
|
143
|
set_single_sysctl('net.inet.carp.allow', '1');
|
144
|
$status = 1;
|
145
|
}
|
146
|
}
|
147
|
|
148
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
149
|
|
150
|
if (!empty($_POST['resetdemotion'])) {
|
151
|
set_single_sysctl("net.inet.carp.demotion", "-{$carp_detected_problems}");
|
152
|
sleep(1);
|
153
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
154
|
}
|
155
|
|
156
|
$pgtitle = array(gettext("Status"), gettext("CARP"));
|
157
|
$shortcut_section = "carp";
|
158
|
|
159
|
include("head.inc");
|
160
|
if ($savemsg) {
|
161
|
print_info_box($savemsg, 'success');
|
162
|
}
|
163
|
|
164
|
$carpcount = 0;
|
165
|
if (is_array($config['virtualip']['vip'])) {
|
166
|
foreach ($config['virtualip']['vip'] as $carp) {
|
167
|
if ($carp['mode'] == "carp") {
|
168
|
$carpcount++;
|
169
|
break;
|
170
|
}
|
171
|
}
|
172
|
}
|
173
|
|
174
|
// If $carpcount > 0 display buttons then display table
|
175
|
// otherwise display error box and quit
|
176
|
|
177
|
if ($carpcount == 0) {
|
178
|
print_info_box(gettext('No CARP interfaces have been defined.') . '<br />' .
|
179
|
'<a href="system_hasync.php" class="alert-link">' .
|
180
|
gettext("You can configure high availability sync settings here.") .
|
181
|
'</a>');
|
182
|
} else {
|
183
|
?>
|
184
|
<form action="status_carp.php" method="post">
|
185
|
<?php
|
186
|
if ($status > 0) {
|
187
|
$carp_enabled = true;
|
188
|
} else {
|
189
|
$carp_enabled = false;
|
190
|
}
|
191
|
|
192
|
// Sadly this needs to be here so that it is inside the form
|
193
|
if ($carp_detected_problems > 0) {
|
194
|
print_info_box(
|
195
|
gettext("CARP has detected a problem and this unit has been demoted to BACKUP status.") .
|
196
|
"<br/>" .
|
197
|
gettext("Check the link status on all interfaces with configured CARP VIPs.") .
|
198
|
"<br/>" .
|
199
|
sprintf(gettext('Search the %1$sSystem Log%2$s for CARP demotion-related events.'), "<a href=\"/status_logs.php?filtertext=carp%3A+demoted+by\">", "</a>") .
|
200
|
"<br/><br/>" .
|
201
|
'<input type="submit" class="btn btn-warning" name="resetdemotion" id="resetdemotion" value="' .
|
202
|
gettext("Reset CARP Demotion Status.") .
|
203
|
'" />',
|
204
|
'danger'
|
205
|
);
|
206
|
}
|
207
|
|
208
|
?>
|
209
|
<input type="submit" class="btn btn-warning" name="disablecarp" value="<?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?>" />
|
210
|
<input type="submit" class="btn btn-info" name="carp_maintenancemode" id="carp_maintenancemode" value="<?=(isset($config["virtualip_carp_maintenancemode"]) ? gettext("Leave Persistent CARP Maintenance Mode") : gettext("Enter Persistent CARP Maintenance Mode"))?>" />
|
211
|
|
212
|
<br /><br />
|
213
|
|
214
|
<div class="panel panel-default">
|
215
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('CARP Interfaces')?></h2></div>
|
216
|
<div class="panel-body table-responsive">
|
217
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap " data-sortable>
|
218
|
<thead>
|
219
|
<tr>
|
220
|
<th><?=gettext("CARP Interface")?></th>
|
221
|
<th><?=gettext("Virtual IP")?></th>
|
222
|
<th><?=gettext("Status")?></th>
|
223
|
</tr>
|
224
|
</thead>
|
225
|
<tbody>
|
226
|
<?php
|
227
|
foreach ($config['virtualip']['vip'] as $carp) {
|
228
|
if ($carp['mode'] != "carp") {
|
229
|
continue;
|
230
|
}
|
231
|
|
232
|
$vhid = $carp['vhid'];
|
233
|
$status = get_carp_interface_status("_vip{$carp['uniqid']}");
|
234
|
$aliases = find_ipalias("_vip{$carp['uniqid']}");
|
235
|
|
236
|
if ($carp_enabled == false) {
|
237
|
$icon = 'times-circle';
|
238
|
$status = "DISABLED";
|
239
|
} else {
|
240
|
if ($status == "MASTER") {
|
241
|
$icon = 'check-circle';
|
242
|
} else if ($status == "BACKUP") {
|
243
|
$icon = 'check-circle-o';
|
244
|
} else if ($status == "INIT") {
|
245
|
$icon = 'question-circle';
|
246
|
}
|
247
|
}
|
248
|
?>
|
249
|
<tr>
|
250
|
<td><?=convert_friendly_interface_to_friendly_descr($carp['interface'])?>@<?=$vhid?></td>
|
251
|
<td>
|
252
|
<?php
|
253
|
printf("{$carp['subnet']}/{$carp['subnet_bits']}");
|
254
|
for ($i = 0; $i < count($aliases); $i++) {
|
255
|
printf("<br>{$aliases[$i]}");
|
256
|
}
|
257
|
?>
|
258
|
</td>
|
259
|
<td><i class="fa fa-<?=$icon?>"></i> <?=$status?></td>
|
260
|
</tr>
|
261
|
<?php }?>
|
262
|
</tbody>
|
263
|
</table>
|
264
|
</div>
|
265
|
</div>
|
266
|
</form>
|
267
|
|
268
|
<div class="panel panel-default">
|
269
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('pfSync Nodes')?></h2></div>
|
270
|
<div class="panel-body">
|
271
|
<ul>
|
272
|
<?php
|
273
|
|
274
|
$nodes = array();
|
275
|
$states = pfSense_get_pf_states();
|
276
|
for ($i = 0; $states != NULL && $i < count($states); $i++) {
|
277
|
$nodes[$states[$i]['creatorid']] = 1;
|
278
|
}
|
279
|
foreach ($nodes as $node => $nenabled) {
|
280
|
echo "<li>$node</li>";
|
281
|
}
|
282
|
?>
|
283
|
</ul>
|
284
|
</div>
|
285
|
</div>
|
286
|
|
287
|
<?php
|
288
|
}
|
289
|
|
290
|
include("foot.inc");
|