1 |
a26686cb
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_carp.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
402c98a2
|
Reid Linnemann
|
* Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
b12ea3fb
|
Renato Botelho
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16 |
fd9ebcd5
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* 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 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
23 |
a26686cb
|
Scott Ullrich
|
|
24 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
25 |
|
|
##|*IDENT=page-status-carp
|
26 |
5230f468
|
jim-p
|
##|*NAME=Status: CARP
|
27 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: CARP' page.
|
28 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=status_carp.php*
|
29 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
30 |
|
|
|
31 |
670fafe5
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
32 |
783f1ee2
|
PiBa-NL
|
require_once("globals.inc");
|
33 |
a26686cb
|
Scott Ullrich
|
|
34 |
a1e58090
|
Scott Ullrich
|
unset($interface_arr_cache);
|
35 |
07e5afeb
|
Scott Ullrich
|
unset($interface_ip_arr_cache);
|
36 |
a1e58090
|
Scott Ullrich
|
|
37 |
2a5960b0
|
Luiz Otavio O Souza
|
|
38 |
|
|
function find_ipalias($carpif) {
|
39 |
|
|
global $config;
|
40 |
|
|
|
41 |
|
|
$ips = array();
|
42 |
|
|
foreach ($config['virtualip']['vip'] as $vip) {
|
43 |
d9901ff4
|
Chris Buechler
|
if ($vip['mode'] != "ipalias") {
|
44 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
45 |
d9901ff4
|
Chris Buechler
|
}
|
46 |
|
|
if ($vip['interface'] != $carpif) {
|
47 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
48 |
d9901ff4
|
Chris Buechler
|
}
|
49 |
2a5960b0
|
Luiz Otavio O Souza
|
$ips[] = "{$vip['subnet']}/{$vip['subnet_bits']}";
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
return ($ips);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
a26686cb
|
Scott Ullrich
|
$status = get_carp_status();
|
56 |
9e4bb200
|
Stephen Beaver
|
|
57 |
cf11a8a5
|
Viktor G
|
if ($_POST['carp_maintenancemode'] != "") {
|
58 |
|
|
if (!isset($config["virtualip_carp_maintenancemode"])) {
|
59 |
|
|
$maintenancemode = true;
|
60 |
|
|
$savemsg = gettext("Entering Persistent CARP Maintenance Mode.");
|
61 |
|
|
} else {
|
62 |
|
|
$maintenancemode = false;
|
63 |
|
|
$savemsg = gettext("Leaving Persistent CARP Maintenance Mode.");
|
64 |
|
|
}
|
65 |
|
|
/* allow to switch to Persistent Maintenance Mode if CARP is disabled
|
66 |
|
|
* see https://redmine.pfsense.org/issues/11727 */
|
67 |
|
|
interfaces_carp_set_maintenancemode($maintenancemode);
|
68 |
|
|
if ($status == 0) {
|
69 |
|
|
$_POST['disablecarp'] = "off";
|
70 |
|
|
}
|
71 |
783f1ee2
|
PiBa-NL
|
}
|
72 |
d3a01571
|
Stephen Beaver
|
|
73 |
|
|
if ($_POST['disablecarp'] != "") {
|
74 |
c6c398c6
|
jim-p
|
init_config_arr(array('virtualip', 'vip'));
|
75 |
|
|
$viparr = &$config['virtualip']['vip'];
|
76 |
3575058b
|
Luiz Otavio O Souza
|
if ($status != 0) {
|
77 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '0');
|
78 |
c6c398c6
|
jim-p
|
foreach ($viparr as $vip) {
|
79 |
|
|
if ($vip['mode'] != "carp" && $vip['mode'] != "ipalias")
|
80 |
|
|
continue;
|
81 |
|
|
if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 4) != "_vip")
|
82 |
|
|
continue;
|
83 |
|
|
interface_vip_bring_down($vip);
|
84 |
aae16684
|
Renato Botelho
|
}
|
85 |
cccee755
|
Chris Buechler
|
$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);
|
86 |
9c296826
|
Ermal
|
$status = 0;
|
87 |
a26686cb
|
Scott Ullrich
|
} else {
|
88 |
cf11a8a5
|
Viktor G
|
$savemsg .= gettext("CARP has been enabled.");
|
89 |
c6c398c6
|
jim-p
|
foreach ($viparr as $vip) {
|
90 |
|
|
switch ($vip['mode']) {
|
91 |
|
|
case "carp":
|
92 |
|
|
interface_carp_configure($vip);
|
93 |
|
|
break;
|
94 |
|
|
case 'ipalias':
|
95 |
|
|
if (substr($vip['interface'], 0, 4) == "_vip") {
|
96 |
|
|
interface_ipalias_configure($vip);
|
97 |
|
|
}
|
98 |
|
|
break;
|
99 |
aae16684
|
Renato Botelho
|
}
|
100 |
|
|
}
|
101 |
8ff85c39
|
Ermal
|
interfaces_sync_setup();
|
102 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '1');
|
103 |
9c296826
|
Ermal
|
$status = 1;
|
104 |
a26686cb
|
Scott Ullrich
|
}
|
105 |
|
|
}
|
106 |
|
|
|
107 |
0a4fbd99
|
jim-p
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
108 |
|
|
|
109 |
|
|
if (!empty($_POST['resetdemotion'])) {
|
110 |
52a3580a
|
jim-p
|
set_single_sysctl("net.inet.carp.demotion", 0 - $carp_detected_problems);
|
111 |
0a4fbd99
|
jim-p
|
sleep(1);
|
112 |
|
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
113 |
|
|
}
|
114 |
8a84b3ab
|
jim-p
|
|
115 |
b191b7b1
|
Stephen Beaver
|
$pgtitle = array(gettext("Status"), gettext("CARP"));
|
116 |
b32dd0a6
|
jim-p
|
$shortcut_section = "carp";
|
117 |
d3a01571
|
Stephen Beaver
|
|
118 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
119 |
abe98adb
|
Phil Davis
|
if ($savemsg) {
|
120 |
d3a01571
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
121 |
abe98adb
|
Phil Davis
|
}
|
122 |
8a84b3ab
|
jim-p
|
|
123 |
7d5b007c
|
Sjon Hortensius
|
$carpcount = 0;
|
124 |
20fb5adf
|
Christian McDonald
|
foreach(config_get_path('virtualip/vip', []) as $carp) {
|
125 |
|
|
if ($carp['mode'] == "carp") {
|
126 |
|
|
$carpcount++;
|
127 |
|
|
break;
|
128 |
7d5b007c
|
Sjon Hortensius
|
}
|
129 |
|
|
}
|
130 |
d3a01571
|
Stephen Beaver
|
|
131 |
|
|
// If $carpcount > 0 display buttons then display table
|
132 |
|
|
// otherwise display error box and quit
|
133 |
|
|
|
134 |
|
|
if ($carpcount == 0) {
|
135 |
|
|
print_info_box(gettext('No CARP interfaces have been defined.') . '<br />' .
|
136 |
0da0d43e
|
Phil Davis
|
'<a href="system_hasync.php" class="alert-link">' .
|
137 |
530c7ccf
|
NOYB
|
gettext("High availability sync settings can be configured here.") .
|
138 |
d3a01571
|
Stephen Beaver
|
'</a>');
|
139 |
abe98adb
|
Phil Davis
|
} else {
|
140 |
d3a01571
|
Stephen Beaver
|
?>
|
141 |
60f533b7
|
Viktor G
|
<div class="panel panel-default">
|
142 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("CARP Maintenance");?></h2></div>
|
143 |
|
|
<div class="panel-body">
|
144 |
|
|
<div class="content">
|
145 |
|
|
<form action="status_carp.php" method="post">
|
146 |
9e4bb200
|
Stephen Beaver
|
<?php
|
147 |
3575058b
|
Luiz Otavio O Souza
|
if ($status != 0) {
|
148 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = true;
|
149 |
abe98adb
|
Phil Davis
|
} else {
|
150 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = false;
|
151 |
abe98adb
|
Phil Davis
|
}
|
152 |
0da0d43e
|
Phil Davis
|
|
153 |
|
|
// Sadly this needs to be here so that it is inside the form
|
154 |
52a3580a
|
jim-p
|
if ($carp_detected_problems != 0) {
|
155 |
61f75117
|
Stephen Beaver
|
print_info_box(
|
156 |
52a3580a
|
jim-p
|
gettext("CARP has detected a problem and this unit has a non-zero demotion status.") .
|
157 |
98128ad6
|
Phil Davis
|
"<br/>" .
|
158 |
52a3580a
|
jim-p
|
gettext("Check the link status on all interfaces configured with CARP VIPs and ") .
|
159 |
|
|
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>") .
|
160 |
98128ad6
|
Phil Davis
|
"<br/><br/>" .
|
161 |
27d6a45b
|
jim-p
|
'<button type="submit" class="btn btn-warning" name="resetdemotion" id="resetdemotion" value="' .
|
162 |
52a3580a
|
jim-p
|
gettext("Reset CARP Demotion Status") .
|
163 |
27d6a45b
|
jim-p
|
'"><i class="fa fa-undo icon-embed-btn"></i>' .
|
164 |
52a3580a
|
jim-p
|
gettext("Reset CARP Demotion Status") .
|
165 |
27d6a45b
|
jim-p
|
'</button>',
|
166 |
98128ad6
|
Phil Davis
|
'danger'
|
167 |
61f75117
|
Stephen Beaver
|
);
|
168 |
|
|
}
|
169 |
|
|
|
170 |
9e4bb200
|
Stephen Beaver
|
?>
|
171 |
60f533b7
|
Viktor G
|
<button type="submit" class="btn btn-warning" name="disablecarp" value="<?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?>" ><i class="fa fa-<?=($carp_enabled) ? 'ban' : 'check' ; ?> icon-embed-btn"></i><?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?></button>
|
172 |
|
|
<button 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"))?>" ><i class="fa fa-wrench icon-embed-btn"></i><?=(isset($config["virtualip_carp_maintenancemode"]) ? gettext("Leave Persistent CARP Maintenance Mode") : gettext("Enter Persistent CARP Maintenance Mode"))?></button>
|
173 |
|
|
</div>
|
174 |
|
|
</div>
|
175 |
|
|
</div>
|
176 |
0da0d43e
|
Phil Davis
|
|
177 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
178 |
60f533b7
|
Viktor G
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('CARP Status')?></h2></div>
|
179 |
d3a01571
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
180 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap " data-sortable>
|
181 |
d3a01571
|
Stephen Beaver
|
<thead>
|
182 |
|
|
<tr>
|
183 |
60f533b7
|
Viktor G
|
<th><?=gettext("Interface and VHID")?></th>
|
184 |
|
|
<th><?=gettext("Virtual IP Address")?></th>
|
185 |
d3a01571
|
Stephen Beaver
|
<th><?=gettext("Status")?></th>
|
186 |
|
|
</tr>
|
187 |
|
|
</thead>
|
188 |
|
|
<tbody>
|
189 |
a26686cb
|
Scott Ullrich
|
<?php
|
190 |
288a2a0f
|
Phil Davis
|
foreach ($config['virtualip']['vip'] as $carp) {
|
191 |
|
|
if ($carp['mode'] != "carp") {
|
192 |
7d5b007c
|
Sjon Hortensius
|
continue;
|
193 |
288a2a0f
|
Phil Davis
|
}
|
194 |
0da0d43e
|
Phil Davis
|
|
195 |
1d87a144
|
Luiz Otavio O Souza
|
$icon = '';
|
196 |
7d5b007c
|
Sjon Hortensius
|
$vhid = $carp['vhid'];
|
197 |
f92ea2e2
|
Luiz Otavio O Souza
|
$status = get_carp_interface_status("_vip{$carp['uniqid']}");
|
198 |
2a5960b0
|
Luiz Otavio O Souza
|
$aliases = find_ipalias("_vip{$carp['uniqid']}");
|
199 |
0da0d43e
|
Phil Davis
|
|
200 |
abe98adb
|
Phil Davis
|
if ($carp_enabled == false) {
|
201 |
1b7379f9
|
Jared Dillard
|
$icon = 'times-circle';
|
202 |
7d5b007c
|
Sjon Hortensius
|
$status = "DISABLED";
|
203 |
|
|
} else {
|
204 |
288a2a0f
|
Phil Davis
|
if ($status == "MASTER") {
|
205 |
8f934add
|
jim-p
|
$icon = 'play-circle text-success';
|
206 |
288a2a0f
|
Phil Davis
|
} else if ($status == "BACKUP") {
|
207 |
8f934add
|
jim-p
|
$icon = 'pause-circle text-warning';
|
208 |
288a2a0f
|
Phil Davis
|
} else if ($status == "INIT") {
|
209 |
8f934add
|
jim-p
|
$icon = 'question-circle text-danger';
|
210 |
7d5b007c
|
Sjon Hortensius
|
}
|
211 |
|
|
}
|
212 |
a26686cb
|
Scott Ullrich
|
?>
|
213 |
d3a01571
|
Stephen Beaver
|
<tr>
|
214 |
|
|
<td><?=convert_friendly_interface_to_friendly_descr($carp['interface'])?>@<?=$vhid?></td>
|
215 |
2a5960b0
|
Luiz Otavio O Souza
|
<td>
|
216 |
|
|
<?php
|
217 |
|
|
printf("{$carp['subnet']}/{$carp['subnet_bits']}");
|
218 |
d9901ff4
|
Chris Buechler
|
for ($i = 0; $i < count($aliases); $i++) {
|
219 |
2a5960b0
|
Luiz Otavio O Souza
|
printf("<br>{$aliases[$i]}");
|
220 |
d9901ff4
|
Chris Buechler
|
}
|
221 |
2a5960b0
|
Luiz Otavio O Souza
|
?>
|
222 |
|
|
</td>
|
223 |
1b7379f9
|
Jared Dillard
|
<td><i class="fa fa-<?=$icon?>"></i> <?=$status?></td>
|
224 |
d3a01571
|
Stephen Beaver
|
</tr>
|
225 |
7d5b007c
|
Sjon Hortensius
|
<?php }?>
|
226 |
d3a01571
|
Stephen Beaver
|
</tbody>
|
227 |
|
|
</table>
|
228 |
61f75117
|
Stephen Beaver
|
</div>
|
229 |
d3a01571
|
Stephen Beaver
|
</div>
|
230 |
0f4317d3
|
Colin Fleming
|
</form>
|
231 |
a26686cb
|
Scott Ullrich
|
|
232 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
233 |
60f533b7
|
Viktor G
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('State Synchronization Status')?></h2></div>
|
234 |
062972b3
|
Jim Pingle
|
<div class="panel-body"><div class="content">
|
235 |
|
|
<?= gettext("State Creator Host IDs") ?>:
|
236 |
d3a01571
|
Stephen Beaver
|
<ul>
|
237 |
1f919154
|
Scott Ullrich
|
<?php
|
238 |
062972b3
|
Jim Pingle
|
$my_id = strtolower(ltrim(filter_get_host_id(), '0'));
|
239 |
|
|
exec("/sbin/pfctl -vvss | /usr/bin/awk '/creatorid:/ {print $4;}' | /usr/bin/sort -u", $hostids);
|
240 |
|
|
if (!is_array($hostids)) {
|
241 |
|
|
$hostids = array();
|
242 |
|
|
}
|
243 |
1f919154
|
Scott Ullrich
|
?>
|
244 |
062972b3
|
Jim Pingle
|
<?php foreach ($hostids as $hid):
|
245 |
|
|
$hid = strtolower(ltrim($hid, '0')); ?>
|
246 |
|
|
<li>
|
247 |
|
|
<?= $hid ?>
|
248 |
|
|
<?php if ($hid == $my_id): ?>
|
249 |
|
|
(<?= gettext("This node") ?>)
|
250 |
|
|
<?php endif; ?>
|
251 |
|
|
</li>
|
252 |
|
|
<?php endforeach; ?>
|
253 |
d3a01571
|
Stephen Beaver
|
</ul>
|
254 |
062972b3
|
Jim Pingle
|
|
255 |
|
|
<div class="infoblock blockopen">
|
256 |
60f533b7
|
Viktor G
|
<?php
|
257 |
e5d97d7c
|
jim-p
|
print_info_box(sprintf(gettext(
|
258 |
|
|
'When state synchronization is enabled and functioning properly the list of state creator host IDs will be identical on each node participating in state synchronization.%1$s%1$s' .
|
259 |
|
|
'The state creator host ID for this node can be set to a custom value under System > High Avail Sync. ' .
|
260 |
|
|
'If the state creator host ID has recently changed, the old ID will remain until all states using the old ID expire or are removed.'
|
261 |
|
|
), '<br/>'), 'info', false);
|
262 |
60f533b7
|
Viktor G
|
?>
|
263 |
062972b3
|
Jim Pingle
|
</div>
|
264 |
|
|
</div></div>
|
265 |
60f533b7
|
Viktor G
|
</div>
|
266 |
d3a01571
|
Stephen Beaver
|
|
267 |
|
|
<?php
|
268 |
|
|
}
|
269 |
1f919154
|
Scott Ullrich
|
|
270 |
d3a01571
|
Stephen Beaver
|
include("foot.inc");
|